highcharts.src.js 2.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602
  1. /**
  2. * @license Highcharts JS v9.1.0 (2021-05-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.0', 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(Highcharts, '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. /* eslint-disable valid-jsdoc */
  1510. /**
  1511. * Return the value of the first element in the array that satisfies the
  1512. * provided testing function.
  1513. *
  1514. * @function Highcharts.find<T>
  1515. *
  1516. * @param {Array<T>} arr
  1517. * The array to test.
  1518. *
  1519. * @param {Function} callback
  1520. * The callback function. The function receives the item as the first
  1521. * argument. Return `true` if this item satisfies the condition.
  1522. *
  1523. * @return {T|undefined}
  1524. * The value of the element.
  1525. */
  1526. var find = Array.prototype.find ?
  1527. /* eslint-enable valid-jsdoc */
  1528. function (arr,
  1529. callback) {
  1530. return arr.find(callback);
  1531. } :
  1532. // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
  1533. function (arr, callback) {
  1534. var i;
  1535. var length = arr.length;
  1536. for (i = 0; i < length; i++) {
  1537. if (callback(arr[i], i)) { // eslint-disable-line callback-return
  1538. return arr[i];
  1539. }
  1540. }
  1541. };
  1542. /**
  1543. * Returns an array of a given object's own properties.
  1544. *
  1545. * @function Highcharts.keys
  1546. * @deprecated
  1547. *
  1548. * @param {*} obj
  1549. * The object of which the properties are to be returned.
  1550. *
  1551. * @return {Array<string>}
  1552. * An array of strings that represents all the properties.
  1553. */
  1554. function keys(obj) {
  1555. error(32, false, void 0, { 'Highcharts.keys': 'use Object.keys' });
  1556. return Object.keys(obj);
  1557. }
  1558. /**
  1559. * Get the element's offset position, corrected for `overflow: auto`.
  1560. *
  1561. * @function Highcharts.offset
  1562. *
  1563. * @param {global.Element} el
  1564. * The DOM element.
  1565. *
  1566. * @return {Highcharts.OffsetObject}
  1567. * An object containing `left` and `top` properties for the position in
  1568. * the page.
  1569. */
  1570. function offset(el) {
  1571. var docElem = doc.documentElement,
  1572. box = (el.parentElement || el.parentNode) ?
  1573. el.getBoundingClientRect() :
  1574. { top: 0,
  1575. left: 0,
  1576. width: 0,
  1577. height: 0 };
  1578. return {
  1579. top: box.top + (win.pageYOffset || docElem.scrollTop) -
  1580. (docElem.clientTop || 0),
  1581. left: box.left + (win.pageXOffset || docElem.scrollLeft) -
  1582. (docElem.clientLeft || 0),
  1583. width: box.width,
  1584. height: box.height
  1585. };
  1586. }
  1587. /* eslint-disable valid-jsdoc */
  1588. /**
  1589. * Iterate over object key pairs in an object.
  1590. *
  1591. * @function Highcharts.objectEach<T>
  1592. *
  1593. * @param {*} obj
  1594. * The object to iterate over.
  1595. *
  1596. * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
  1597. * The iterator callback. It passes three arguments:
  1598. * * value - The property value.
  1599. * * key - The property key.
  1600. * * obj - The object that objectEach is being applied to.
  1601. *
  1602. * @param {T} [ctx]
  1603. * The context.
  1604. *
  1605. * @return {void}
  1606. */
  1607. function objectEach(obj, fn, ctx) {
  1608. /* eslint-enable valid-jsdoc */
  1609. for (var key in obj) {
  1610. if (Object.hasOwnProperty.call(obj, key)) {
  1611. fn.call(ctx || obj[key], obj[key], key, obj);
  1612. }
  1613. }
  1614. }
  1615. /**
  1616. * Iterate over an array.
  1617. *
  1618. * @deprecated
  1619. * @function Highcharts.each
  1620. *
  1621. * @param {Array<*>} arr
  1622. * The array to iterate over.
  1623. *
  1624. * @param {Function} fn
  1625. * The iterator callback. It passes three arguments:
  1626. * - `item`: The array item.
  1627. * - `index`: The item's index in the array.
  1628. * - `arr`: The array that each is being applied to.
  1629. *
  1630. * @param {*} [ctx]
  1631. * The context.
  1632. *
  1633. * @return {void}
  1634. */
  1635. /**
  1636. * Filter an array by a callback.
  1637. *
  1638. * @deprecated
  1639. * @function Highcharts.grep
  1640. *
  1641. * @param {Array<*>} arr
  1642. * The array to filter.
  1643. *
  1644. * @param {Function} callback
  1645. * The callback function. The function receives the item as the first
  1646. * argument. Return `true` if the item is to be preserved.
  1647. *
  1648. * @return {Array<*>}
  1649. * A new, filtered array.
  1650. */
  1651. /**
  1652. * Map an array by a callback.
  1653. *
  1654. * @deprecated
  1655. * @function Highcharts.map
  1656. *
  1657. * @param {Array<*>} arr
  1658. * The array to map.
  1659. *
  1660. * @param {Function} fn
  1661. * The callback function. Return the new value for the new array.
  1662. *
  1663. * @return {Array<*>}
  1664. * A new array item with modified items.
  1665. */
  1666. /**
  1667. * Reduce an array to a single value.
  1668. *
  1669. * @deprecated
  1670. * @function Highcharts.reduce
  1671. *
  1672. * @param {Array<*>} arr
  1673. * The array to reduce.
  1674. *
  1675. * @param {Function} fn
  1676. * The callback function. Return the reduced value. Receives 4
  1677. * arguments: Accumulated/reduced value, current value, current array
  1678. * index, and the array.
  1679. *
  1680. * @param {*} initialValue
  1681. * The initial value of the accumulator.
  1682. *
  1683. * @return {*}
  1684. * The reduced value.
  1685. */
  1686. /**
  1687. * Test whether at least one element in the array passes the test implemented by
  1688. * the provided function.
  1689. *
  1690. * @deprecated
  1691. * @function Highcharts.some
  1692. *
  1693. * @param {Array<*>} arr
  1694. * The array to test
  1695. *
  1696. * @param {Function} fn
  1697. * The function to run on each item. Return truty to pass the test.
  1698. * Receives arguments `currentValue`, `index` and `array`.
  1699. *
  1700. * @param {*} ctx
  1701. * The context.
  1702. *
  1703. * @return {boolean}
  1704. */
  1705. objectEach({
  1706. map: 'map',
  1707. each: 'forEach',
  1708. grep: 'filter',
  1709. reduce: 'reduce',
  1710. some: 'some'
  1711. }, function (val, key) {
  1712. H[key] = function (arr) {
  1713. var _a;
  1714. error(32, false, void 0, (_a = {}, _a["Highcharts." + key] = "use Array." + val, _a));
  1715. return Array.prototype[val].apply(arr, [].slice.call(arguments, 1));
  1716. };
  1717. });
  1718. /* eslint-disable valid-jsdoc */
  1719. /**
  1720. * Add an event listener.
  1721. *
  1722. * @function Highcharts.addEvent<T>
  1723. *
  1724. * @param {Highcharts.Class<T>|T} el
  1725. * The element or object to add a listener to. It can be a
  1726. * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
  1727. *
  1728. * @param {string} type
  1729. * The event type.
  1730. *
  1731. * @param {Highcharts.EventCallbackFunction<T>|Function} fn
  1732. * The function callback to execute when the event is fired.
  1733. *
  1734. * @param {Highcharts.EventOptionsObject} [options]
  1735. * Options for adding the event.
  1736. *
  1737. * @return {Function}
  1738. * A callback function to remove the added event.
  1739. */
  1740. function addEvent(el, type, fn, options) {
  1741. /* eslint-enable valid-jsdoc */
  1742. if (options === void 0) { options = {}; }
  1743. // Add hcEvents to either the prototype (in case we're running addEvent on a
  1744. // class) or the instance. If hasOwnProperty('hcEvents') is false, it is
  1745. // inherited down the prototype chain, in which case we need to set the
  1746. // property on this instance (which may itself be a prototype).
  1747. var owner = typeof el === 'function' && el.prototype || el;
  1748. if (!Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1749. owner.hcEvents = {};
  1750. }
  1751. var events = owner.hcEvents;
  1752. // Allow click events added to points, otherwise they will be prevented by
  1753. // the TouchPointer.pinch function after a pinch zoom operation (#7091).
  1754. if (H.Point && // without H a dependency loop occurs
  1755. el instanceof H.Point &&
  1756. el.series &&
  1757. el.series.chart) {
  1758. el.series.chart.runTrackerClick = true;
  1759. }
  1760. // Handle DOM events
  1761. // If the browser supports passive events, add it to improve performance
  1762. // on touch events (#11353).
  1763. var addEventListener = (el.addEventListener || H.addEventListenerPolyfill);
  1764. if (addEventListener) {
  1765. addEventListener.call(el, type, fn, H.supportsPassiveEvents ? {
  1766. passive: options.passive === void 0 ?
  1767. type.indexOf('touch') !== -1 : options.passive,
  1768. capture: false
  1769. } : false);
  1770. }
  1771. if (!events[type]) {
  1772. events[type] = [];
  1773. }
  1774. var eventObject = {
  1775. fn: fn,
  1776. order: typeof options.order === 'number' ? options.order : Infinity
  1777. };
  1778. events[type].push(eventObject);
  1779. // Order the calls
  1780. events[type].sort(function (a, b) { return a.order - b.order; });
  1781. // Return a function that can be called to remove this event.
  1782. return function () {
  1783. removeEvent(el, type, fn);
  1784. };
  1785. }
  1786. /* eslint-disable valid-jsdoc */
  1787. /**
  1788. * Remove an event that was added with {@link Highcharts#addEvent}.
  1789. *
  1790. * @function Highcharts.removeEvent<T>
  1791. *
  1792. * @param {Highcharts.Class<T>|T} el
  1793. * The element to remove events on.
  1794. *
  1795. * @param {string} [type]
  1796. * The type of events to remove. If undefined, all events are removed
  1797. * from the element.
  1798. *
  1799. * @param {Highcharts.EventCallbackFunction<T>} [fn]
  1800. * The specific callback to remove. If undefined, all events that match
  1801. * the element and optionally the type are removed.
  1802. *
  1803. * @return {void}
  1804. */
  1805. function removeEvent(el, type, fn) {
  1806. /* eslint-enable valid-jsdoc */
  1807. /**
  1808. * @private
  1809. * @param {string} type - event type
  1810. * @param {Highcharts.EventCallbackFunction<T>} fn - callback
  1811. * @return {void}
  1812. */
  1813. function removeOneEvent(type, fn) {
  1814. var removeEventListener = (el.removeEventListener || H.removeEventListenerPolyfill);
  1815. if (removeEventListener) {
  1816. removeEventListener.call(el, type, fn, false);
  1817. }
  1818. }
  1819. /**
  1820. * @private
  1821. * @param {any} eventCollection - collection
  1822. * @return {void}
  1823. */
  1824. function removeAllEvents(eventCollection) {
  1825. var types,
  1826. len;
  1827. if (!el.nodeName) {
  1828. return; // break on non-DOM events
  1829. }
  1830. if (type) {
  1831. types = {};
  1832. types[type] = true;
  1833. }
  1834. else {
  1835. types = eventCollection;
  1836. }
  1837. objectEach(types, function (_val, n) {
  1838. if (eventCollection[n]) {
  1839. len = eventCollection[n].length;
  1840. while (len--) {
  1841. removeOneEvent(n, eventCollection[n][len].fn);
  1842. }
  1843. }
  1844. });
  1845. }
  1846. var owner = typeof el === 'function' && el.prototype || el;
  1847. if (Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1848. var events = owner.hcEvents;
  1849. if (type) {
  1850. var typeEvents = (events[type] || []);
  1851. if (fn) {
  1852. events[type] = typeEvents.filter(function (obj) {
  1853. return fn !== obj.fn;
  1854. });
  1855. removeOneEvent(type, fn);
  1856. }
  1857. else {
  1858. removeAllEvents(events);
  1859. events[type] = [];
  1860. }
  1861. }
  1862. else {
  1863. removeAllEvents(events);
  1864. delete owner.hcEvents;
  1865. }
  1866. }
  1867. }
  1868. /* eslint-disable valid-jsdoc */
  1869. /**
  1870. * Fire an event that was registered with {@link Highcharts#addEvent}.
  1871. *
  1872. * @function Highcharts.fireEvent<T>
  1873. *
  1874. * @param {T} el
  1875. * The object to fire the event on. It can be a {@link HTMLDOMElement},
  1876. * an {@link SVGElement} or any other object.
  1877. *
  1878. * @param {string} type
  1879. * The type of event.
  1880. *
  1881. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  1882. * Custom event arguments that are passed on as an argument to the event
  1883. * handler.
  1884. *
  1885. * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
  1886. * The default function to execute if the other listeners haven't
  1887. * returned false.
  1888. *
  1889. * @return {void}
  1890. */
  1891. function fireEvent(el, type, eventArguments, defaultFunction) {
  1892. /* eslint-enable valid-jsdoc */
  1893. var e,
  1894. i;
  1895. eventArguments = eventArguments || {};
  1896. if (doc.createEvent &&
  1897. (el.dispatchEvent ||
  1898. (el.fireEvent &&
  1899. // Enable firing events on Highcharts instance.
  1900. el !== H))) {
  1901. e = doc.createEvent('Events');
  1902. e.initEvent(type, true, true);
  1903. eventArguments = extend(e, eventArguments);
  1904. if (el.dispatchEvent) {
  1905. el.dispatchEvent(eventArguments);
  1906. }
  1907. else {
  1908. el.fireEvent(type, eventArguments);
  1909. }
  1910. }
  1911. else if (el.hcEvents) {
  1912. if (!eventArguments.target) {
  1913. // We're running a custom event
  1914. extend(eventArguments, {
  1915. // Attach a simple preventDefault function to skip
  1916. // default handler if called. The built-in
  1917. // defaultPrevented property is not overwritable (#5112)
  1918. preventDefault: function () {
  1919. eventArguments.defaultPrevented = true;
  1920. },
  1921. // Setting target to native events fails with clicking
  1922. // the zoom-out button in Chrome.
  1923. target: el,
  1924. // If the type is not set, we're running a custom event
  1925. // (#2297). If it is set, we're running a browser event,
  1926. // and setting it will cause en error in IE8 (#2465).
  1927. type: type
  1928. });
  1929. }
  1930. var events = [];
  1931. var object = el;
  1932. var multilevel = false;
  1933. // Recurse up the inheritance chain and collect hcEvents set as own
  1934. // objects on the prototypes.
  1935. while (object.hcEvents) {
  1936. if (Object.hasOwnProperty.call(object, 'hcEvents') &&
  1937. object.hcEvents[type]) {
  1938. if (events.length) {
  1939. multilevel = true;
  1940. }
  1941. events.unshift.apply(events, object.hcEvents[type]);
  1942. }
  1943. object = Object.getPrototypeOf(object);
  1944. }
  1945. // For performance reasons, only sort the event handlers in case we are
  1946. // dealing with multiple levels in the prototype chain. Otherwise, the
  1947. // events are already sorted in the addEvent function.
  1948. if (multilevel) {
  1949. // Order the calls
  1950. events.sort(function (a, b) { return a.order - b.order; });
  1951. }
  1952. // Call the collected event handlers
  1953. events.forEach(function (obj) {
  1954. // If the event handler returns false, prevent the default handler
  1955. // from executing
  1956. if (obj.fn.call(el, eventArguments) === false) {
  1957. eventArguments.preventDefault();
  1958. }
  1959. });
  1960. }
  1961. // Run the default if not prevented
  1962. if (defaultFunction && !eventArguments.defaultPrevented) {
  1963. defaultFunction.call(el, eventArguments);
  1964. }
  1965. }
  1966. var serialMode;
  1967. /**
  1968. * Get a unique key for using in internal element id's and pointers. The key is
  1969. * composed of a random hash specific to this Highcharts instance, and a
  1970. * counter.
  1971. *
  1972. * @example
  1973. * let id = uniqueKey(); // => 'highcharts-x45f6hp-0'
  1974. *
  1975. * @function Highcharts.uniqueKey
  1976. *
  1977. * @return {string}
  1978. * A unique key.
  1979. */
  1980. var uniqueKey = (function () {
  1981. var hash = Math.random().toString(36).substring(2, 9) + '-';
  1982. var id = 0;
  1983. return function () {
  1984. return 'highcharts-' + (serialMode ? '' : hash) + id++;
  1985. };
  1986. }());
  1987. /**
  1988. * Activates a serial mode for element IDs provided by
  1989. * {@link Highcharts.uniqueKey}. This mode can be used in automated tests, where
  1990. * a simple comparison of two rendered SVG graphics is needed.
  1991. *
  1992. * **Note:** This is only for testing purposes and will break functionality in
  1993. * webpages with multiple charts.
  1994. *
  1995. * @example
  1996. * if (
  1997. * process &&
  1998. * process.env.NODE_ENV === 'development'
  1999. * ) {
  2000. * Highcharts.useSerialIds(true);
  2001. * }
  2002. *
  2003. * @function Highcharts.useSerialIds
  2004. *
  2005. * @param {boolean} [mode]
  2006. * Changes the state of serial mode.
  2007. *
  2008. * @return {boolean|undefined}
  2009. * State of the serial mode.
  2010. */
  2011. function useSerialIds(mode) {
  2012. return (serialMode = pick(mode, serialMode));
  2013. }
  2014. function isFunction(obj) {
  2015. return typeof obj === 'function';
  2016. }
  2017. // Register Highcharts as a plugin in jQuery
  2018. if (win.jQuery) {
  2019. /**
  2020. * Highcharts-extended JQuery.
  2021. *
  2022. * @external JQuery
  2023. */
  2024. /**
  2025. * Helper function to return the chart of the current JQuery selector
  2026. * element.
  2027. *
  2028. * @function external:JQuery#highcharts
  2029. *
  2030. * @return {Highcharts.Chart}
  2031. * The chart that is linked to the JQuery selector element.
  2032. */ /**
  2033. * Factory function to create a chart in the current JQuery selector
  2034. * element.
  2035. *
  2036. * @function external:JQuery#highcharts
  2037. *
  2038. * @param {'Chart'|'Map'|'StockChart'|string} [className]
  2039. * Name of the factory class in the Highcharts namespace.
  2040. *
  2041. * @param {Highcharts.Options} [options]
  2042. * The chart options structure.
  2043. *
  2044. * @param {Highcharts.ChartCallbackFunction} [callback]
  2045. * Function to run when the chart has loaded and and all external
  2046. * images are loaded. Defining a
  2047. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  2048. * handler is equivalent.
  2049. *
  2050. * @return {JQuery}
  2051. * The current JQuery selector.
  2052. */
  2053. win.jQuery.fn.highcharts = function () {
  2054. var args = [].slice.call(arguments);
  2055. if (this[0]) { // this[0] is the renderTo div
  2056. // Create the chart
  2057. if (args[0]) {
  2058. new H[ // eslint-disable-line computed-property-spacing, no-new
  2059. // Constructor defaults to Chart
  2060. isString(args[0]) ? args.shift() : 'Chart'](this[0], args[0], args[1]);
  2061. return this;
  2062. }
  2063. // When called without parameters or with the return argument,
  2064. // return an existing chart
  2065. return charts[attr(this[0], 'data-highcharts-chart')];
  2066. }
  2067. };
  2068. }
  2069. // TODO use named exports when supported.
  2070. var utilitiesModule = {
  2071. addEvent: addEvent,
  2072. arrayMax: arrayMax,
  2073. arrayMin: arrayMin,
  2074. attr: attr,
  2075. clamp: clamp,
  2076. cleanRecursively: cleanRecursively,
  2077. clearTimeout: internalClearTimeout,
  2078. correctFloat: correctFloat,
  2079. createElement: createElement,
  2080. css: css,
  2081. defined: defined,
  2082. destroyObjectProperties: destroyObjectProperties,
  2083. discardElement: discardElement,
  2084. erase: erase,
  2085. error: error,
  2086. extend: extend,
  2087. extendClass: extendClass,
  2088. find: find,
  2089. fireEvent: fireEvent,
  2090. getMagnitude: getMagnitude,
  2091. getNestedProperty: getNestedProperty,
  2092. getStyle: getStyle,
  2093. inArray: inArray,
  2094. isArray: isArray,
  2095. isClass: isClass,
  2096. isDOMElement: isDOMElement,
  2097. isFunction: isFunction,
  2098. isNumber: isNumber,
  2099. isObject: isObject,
  2100. isString: isString,
  2101. keys: keys,
  2102. merge: merge,
  2103. normalizeTickInterval: normalizeTickInterval,
  2104. objectEach: objectEach,
  2105. offset: offset,
  2106. pad: pad,
  2107. pick: pick,
  2108. pInt: pInt,
  2109. relativeLength: relativeLength,
  2110. removeEvent: removeEvent,
  2111. splat: splat,
  2112. stableSort: stableSort,
  2113. syncTimeout: syncTimeout,
  2114. timeUnits: timeUnits,
  2115. uniqueKey: uniqueKey,
  2116. useSerialIds: useSerialIds,
  2117. wrap: wrap
  2118. };
  2119. return utilitiesModule;
  2120. });
  2121. _registerModule(_modules, 'Core/Color/Color.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  2122. /* *
  2123. *
  2124. * (c) 2010-2021 Torstein Honsi
  2125. *
  2126. * License: www.highcharts.com/license
  2127. *
  2128. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2129. *
  2130. * */
  2131. var isNumber = U.isNumber,
  2132. merge = U.merge,
  2133. pInt = U.pInt;
  2134. /**
  2135. * A valid color to be parsed and handled by Highcharts. Highcharts internally
  2136. * supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
  2137. * rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
  2138. * browsers and displayed correctly, but Highcharts is not able to process them
  2139. * and apply concepts like opacity and brightening.
  2140. *
  2141. * @typedef {string} Highcharts.ColorString
  2142. */
  2143. /**
  2144. * A valid color type than can be parsed and handled by Highcharts. It can be a
  2145. * color string, a gradient object, or a pattern object.
  2146. *
  2147. * @typedef {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} Highcharts.ColorType
  2148. */
  2149. /**
  2150. * Gradient options instead of a solid color.
  2151. *
  2152. * @example
  2153. * // Linear gradient used as a color option
  2154. * color: {
  2155. * linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
  2156. * stops: [
  2157. * [0, '#003399'], // start
  2158. * [0.5, '#ffffff'], // middle
  2159. * [1, '#3366AA'] // end
  2160. * ]
  2161. * }
  2162. *
  2163. * @interface Highcharts.GradientColorObject
  2164. */ /**
  2165. * Holds an object that defines the start position and the end position relative
  2166. * to the shape.
  2167. * @name Highcharts.GradientColorObject#linearGradient
  2168. * @type {Highcharts.LinearGradientColorObject|undefined}
  2169. */ /**
  2170. * Holds an object that defines the center position and the radius.
  2171. * @name Highcharts.GradientColorObject#radialGradient
  2172. * @type {Highcharts.RadialGradientColorObject|undefined}
  2173. */ /**
  2174. * The first item in each tuple is the position in the gradient, where 0 is the
  2175. * start of the gradient and 1 is the end of the gradient. Multiple stops can be
  2176. * applied. The second item is the color for each stop. This color can also be
  2177. * given in the rgba format.
  2178. * @name Highcharts.GradientColorObject#stops
  2179. * @type {Array<Highcharts.GradientColorStopObject>}
  2180. */
  2181. /**
  2182. * Color stop tuple.
  2183. *
  2184. * @see Highcharts.GradientColorObject
  2185. *
  2186. * @interface Highcharts.GradientColorStopObject
  2187. */ /**
  2188. * @name Highcharts.GradientColorStopObject#0
  2189. * @type {number}
  2190. */ /**
  2191. * @name Highcharts.GradientColorStopObject#1
  2192. * @type {Highcharts.ColorString}
  2193. */ /**
  2194. * @name Highcharts.GradientColorStopObject#color
  2195. * @type {Highcharts.Color|undefined}
  2196. */
  2197. /**
  2198. * Defines the start position and the end position for a gradient relative
  2199. * to the shape. Start position (x1, y1) and end position (x2, y2) are relative
  2200. * to the shape, where 0 means top/left and 1 is bottom/right.
  2201. *
  2202. * @interface Highcharts.LinearGradientColorObject
  2203. */ /**
  2204. * Start horizontal position of the gradient. Float ranges 0-1.
  2205. * @name Highcharts.LinearGradientColorObject#x1
  2206. * @type {number}
  2207. */ /**
  2208. * End horizontal position of the gradient. Float ranges 0-1.
  2209. * @name Highcharts.LinearGradientColorObject#x2
  2210. * @type {number}
  2211. */ /**
  2212. * Start vertical position of the gradient. Float ranges 0-1.
  2213. * @name Highcharts.LinearGradientColorObject#y1
  2214. * @type {number}
  2215. */ /**
  2216. * End vertical position of the gradient. Float ranges 0-1.
  2217. * @name Highcharts.LinearGradientColorObject#y2
  2218. * @type {number}
  2219. */
  2220. /**
  2221. * Defines the center position and the radius for a gradient.
  2222. *
  2223. * @interface Highcharts.RadialGradientColorObject
  2224. */ /**
  2225. * Center horizontal position relative to the shape. Float ranges 0-1.
  2226. * @name Highcharts.RadialGradientColorObject#cx
  2227. * @type {number}
  2228. */ /**
  2229. * Center vertical position relative to the shape. Float ranges 0-1.
  2230. * @name Highcharts.RadialGradientColorObject#cy
  2231. * @type {number}
  2232. */ /**
  2233. * Radius relative to the shape. Float ranges 0-1.
  2234. * @name Highcharts.RadialGradientColorObject#r
  2235. * @type {number}
  2236. */
  2237. ''; // detach doclets above
  2238. /* *
  2239. *
  2240. * Class
  2241. *
  2242. * */
  2243. /* eslint-disable no-invalid-this, valid-jsdoc */
  2244. /**
  2245. * Handle color operations. Some object methods are chainable.
  2246. *
  2247. * @class
  2248. * @name Highcharts.Color
  2249. *
  2250. * @param {Highcharts.ColorType} input
  2251. * The input color in either rbga or hex format
  2252. */
  2253. var Color = /** @class */ (function () {
  2254. /* *
  2255. *
  2256. * Constructors
  2257. *
  2258. * */
  2259. function Color(input) {
  2260. // Collection of parsers. This can be extended from the outside by pushing
  2261. // parsers to Highcharts.Color.prototype.parsers.
  2262. this.parsers = [{
  2263. // RGBA color
  2264. // eslint-disable-next-line max-len
  2265. 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*\)/,
  2266. parse: function (result) {
  2267. return [
  2268. pInt(result[1]),
  2269. pInt(result[2]),
  2270. pInt(result[3]),
  2271. parseFloat(result[4], 10)
  2272. ];
  2273. }
  2274. }, {
  2275. // RGB color
  2276. regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
  2277. parse: function (result) {
  2278. return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
  2279. }
  2280. }];
  2281. this.rgba = [];
  2282. // Backwards compatibility, allow class overwrite
  2283. if (H.Color !== Color) {
  2284. return new H.Color(input);
  2285. }
  2286. // Backwards compatibility, allow instanciation without new (#13053)
  2287. if (!(this instanceof Color)) {
  2288. return new Color(input);
  2289. }
  2290. this.init(input);
  2291. }
  2292. /* *
  2293. *
  2294. * Static Functions
  2295. *
  2296. * */
  2297. /**
  2298. * Creates a color instance out of a color string or object.
  2299. *
  2300. * @function Highcharts.Color.parse
  2301. *
  2302. * @param {Highcharts.ColorType} input
  2303. * The input color in either rbga or hex format.
  2304. *
  2305. * @return {Highcharts.Color}
  2306. * Color instance.
  2307. */
  2308. Color.parse = function (input) {
  2309. return new Color(input);
  2310. };
  2311. /* *
  2312. *
  2313. * Functions
  2314. *
  2315. * */
  2316. /**
  2317. * Parse the input color to rgba array
  2318. *
  2319. * @private
  2320. * @function Highcharts.Color#init
  2321. *
  2322. * @param {Highcharts.ColorType} input
  2323. * The input color in either rbga or hex format
  2324. *
  2325. * @return {void}
  2326. */
  2327. Color.prototype.init = function (input) {
  2328. var result,
  2329. rgba,
  2330. i,
  2331. parser,
  2332. len;
  2333. this.input = input = Color.names[input && input.toLowerCase ?
  2334. input.toLowerCase() :
  2335. ''] || input;
  2336. // Gradients
  2337. if (input && input.stops) {
  2338. this.stops = input.stops.map(function (stop) {
  2339. return new Color(stop[1]);
  2340. });
  2341. // Solid colors
  2342. }
  2343. else {
  2344. // Bitmasking as input[0] is not working for legacy IE.
  2345. if (input &&
  2346. input.charAt &&
  2347. input.charAt() === '#') {
  2348. len = input.length;
  2349. input = parseInt(input.substr(1), 16);
  2350. // Handle long-form, e.g. #AABBCC
  2351. if (len === 7) {
  2352. rgba = [
  2353. (input & 0xFF0000) >> 16,
  2354. (input & 0xFF00) >> 8,
  2355. (input & 0xFF),
  2356. 1
  2357. ];
  2358. // Handle short-form, e.g. #ABC
  2359. // In short form, the value is assumed to be the same
  2360. // for both nibbles for each component. e.g. #ABC = #AABBCC
  2361. }
  2362. else if (len === 4) {
  2363. rgba = [
  2364. (((input & 0xF00) >> 4) |
  2365. (input & 0xF00) >> 8),
  2366. (((input & 0xF0) >> 4) |
  2367. (input & 0xF0)),
  2368. ((input & 0xF) << 4) | (input & 0xF),
  2369. 1
  2370. ];
  2371. }
  2372. }
  2373. // Otherwise, check regex parsers
  2374. if (!rgba) {
  2375. i = this.parsers.length;
  2376. while (i-- && !rgba) {
  2377. parser = this.parsers[i];
  2378. result = parser.regex.exec(input);
  2379. if (result) {
  2380. rgba = parser.parse(result);
  2381. }
  2382. }
  2383. }
  2384. }
  2385. this.rgba = rgba || [];
  2386. };
  2387. /**
  2388. * Return the color or gradient stops in the specified format
  2389. *
  2390. * @function Highcharts.Color#get
  2391. *
  2392. * @param {string} [format]
  2393. * Possible values are 'a', 'rgb', 'rgba' (default).
  2394. *
  2395. * @return {Highcharts.ColorType}
  2396. * This color as a string or gradient stops.
  2397. */
  2398. Color.prototype.get = function (format) {
  2399. var input = this.input,
  2400. rgba = this.rgba,
  2401. ret;
  2402. if (typeof this.stops !== 'undefined') {
  2403. ret = merge(input);
  2404. ret.stops = [].concat(ret.stops);
  2405. this.stops.forEach(function (stop, i) {
  2406. ret.stops[i] = [
  2407. ret.stops[i][0],
  2408. stop.get(format)
  2409. ];
  2410. });
  2411. // it's NaN if gradient colors on a column chart
  2412. }
  2413. else if (rgba && isNumber(rgba[0])) {
  2414. if (format === 'rgb' || (!format && rgba[3] === 1)) {
  2415. ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
  2416. }
  2417. else if (format === 'a') {
  2418. ret = rgba[3];
  2419. }
  2420. else {
  2421. ret = 'rgba(' + rgba.join(',') + ')';
  2422. }
  2423. }
  2424. else {
  2425. ret = input;
  2426. }
  2427. return ret;
  2428. };
  2429. /**
  2430. * Brighten the color instance.
  2431. *
  2432. * @function Highcharts.Color#brighten
  2433. *
  2434. * @param {number} alpha
  2435. * The alpha value.
  2436. *
  2437. * @return {Highcharts.Color}
  2438. * This color with modifications.
  2439. */
  2440. Color.prototype.brighten = function (alpha) {
  2441. var i,
  2442. rgba = this.rgba;
  2443. if (this.stops) {
  2444. this.stops.forEach(function (stop) {
  2445. stop.brighten(alpha);
  2446. });
  2447. }
  2448. else if (isNumber(alpha) && alpha !== 0) {
  2449. for (i = 0; i < 3; i++) {
  2450. rgba[i] += pInt(alpha * 255);
  2451. if (rgba[i] < 0) {
  2452. rgba[i] = 0;
  2453. }
  2454. if (rgba[i] > 255) {
  2455. rgba[i] = 255;
  2456. }
  2457. }
  2458. }
  2459. return this;
  2460. };
  2461. /**
  2462. * Set the color's opacity to a given alpha value.
  2463. *
  2464. * @function Highcharts.Color#setOpacity
  2465. *
  2466. * @param {number} alpha
  2467. * Opacity between 0 and 1.
  2468. *
  2469. * @return {Highcharts.Color}
  2470. * Color with modifications.
  2471. */
  2472. Color.prototype.setOpacity = function (alpha) {
  2473. this.rgba[3] = alpha;
  2474. return this;
  2475. };
  2476. /**
  2477. * Return an intermediate color between two colors.
  2478. *
  2479. * @function Highcharts.Color#tweenTo
  2480. *
  2481. * @param {Highcharts.Color} to
  2482. * The color object to tween to.
  2483. *
  2484. * @param {number} pos
  2485. * The intermediate position, where 0 is the from color (current
  2486. * color item), and 1 is the `to` color.
  2487. *
  2488. * @return {Highcharts.ColorString}
  2489. * The intermediate color in rgba notation.
  2490. */
  2491. Color.prototype.tweenTo = function (to, pos) {
  2492. // Check for has alpha, because rgba colors perform worse due to lack of
  2493. // support in WebKit.
  2494. var fromRgba = this.rgba,
  2495. toRgba = to.rgba,
  2496. hasAlpha,
  2497. ret;
  2498. // Unsupported color, return to-color (#3920, #7034)
  2499. if (!toRgba.length || !fromRgba || !fromRgba.length) {
  2500. ret = to.input || 'none';
  2501. // Interpolate
  2502. }
  2503. else {
  2504. hasAlpha = (toRgba[3] !== 1 || fromRgba[3] !== 1);
  2505. ret = (hasAlpha ? 'rgba(' : 'rgb(') +
  2506. Math.round(toRgba[0] + (fromRgba[0] - toRgba[0]) * (1 - pos)) +
  2507. ',' +
  2508. Math.round(toRgba[1] + (fromRgba[1] - toRgba[1]) * (1 - pos)) +
  2509. ',' +
  2510. Math.round(toRgba[2] + (fromRgba[2] - toRgba[2]) * (1 - pos)) +
  2511. (hasAlpha ?
  2512. (',' +
  2513. (toRgba[3] + (fromRgba[3] - toRgba[3]) * (1 - pos))) :
  2514. '') +
  2515. ')';
  2516. }
  2517. return ret;
  2518. };
  2519. /* *
  2520. *
  2521. * Static Properties
  2522. *
  2523. * */
  2524. // Collection of named colors. Can be extended from the outside by adding
  2525. // colors to Highcharts.Color.names.
  2526. Color.names = {
  2527. white: '#ffffff',
  2528. black: '#000000'
  2529. };
  2530. return Color;
  2531. }());
  2532. H.Color = Color;
  2533. /**
  2534. * Creates a color instance out of a color string.
  2535. *
  2536. * @function Highcharts.color
  2537. *
  2538. * @param {Highcharts.ColorType} input
  2539. * The input color in either rbga or hex format
  2540. *
  2541. * @return {Highcharts.Color}
  2542. * Color instance
  2543. */
  2544. H.color = Color.parse;
  2545. /* *
  2546. *
  2547. * Export
  2548. *
  2549. * */
  2550. return Color;
  2551. });
  2552. _registerModule(_modules, 'Core/Color/Palette.js', [], function () {
  2553. var palette = {
  2554. /**
  2555. * Colors for data series and points.
  2556. */
  2557. colors: [
  2558. '#7cb5ec',
  2559. '#434348',
  2560. '#90ed7d',
  2561. '#f7a35c',
  2562. '#8085e9',
  2563. '#f15c80',
  2564. '#e4d354',
  2565. '#2b908f',
  2566. '#f45b5b',
  2567. '#91e8e1'
  2568. ],
  2569. /**
  2570. * Chart background,
  2571. point stroke for markers and columns etc
  2572. */
  2573. backgroundColor: '#ffffff',
  2574. /**
  2575. * Strong text.
  2576. */
  2577. neutralColor100: '#000000',
  2578. /**
  2579. * Main text and some strokes.
  2580. */
  2581. neutralColor80: '#333333',
  2582. /**
  2583. * Axis labels,
  2584. axis title,
  2585. connector fallback.
  2586. */
  2587. neutralColor60: '#666666',
  2588. /**
  2589. * Credits text,
  2590. export menu stroke.
  2591. */
  2592. neutralColor40: '#999999',
  2593. /**
  2594. * Disabled texts,
  2595. button strokes,
  2596. crosshair etc.
  2597. */
  2598. neutralColor20: '#cccccc',
  2599. /**
  2600. * Grid lines etc.
  2601. */
  2602. neutralColor10: '#e6e6e6',
  2603. /**
  2604. * Minor grid lines etc.
  2605. */
  2606. neutralColor5: '#f2f2f2',
  2607. /**
  2608. * Tooltip backgroud,
  2609. button fills,
  2610. map null points.
  2611. */
  2612. neutralColor3: '#f7f7f7',
  2613. /**
  2614. * Drilldown clickable labels,
  2615. color axis max color.
  2616. */
  2617. highlightColor100: '#003399',
  2618. /**
  2619. * Selection marker,
  2620. menu hover,
  2621. button hover,
  2622. chart border,
  2623. navigator series.
  2624. */
  2625. highlightColor80: '#335cad',
  2626. /**
  2627. * Navigator mask fill.
  2628. */
  2629. highlightColor60: '#6685c2',
  2630. /**
  2631. * Ticks and axis line.
  2632. */
  2633. highlightColor20: '#ccd6eb',
  2634. /**
  2635. * Pressed button,
  2636. color axis min color.
  2637. */
  2638. highlightColor10: '#e6ebf5',
  2639. /**
  2640. * Positive indicator color
  2641. */
  2642. positiveColor: '#06b535',
  2643. /**
  2644. * Negative indicator color
  2645. */
  2646. negativeColor: '#f21313'
  2647. };
  2648. return palette;
  2649. });
  2650. _registerModule(_modules, 'Core/Time.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  2651. /* *
  2652. *
  2653. * (c) 2010-2021 Torstein Honsi
  2654. *
  2655. * License: www.highcharts.com/license
  2656. *
  2657. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2658. *
  2659. * */
  2660. var win = H.win;
  2661. var defined = U.defined,
  2662. error = U.error,
  2663. extend = U.extend,
  2664. isObject = U.isObject,
  2665. merge = U.merge,
  2666. objectEach = U.objectEach,
  2667. pad = U.pad,
  2668. pick = U.pick,
  2669. splat = U.splat,
  2670. timeUnits = U.timeUnits;
  2671. /**
  2672. * Normalized interval.
  2673. *
  2674. * @interface Highcharts.TimeNormalizedObject
  2675. */ /**
  2676. * The count.
  2677. *
  2678. * @name Highcharts.TimeNormalizedObject#count
  2679. * @type {number}
  2680. */ /**
  2681. * The interval in axis values (ms).
  2682. *
  2683. * @name Highcharts.TimeNormalizedObject#unitRange
  2684. * @type {number}
  2685. */
  2686. /**
  2687. * Function of an additional date format specifier.
  2688. *
  2689. * @callback Highcharts.TimeFormatCallbackFunction
  2690. *
  2691. * @param {number} timestamp
  2692. * The time to format.
  2693. *
  2694. * @return {string}
  2695. * The formatted portion of the date.
  2696. */
  2697. /**
  2698. * Time ticks.
  2699. *
  2700. * @interface Highcharts.AxisTickPositionsArray
  2701. * @extends global.Array<number>
  2702. */ /**
  2703. * @name Highcharts.AxisTickPositionsArray#info
  2704. * @type {Highcharts.TimeTicksInfoObject|undefined}
  2705. */
  2706. /**
  2707. * A callback to return the time zone offset for a given datetime. It
  2708. * takes the timestamp in terms of milliseconds since January 1 1970,
  2709. * and returns the timezone offset in minutes. This provides a hook
  2710. * for drawing time based charts in specific time zones using their
  2711. * local DST crossover dates, with the help of external libraries.
  2712. *
  2713. * @callback Highcharts.TimezoneOffsetCallbackFunction
  2714. *
  2715. * @param {number} timestamp
  2716. * Timestamp in terms of milliseconds since January 1 1970.
  2717. *
  2718. * @return {number}
  2719. * Timezone offset in minutes.
  2720. */
  2721. /**
  2722. * Allows to manually load the `moment.js` library from Highcharts options
  2723. * instead of the `window`.
  2724. * In case of loading the library from a `script` tag,
  2725. * this option is not needed, it will be loaded from there by default.
  2726. *
  2727. * @type {function}
  2728. * @since 8.2.0
  2729. * @apioption time.moment
  2730. */
  2731. ''; // detach doclets above
  2732. /* eslint-disable no-invalid-this, valid-jsdoc */
  2733. /**
  2734. * The Time class. Time settings are applied in general for each page using
  2735. * `Highcharts.setOptions`, or individually for each Chart item through the
  2736. * [time](https://api.highcharts.com/highcharts/time) options set.
  2737. *
  2738. * The Time object is available from {@link Highcharts.Chart#time},
  2739. * which refers to `Highcharts.time` if no individual time settings are
  2740. * applied.
  2741. *
  2742. * @example
  2743. * // Apply time settings globally
  2744. * Highcharts.setOptions({
  2745. * time: {
  2746. * timezone: 'Europe/London'
  2747. * }
  2748. * });
  2749. *
  2750. * // Apply time settings by instance
  2751. * let chart = Highcharts.chart('container', {
  2752. * time: {
  2753. * timezone: 'America/New_York'
  2754. * },
  2755. * series: [{
  2756. * data: [1, 4, 3, 5]
  2757. * }]
  2758. * });
  2759. *
  2760. * // Use the Time object
  2761. * console.log(
  2762. * 'Current time in New York',
  2763. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  2764. * );
  2765. *
  2766. * @since 6.0.5
  2767. *
  2768. * @class
  2769. * @name Highcharts.Time
  2770. *
  2771. * @param {Highcharts.TimeOptions} options
  2772. * Time options as defined in [chart.options.time](/highcharts/time).
  2773. */
  2774. var Time = /** @class */ (function () {
  2775. /* *
  2776. *
  2777. * Constructors
  2778. *
  2779. * */
  2780. function Time(options) {
  2781. /* *
  2782. *
  2783. * Properties
  2784. *
  2785. * */
  2786. this.options = {};
  2787. this.useUTC = false;
  2788. this.variableTimezone = false;
  2789. this.Date = win.Date;
  2790. /**
  2791. * Get the time zone offset based on the current timezone information as
  2792. * set in the global options.
  2793. *
  2794. * @function Highcharts.Time#getTimezoneOffset
  2795. *
  2796. * @param {number} timestamp
  2797. * The JavaScript timestamp to inspect.
  2798. *
  2799. * @return {number}
  2800. * The timezone offset in minutes compared to UTC.
  2801. */
  2802. this.getTimezoneOffset = this.timezoneOffsetFunction();
  2803. this.update(options);
  2804. }
  2805. /* *
  2806. *
  2807. * Functions
  2808. *
  2809. * */
  2810. /**
  2811. * Time units used in `Time.get` and `Time.set`
  2812. *
  2813. * @typedef {"Date"|"Day"|"FullYear"|"Hours"|"Milliseconds"|"Minutes"|"Month"|"Seconds"} Highcharts.TimeUnitValue
  2814. */
  2815. /**
  2816. * Get the value of a date object in given units, and subject to the Time
  2817. * object's current timezone settings. This function corresponds directly to
  2818. * JavaScripts `Date.getXXX / Date.getUTCXXX`, so instead of calling
  2819. * `date.getHours()` or `date.getUTCHours()` we will call
  2820. * `time.get('Hours')`.
  2821. *
  2822. * @function Highcharts.Time#get
  2823. *
  2824. * @param {Highcharts.TimeUnitValue} unit
  2825. * @param {Date} date
  2826. *
  2827. * @return {number}
  2828. * The given time unit
  2829. */
  2830. Time.prototype.get = function (unit, date) {
  2831. if (this.variableTimezone || this.timezoneOffset) {
  2832. var realMs = date.getTime();
  2833. var ms = realMs - this.getTimezoneOffset(date);
  2834. date.setTime(ms); // Temporary adjust to timezone
  2835. var ret = date['getUTC' + unit]();
  2836. date.setTime(realMs); // Reset
  2837. return ret;
  2838. }
  2839. // UTC time with no timezone handling
  2840. if (this.useUTC) {
  2841. return date['getUTC' + unit]();
  2842. }
  2843. // Else, local time
  2844. return date['get' + unit]();
  2845. };
  2846. /**
  2847. * Set the value of a date object in given units, and subject to the Time
  2848. * object's current timezone settings. This function corresponds directly to
  2849. * JavaScripts `Date.setXXX / Date.setUTCXXX`, so instead of calling
  2850. * `date.setHours(0)` or `date.setUTCHours(0)` we will call
  2851. * `time.set('Hours', 0)`.
  2852. *
  2853. * @function Highcharts.Time#set
  2854. *
  2855. * @param {Highcharts.TimeUnitValue} unit
  2856. * @param {Date} date
  2857. * @param {number} value
  2858. *
  2859. * @return {number}
  2860. * The epoch milliseconds of the updated date
  2861. */
  2862. Time.prototype.set = function (unit, date, value) {
  2863. // UTC time with timezone handling
  2864. if (this.variableTimezone || this.timezoneOffset) {
  2865. // For lower order time units, just set it directly using UTC
  2866. // time
  2867. if (unit === 'Milliseconds' ||
  2868. unit === 'Seconds' ||
  2869. (unit === 'Minutes' && this.getTimezoneOffset(date) % 3600000 === 0) // #13961
  2870. ) {
  2871. return date['setUTC' + unit](value);
  2872. }
  2873. // Higher order time units need to take the time zone into
  2874. // account
  2875. // Adjust by timezone
  2876. var offset = this.getTimezoneOffset(date);
  2877. var ms = date.getTime() - offset;
  2878. date.setTime(ms);
  2879. date['setUTC' + unit](value);
  2880. var newOffset = this.getTimezoneOffset(date);
  2881. ms = date.getTime() + newOffset;
  2882. return date.setTime(ms);
  2883. }
  2884. // UTC time with no timezone handling
  2885. if (this.useUTC) {
  2886. return date['setUTC' + unit](value);
  2887. }
  2888. // Else, local time
  2889. return date['set' + unit](value);
  2890. };
  2891. /**
  2892. * Update the Time object with current options. It is called internally on
  2893. * initializing Highcharts, after running `Highcharts.setOptions` and on
  2894. * `Chart.update`.
  2895. *
  2896. * @private
  2897. * @function Highcharts.Time#update
  2898. *
  2899. * @param {Highcharts.TimeOptions} options
  2900. *
  2901. * @return {void}
  2902. */
  2903. Time.prototype.update = function (options) {
  2904. var useUTC = pick(options && options.useUTC,
  2905. true),
  2906. time = this;
  2907. this.options = options = merge(true, this.options || {}, options);
  2908. // Allow using a different Date class
  2909. this.Date = options.Date || win.Date || Date;
  2910. this.useUTC = useUTC;
  2911. this.timezoneOffset = (useUTC && options.timezoneOffset);
  2912. this.getTimezoneOffset = this.timezoneOffsetFunction();
  2913. /*
  2914. * The time object has options allowing for variable time zones, meaning
  2915. * the axis ticks or series data needs to consider this.
  2916. */
  2917. this.variableTimezone = useUTC && !!(options.getTimezoneOffset ||
  2918. options.timezone);
  2919. };
  2920. /**
  2921. * Make a time and returns milliseconds. Interprets the inputs as UTC time,
  2922. * local time or a specific timezone time depending on the current time
  2923. * settings.
  2924. *
  2925. * @function Highcharts.Time#makeTime
  2926. *
  2927. * @param {number} year
  2928. * The year
  2929. *
  2930. * @param {number} month
  2931. * The month. Zero-based, so January is 0.
  2932. *
  2933. * @param {number} [date=1]
  2934. * The day of the month
  2935. *
  2936. * @param {number} [hours=0]
  2937. * The hour of the day, 0-23.
  2938. *
  2939. * @param {number} [minutes=0]
  2940. * The minutes
  2941. *
  2942. * @param {number} [seconds=0]
  2943. * The seconds
  2944. *
  2945. * @return {number}
  2946. * The time in milliseconds since January 1st 1970.
  2947. */
  2948. Time.prototype.makeTime = function (year, month, date, hours, minutes, seconds) {
  2949. var d,
  2950. offset,
  2951. newOffset;
  2952. if (this.useUTC) {
  2953. d = this.Date.UTC.apply(0, arguments);
  2954. offset = this.getTimezoneOffset(d);
  2955. d += offset;
  2956. newOffset = this.getTimezoneOffset(d);
  2957. if (offset !== newOffset) {
  2958. d += newOffset - offset;
  2959. // A special case for transitioning from summer time to winter time.
  2960. // When the clock is set back, the same time is repeated twice, i.e.
  2961. // 02:30 am is repeated since the clock is set back from 3 am to
  2962. // 2 am. We need to make the same time as local Date does.
  2963. }
  2964. else if (offset - 36e5 === this.getTimezoneOffset(d - 36e5) &&
  2965. !H.isSafari) {
  2966. d -= 36e5;
  2967. }
  2968. }
  2969. else {
  2970. d = new this.Date(year, month, pick(date, 1), pick(hours, 0), pick(minutes, 0), pick(seconds, 0)).getTime();
  2971. }
  2972. return d;
  2973. };
  2974. /**
  2975. * Sets the getTimezoneOffset function. If the `timezone` option is set, a
  2976. * default getTimezoneOffset function with that timezone is returned. If
  2977. * a `getTimezoneOffset` option is defined, it is returned. If neither are
  2978. * specified, the function using the `timezoneOffset` option or 0 offset is
  2979. * returned.
  2980. *
  2981. * @private
  2982. * @function Highcharts.Time#timezoneOffsetFunction
  2983. *
  2984. * @return {Function}
  2985. * A getTimezoneOffset function
  2986. */
  2987. Time.prototype.timezoneOffsetFunction = function () {
  2988. var time = this,
  2989. options = this.options,
  2990. moment = options.moment || win.moment;
  2991. if (!this.useUTC) {
  2992. return function (timestamp) {
  2993. return new Date(timestamp.toString()).getTimezoneOffset() * 60000;
  2994. };
  2995. }
  2996. if (options.timezone) {
  2997. if (!moment) {
  2998. // getTimezoneOffset-function stays undefined because it depends
  2999. // on Moment.js
  3000. error(25);
  3001. }
  3002. else {
  3003. return function (timestamp) {
  3004. return -moment.tz(timestamp, options.timezone).utcOffset() * 60000;
  3005. };
  3006. }
  3007. }
  3008. // If not timezone is set, look for the getTimezoneOffset callback
  3009. if (this.useUTC && options.getTimezoneOffset) {
  3010. return function (timestamp) {
  3011. return options.getTimezoneOffset(timestamp.valueOf()) * 60000;
  3012. };
  3013. }
  3014. // Last, use the `timezoneOffset` option if set
  3015. return function () {
  3016. return (time.timezoneOffset || 0) * 60000;
  3017. };
  3018. };
  3019. /**
  3020. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970)
  3021. * into a human readable date string. The available format keys are listed
  3022. * below. Additional formats can be given in the
  3023. * {@link Highcharts.dateFormats} hook.
  3024. *
  3025. * Supported format keys:
  3026. * - `%a`: Short weekday, like 'Mon'
  3027. * - `%A`: Long weekday, like 'Monday'
  3028. * - `%d`: Two digit day of the month, 01 to 31
  3029. * - `%e`: Day of the month, 1 through 31
  3030. * - `%w`: Day of the week, 0 through 6
  3031. * - `%b`: Short month, like 'Jan'
  3032. * - `%B`: Long month, like 'January'
  3033. * - `%m`: Two digit month number, 01 through 12
  3034. * - `%y`: Two digits year, like 09 for 2009
  3035. * - `%Y`: Four digits year, like 2009
  3036. * - `%H`: Two digits hours in 24h format, 00 through 23
  3037. * - `%k`: Hours in 24h format, 0 through 23
  3038. * - `%I`: Two digits hours in 12h format, 00 through 11
  3039. * - `%l`: Hours in 12h format, 1 through 12
  3040. * - `%M`: Two digits minutes, 00 through 59
  3041. * - `%p`: Upper case AM or PM
  3042. * - `%P`: Lower case AM or PM
  3043. * - `%S`: Two digits seconds, 00 through 59
  3044. * - `%L`: Milliseconds (naming from Ruby)
  3045. *
  3046. * @example
  3047. * const time = new Highcharts.Time();
  3048. * const s = time.dateFormat('%Y-%m-%d %H:%M:%S', Date.UTC(2020, 0, 1));
  3049. * console.log(s); // => 2020-01-01 00:00:00
  3050. *
  3051. * @function Highcharts.Time#dateFormat
  3052. *
  3053. * @param {string} format
  3054. * The desired format where various time representations are
  3055. * prefixed with %.
  3056. *
  3057. * @param {number} [timestamp]
  3058. * The JavaScript timestamp.
  3059. *
  3060. * @param {boolean} [capitalize=false]
  3061. * Upper case first letter in the return.
  3062. *
  3063. * @return {string}
  3064. * The formatted date.
  3065. */
  3066. Time.prototype.dateFormat = function (format, timestamp, capitalize) {
  3067. if (!defined(timestamp) || isNaN(timestamp)) {
  3068. return (H.defaultOptions.lang &&
  3069. H.defaultOptions.lang.invalidDate ||
  3070. '');
  3071. }
  3072. format = pick(format, '%Y-%m-%d %H:%M:%S');
  3073. var time = this, date = new this.Date(timestamp),
  3074. // get the basic time values
  3075. 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),
  3076. // List all format keys. Custom formats can be added from the
  3077. // outside.
  3078. replacements = extend({
  3079. // Day
  3080. // Short weekday, like 'Mon'
  3081. a: shortWeekdays ?
  3082. shortWeekdays[day] :
  3083. langWeekdays[day].substr(0, 3),
  3084. // Long weekday, like 'Monday'
  3085. A: langWeekdays[day],
  3086. // Two digit day of the month, 01 to 31
  3087. d: pad(dayOfMonth),
  3088. // Day of the month, 1 through 31
  3089. e: pad(dayOfMonth, 2, ' '),
  3090. // Day of the week, 0 through 6
  3091. w: day,
  3092. // Week (none implemented)
  3093. // 'W': weekNumber(),
  3094. // Month
  3095. // Short month, like 'Jan'
  3096. b: lang.shortMonths[month],
  3097. // Long month, like 'January'
  3098. B: lang.months[month],
  3099. // Two digit month number, 01 through 12
  3100. m: pad(month + 1),
  3101. // Month number, 1 through 12 (#8150)
  3102. o: month + 1,
  3103. // Year
  3104. // Two digits year, like 09 for 2009
  3105. y: fullYear.toString().substr(2, 2),
  3106. // Four digits year, like 2009
  3107. Y: fullYear,
  3108. // Time
  3109. // Two digits hours in 24h format, 00 through 23
  3110. H: pad(hours),
  3111. // Hours in 24h format, 0 through 23
  3112. k: hours,
  3113. // Two digits hours in 12h format, 00 through 11
  3114. I: pad((hours % 12) || 12),
  3115. // Hours in 12h format, 1 through 12
  3116. l: (hours % 12) || 12,
  3117. // Two digits minutes, 00 through 59
  3118. M: pad(this.get('Minutes', date)),
  3119. // Upper case AM or PM
  3120. p: hours < 12 ? 'AM' : 'PM',
  3121. // Lower case AM or PM
  3122. P: hours < 12 ? 'am' : 'pm',
  3123. // Two digits seconds, 00 through 59
  3124. S: pad(date.getSeconds()),
  3125. // Milliseconds (naming from Ruby)
  3126. L: pad(Math.floor(timestamp % 1000), 3)
  3127. }, H.dateFormats);
  3128. // Do the replaces
  3129. objectEach(replacements, function (val, key) {
  3130. // Regex would do it in one line, but this is faster
  3131. while (format.indexOf('%' + key) !== -1) {
  3132. format = format.replace('%' + key, typeof val === 'function' ? val.call(time, timestamp) : val);
  3133. }
  3134. });
  3135. // Optionally capitalize the string and return
  3136. return capitalize ?
  3137. (format.substr(0, 1).toUpperCase() +
  3138. format.substr(1)) :
  3139. format;
  3140. };
  3141. /**
  3142. * Resolve legacy formats of dateTimeLabelFormats (strings and arrays) into
  3143. * an object.
  3144. * @private
  3145. * @param {string|Array<T>|Highcharts.Dictionary<T>} f - General format description
  3146. * @return {Highcharts.Dictionary<T>} - The object definition
  3147. */
  3148. Time.prototype.resolveDTLFormat = function (f) {
  3149. if (!isObject(f, true)) { // check for string or array
  3150. f = splat(f);
  3151. return {
  3152. main: f[0],
  3153. from: f[1],
  3154. to: f[2]
  3155. };
  3156. }
  3157. return f;
  3158. };
  3159. /**
  3160. * Return an array with time positions distributed on round time values
  3161. * right and right after min and max. Used in datetime axes as well as for
  3162. * grouping data on a datetime axis.
  3163. *
  3164. * @function Highcharts.Time#getTimeTicks
  3165. *
  3166. * @param {Highcharts.TimeNormalizedObject} normalizedInterval
  3167. * The interval in axis values (ms) and the count
  3168. *
  3169. * @param {number} [min]
  3170. * The minimum in axis values
  3171. *
  3172. * @param {number} [max]
  3173. * The maximum in axis values
  3174. *
  3175. * @param {number} [startOfWeek=1]
  3176. *
  3177. * @return {Highcharts.AxisTickPositionsArray}
  3178. */
  3179. Time.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek) {
  3180. var time = this,
  3181. Date = time.Date,
  3182. tickPositions = [],
  3183. i,
  3184. higherRanks = {},
  3185. minYear, // used in months and years as a basis for Date.UTC()
  3186. // When crossing DST, use the max. Resolves #6278.
  3187. minDate = new Date(min),
  3188. interval = normalizedInterval.unitRange,
  3189. count = normalizedInterval.count || 1,
  3190. variableDayLength,
  3191. minDay;
  3192. startOfWeek = pick(startOfWeek, 1);
  3193. if (defined(min)) { // #1300
  3194. time.set('Milliseconds', minDate, interval >= timeUnits.second ?
  3195. 0 : // #3935
  3196. count * Math.floor(time.get('Milliseconds', minDate) / count)); // #3652, #3654
  3197. if (interval >= timeUnits.second) { // second
  3198. time.set('Seconds', minDate, interval >= timeUnits.minute ?
  3199. 0 : // #3935
  3200. count * Math.floor(time.get('Seconds', minDate) / count));
  3201. }
  3202. if (interval >= timeUnits.minute) { // minute
  3203. time.set('Minutes', minDate, interval >= timeUnits.hour ?
  3204. 0 :
  3205. count * Math.floor(time.get('Minutes', minDate) / count));
  3206. }
  3207. if (interval >= timeUnits.hour) { // hour
  3208. time.set('Hours', minDate, interval >= timeUnits.day ?
  3209. 0 :
  3210. count * Math.floor(time.get('Hours', minDate) / count));
  3211. }
  3212. if (interval >= timeUnits.day) { // day
  3213. time.set('Date', minDate, interval >= timeUnits.month ?
  3214. 1 :
  3215. Math.max(1, count * Math.floor(time.get('Date', minDate) / count)));
  3216. }
  3217. if (interval >= timeUnits.month) { // month
  3218. time.set('Month', minDate, interval >= timeUnits.year ? 0 :
  3219. count * Math.floor(time.get('Month', minDate) / count));
  3220. minYear = time.get('FullYear', minDate);
  3221. }
  3222. if (interval >= timeUnits.year) { // year
  3223. minYear -= minYear % count;
  3224. time.set('FullYear', minDate, minYear);
  3225. }
  3226. // week is a special case that runs outside the hierarchy
  3227. if (interval === timeUnits.week) {
  3228. // get start of current week, independent of count
  3229. minDay = time.get('Day', minDate);
  3230. time.set('Date', minDate, (time.get('Date', minDate) -
  3231. minDay + startOfWeek +
  3232. // We don't want to skip days that are before
  3233. // startOfWeek (#7051)
  3234. (minDay < startOfWeek ? -7 : 0)));
  3235. }
  3236. // Get basics for variable time spans
  3237. minYear = time.get('FullYear', minDate);
  3238. var minMonth = time.get('Month', minDate), minDateDate = time.get('Date', minDate), minHours = time.get('Hours', minDate);
  3239. // Redefine min to the floored/rounded minimum time (#7432)
  3240. min = minDate.getTime();
  3241. // Handle local timezone offset
  3242. if ((time.variableTimezone || !time.useUTC) && defined(max)) {
  3243. // Detect whether we need to take the DST crossover into
  3244. // consideration. If we're crossing over DST, the day length may
  3245. // be 23h or 25h and we need to compute the exact clock time for
  3246. // each tick instead of just adding hours. This comes at a cost,
  3247. // so first we find out if it is needed (#4951).
  3248. variableDayLength = (
  3249. // Long range, assume we're crossing over.
  3250. max - min > 4 * timeUnits.month ||
  3251. // Short range, check if min and max are in different time
  3252. // zones.
  3253. time.getTimezoneOffset(min) !==
  3254. time.getTimezoneOffset(max));
  3255. }
  3256. // Iterate and add tick positions at appropriate values
  3257. var t = minDate.getTime();
  3258. i = 1;
  3259. while (t < max) {
  3260. tickPositions.push(t);
  3261. // if the interval is years, use Date.UTC to increase years
  3262. if (interval === timeUnits.year) {
  3263. t = time.makeTime(minYear + i * count, 0);
  3264. // if the interval is months, use Date.UTC to increase months
  3265. }
  3266. else if (interval === timeUnits.month) {
  3267. t = time.makeTime(minYear, minMonth + i * count);
  3268. // if we're using global time, the interval is not fixed as it
  3269. // jumps one hour at the DST crossover
  3270. }
  3271. else if (variableDayLength &&
  3272. (interval === timeUnits.day || interval === timeUnits.week)) {
  3273. t = time.makeTime(minYear, minMonth, minDateDate +
  3274. i * count * (interval === timeUnits.day ? 1 : 7));
  3275. }
  3276. else if (variableDayLength &&
  3277. interval === timeUnits.hour &&
  3278. count > 1) {
  3279. // make sure higher ranks are preserved across DST (#6797,
  3280. // #7621)
  3281. t = time.makeTime(minYear, minMonth, minDateDate, minHours + i * count);
  3282. // else, the interval is fixed and we use simple addition
  3283. }
  3284. else {
  3285. t += interval * count;
  3286. }
  3287. i++;
  3288. }
  3289. // push the last time
  3290. tickPositions.push(t);
  3291. // Handle higher ranks. Mark new days if the time is on midnight
  3292. // (#950, #1649, #1760, #3349). Use a reasonable dropout threshold
  3293. // to prevent looping over dense data grouping (#6156).
  3294. if (interval <= timeUnits.hour && tickPositions.length < 10000) {
  3295. tickPositions.forEach(function (t) {
  3296. if (
  3297. // Speed optimization, no need to run dateFormat unless
  3298. // we're on a full or half hour
  3299. t % 1800000 === 0 &&
  3300. // Check for local or global midnight
  3301. time.dateFormat('%H%M%S%L', t) === '000000000') {
  3302. higherRanks[t] = 'day';
  3303. }
  3304. });
  3305. }
  3306. }
  3307. // record information on the chosen unit - for dynamic label formatter
  3308. tickPositions.info = extend(normalizedInterval, {
  3309. higherRanks: higherRanks,
  3310. totalRange: interval * count
  3311. });
  3312. return tickPositions;
  3313. };
  3314. return Time;
  3315. }());
  3316. H.Time = Time;
  3317. return H.Time;
  3318. });
  3319. _registerModule(_modules, 'Core/Options.js', [_modules['Core/Globals.js'], _modules['Core/Color/Color.js'], _modules['Core/Color/Palette.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (H, Color, palette, Time, U) {
  3320. /* *
  3321. *
  3322. * (c) 2010-2021 Torstein Honsi
  3323. *
  3324. * License: www.highcharts.com/license
  3325. *
  3326. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3327. *
  3328. * */
  3329. var isTouchDevice = H.isTouchDevice,
  3330. svg = H.svg;
  3331. var color = Color.parse;
  3332. var getNestedProperty = U.getNestedProperty,
  3333. isNumber = U.isNumber,
  3334. merge = U.merge,
  3335. pick = U.pick,
  3336. pInt = U.pInt;
  3337. /* *
  3338. *
  3339. * API Declarations
  3340. *
  3341. * */
  3342. /**
  3343. * @typedef {"plotBox"|"spacingBox"} Highcharts.ButtonRelativeToValue
  3344. */
  3345. /**
  3346. * Gets fired when a series is added to the chart after load time, using the
  3347. * `addSeries` method. Returning `false` prevents the series from being added.
  3348. *
  3349. * @callback Highcharts.ChartAddSeriesCallbackFunction
  3350. *
  3351. * @param {Highcharts.Chart} this
  3352. * The chart on which the event occured.
  3353. *
  3354. * @param {Highcharts.ChartAddSeriesEventObject} event
  3355. * The event that occured.
  3356. */
  3357. /**
  3358. * Contains common event information. Through the `options` property you can
  3359. * access the series options that were passed to the `addSeries` method.
  3360. *
  3361. * @interface Highcharts.ChartAddSeriesEventObject
  3362. */ /**
  3363. * The series options that were passed to the `addSeries` method.
  3364. * @name Highcharts.ChartAddSeriesEventObject#options
  3365. * @type {Highcharts.SeriesOptionsType}
  3366. */ /**
  3367. * Prevents the default behaviour of the event.
  3368. * @name Highcharts.ChartAddSeriesEventObject#preventDefault
  3369. * @type {Function}
  3370. */ /**
  3371. * The event target.
  3372. * @name Highcharts.ChartAddSeriesEventObject#target
  3373. * @type {Highcharts.Chart}
  3374. */ /**
  3375. * The event type.
  3376. * @name Highcharts.ChartAddSeriesEventObject#type
  3377. * @type {"addSeries"}
  3378. */
  3379. /**
  3380. * Gets fired when clicking on the plot background.
  3381. *
  3382. * @callback Highcharts.ChartClickCallbackFunction
  3383. *
  3384. * @param {Highcharts.Chart} this
  3385. * The chart on which the event occured.
  3386. *
  3387. * @param {Highcharts.PointerEventObject} event
  3388. * The event that occured.
  3389. */
  3390. /**
  3391. * Contains an axes of the clicked spot.
  3392. *
  3393. * @interface Highcharts.ChartClickEventAxisObject
  3394. */ /**
  3395. * Axis at the clicked spot.
  3396. * @name Highcharts.ChartClickEventAxisObject#axis
  3397. * @type {Highcharts.Axis}
  3398. */ /**
  3399. * Axis value at the clicked spot.
  3400. * @name Highcharts.ChartClickEventAxisObject#value
  3401. * @type {number}
  3402. */
  3403. /**
  3404. * Contains information about the clicked spot on the chart. Remember the unit
  3405. * of a datetime axis is milliseconds since 1970-01-01 00:00:00.
  3406. *
  3407. * @interface Highcharts.ChartClickEventObject
  3408. * @extends Highcharts.PointerEventObject
  3409. */ /**
  3410. * Information about the x-axis on the clicked spot.
  3411. * @name Highcharts.ChartClickEventObject#xAxis
  3412. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  3413. */ /**
  3414. * Information about the y-axis on the clicked spot.
  3415. * @name Highcharts.ChartClickEventObject#yAxis
  3416. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  3417. */ /**
  3418. * Information about the z-axis on the clicked spot.
  3419. * @name Highcharts.ChartClickEventObject#zAxis
  3420. * @type {Array<Highcharts.ChartClickEventAxisObject>|undefined}
  3421. */
  3422. /**
  3423. * Gets fired when the chart is finished loading.
  3424. *
  3425. * @callback Highcharts.ChartLoadCallbackFunction
  3426. *
  3427. * @param {Highcharts.Chart} this
  3428. * The chart on which the event occured.
  3429. *
  3430. * @param {global.Event} event
  3431. * The event that occured.
  3432. */
  3433. /**
  3434. * Fires when the chart is redrawn, either after a call to `chart.redraw()` or
  3435. * after an axis, series or point is modified with the `redraw` option set to
  3436. * `true`.
  3437. *
  3438. * @callback Highcharts.ChartRedrawCallbackFunction
  3439. *
  3440. * @param {Highcharts.Chart} this
  3441. * The chart on which the event occured.
  3442. *
  3443. * @param {global.Event} event
  3444. * The event that occured.
  3445. */
  3446. /**
  3447. * Gets fired after initial load of the chart (directly after the `load` event),
  3448. * and after each redraw (directly after the `redraw` event).
  3449. *
  3450. * @callback Highcharts.ChartRenderCallbackFunction
  3451. *
  3452. * @param {Highcharts.Chart} this
  3453. * The chart on which the event occured.
  3454. *
  3455. * @param {global.Event} event
  3456. * The event that occured.
  3457. */
  3458. /**
  3459. * Gets fired when an area of the chart has been selected. The default action
  3460. * for the selection event is to zoom the chart to the selected area. It can be
  3461. * prevented by calling `event.preventDefault()` or return false.
  3462. *
  3463. * @callback Highcharts.ChartSelectionCallbackFunction
  3464. *
  3465. * @param {Highcharts.Chart} this
  3466. * The chart on which the event occured.
  3467. *
  3468. * @param {global.ChartSelectionContextObject} event
  3469. * Event informations
  3470. *
  3471. * @return {boolean|undefined}
  3472. * Return false to prevent the default action, usually zoom.
  3473. */
  3474. /**
  3475. * The primary axes are `xAxis[0]` and `yAxis[0]`. Remember the unit of a
  3476. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  3477. *
  3478. * @interface Highcharts.ChartSelectionContextObject
  3479. * @extends global.Event
  3480. */ /**
  3481. * Arrays containing the axes of each dimension and each axis' min and max
  3482. * values.
  3483. * @name Highcharts.ChartSelectionContextObject#xAxis
  3484. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  3485. */ /**
  3486. * Arrays containing the axes of each dimension and each axis' min and max
  3487. * values.
  3488. * @name Highcharts.ChartSelectionContextObject#yAxis
  3489. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  3490. */
  3491. /**
  3492. * Axis context of the selection.
  3493. *
  3494. * @interface Highcharts.ChartSelectionAxisContextObject
  3495. */ /**
  3496. * The selected Axis.
  3497. * @name Highcharts.ChartSelectionAxisContextObject#axis
  3498. * @type {Highcharts.Axis}
  3499. */ /**
  3500. * The maximum axis value, either automatic or set manually.
  3501. * @name Highcharts.ChartSelectionAxisContextObject#max
  3502. * @type {number}
  3503. */ /**
  3504. * The minimum axis value, either automatic or set manually.
  3505. * @name Highcharts.ChartSelectionAxisContextObject#min
  3506. * @type {number}
  3507. */
  3508. (''); // detach doclets above
  3509. /* *
  3510. *
  3511. * API Options
  3512. *
  3513. * */
  3514. /**
  3515. * Global default settings.
  3516. *
  3517. * @name Highcharts.defaultOptions
  3518. * @type {Highcharts.Options}
  3519. */ /**
  3520. * @optionparent
  3521. */
  3522. var defaultOptions = {
  3523. /**
  3524. * An array containing the default colors for the chart's series. When
  3525. * all colors are used, new colors are pulled from the start again.
  3526. *
  3527. * Default colors can also be set on a series or series.type basis,
  3528. * see [column.colors](#plotOptions.column.colors),
  3529. * [pie.colors](#plotOptions.pie.colors).
  3530. *
  3531. * In styled mode, the colors option doesn't exist. Instead, colors
  3532. * are defined in CSS and applied either through series or point class
  3533. * names, or through the [chart.colorCount](#chart.colorCount) option.
  3534. *
  3535. *
  3536. * ### Legacy
  3537. *
  3538. * In Highcharts 3.x, the default colors were:
  3539. * ```js
  3540. * colors: ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce',
  3541. * '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']
  3542. * ```
  3543. *
  3544. * In Highcharts 2.x, the default colors were:
  3545. * ```js
  3546. * colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE',
  3547. * '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
  3548. * ```
  3549. *
  3550. * @sample {highcharts} highcharts/chart/colors/
  3551. * Assign a global color theme
  3552. *
  3553. * @type {Array<Highcharts.ColorString>}
  3554. * @default ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9",
  3555. * "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
  3556. */
  3557. colors: palette.colors,
  3558. /**
  3559. * Styled mode only. Configuration object for adding SVG definitions for
  3560. * reusable elements. See [gradients, shadows and
  3561. * patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns)
  3562. * for more information and code examples.
  3563. *
  3564. * @type {*}
  3565. * @since 5.0.0
  3566. * @apioption defs
  3567. */
  3568. /**
  3569. * @ignore-option
  3570. */
  3571. symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
  3572. /**
  3573. * The language object is global and it can't be set on each chart
  3574. * initialization. Instead, use `Highcharts.setOptions` to set it before any
  3575. * chart is initialized.
  3576. *
  3577. * ```js
  3578. * Highcharts.setOptions({
  3579. * lang: {
  3580. * months: [
  3581. * 'Janvier', 'Février', 'Mars', 'Avril',
  3582. * 'Mai', 'Juin', 'Juillet', 'Août',
  3583. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  3584. * ],
  3585. * weekdays: [
  3586. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  3587. * 'Jeudi', 'Vendredi', 'Samedi'
  3588. * ]
  3589. * }
  3590. * });
  3591. * ```
  3592. */
  3593. lang: {
  3594. /**
  3595. * The loading text that appears when the chart is set into the loading
  3596. * state following a call to `chart.showLoading`.
  3597. */
  3598. loading: 'Loading...',
  3599. /**
  3600. * An array containing the months names. Corresponds to the `%B` format
  3601. * in `Highcharts.dateFormat()`.
  3602. *
  3603. * @type {Array<string>}
  3604. * @default ["January", "February", "March", "April", "May", "June",
  3605. * "July", "August", "September", "October", "November",
  3606. * "December"]
  3607. */
  3608. months: [
  3609. 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  3610. 'August', 'September', 'October', 'November', 'December'
  3611. ],
  3612. /**
  3613. * An array containing the months names in abbreviated form. Corresponds
  3614. * to the `%b` format in `Highcharts.dateFormat()`.
  3615. *
  3616. * @type {Array<string>}
  3617. * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  3618. * "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  3619. */
  3620. shortMonths: [
  3621. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
  3622. 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
  3623. ],
  3624. /**
  3625. * An array containing the weekday names.
  3626. *
  3627. * @type {Array<string>}
  3628. * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
  3629. * "Friday", "Saturday"]
  3630. */
  3631. weekdays: [
  3632. 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  3633. 'Thursday', 'Friday', 'Saturday'
  3634. ],
  3635. /**
  3636. * Short week days, starting Sunday. If not specified, Highcharts uses
  3637. * the first three letters of the `lang.weekdays` option.
  3638. *
  3639. * @sample highcharts/lang/shortweekdays/
  3640. * Finnish two-letter abbreviations
  3641. *
  3642. * @type {Array<string>}
  3643. * @since 4.2.4
  3644. * @apioption lang.shortWeekdays
  3645. */
  3646. /**
  3647. * What to show in a date field for invalid dates. Defaults to an empty
  3648. * string.
  3649. *
  3650. * @type {string}
  3651. * @since 4.1.8
  3652. * @product highcharts highstock
  3653. * @apioption lang.invalidDate
  3654. */
  3655. /**
  3656. * The title appearing on hovering the zoom in button. The text itself
  3657. * defaults to "+" and can be changed in the button options.
  3658. *
  3659. * @type {string}
  3660. * @default Zoom in
  3661. * @product highmaps
  3662. * @apioption lang.zoomIn
  3663. */
  3664. /**
  3665. * The title appearing on hovering the zoom out button. The text itself
  3666. * defaults to "-" and can be changed in the button options.
  3667. *
  3668. * @type {string}
  3669. * @default Zoom out
  3670. * @product highmaps
  3671. * @apioption lang.zoomOut
  3672. */
  3673. /**
  3674. * The default decimal point used in the `Highcharts.numberFormat`
  3675. * method unless otherwise specified in the function arguments.
  3676. *
  3677. * @since 1.2.2
  3678. */
  3679. decimalPoint: '.',
  3680. /**
  3681. * [Metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) used
  3682. * to shorten high numbers in axis labels. Replacing any of the
  3683. * positions with `null` causes the full number to be written. Setting
  3684. * `numericSymbols` to `null` disables shortening altogether.
  3685. *
  3686. * @sample {highcharts} highcharts/lang/numericsymbols/
  3687. * Replacing the symbols with text
  3688. * @sample {highstock} highcharts/lang/numericsymbols/
  3689. * Replacing the symbols with text
  3690. *
  3691. * @type {Array<string>}
  3692. * @default ["k", "M", "G", "T", "P", "E"]
  3693. * @since 2.3.0
  3694. */
  3695. numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'],
  3696. /**
  3697. * The magnitude of [numericSymbols](#lang.numericSymbol) replacements.
  3698. * Use 10000 for Japanese, Korean and various Chinese locales, which
  3699. * use symbols for 10^4, 10^8 and 10^12.
  3700. *
  3701. * @sample highcharts/lang/numericsymbolmagnitude/
  3702. * 10000 magnitude for Japanese
  3703. *
  3704. * @type {number}
  3705. * @default 1000
  3706. * @since 5.0.3
  3707. * @apioption lang.numericSymbolMagnitude
  3708. */
  3709. /**
  3710. * The text for the label appearing when a chart is zoomed.
  3711. *
  3712. * @since 1.2.4
  3713. */
  3714. resetZoom: 'Reset zoom',
  3715. /**
  3716. * The tooltip title for the label appearing when a chart is zoomed.
  3717. *
  3718. * @since 1.2.4
  3719. */
  3720. resetZoomTitle: 'Reset zoom level 1:1',
  3721. /**
  3722. * The default thousands separator used in the `Highcharts.numberFormat`
  3723. * method unless otherwise specified in the function arguments. Defaults
  3724. * to a single space character, which is recommended in
  3725. * [ISO 31-0](https://en.wikipedia.org/wiki/ISO_31-0#Numbers) and works
  3726. * across Anglo-American and continental European languages.
  3727. *
  3728. * @default \u0020
  3729. * @since 1.2.2
  3730. */
  3731. thousandsSep: ' '
  3732. },
  3733. /**
  3734. * Global options that don't apply to each chart. These options, like
  3735. * the `lang` options, must be set using the `Highcharts.setOptions`
  3736. * method.
  3737. *
  3738. * ```js
  3739. * Highcharts.setOptions({
  3740. * global: {
  3741. * useUTC: false
  3742. * }
  3743. * });
  3744. * ```
  3745. */
  3746. /**
  3747. * _Canvg rendering for Android 2.x is removed as of Highcharts 5.0\.
  3748. * Use the [libURL](#exporting.libURL) option to configure exporting._
  3749. *
  3750. * The URL to the additional file to lazy load for Android 2.x devices.
  3751. * These devices don't support SVG, so we download a helper file that
  3752. * contains [canvg](https://github.com/canvg/canvg), its dependency
  3753. * rbcolor, and our own CanVG Renderer class. To avoid hotlinking to
  3754. * our site, you can install canvas-tools.js on your own server and
  3755. * change this option accordingly.
  3756. *
  3757. * @deprecated
  3758. *
  3759. * @type {string}
  3760. * @default https://code.highcharts.com/{version}/modules/canvas-tools.js
  3761. * @product highcharts highmaps
  3762. * @apioption global.canvasToolsURL
  3763. */
  3764. /**
  3765. * This option is deprecated since v6.0.5. Instead, use
  3766. * [time.useUTC](#time.useUTC) that supports individual time settings
  3767. * per chart.
  3768. *
  3769. * @deprecated
  3770. *
  3771. * @type {boolean}
  3772. * @apioption global.useUTC
  3773. */
  3774. /**
  3775. * This option is deprecated since v6.0.5. Instead, use
  3776. * [time.Date](#time.Date) that supports individual time settings
  3777. * per chart.
  3778. *
  3779. * @deprecated
  3780. *
  3781. * @type {Function}
  3782. * @product highcharts highstock
  3783. * @apioption global.Date
  3784. */
  3785. /**
  3786. * This option is deprecated since v6.0.5. Instead, use
  3787. * [time.getTimezoneOffset](#time.getTimezoneOffset) that supports
  3788. * individual time settings per chart.
  3789. *
  3790. * @deprecated
  3791. *
  3792. * @type {Function}
  3793. * @product highcharts highstock
  3794. * @apioption global.getTimezoneOffset
  3795. */
  3796. /**
  3797. * This option is deprecated since v6.0.5. Instead, use
  3798. * [time.timezone](#time.timezone) that supports individual time
  3799. * settings per chart.
  3800. *
  3801. * @deprecated
  3802. *
  3803. * @type {string}
  3804. * @product highcharts highstock
  3805. * @apioption global.timezone
  3806. */
  3807. /**
  3808. * This option is deprecated since v6.0.5. Instead, use
  3809. * [time.timezoneOffset](#time.timezoneOffset) that supports individual
  3810. * time settings per chart.
  3811. *
  3812. * @deprecated
  3813. *
  3814. * @type {number}
  3815. * @product highcharts highstock
  3816. * @apioption global.timezoneOffset
  3817. */
  3818. global: {},
  3819. /**
  3820. * Time options that can apply globally or to individual charts. These
  3821. * settings affect how `datetime` axes are laid out, how tooltips are
  3822. * formatted, how series
  3823. * [pointIntervalUnit](#plotOptions.series.pointIntervalUnit) works and how
  3824. * the Highcharts Stock range selector handles time.
  3825. *
  3826. * The common use case is that all charts in the same Highcharts object
  3827. * share the same time settings, in which case the global settings are set
  3828. * using `setOptions`.
  3829. *
  3830. * ```js
  3831. * // Apply time settings globally
  3832. * Highcharts.setOptions({
  3833. * time: {
  3834. * timezone: 'Europe/London'
  3835. * }
  3836. * });
  3837. * // Apply time settings by instance
  3838. * let chart = Highcharts.chart('container', {
  3839. * time: {
  3840. * timezone: 'America/New_York'
  3841. * },
  3842. * series: [{
  3843. * data: [1, 4, 3, 5]
  3844. * }]
  3845. * });
  3846. *
  3847. * // Use the Time object
  3848. * console.log(
  3849. * 'Current time in New York',
  3850. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  3851. * );
  3852. * ```
  3853. *
  3854. * Since v6.0.5, the time options were moved from the `global` obect to the
  3855. * `time` object, and time options can be set on each individual chart.
  3856. *
  3857. * @sample {highcharts|highstock}
  3858. * highcharts/time/timezone/
  3859. * Set the timezone globally
  3860. * @sample {highcharts}
  3861. * highcharts/time/individual/
  3862. * Set the timezone per chart instance
  3863. * @sample {highstock}
  3864. * stock/time/individual/
  3865. * Set the timezone per chart instance
  3866. *
  3867. * @since 6.0.5
  3868. * @optionparent time
  3869. */
  3870. time: {
  3871. /**
  3872. * A custom `Date` class for advanced date handling. For example,
  3873. * [JDate](https://github.com/tahajahangir/jdate) can be hooked in to
  3874. * handle Jalali dates.
  3875. *
  3876. * @type {*}
  3877. * @since 4.0.4
  3878. * @product highcharts highstock gantt
  3879. */
  3880. Date: void 0,
  3881. /**
  3882. * A callback to return the time zone offset for a given datetime. It
  3883. * takes the timestamp in terms of milliseconds since January 1 1970,
  3884. * and returns the timezone offset in minutes. This provides a hook
  3885. * for drawing time based charts in specific time zones using their
  3886. * local DST crossover dates, with the help of external libraries.
  3887. *
  3888. * @see [global.timezoneOffset](#global.timezoneOffset)
  3889. *
  3890. * @sample {highcharts|highstock} highcharts/time/gettimezoneoffset/
  3891. * Use moment.js to draw Oslo time regardless of browser locale
  3892. *
  3893. * @type {Highcharts.TimezoneOffsetCallbackFunction}
  3894. * @since 4.1.0
  3895. * @product highcharts highstock gantt
  3896. */
  3897. getTimezoneOffset: void 0,
  3898. /**
  3899. * Requires [moment.js](https://momentjs.com/). If the timezone option
  3900. * is specified, it creates a default
  3901. * [getTimezoneOffset](#time.getTimezoneOffset) function that looks
  3902. * up the specified timezone in moment.js. If moment.js is not included,
  3903. * this throws a Highcharts error in the console, but does not crash the
  3904. * chart.
  3905. *
  3906. * @see [getTimezoneOffset](#time.getTimezoneOffset)
  3907. *
  3908. * @sample {highcharts|highstock} highcharts/time/timezone/
  3909. * Europe/Oslo
  3910. *
  3911. * @type {string}
  3912. * @since 5.0.7
  3913. * @product highcharts highstock gantt
  3914. */
  3915. timezone: void 0,
  3916. /**
  3917. * The timezone offset in minutes. Positive values are west, negative
  3918. * values are east of UTC, as in the ECMAScript
  3919. * [getTimezoneOffset](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
  3920. * method. Use this to display UTC based data in a predefined time zone.
  3921. *
  3922. * @see [time.getTimezoneOffset](#time.getTimezoneOffset)
  3923. *
  3924. * @sample {highcharts|highstock} highcharts/time/timezoneoffset/
  3925. * Timezone offset
  3926. *
  3927. * @since 3.0.8
  3928. * @product highcharts highstock gantt
  3929. */
  3930. timezoneOffset: 0,
  3931. /**
  3932. * Whether to use UTC time for axis scaling, tickmark placement and
  3933. * time display in `Highcharts.dateFormat`. Advantages of using UTC
  3934. * is that the time displays equally regardless of the user agent's
  3935. * time zone settings. Local time can be used when the data is loaded
  3936. * in real time or when correct Daylight Saving Time transitions are
  3937. * required.
  3938. *
  3939. * @sample {highcharts} highcharts/time/useutc-true/
  3940. * True by default
  3941. * @sample {highcharts} highcharts/time/useutc-false/
  3942. * False
  3943. */
  3944. useUTC: true
  3945. },
  3946. /**
  3947. * General options for the chart.
  3948. */
  3949. chart: {
  3950. /**
  3951. * Default `mapData` for all series. If set to a string, it functions
  3952. * as an index into the `Highcharts.maps` array. Otherwise it is
  3953. * interpreted as map data.
  3954. *
  3955. * @see [mapData](#series.map.mapData)
  3956. *
  3957. * @sample maps/demo/geojson
  3958. * Loading geoJSON data
  3959. * @sample maps/chart/topojson
  3960. * Loading topoJSON converted to geoJSON
  3961. *
  3962. * @type {string|Array<*>|Highcharts.GeoJSON}
  3963. * @since 5.0.0
  3964. * @product highmaps
  3965. * @apioption chart.map
  3966. */
  3967. /**
  3968. * Set lat/lon transformation definitions for the chart. If not defined,
  3969. * these are extracted from the map data.
  3970. *
  3971. * @type {*}
  3972. * @since 5.0.0
  3973. * @product highmaps
  3974. * @apioption chart.mapTransforms
  3975. */
  3976. /**
  3977. * When using multiple axis, the ticks of two or more opposite axes
  3978. * will automatically be aligned by adding ticks to the axis or axes
  3979. * with the least ticks, as if `tickAmount` were specified.
  3980. *
  3981. * This can be prevented by setting `alignTicks` to false. If the grid
  3982. * lines look messy, it's a good idea to hide them for the secondary
  3983. * axis by setting `gridLineWidth` to 0.
  3984. *
  3985. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  3986. * then the `alignTicks ` will be disabled for the Axis.
  3987. *
  3988. * Disabled for logarithmic axes.
  3989. *
  3990. * @sample {highcharts} highcharts/chart/alignticks-true/
  3991. * True by default
  3992. * @sample {highcharts} highcharts/chart/alignticks-false/
  3993. * False
  3994. * @sample {highstock} stock/chart/alignticks-true/
  3995. * True by default
  3996. * @sample {highstock} stock/chart/alignticks-false/
  3997. * False
  3998. *
  3999. * @type {boolean}
  4000. * @default true
  4001. * @product highcharts highstock gantt
  4002. * @apioption chart.alignTicks
  4003. */
  4004. /**
  4005. * Set the overall animation for all chart updating. Animation can be
  4006. * disabled throughout the chart by setting it to false here. It can
  4007. * be overridden for each individual API method as a function parameter.
  4008. * The only animation not affected by this option is the initial series
  4009. * animation, see [plotOptions.series.animation](
  4010. * #plotOptions.series.animation).
  4011. *
  4012. * The animation can either be set as a boolean or a configuration
  4013. * object. If `true`, it will use the 'swing' jQuery easing and a
  4014. * duration of 500 ms. If used as a configuration object, the following
  4015. * properties are supported:
  4016. *
  4017. * - `defer`: The animation delay time in milliseconds.
  4018. *
  4019. * - `duration`: The duration of the animation in milliseconds.
  4020. *
  4021. * - `easing`: A string reference to an easing function set on the
  4022. * `Math` object. See
  4023. * [the easing demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-animation-easing/).
  4024. *
  4025. * When zooming on a series with less than 100 points, the chart redraw
  4026. * will be done with animation, but in case of more data points, it is
  4027. * necessary to set this option to ensure animation on zoom.
  4028. *
  4029. * @sample {highcharts} highcharts/chart/animation-none/
  4030. * Updating with no animation
  4031. * @sample {highcharts} highcharts/chart/animation-duration/
  4032. * With a longer duration
  4033. * @sample {highcharts} highcharts/chart/animation-easing/
  4034. * With a jQuery UI easing
  4035. * @sample {highmaps} maps/chart/animation-none/
  4036. * Updating with no animation
  4037. * @sample {highmaps} maps/chart/animation-duration/
  4038. * With a longer duration
  4039. *
  4040. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  4041. * @default undefined
  4042. * @apioption chart.animation
  4043. */
  4044. /**
  4045. * A CSS class name to apply to the charts container `div`, allowing
  4046. * unique CSS styling for each chart.
  4047. *
  4048. * @type {string}
  4049. * @apioption chart.className
  4050. */
  4051. /**
  4052. * Event listeners for the chart.
  4053. *
  4054. * @apioption chart.events
  4055. */
  4056. /**
  4057. * Fires when a series is added to the chart after load time, using the
  4058. * `addSeries` method. One parameter, `event`, is passed to the
  4059. * function, containing common event information. Through
  4060. * `event.options` you can access the series options that were passed to
  4061. * the `addSeries` method. Returning false prevents the series from
  4062. * being added.
  4063. *
  4064. * @sample {highcharts} highcharts/chart/events-addseries/
  4065. * Alert on add series
  4066. * @sample {highstock} stock/chart/events-addseries/
  4067. * Alert on add series
  4068. *
  4069. * @type {Highcharts.ChartAddSeriesCallbackFunction}
  4070. * @since 1.2.0
  4071. * @context Highcharts.Chart
  4072. * @apioption chart.events.addSeries
  4073. */
  4074. /**
  4075. * Fires when clicking on the plot background. One parameter, `event`,
  4076. * is passed to the function, containing common event information.
  4077. *
  4078. * Information on the clicked spot can be found through `event.xAxis`
  4079. * and `event.yAxis`, which are arrays containing the axes of each
  4080. * dimension and each axis' value at the clicked spot. The primary axes
  4081. * are `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  4082. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  4083. *
  4084. * ```js
  4085. * click: function(e) {
  4086. * console.log(
  4087. * Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', e.xAxis[0].value),
  4088. * e.yAxis[0].value
  4089. * )
  4090. * }
  4091. * ```
  4092. *
  4093. * @sample {highcharts} highcharts/chart/events-click/
  4094. * Alert coordinates on click
  4095. * @sample {highcharts} highcharts/chart/events-container/
  4096. * Alternatively, attach event to container
  4097. * @sample {highstock} stock/chart/events-click/
  4098. * Alert coordinates on click
  4099. * @sample {highstock} highcharts/chart/events-container/
  4100. * Alternatively, attach event to container
  4101. * @sample {highmaps} maps/chart/events-click/
  4102. * Record coordinates on click
  4103. * @sample {highmaps} highcharts/chart/events-container/
  4104. * Alternatively, attach event to container
  4105. *
  4106. * @type {Highcharts.ChartClickCallbackFunction}
  4107. * @since 1.2.0
  4108. * @context Highcharts.Chart
  4109. * @apioption chart.events.click
  4110. */
  4111. /**
  4112. * Fires when the chart is finished loading. Since v4.2.2, it also waits
  4113. * for images to be loaded, for example from point markers. One
  4114. * parameter, `event`, is passed to the function, containing common
  4115. * event information.
  4116. *
  4117. * There is also a second parameter to the chart constructor where a
  4118. * callback function can be passed to be executed on chart.load.
  4119. *
  4120. * @sample {highcharts} highcharts/chart/events-load/
  4121. * Alert on chart load
  4122. * @sample {highstock} stock/chart/events-load/
  4123. * Alert on chart load
  4124. * @sample {highmaps} maps/chart/events-load/
  4125. * Add series on chart load
  4126. *
  4127. * @type {Highcharts.ChartLoadCallbackFunction}
  4128. * @context Highcharts.Chart
  4129. * @apioption chart.events.load
  4130. */
  4131. /**
  4132. * Fires when the chart is redrawn, either after a call to
  4133. * `chart.redraw()` or after an axis, series or point is modified with
  4134. * the `redraw` option set to `true`. One parameter, `event`, is passed
  4135. * to the function, containing common event information.
  4136. *
  4137. * @sample {highcharts} highcharts/chart/events-redraw/
  4138. * Alert on chart redraw
  4139. * @sample {highstock} stock/chart/events-redraw/
  4140. * Alert on chart redraw when adding a series or moving the
  4141. * zoomed range
  4142. * @sample {highmaps} maps/chart/events-redraw/
  4143. * Set subtitle on chart redraw
  4144. *
  4145. * @type {Highcharts.ChartRedrawCallbackFunction}
  4146. * @since 1.2.0
  4147. * @context Highcharts.Chart
  4148. * @apioption chart.events.redraw
  4149. */
  4150. /**
  4151. * Fires after initial load of the chart (directly after the `load`
  4152. * event), and after each redraw (directly after the `redraw` event).
  4153. *
  4154. * @type {Highcharts.ChartRenderCallbackFunction}
  4155. * @since 5.0.7
  4156. * @context Highcharts.Chart
  4157. * @apioption chart.events.render
  4158. */
  4159. /**
  4160. * Fires when an area of the chart has been selected. Selection is
  4161. * enabled by setting the chart's zoomType. One parameter, `event`, is
  4162. * passed to the function, containing common event information. The
  4163. * default action for the selection event is to zoom the chart to the
  4164. * selected area. It can be prevented by calling
  4165. * `event.preventDefault()` or return false.
  4166. *
  4167. * Information on the selected area can be found through `event.xAxis`
  4168. * and `event.yAxis`, which are arrays containing the axes of each
  4169. * dimension and each axis' min and max values. The primary axes are
  4170. * `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  4171. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  4172. *
  4173. * ```js
  4174. * selection: function(event) {
  4175. * // log the min and max of the primary, datetime x-axis
  4176. * console.log(
  4177. * Highcharts.dateFormat(
  4178. * '%Y-%m-%d %H:%M:%S',
  4179. * event.xAxis[0].min
  4180. * ),
  4181. * Highcharts.dateFormat(
  4182. * '%Y-%m-%d %H:%M:%S',
  4183. * event.xAxis[0].max
  4184. * )
  4185. * );
  4186. * // log the min and max of the y axis
  4187. * console.log(event.yAxis[0].min, event.yAxis[0].max);
  4188. * }
  4189. * ```
  4190. *
  4191. * @sample {highcharts} highcharts/chart/events-selection/
  4192. * Report on selection and reset
  4193. * @sample {highcharts} highcharts/chart/events-selection-points/
  4194. * Select a range of points through a drag selection
  4195. * @sample {highstock} stock/chart/events-selection/
  4196. * Report on selection and reset
  4197. * @sample {highstock} highcharts/chart/events-selection-points/
  4198. * Select a range of points through a drag selection
  4199. * (Highcharts)
  4200. *
  4201. * @type {Highcharts.ChartSelectionCallbackFunction}
  4202. * @apioption chart.events.selection
  4203. */
  4204. /**
  4205. * The margin between the outer edge of the chart and the plot area.
  4206. * The numbers in the array designate top, right, bottom and left
  4207. * respectively. Use the options `marginTop`, `marginRight`,
  4208. * `marginBottom` and `marginLeft` for shorthand setting of one option.
  4209. *
  4210. * By default there is no margin. The actual space is dynamically
  4211. * calculated from the offset of axis labels, axis title, title,
  4212. * subtitle and legend in addition to the `spacingTop`, `spacingRight`,
  4213. * `spacingBottom` and `spacingLeft` options.
  4214. *
  4215. * @sample {highcharts} highcharts/chart/margins-zero/
  4216. * Zero margins
  4217. * @sample {highstock} stock/chart/margin-zero/
  4218. * Zero margins
  4219. *
  4220. * @type {number|Array<number>}
  4221. * @apioption chart.margin
  4222. */
  4223. /**
  4224. * The margin between the bottom outer edge of the chart and the plot
  4225. * area. Use this to set a fixed pixel value for the margin as opposed
  4226. * to the default dynamic margin. See also `spacingBottom`.
  4227. *
  4228. * @sample {highcharts} highcharts/chart/marginbottom/
  4229. * 100px bottom margin
  4230. * @sample {highstock} stock/chart/marginbottom/
  4231. * 100px bottom margin
  4232. * @sample {highmaps} maps/chart/margin/
  4233. * 100px margins
  4234. *
  4235. * @type {number}
  4236. * @since 2.0
  4237. * @apioption chart.marginBottom
  4238. */
  4239. /**
  4240. * The margin between the left outer edge of the chart and the plot
  4241. * area. Use this to set a fixed pixel value for the margin as opposed
  4242. * to the default dynamic margin. See also `spacingLeft`.
  4243. *
  4244. * @sample {highcharts} highcharts/chart/marginleft/
  4245. * 150px left margin
  4246. * @sample {highstock} stock/chart/marginleft/
  4247. * 150px left margin
  4248. * @sample {highmaps} maps/chart/margin/
  4249. * 100px margins
  4250. *
  4251. * @type {number}
  4252. * @since 2.0
  4253. * @apioption chart.marginLeft
  4254. */
  4255. /**
  4256. * The margin between the right outer edge of the chart and the plot
  4257. * area. Use this to set a fixed pixel value for the margin as opposed
  4258. * to the default dynamic margin. See also `spacingRight`.
  4259. *
  4260. * @sample {highcharts} highcharts/chart/marginright/
  4261. * 100px right margin
  4262. * @sample {highstock} stock/chart/marginright/
  4263. * 100px right margin
  4264. * @sample {highmaps} maps/chart/margin/
  4265. * 100px margins
  4266. *
  4267. * @type {number}
  4268. * @since 2.0
  4269. * @apioption chart.marginRight
  4270. */
  4271. /**
  4272. * The margin between the top outer edge of the chart and the plot area.
  4273. * Use this to set a fixed pixel value for the margin as opposed to
  4274. * the default dynamic margin. See also `spacingTop`.
  4275. *
  4276. * @sample {highcharts} highcharts/chart/margintop/ 100px top margin
  4277. * @sample {highstock} stock/chart/margintop/
  4278. * 100px top margin
  4279. * @sample {highmaps} maps/chart/margin/
  4280. * 100px margins
  4281. *
  4282. * @type {number}
  4283. * @since 2.0
  4284. * @apioption chart.marginTop
  4285. */
  4286. /**
  4287. * Callback function to override the default function that formats all
  4288. * the numbers in the chart. Returns a string with the formatted number.
  4289. *
  4290. * @sample highcharts/members/highcharts-numberformat
  4291. * Arabic digits in Highcharts
  4292. * @type {Highcharts.NumberFormatterCallbackFunction}
  4293. * @since 8.0.0
  4294. * @apioption chart.numberFormatter
  4295. */
  4296. /**
  4297. * Allows setting a key to switch between zooming and panning. Can be
  4298. * one of `alt`, `ctrl`, `meta` (the command key on Mac and Windows
  4299. * key on Windows) or `shift`. The keys are mapped directly to the key
  4300. * properties of the click event argument (`event.altKey`,
  4301. * `event.ctrlKey`, `event.metaKey` and `event.shiftKey`).
  4302. *
  4303. * @type {string}
  4304. * @since 4.0.3
  4305. * @product highcharts gantt
  4306. * @validvalue ["alt", "ctrl", "meta", "shift"]
  4307. * @apioption chart.panKey
  4308. */
  4309. /**
  4310. * Allow panning in a chart. Best used with [panKey](#chart.panKey)
  4311. * to combine zooming and panning.
  4312. *
  4313. * On touch devices, when the [tooltip.followTouchMove](
  4314. * #tooltip.followTouchMove) option is `true` (default), panning
  4315. * requires two fingers. To allow panning with one finger, set
  4316. * `followTouchMove` to `false`.
  4317. *
  4318. * @sample {highcharts} highcharts/chart/pankey/ Zooming and panning
  4319. * @sample {highstock} stock/chart/panning/ Zooming and xy panning
  4320. */
  4321. panning: {
  4322. /**
  4323. * Enable or disable chart panning.
  4324. *
  4325. * @type {boolean}
  4326. * @default {highcharts} false
  4327. * @default {highstock|highmaps} true
  4328. */
  4329. enabled: false,
  4330. /**
  4331. * Decides in what dimensions the user can pan the chart. Can be
  4332. * one of `x`, `y`, or `xy`.
  4333. *
  4334. * @sample {highcharts} highcharts/chart/panning-type
  4335. * Zooming and xy panning
  4336. *
  4337. * @type {string}
  4338. * @validvalue ["x", "y", "xy"]
  4339. * @default {highcharts|highstock} x
  4340. * @default {highmaps} xy
  4341. */
  4342. type: 'x'
  4343. },
  4344. /**
  4345. * Equivalent to [zoomType](#chart.zoomType), but for multitouch
  4346. * gestures only. By default, the `pinchType` is the same as the
  4347. * `zoomType` setting. However, pinching can be enabled separately in
  4348. * some cases, for example in stock charts where a mouse drag pans the
  4349. * chart, while pinching is enabled. When [tooltip.followTouchMove](
  4350. * #tooltip.followTouchMove) is true, pinchType only applies to
  4351. * two-finger touches.
  4352. *
  4353. * @type {string}
  4354. * @default {highcharts} undefined
  4355. * @default {highstock} x
  4356. * @since 3.0
  4357. * @product highcharts highstock gantt
  4358. * @validvalue ["x", "y", "xy"]
  4359. * @apioption chart.pinchType
  4360. */
  4361. /**
  4362. * Whether to apply styled mode. When in styled mode, no presentational
  4363. * attributes or CSS are applied to the chart SVG. Instead, CSS rules
  4364. * are required to style the chart. The default style sheet is
  4365. * available from `https://code.highcharts.com/css/highcharts.css`.
  4366. *
  4367. * @type {boolean}
  4368. * @default false
  4369. * @since 7.0
  4370. * @apioption chart.styledMode
  4371. */
  4372. styledMode: false,
  4373. /**
  4374. * The corner radius of the outer chart border.
  4375. *
  4376. * @sample {highcharts} highcharts/chart/borderradius/
  4377. * 20px radius
  4378. * @sample {highstock} stock/chart/border/
  4379. * 10px radius
  4380. * @sample {highmaps} maps/chart/border/
  4381. * Border options
  4382. *
  4383. */
  4384. borderRadius: 0,
  4385. /**
  4386. * In styled mode, this sets how many colors the class names
  4387. * should rotate between. With ten colors, series (or points) are
  4388. * given class names like `highcharts-color-0`, `highcharts-color-0`
  4389. * [...] `highcharts-color-9`. The equivalent in non-styled mode
  4390. * is to set colors using the [colors](#colors) setting.
  4391. *
  4392. * @since 5.0.0
  4393. */
  4394. colorCount: 10,
  4395. /**
  4396. * Alias of `type`.
  4397. *
  4398. * @sample {highcharts} highcharts/chart/defaultseriestype/
  4399. * Bar
  4400. *
  4401. * @deprecated
  4402. *
  4403. * @product highcharts
  4404. */
  4405. defaultSeriesType: 'line',
  4406. /**
  4407. * If true, the axes will scale to the remaining visible series once
  4408. * one series is hidden. If false, hiding and showing a series will
  4409. * not affect the axes or the other series. For stacks, once one series
  4410. * within the stack is hidden, the rest of the stack will close in
  4411. * around it even if the axis is not affected.
  4412. *
  4413. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true/
  4414. * True by default
  4415. * @sample {highcharts} highcharts/chart/ignorehiddenseries-false/
  4416. * False
  4417. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true-stacked/
  4418. * True with stack
  4419. * @sample {highstock} stock/chart/ignorehiddenseries-true/
  4420. * True by default
  4421. * @sample {highstock} stock/chart/ignorehiddenseries-false/
  4422. * False
  4423. *
  4424. * @since 1.2.0
  4425. * @product highcharts highstock gantt
  4426. */
  4427. ignoreHiddenSeries: true,
  4428. /**
  4429. * Whether to invert the axes so that the x axis is vertical and y axis
  4430. * is horizontal. When `true`, the x axis is [reversed](#xAxis.reversed)
  4431. * by default.
  4432. *
  4433. * @productdesc {highcharts}
  4434. * If a bar series is present in the chart, it will be inverted
  4435. * automatically. Inverting the chart doesn't have an effect if there
  4436. * are no cartesian series in the chart, or if the chart is
  4437. * [polar](#chart.polar).
  4438. *
  4439. * @sample {highcharts} highcharts/chart/inverted/
  4440. * Inverted line
  4441. * @sample {highstock} stock/navigator/inverted/
  4442. * Inverted stock chart
  4443. *
  4444. * @type {boolean}
  4445. * @default false
  4446. * @product highcharts highstock gantt
  4447. * @apioption chart.inverted
  4448. */
  4449. /**
  4450. * The distance between the outer edge of the chart and the content,
  4451. * like title or legend, or axis title and labels if present. The
  4452. * numbers in the array designate top, right, bottom and left
  4453. * respectively. Use the options spacingTop, spacingRight, spacingBottom
  4454. * and spacingLeft options for shorthand setting of one option.
  4455. *
  4456. * @type {Array<number>}
  4457. * @see [chart.margin](#chart.margin)
  4458. * @default [10, 10, 15, 10]
  4459. * @since 3.0.6
  4460. */
  4461. spacing: [10, 10, 15, 10],
  4462. /**
  4463. * The button that appears after a selection zoom, allowing the user
  4464. * to reset zoom.
  4465. */
  4466. resetZoomButton: {
  4467. /**
  4468. * What frame the button placement should be related to. Can be
  4469. * either `plotBox` or `spacingBox`.
  4470. *
  4471. * @sample {highcharts} highcharts/chart/resetzoombutton-relativeto/
  4472. * Relative to the chart
  4473. * @sample {highstock} highcharts/chart/resetzoombutton-relativeto/
  4474. * Relative to the chart
  4475. *
  4476. * @type {Highcharts.ButtonRelativeToValue}
  4477. * @default plot
  4478. * @since 2.2
  4479. * @apioption chart.resetZoomButton.relativeTo
  4480. */
  4481. /**
  4482. * A collection of attributes for the button. The object takes SVG
  4483. * attributes like `fill`, `stroke`, `stroke-width` or `r`, the
  4484. * border radius. The theme also supports `style`, a collection of
  4485. * CSS properties for the text. Equivalent attributes for the hover
  4486. * state are given in `theme.states.hover`.
  4487. *
  4488. * @sample {highcharts} highcharts/chart/resetzoombutton-theme/
  4489. * Theming the button
  4490. * @sample {highstock} highcharts/chart/resetzoombutton-theme/
  4491. * Theming the button
  4492. *
  4493. * @type {Highcharts.SVGAttributes}
  4494. * @since 2.2
  4495. */
  4496. theme: {
  4497. /** @internal */
  4498. zIndex: 6
  4499. },
  4500. /**
  4501. * The position of the button.
  4502. *
  4503. * @sample {highcharts} highcharts/chart/resetzoombutton-position/
  4504. * Above the plot area
  4505. * @sample {highstock} highcharts/chart/resetzoombutton-position/
  4506. * Above the plot area
  4507. * @sample {highmaps} highcharts/chart/resetzoombutton-position/
  4508. * Above the plot area
  4509. *
  4510. * @type {Highcharts.AlignObject}
  4511. * @since 2.2
  4512. */
  4513. position: {
  4514. /**
  4515. * The horizontal alignment of the button.
  4516. */
  4517. align: 'right',
  4518. /**
  4519. * The horizontal offset of the button.
  4520. */
  4521. x: -10,
  4522. /**
  4523. * The vertical alignment of the button.
  4524. *
  4525. * @type {Highcharts.VerticalAlignValue}
  4526. * @default top
  4527. * @apioption chart.resetZoomButton.position.verticalAlign
  4528. */
  4529. /**
  4530. * The vertical offset of the button.
  4531. */
  4532. y: 10
  4533. }
  4534. },
  4535. /**
  4536. * The pixel width of the plot area border.
  4537. *
  4538. * @sample {highcharts} highcharts/chart/plotborderwidth/
  4539. * 1px border
  4540. * @sample {highstock} stock/chart/plotborder/
  4541. * 2px border
  4542. * @sample {highmaps} maps/chart/plotborder/
  4543. * Plot border options
  4544. *
  4545. * @type {number}
  4546. * @default 0
  4547. * @apioption chart.plotBorderWidth
  4548. */
  4549. /**
  4550. * Whether to apply a drop shadow to the plot area. Requires that
  4551. * plotBackgroundColor be set. The shadow can be an object configuration
  4552. * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
  4553. *
  4554. * @sample {highcharts} highcharts/chart/plotshadow/
  4555. * Plot shadow
  4556. * @sample {highstock} stock/chart/plotshadow/
  4557. * Plot shadow
  4558. * @sample {highmaps} maps/chart/plotborder/
  4559. * Plot border options
  4560. *
  4561. * @type {boolean|Highcharts.CSSObject}
  4562. * @default false
  4563. * @apioption chart.plotShadow
  4564. */
  4565. /**
  4566. * When true, cartesian charts like line, spline, area and column are
  4567. * transformed into the polar coordinate system. This produces _polar
  4568. * charts_, also known as _radar charts_.
  4569. *
  4570. * @sample {highcharts} highcharts/demo/polar/
  4571. * Polar chart
  4572. * @sample {highcharts} highcharts/demo/polar-wind-rose/
  4573. * Wind rose, stacked polar column chart
  4574. * @sample {highcharts} highcharts/demo/polar-spider/
  4575. * Spider web chart
  4576. * @sample {highcharts} highcharts/parallel-coordinates/polar/
  4577. * Star plot, multivariate data in a polar chart
  4578. *
  4579. * @type {boolean}
  4580. * @default false
  4581. * @since 2.3.0
  4582. * @product highcharts
  4583. * @requires highcharts-more
  4584. * @apioption chart.polar
  4585. */
  4586. /**
  4587. * Whether to reflow the chart to fit the width of the container div
  4588. * on resizing the window.
  4589. *
  4590. * @sample {highcharts} highcharts/chart/reflow-true/
  4591. * True by default
  4592. * @sample {highcharts} highcharts/chart/reflow-false/
  4593. * False
  4594. * @sample {highstock} stock/chart/reflow-true/
  4595. * True by default
  4596. * @sample {highstock} stock/chart/reflow-false/
  4597. * False
  4598. * @sample {highmaps} maps/chart/reflow-true/
  4599. * True by default
  4600. * @sample {highmaps} maps/chart/reflow-false/
  4601. * False
  4602. *
  4603. * @type {boolean}
  4604. * @default true
  4605. * @since 2.1
  4606. * @apioption chart.reflow
  4607. */
  4608. /**
  4609. * The HTML element where the chart will be rendered. If it is a string,
  4610. * the element by that id is used. The HTML element can also be passed
  4611. * by direct reference, or as the first argument of the chart
  4612. * constructor, in which case the option is not needed.
  4613. *
  4614. * @sample {highcharts} highcharts/chart/reflow-true/
  4615. * String
  4616. * @sample {highcharts} highcharts/chart/renderto-object/
  4617. * Object reference
  4618. * @sample {highstock} stock/chart/renderto-string/
  4619. * String
  4620. * @sample {highstock} stock/chart/renderto-object/
  4621. * Object reference
  4622. *
  4623. * @type {string|Highcharts.HTMLDOMElement}
  4624. * @apioption chart.renderTo
  4625. */
  4626. /**
  4627. * The background color of the marker square when selecting (zooming
  4628. * in on) an area of the chart.
  4629. *
  4630. * @see In styled mode, the selection marker fill is set with the
  4631. * `.highcharts-selection-marker` class.
  4632. *
  4633. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4634. * @default rgba(51,92,173,0.25)
  4635. * @since 2.1.7
  4636. * @apioption chart.selectionMarkerFill
  4637. */
  4638. /**
  4639. * Whether to apply a drop shadow to the outer chart area. Requires
  4640. * that backgroundColor be set. The shadow can be an object
  4641. * configuration containing `color`, `offsetX`, `offsetY`, `opacity` and
  4642. * `width`.
  4643. *
  4644. * @sample {highcharts} highcharts/chart/shadow/
  4645. * Shadow
  4646. * @sample {highstock} stock/chart/shadow/
  4647. * Shadow
  4648. * @sample {highmaps} maps/chart/border/
  4649. * Chart border and shadow
  4650. *
  4651. * @type {boolean|Highcharts.CSSObject}
  4652. * @default false
  4653. * @apioption chart.shadow
  4654. */
  4655. /**
  4656. * Whether to show the axes initially. This only applies to empty charts
  4657. * where series are added dynamically, as axes are automatically added
  4658. * to cartesian series.
  4659. *
  4660. * @sample {highcharts} highcharts/chart/showaxes-false/
  4661. * False by default
  4662. * @sample {highcharts} highcharts/chart/showaxes-true/
  4663. * True
  4664. *
  4665. * @type {boolean}
  4666. * @since 1.2.5
  4667. * @product highcharts gantt
  4668. * @apioption chart.showAxes
  4669. */
  4670. /**
  4671. * The space between the bottom edge of the chart and the content (plot
  4672. * area, axis title and labels, title, subtitle or legend in top
  4673. * position).
  4674. *
  4675. * @sample {highcharts} highcharts/chart/spacingbottom/
  4676. * Spacing bottom set to 100
  4677. * @sample {highstock} stock/chart/spacingbottom/
  4678. * Spacing bottom set to 100
  4679. * @sample {highmaps} maps/chart/spacing/
  4680. * Spacing 100 all around
  4681. *
  4682. * @type {number}
  4683. * @default 15
  4684. * @since 2.1
  4685. * @apioption chart.spacingBottom
  4686. */
  4687. /**
  4688. * The space between the left edge of the chart and the content (plot
  4689. * area, axis title and labels, title, subtitle or legend in top
  4690. * position).
  4691. *
  4692. * @sample {highcharts} highcharts/chart/spacingleft/
  4693. * Spacing left set to 100
  4694. * @sample {highstock} stock/chart/spacingleft/
  4695. * Spacing left set to 100
  4696. * @sample {highmaps} maps/chart/spacing/
  4697. * Spacing 100 all around
  4698. *
  4699. * @type {number}
  4700. * @default 10
  4701. * @since 2.1
  4702. * @apioption chart.spacingLeft
  4703. */
  4704. /**
  4705. * The space between the right edge of the chart and the content (plot
  4706. * area, axis title and labels, title, subtitle or legend in top
  4707. * position).
  4708. *
  4709. * @sample {highcharts} highcharts/chart/spacingright-100/
  4710. * Spacing set to 100
  4711. * @sample {highcharts} highcharts/chart/spacingright-legend/
  4712. * Legend in right position with default spacing
  4713. * @sample {highstock} stock/chart/spacingright/
  4714. * Spacing set to 100
  4715. * @sample {highmaps} maps/chart/spacing/
  4716. * Spacing 100 all around
  4717. *
  4718. * @type {number}
  4719. * @default 10
  4720. * @since 2.1
  4721. * @apioption chart.spacingRight
  4722. */
  4723. /**
  4724. * The space between the top edge of the chart and the content (plot
  4725. * area, axis title and labels, title, subtitle or legend in top
  4726. * position).
  4727. *
  4728. * @sample {highcharts} highcharts/chart/spacingtop-100/
  4729. * A top spacing of 100
  4730. * @sample {highcharts} highcharts/chart/spacingtop-10/
  4731. * Floating chart title makes the plot area align to the default
  4732. * spacingTop of 10.
  4733. * @sample {highstock} stock/chart/spacingtop/
  4734. * A top spacing of 100
  4735. * @sample {highmaps} maps/chart/spacing/
  4736. * Spacing 100 all around
  4737. *
  4738. * @type {number}
  4739. * @default 10
  4740. * @since 2.1
  4741. * @apioption chart.spacingTop
  4742. */
  4743. /**
  4744. * Additional CSS styles to apply inline to the container `div`. Note
  4745. * that since the default font styles are applied in the renderer, it
  4746. * is ignorant of the individual chart options and must be set globally.
  4747. *
  4748. * @see In styled mode, general chart styles can be set with the
  4749. * `.highcharts-root` class.
  4750. * @sample {highcharts} highcharts/chart/style-serif-font/
  4751. * Using a serif type font
  4752. * @sample {highcharts} highcharts/css/em/
  4753. * Styled mode with relative font sizes
  4754. * @sample {highstock} stock/chart/style/
  4755. * Using a serif type font
  4756. * @sample {highmaps} maps/chart/style-serif-font/
  4757. * Using a serif type font
  4758. *
  4759. * @type {Highcharts.CSSObject}
  4760. * @default {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}
  4761. * @apioption chart.style
  4762. */
  4763. /**
  4764. * The default series type for the chart. Can be any of the chart types
  4765. * listed under [plotOptions](#plotOptions) and [series](#series) or can
  4766. * be a series provided by an additional module.
  4767. *
  4768. * In TypeScript this option has no effect in sense of typing and
  4769. * instead the `type` option must always be set in the series.
  4770. *
  4771. * @sample {highcharts} highcharts/chart/type-bar/
  4772. * Bar
  4773. * @sample {highstock} stock/chart/type/
  4774. * Areaspline
  4775. * @sample {highmaps} maps/chart/type-mapline/
  4776. * Mapline
  4777. *
  4778. * @type {string}
  4779. * @default {highcharts} line
  4780. * @default {highstock} line
  4781. * @default {highmaps} map
  4782. * @since 2.1.0
  4783. * @apioption chart.type
  4784. */
  4785. /**
  4786. * Decides in what dimensions the user can zoom by dragging the mouse.
  4787. * Can be one of `x`, `y` or `xy`.
  4788. *
  4789. * @see [panKey](#chart.panKey)
  4790. *
  4791. * @sample {highcharts} highcharts/chart/zoomtype-none/
  4792. * None by default
  4793. * @sample {highcharts} highcharts/chart/zoomtype-x/
  4794. * X
  4795. * @sample {highcharts} highcharts/chart/zoomtype-y/
  4796. * Y
  4797. * @sample {highcharts} highcharts/chart/zoomtype-xy/
  4798. * Xy
  4799. * @sample {highstock} stock/demo/basic-line/
  4800. * None by default
  4801. * @sample {highstock} stock/chart/zoomtype-x/
  4802. * X
  4803. * @sample {highstock} stock/chart/zoomtype-y/
  4804. * Y
  4805. * @sample {highstock} stock/chart/zoomtype-xy/
  4806. * Xy
  4807. *
  4808. * @type {string}
  4809. * @product highcharts highstock gantt
  4810. * @validvalue ["x", "y", "xy"]
  4811. * @apioption chart.zoomType
  4812. */
  4813. /**
  4814. * Enables zooming by a single touch, in combination with
  4815. * [chart.zoomType](#chart.zoomType). When enabled, two-finger pinch
  4816. * will still work as set up by [chart.pinchType](#chart.pinchType).
  4817. * However, `zoomBySingleTouch` will interfere with touch-dragging the
  4818. * chart to read the tooltip. And especially when vertical zooming is
  4819. * enabled, it will make it hard to scroll vertically on the page.
  4820. * @since 9.0.0
  4821. * @sample highcharts/chart/zoombysingletouch
  4822. * Zoom by single touch enabled, with buttons to toggle
  4823. * @product highcharts highstock gantt
  4824. */
  4825. zoomBySingleTouch: false,
  4826. /**
  4827. * An explicit width for the chart. By default (when `null`) the width
  4828. * is calculated from the offset width of the containing element.
  4829. *
  4830. * @sample {highcharts} highcharts/chart/width/
  4831. * 800px wide
  4832. * @sample {highstock} stock/chart/width/
  4833. * 800px wide
  4834. * @sample {highmaps} maps/chart/size/
  4835. * Chart with explicit size
  4836. *
  4837. * @type {null|number|string}
  4838. */
  4839. width: null,
  4840. /**
  4841. * An explicit height for the chart. If a _number_, the height is
  4842. * given in pixels. If given a _percentage string_ (for example
  4843. * `'56%'`), the height is given as the percentage of the actual chart
  4844. * width. This allows for preserving the aspect ratio across responsive
  4845. * sizes.
  4846. *
  4847. * By default (when `null`) the height is calculated from the offset
  4848. * height of the containing element, or 400 pixels if the containing
  4849. * element's height is 0.
  4850. *
  4851. * @sample {highcharts} highcharts/chart/height/
  4852. * 500px height
  4853. * @sample {highstock} stock/chart/height/
  4854. * 300px height
  4855. * @sample {highmaps} maps/chart/size/
  4856. * Chart with explicit size
  4857. * @sample highcharts/chart/height-percent/
  4858. * Highcharts with percentage height
  4859. *
  4860. * @type {null|number|string}
  4861. */
  4862. height: null,
  4863. /**
  4864. * The color of the outer chart border.
  4865. *
  4866. * @see In styled mode, the stroke is set with the
  4867. * `.highcharts-background` class.
  4868. *
  4869. * @sample {highcharts} highcharts/chart/bordercolor/
  4870. * Brown border
  4871. * @sample {highstock} stock/chart/border/
  4872. * Brown border
  4873. * @sample {highmaps} maps/chart/border/
  4874. * Border options
  4875. *
  4876. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4877. */
  4878. borderColor: palette.highlightColor80,
  4879. /**
  4880. * The pixel width of the outer chart border.
  4881. *
  4882. * @see In styled mode, the stroke is set with the
  4883. * `.highcharts-background` class.
  4884. *
  4885. * @sample {highcharts} highcharts/chart/borderwidth/
  4886. * 5px border
  4887. * @sample {highstock} stock/chart/border/
  4888. * 2px border
  4889. * @sample {highmaps} maps/chart/border/
  4890. * Border options
  4891. *
  4892. * @type {number}
  4893. * @default 0
  4894. * @apioption chart.borderWidth
  4895. */
  4896. /**
  4897. * The background color or gradient for the outer chart area.
  4898. *
  4899. * @see In styled mode, the background is set with the
  4900. * `.highcharts-background` class.
  4901. *
  4902. * @sample {highcharts} highcharts/chart/backgroundcolor-color/
  4903. * Color
  4904. * @sample {highcharts} highcharts/chart/backgroundcolor-gradient/
  4905. * Gradient
  4906. * @sample {highstock} stock/chart/backgroundcolor-color/
  4907. * Color
  4908. * @sample {highstock} stock/chart/backgroundcolor-gradient/
  4909. * Gradient
  4910. * @sample {highmaps} maps/chart/backgroundcolor-color/
  4911. * Color
  4912. * @sample {highmaps} maps/chart/backgroundcolor-gradient/
  4913. * Gradient
  4914. *
  4915. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4916. */
  4917. backgroundColor: palette.backgroundColor,
  4918. /**
  4919. * The background color or gradient for the plot area.
  4920. *
  4921. * @see In styled mode, the plot background is set with the
  4922. * `.highcharts-plot-background` class.
  4923. *
  4924. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-color/
  4925. * Color
  4926. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-gradient/
  4927. * Gradient
  4928. * @sample {highstock} stock/chart/plotbackgroundcolor-color/
  4929. * Color
  4930. * @sample {highstock} stock/chart/plotbackgroundcolor-gradient/
  4931. * Gradient
  4932. * @sample {highmaps} maps/chart/plotbackgroundcolor-color/
  4933. * Color
  4934. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  4935. * Gradient
  4936. *
  4937. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4938. * @apioption chart.plotBackgroundColor
  4939. */
  4940. /**
  4941. * The URL for an image to use as the plot background. To set an image
  4942. * as the background for the entire chart, set a CSS background image
  4943. * to the container element. Note that for the image to be applied to
  4944. * exported charts, its URL needs to be accessible by the export server.
  4945. *
  4946. * @see In styled mode, a plot background image can be set with the
  4947. * `.highcharts-plot-background` class and a [custom pattern](
  4948. * https://www.highcharts.com/docs/chart-design-and-style/
  4949. * gradients-shadows-and-patterns).
  4950. *
  4951. * @sample {highcharts} highcharts/chart/plotbackgroundimage/
  4952. * Skies
  4953. * @sample {highstock} stock/chart/plotbackgroundimage/
  4954. * Skies
  4955. *
  4956. * @type {string}
  4957. * @apioption chart.plotBackgroundImage
  4958. */
  4959. /**
  4960. * The color of the inner chart or plot area border.
  4961. *
  4962. * @see In styled mode, a plot border stroke can be set with the
  4963. * `.highcharts-plot-border` class.
  4964. *
  4965. * @sample {highcharts} highcharts/chart/plotbordercolor/
  4966. * Blue border
  4967. * @sample {highstock} stock/chart/plotborder/
  4968. * Blue border
  4969. * @sample {highmaps} maps/chart/plotborder/
  4970. * Plot border options
  4971. *
  4972. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4973. */
  4974. plotBorderColor: palette.neutralColor20
  4975. },
  4976. /**
  4977. * The chart's main title.
  4978. *
  4979. * @sample {highmaps} maps/title/title/
  4980. * Title options demonstrated
  4981. */
  4982. title: {
  4983. /**
  4984. * When the title is floating, the plot area will not move to make space
  4985. * for it.
  4986. *
  4987. * @sample {highcharts} highcharts/chart/zoomtype-none/
  4988. * False by default
  4989. * @sample {highcharts} highcharts/title/floating/
  4990. * True - title on top of the plot area
  4991. * @sample {highstock} stock/chart/title-floating/
  4992. * True - title on top of the plot area
  4993. *
  4994. * @type {boolean}
  4995. * @default false
  4996. * @since 2.1
  4997. * @apioption title.floating
  4998. */
  4999. /**
  5000. * CSS styles for the title. Use this for font styling, but use `align`,
  5001. * `x` and `y` for text alignment.
  5002. *
  5003. * In styled mode, the title style is given in the `.highcharts-title`
  5004. * class.
  5005. *
  5006. * @sample {highcharts} highcharts/title/style/
  5007. * Custom color and weight
  5008. * @sample {highstock} stock/chart/title-style/
  5009. * Custom color and weight
  5010. * @sample highcharts/css/titles/
  5011. * Styled mode
  5012. *
  5013. * @type {Highcharts.CSSObject}
  5014. * @default {highcharts|highmaps} { "color": "#333333", "fontSize": "18px" }
  5015. * @default {highstock} { "color": "#333333", "fontSize": "16px" }
  5016. * @apioption title.style
  5017. */
  5018. /**
  5019. * Whether to
  5020. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5021. * to render the text.
  5022. *
  5023. * @type {boolean}
  5024. * @default false
  5025. * @apioption title.useHTML
  5026. */
  5027. /**
  5028. * The vertical alignment of the title. Can be one of `"top"`,
  5029. * `"middle"` and `"bottom"`. When a value is given, the title behaves
  5030. * as if [floating](#title.floating) were `true`.
  5031. *
  5032. * @sample {highcharts} highcharts/title/verticalalign/
  5033. * Chart title in bottom right corner
  5034. * @sample {highstock} stock/chart/title-verticalalign/
  5035. * Chart title in bottom right corner
  5036. *
  5037. * @type {Highcharts.VerticalAlignValue}
  5038. * @since 2.1
  5039. * @apioption title.verticalAlign
  5040. */
  5041. /**
  5042. * The x position of the title relative to the alignment within
  5043. * `chart.spacingLeft` and `chart.spacingRight`.
  5044. *
  5045. * @sample {highcharts} highcharts/title/align/
  5046. * Aligned to the plot area (x = 70px = margin left - spacing
  5047. * left)
  5048. * @sample {highstock} stock/chart/title-align/
  5049. * Aligned to the plot area (x = 50px = margin left - spacing
  5050. * left)
  5051. *
  5052. * @type {number}
  5053. * @default 0
  5054. * @since 2.0
  5055. * @apioption title.x
  5056. */
  5057. /**
  5058. * The y position of the title relative to the alignment within
  5059. * [chart.spacingTop](#chart.spacingTop) and [chart.spacingBottom](
  5060. * #chart.spacingBottom). By default it depends on the font size.
  5061. *
  5062. * @sample {highcharts} highcharts/title/y/
  5063. * Title inside the plot area
  5064. * @sample {highstock} stock/chart/title-verticalalign/
  5065. * Chart title in bottom right corner
  5066. *
  5067. * @type {number}
  5068. * @since 2.0
  5069. * @apioption title.y
  5070. */
  5071. /**
  5072. * The title of the chart. To disable the title, set the `text` to
  5073. * `undefined`.
  5074. *
  5075. * @sample {highcharts} highcharts/title/text/
  5076. * Custom title
  5077. * @sample {highstock} stock/chart/title-text/
  5078. * Custom title
  5079. *
  5080. * @default {highcharts|highmaps} Chart title
  5081. * @default {highstock} undefined
  5082. */
  5083. text: 'Chart title',
  5084. /**
  5085. * The horizontal alignment of the title. Can be one of "left", "center"
  5086. * and "right".
  5087. *
  5088. * @sample {highcharts} highcharts/title/align/
  5089. * Aligned to the plot area (x = 70px = margin left - spacing
  5090. * left)
  5091. * @sample {highstock} stock/chart/title-align/
  5092. * Aligned to the plot area (x = 50px = margin left - spacing
  5093. * left)
  5094. *
  5095. * @type {Highcharts.AlignValue}
  5096. * @since 2.0
  5097. */
  5098. align: 'center',
  5099. /**
  5100. * The margin between the title and the plot area, or if a subtitle
  5101. * is present, the margin between the subtitle and the plot area.
  5102. *
  5103. * @sample {highcharts} highcharts/title/margin-50/
  5104. * A chart title margin of 50
  5105. * @sample {highcharts} highcharts/title/margin-subtitle/
  5106. * The same margin applied with a subtitle
  5107. * @sample {highstock} stock/chart/title-margin/
  5108. * A chart title margin of 50
  5109. *
  5110. * @since 2.1
  5111. */
  5112. margin: 15,
  5113. /**
  5114. * Adjustment made to the title width, normally to reserve space for
  5115. * the exporting burger menu.
  5116. *
  5117. * @sample highcharts/title/widthadjust/
  5118. * Wider menu, greater padding
  5119. *
  5120. * @since 4.2.5
  5121. */
  5122. widthAdjust: -44
  5123. },
  5124. /**
  5125. * The chart's subtitle. This can be used both to display a subtitle below
  5126. * the main title, and to display random text anywhere in the chart. The
  5127. * subtitle can be updated after chart initialization through the
  5128. * `Chart.setTitle` method.
  5129. *
  5130. * @sample {highmaps} maps/title/subtitle/
  5131. * Subtitle options demonstrated
  5132. */
  5133. subtitle: {
  5134. /**
  5135. * When the subtitle is floating, the plot area will not move to make
  5136. * space for it.
  5137. *
  5138. * @sample {highcharts} highcharts/subtitle/floating/
  5139. * Floating title and subtitle
  5140. * @sample {highstock} stock/chart/subtitle-footnote
  5141. * Footnote floating at bottom right of plot area
  5142. *
  5143. * @type {boolean}
  5144. * @default false
  5145. * @since 2.1
  5146. * @apioption subtitle.floating
  5147. */
  5148. /**
  5149. * CSS styles for the title.
  5150. *
  5151. * In styled mode, the subtitle style is given in the
  5152. * `.highcharts-subtitle` class.
  5153. *
  5154. * @sample {highcharts} highcharts/subtitle/style/
  5155. * Custom color and weight
  5156. * @sample {highcharts} highcharts/css/titles/
  5157. * Styled mode
  5158. * @sample {highstock} stock/chart/subtitle-style
  5159. * Custom color and weight
  5160. * @sample {highstock} highcharts/css/titles/
  5161. * Styled mode
  5162. * @sample {highmaps} highcharts/css/titles/
  5163. * Styled mode
  5164. *
  5165. * @type {Highcharts.CSSObject}
  5166. * @default {"color": "#666666"}
  5167. * @apioption subtitle.style
  5168. */
  5169. /**
  5170. * Whether to
  5171. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5172. * to render the text.
  5173. *
  5174. * @type {boolean}
  5175. * @default false
  5176. * @apioption subtitle.useHTML
  5177. */
  5178. /**
  5179. * The vertical alignment of the title. Can be one of `"top"`,
  5180. * `"middle"` and `"bottom"`. When middle, the subtitle behaves as
  5181. * floating.
  5182. *
  5183. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5184. * Footnote at the bottom right of plot area
  5185. * @sample {highstock} stock/chart/subtitle-footnote
  5186. * Footnote at the bottom right of plot area
  5187. *
  5188. * @type {Highcharts.VerticalAlignValue}
  5189. * @since 2.1
  5190. * @apioption subtitle.verticalAlign
  5191. */
  5192. /**
  5193. * The x position of the subtitle relative to the alignment within
  5194. * `chart.spacingLeft` and `chart.spacingRight`.
  5195. *
  5196. * @sample {highcharts} highcharts/subtitle/align/
  5197. * Footnote at right of plot area
  5198. * @sample {highstock} stock/chart/subtitle-footnote
  5199. * Footnote at the bottom right of plot area
  5200. *
  5201. * @type {number}
  5202. * @default 0
  5203. * @since 2.0
  5204. * @apioption subtitle.x
  5205. */
  5206. /**
  5207. * The y position of the subtitle relative to the alignment within
  5208. * `chart.spacingTop` and `chart.spacingBottom`. By default the subtitle
  5209. * is laid out below the title unless the title is floating.
  5210. *
  5211. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5212. * Footnote at the bottom right of plot area
  5213. * @sample {highstock} stock/chart/subtitle-footnote
  5214. * Footnote at the bottom right of plot area
  5215. *
  5216. * @type {number}
  5217. * @since 2.0
  5218. * @apioption subtitle.y
  5219. */
  5220. /**
  5221. * The subtitle of the chart.
  5222. *
  5223. * @sample {highcharts|highstock} highcharts/subtitle/text/
  5224. * Custom subtitle
  5225. * @sample {highcharts|highstock} highcharts/subtitle/text-formatted/
  5226. * Formatted and linked text.
  5227. */
  5228. text: '',
  5229. /**
  5230. * The horizontal alignment of the subtitle. Can be one of "left",
  5231. * "center" and "right".
  5232. *
  5233. * @sample {highcharts} highcharts/subtitle/align/
  5234. * Footnote at right of plot area
  5235. * @sample {highstock} stock/chart/subtitle-footnote
  5236. * Footnote at bottom right of plot area
  5237. *
  5238. * @type {Highcharts.AlignValue}
  5239. * @since 2.0
  5240. */
  5241. align: 'center',
  5242. /**
  5243. * Adjustment made to the subtitle width, normally to reserve space
  5244. * for the exporting burger menu.
  5245. *
  5246. * @see [title.widthAdjust](#title.widthAdjust)
  5247. *
  5248. * @sample highcharts/title/widthadjust/
  5249. * Wider menu, greater padding
  5250. *
  5251. * @since 4.2.5
  5252. */
  5253. widthAdjust: -44
  5254. },
  5255. /**
  5256. * The chart's caption, which will render below the chart and will be part
  5257. * of exported charts. The caption can be updated after chart initialization
  5258. * through the `Chart.update` or `Chart.caption.update` methods.
  5259. *
  5260. * @sample highcharts/caption/text/
  5261. * A chart with a caption
  5262. * @since 7.2.0
  5263. */
  5264. caption: {
  5265. /**
  5266. * When the caption is floating, the plot area will not move to make
  5267. * space for it.
  5268. *
  5269. * @type {boolean}
  5270. * @default false
  5271. * @apioption caption.floating
  5272. */
  5273. /**
  5274. * The margin between the caption and the plot area.
  5275. */
  5276. margin: 15,
  5277. /**
  5278. * CSS styles for the caption.
  5279. *
  5280. * In styled mode, the caption style is given in the
  5281. * `.highcharts-caption` class.
  5282. *
  5283. * @sample {highcharts} highcharts/css/titles/
  5284. * Styled mode
  5285. *
  5286. * @type {Highcharts.CSSObject}
  5287. * @default {"color": "#666666"}
  5288. * @apioption caption.style
  5289. */
  5290. /**
  5291. * Whether to
  5292. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5293. * to render the text.
  5294. *
  5295. * @type {boolean}
  5296. * @default false
  5297. * @apioption caption.useHTML
  5298. */
  5299. /**
  5300. * The x position of the caption relative to the alignment within
  5301. * `chart.spacingLeft` and `chart.spacingRight`.
  5302. *
  5303. * @type {number}
  5304. * @default 0
  5305. * @apioption caption.x
  5306. */
  5307. /**
  5308. * The y position of the caption relative to the alignment within
  5309. * `chart.spacingTop` and `chart.spacingBottom`.
  5310. *
  5311. * @type {number}
  5312. * @apioption caption.y
  5313. */
  5314. /**
  5315. * The caption text of the chart.
  5316. *
  5317. * @sample {highcharts} highcharts/caption/text/
  5318. * Custom caption
  5319. */
  5320. text: '',
  5321. /**
  5322. * The horizontal alignment of the caption. Can be one of "left",
  5323. * "center" and "right".
  5324. *
  5325. * @type {Highcharts.AlignValue}
  5326. */
  5327. align: 'left',
  5328. /**
  5329. * The vertical alignment of the caption. Can be one of `"top"`,
  5330. * `"middle"` and `"bottom"`. When middle, the caption behaves as
  5331. * floating.
  5332. *
  5333. * @type {Highcharts.VerticalAlignValue}
  5334. */
  5335. verticalAlign: 'bottom'
  5336. },
  5337. /**
  5338. * The plotOptions is a wrapper object for config objects for each series
  5339. * type. The config objects for each series can also be overridden for
  5340. * each series item as given in the series array.
  5341. *
  5342. * Configuration options for the series are given in three levels. Options
  5343. * for all series in a chart are given in the [plotOptions.series](
  5344. * #plotOptions.series) object. Then options for all series of a specific
  5345. * type are given in the plotOptions of that type, for example
  5346. * `plotOptions.line`. Next, options for one single series are given in
  5347. * [the series array](#series).
  5348. */
  5349. plotOptions: {},
  5350. /**
  5351. * HTML labels that can be positioned anywhere in the chart area.
  5352. *
  5353. * This option is deprecated since v7.1.2. Instead, use
  5354. * [annotations](#annotations) that support labels.
  5355. *
  5356. * @deprecated
  5357. * @product highcharts highstock
  5358. */
  5359. labels: {
  5360. /**
  5361. * An HTML label that can be positioned anywhere in the chart area.
  5362. *
  5363. * @deprecated
  5364. * @type {Array<*>}
  5365. * @apioption labels.items
  5366. */
  5367. /**
  5368. * Inner HTML or text for the label.
  5369. *
  5370. * @deprecated
  5371. * @type {string}
  5372. * @apioption labels.items.html
  5373. */
  5374. /**
  5375. * CSS styles for each label. To position the label, use left and top
  5376. * like this:
  5377. * ```js
  5378. * style: {
  5379. * left: '100px',
  5380. * top: '100px'
  5381. * }
  5382. * ```
  5383. *
  5384. * @deprecated
  5385. * @type {Highcharts.CSSObject}
  5386. * @apioption labels.items.style
  5387. */
  5388. /**
  5389. * Shared CSS styles for all labels.
  5390. *
  5391. * @deprecated
  5392. * @type {Highcharts.CSSObject}
  5393. * @default {"color": "#333333", "position": "absolute"}
  5394. */
  5395. style: {
  5396. /**
  5397. * @ignore-option
  5398. */
  5399. position: 'absolute',
  5400. /**
  5401. * @ignore-option
  5402. */
  5403. color: palette.neutralColor80
  5404. }
  5405. },
  5406. /**
  5407. * The legend is a box containing a symbol and name for each series
  5408. * item or point item in the chart. Each series (or points in case
  5409. * of pie charts) is represented by a symbol and its name in the legend.
  5410. *
  5411. * It is possible to override the symbol creator function and create
  5412. * [custom legend symbols](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/studies/legend-custom-symbol/).
  5413. *
  5414. * @productdesc {highmaps}
  5415. * A Highmaps legend by default contains one legend item per series, but if
  5416. * a `colorAxis` is defined, the axis will be displayed in the legend.
  5417. * Either as a gradient, or as multiple legend items for `dataClasses`.
  5418. */
  5419. legend: {
  5420. /**
  5421. * The background color of the legend.
  5422. *
  5423. * @see In styled mode, the legend background fill can be applied with
  5424. * the `.highcharts-legend-box` class.
  5425. *
  5426. * @sample {highcharts} highcharts/legend/backgroundcolor/
  5427. * Yellowish background
  5428. * @sample {highstock} stock/legend/align/
  5429. * Various legend options
  5430. * @sample {highmaps} maps/legend/border-background/
  5431. * Border and background options
  5432. *
  5433. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5434. * @apioption legend.backgroundColor
  5435. */
  5436. /**
  5437. * The width of the drawn border around the legend.
  5438. *
  5439. * @see In styled mode, the legend border stroke width can be applied
  5440. * with the `.highcharts-legend-box` class.
  5441. *
  5442. * @sample {highcharts} highcharts/legend/borderwidth/
  5443. * 2px border width
  5444. * @sample {highstock} stock/legend/align/
  5445. * Various legend options
  5446. * @sample {highmaps} maps/legend/border-background/
  5447. * Border and background options
  5448. *
  5449. * @type {number}
  5450. * @default 0
  5451. * @apioption legend.borderWidth
  5452. */
  5453. /**
  5454. * Enable or disable the legend. There is also a series-specific option,
  5455. * [showInLegend](#plotOptions.series.showInLegend), that can hide the
  5456. * series from the legend. In some series types this is `false` by
  5457. * default, so it must set to `true` in order to show the legend for the
  5458. * series.
  5459. *
  5460. * @sample {highcharts} highcharts/legend/enabled-false/ Legend disabled
  5461. * @sample {highstock} stock/legend/align/ Various legend options
  5462. * @sample {highmaps} maps/legend/enabled-false/ Legend disabled
  5463. *
  5464. * @default {highstock} false
  5465. * @default {highmaps} true
  5466. * @default {gantt} false
  5467. */
  5468. enabled: true,
  5469. /**
  5470. * The horizontal alignment of the legend box within the chart area.
  5471. * Valid values are `left`, `center` and `right`.
  5472. *
  5473. * In the case that the legend is aligned in a corner position, the
  5474. * `layout` option will determine whether to place it above/below
  5475. * or on the side of the plot area.
  5476. *
  5477. * @sample {highcharts} highcharts/legend/align/
  5478. * Legend at the right of the chart
  5479. * @sample {highstock} stock/legend/align/
  5480. * Various legend options
  5481. * @sample {highmaps} maps/legend/alignment/
  5482. * Legend alignment
  5483. *
  5484. * @type {Highcharts.AlignValue}
  5485. * @since 2.0
  5486. */
  5487. align: 'center',
  5488. /**
  5489. * If the [layout](legend.layout) is `horizontal` and the legend items
  5490. * span over two lines or more, whether to align the items into vertical
  5491. * columns. Setting this to `false` makes room for more items, but will
  5492. * look more messy.
  5493. *
  5494. * @since 6.1.0
  5495. */
  5496. alignColumns: true,
  5497. /**
  5498. * When the legend is floating, the plot area ignores it and is allowed
  5499. * to be placed below it.
  5500. *
  5501. * @sample {highcharts} highcharts/legend/floating-false/
  5502. * False by default
  5503. * @sample {highcharts} highcharts/legend/floating-true/
  5504. * True
  5505. * @sample {highmaps} maps/legend/alignment/
  5506. * Floating legend
  5507. *
  5508. * @type {boolean}
  5509. * @default false
  5510. * @since 2.1
  5511. * @apioption legend.floating
  5512. */
  5513. /**
  5514. * The layout of the legend items. Can be one of `horizontal` or
  5515. * `vertical` or `proximate`. When `proximate`, the legend items will be
  5516. * placed as close as possible to the graphs they're representing,
  5517. * except in inverted charts or when the legend position doesn't allow
  5518. * it.
  5519. *
  5520. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5521. * Horizontal by default
  5522. * @sample {highcharts} highcharts/legend/layout-vertical/
  5523. * Vertical
  5524. * @sample highcharts/legend/layout-proximate
  5525. * Labels proximate to the data
  5526. * @sample {highstock} stock/legend/layout-horizontal/
  5527. * Horizontal by default
  5528. * @sample {highmaps} maps/legend/padding-itemmargin/
  5529. * Vertical with data classes
  5530. * @sample {highmaps} maps/legend/layout-vertical/
  5531. * Vertical with color axis gradient
  5532. *
  5533. * @validvalue ["horizontal", "vertical", "proximate"]
  5534. */
  5535. layout: 'horizontal',
  5536. /**
  5537. * In a legend with horizontal layout, the itemDistance defines the
  5538. * pixel distance between each item.
  5539. *
  5540. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5541. * 50px item distance
  5542. * @sample {highstock} highcharts/legend/layout-horizontal/
  5543. * 50px item distance
  5544. *
  5545. * @type {number}
  5546. * @default {highcharts} 20
  5547. * @default {highstock} 20
  5548. * @default {highmaps} 8
  5549. * @since 3.0.3
  5550. * @apioption legend.itemDistance
  5551. */
  5552. /**
  5553. * The pixel bottom margin for each legend item.
  5554. *
  5555. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5556. * Padding and item margins demonstrated
  5557. * @sample {highmaps} maps/legend/padding-itemmargin/
  5558. * Padding and item margins demonstrated
  5559. *
  5560. * @type {number}
  5561. * @default 0
  5562. * @since 2.2.0
  5563. * @apioption legend.itemMarginBottom
  5564. */
  5565. /**
  5566. * The pixel top margin for each legend item.
  5567. *
  5568. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5569. * Padding and item margins demonstrated
  5570. * @sample {highmaps} maps/legend/padding-itemmargin/
  5571. * Padding and item margins demonstrated
  5572. *
  5573. * @type {number}
  5574. * @default 0
  5575. * @since 2.2.0
  5576. * @apioption legend.itemMarginTop
  5577. */
  5578. /**
  5579. * The width for each legend item. By default the items are laid out
  5580. * successively. In a [horizontal layout](legend.layout), if the items
  5581. * are laid out across two rows or more, they will be vertically aligned
  5582. * depending on the [legend.alignColumns](legend.alignColumns) option.
  5583. *
  5584. * @sample {highcharts} highcharts/legend/itemwidth-default/
  5585. * Undefined by default
  5586. * @sample {highcharts} highcharts/legend/itemwidth-80/
  5587. * 80 for aligned legend items
  5588. *
  5589. * @type {number}
  5590. * @since 2.0
  5591. * @apioption legend.itemWidth
  5592. */
  5593. /**
  5594. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  5595. * for each legend label. Available variables relates to properties on
  5596. * the series, or the point in case of pies.
  5597. *
  5598. * @type {string}
  5599. * @default {name}
  5600. * @since 1.3
  5601. * @apioption legend.labelFormat
  5602. */
  5603. /* eslint-disable valid-jsdoc */
  5604. /**
  5605. * Callback function to format each of the series' labels. The `this`
  5606. * keyword refers to the series object, or the point object in case of
  5607. * pie charts. By default the series or point name is printed.
  5608. *
  5609. * @productdesc {highmaps}
  5610. * In Highmaps the context can also be a data class in case of a
  5611. * `colorAxis`.
  5612. *
  5613. * @sample {highcharts} highcharts/legend/labelformatter/
  5614. * Add text
  5615. * @sample {highmaps} maps/legend/labelformatter/
  5616. * Data classes with label formatter
  5617. *
  5618. * @type {Highcharts.FormatterCallbackFunction<Point|Series>}
  5619. */
  5620. labelFormatter: function () {
  5621. /** eslint-enable valid-jsdoc */
  5622. return this.name;
  5623. },
  5624. /**
  5625. * Line height for the legend items. Deprecated as of 2.1\. Instead,
  5626. * the line height for each item can be set using
  5627. * `itemStyle.lineHeight`, and the padding between items using
  5628. * `itemMarginTop` and `itemMarginBottom`.
  5629. *
  5630. * @sample {highcharts} highcharts/legend/lineheight/
  5631. * Setting padding
  5632. *
  5633. * @deprecated
  5634. *
  5635. * @type {number}
  5636. * @default 16
  5637. * @since 2.0
  5638. * @product highcharts gantt
  5639. * @apioption legend.lineHeight
  5640. */
  5641. /**
  5642. * If the plot area sized is calculated automatically and the legend is
  5643. * not floating, the legend margin is the space between the legend and
  5644. * the axis labels or plot area.
  5645. *
  5646. * @sample {highcharts} highcharts/legend/margin-default/
  5647. * 12 pixels by default
  5648. * @sample {highcharts} highcharts/legend/margin-30/
  5649. * 30 pixels
  5650. *
  5651. * @type {number}
  5652. * @default 12
  5653. * @since 2.1
  5654. * @apioption legend.margin
  5655. */
  5656. /**
  5657. * Maximum pixel height for the legend. When the maximum height is
  5658. * extended, navigation will show.
  5659. *
  5660. * @type {number}
  5661. * @since 2.3.0
  5662. * @apioption legend.maxHeight
  5663. */
  5664. /**
  5665. * The color of the drawn border around the legend.
  5666. *
  5667. * @see In styled mode, the legend border stroke can be applied with the
  5668. * `.highcharts-legend-box` class.
  5669. *
  5670. * @sample {highcharts} highcharts/legend/bordercolor/
  5671. * Brown border
  5672. * @sample {highstock} stock/legend/align/
  5673. * Various legend options
  5674. * @sample {highmaps} maps/legend/border-background/
  5675. * Border and background options
  5676. *
  5677. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5678. */
  5679. borderColor: palette.neutralColor40,
  5680. /**
  5681. * The border corner radius of the legend.
  5682. *
  5683. * @sample {highcharts} highcharts/legend/borderradius-default/
  5684. * Square by default
  5685. * @sample {highcharts} highcharts/legend/borderradius-round/
  5686. * 5px rounded
  5687. * @sample {highmaps} maps/legend/border-background/
  5688. * Border and background options
  5689. */
  5690. borderRadius: 0,
  5691. /**
  5692. * Options for the paging or navigation appearing when the legend is
  5693. * overflown. Navigation works well on screen, but not in static
  5694. * exported images. One way of working around that is to
  5695. * [increase the chart height in
  5696. * export](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/legend/navigation-enabled-false/).
  5697. */
  5698. navigation: {
  5699. /**
  5700. * How to animate the pages when navigating up or down. A value of
  5701. * `true` applies the default navigation given in the
  5702. * `chart.animation` option. Additional options can be given as an
  5703. * object containing values for easing and duration.
  5704. *
  5705. * @sample {highcharts} highcharts/legend/navigation/
  5706. * Legend page navigation demonstrated
  5707. * @sample {highstock} highcharts/legend/navigation/
  5708. * Legend page navigation demonstrated
  5709. *
  5710. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  5711. * @default true
  5712. * @since 2.2.4
  5713. * @apioption legend.navigation.animation
  5714. */
  5715. /**
  5716. * The pixel size of the up and down arrows in the legend paging
  5717. * navigation.
  5718. *
  5719. * @sample {highcharts} highcharts/legend/navigation/
  5720. * Legend page navigation demonstrated
  5721. * @sample {highstock} highcharts/legend/navigation/
  5722. * Legend page navigation demonstrated
  5723. *
  5724. * @type {number}
  5725. * @default 12
  5726. * @since 2.2.4
  5727. * @apioption legend.navigation.arrowSize
  5728. */
  5729. /**
  5730. * Whether to enable the legend navigation. In most cases, disabling
  5731. * the navigation results in an unwanted overflow.
  5732. *
  5733. * See also the [adapt chart to legend](
  5734. * https://www.highcharts.com/products/plugin-registry/single/8/Adapt-Chart-To-Legend)
  5735. * plugin for a solution to extend the chart height to make room for
  5736. * the legend, optionally in exported charts only.
  5737. *
  5738. * @type {boolean}
  5739. * @default true
  5740. * @since 4.2.4
  5741. * @apioption legend.navigation.enabled
  5742. */
  5743. /**
  5744. * Text styles for the legend page navigation.
  5745. *
  5746. * @see In styled mode, the navigation items are styled with the
  5747. * `.highcharts-legend-navigation` class.
  5748. *
  5749. * @sample {highcharts} highcharts/legend/navigation/
  5750. * Legend page navigation demonstrated
  5751. * @sample {highstock} highcharts/legend/navigation/
  5752. * Legend page navigation demonstrated
  5753. *
  5754. * @type {Highcharts.CSSObject}
  5755. * @since 2.2.4
  5756. * @apioption legend.navigation.style
  5757. */
  5758. /**
  5759. * The color for the active up or down arrow in the legend page
  5760. * navigation.
  5761. *
  5762. * @see In styled mode, the active arrow be styled with the
  5763. * `.highcharts-legend-nav-active` class.
  5764. *
  5765. * @sample {highcharts} highcharts/legend/navigation/
  5766. * Legend page navigation demonstrated
  5767. * @sample {highstock} highcharts/legend/navigation/
  5768. * Legend page navigation demonstrated
  5769. *
  5770. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5771. * @since 2.2.4
  5772. */
  5773. activeColor: palette.highlightColor100,
  5774. /**
  5775. * The color of the inactive up or down arrow in the legend page
  5776. * navigation. .
  5777. *
  5778. * @see In styled mode, the inactive arrow be styled with the
  5779. * `.highcharts-legend-nav-inactive` class.
  5780. *
  5781. * @sample {highcharts} highcharts/legend/navigation/
  5782. * Legend page navigation demonstrated
  5783. * @sample {highstock} highcharts/legend/navigation/
  5784. * Legend page navigation demonstrated
  5785. *
  5786. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5787. * @since 2.2.4
  5788. */
  5789. inactiveColor: palette.neutralColor20
  5790. },
  5791. /**
  5792. * The inner padding of the legend box.
  5793. *
  5794. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5795. * Padding and item margins demonstrated
  5796. * @sample {highmaps} maps/legend/padding-itemmargin/
  5797. * Padding and item margins demonstrated
  5798. *
  5799. * @type {number}
  5800. * @default 8
  5801. * @since 2.2.0
  5802. * @apioption legend.padding
  5803. */
  5804. /**
  5805. * Whether to reverse the order of the legend items compared to the
  5806. * order of the series or points as defined in the configuration object.
  5807. *
  5808. * @see [yAxis.reversedStacks](#yAxis.reversedStacks),
  5809. * [series.legendIndex](#series.legendIndex)
  5810. *
  5811. * @sample {highcharts} highcharts/legend/reversed/
  5812. * Stacked bar with reversed legend
  5813. *
  5814. * @type {boolean}
  5815. * @default false
  5816. * @since 1.2.5
  5817. * @apioption legend.reversed
  5818. */
  5819. /**
  5820. * Whether to show the symbol on the right side of the text rather than
  5821. * the left side. This is common in Arabic and Hebrew.
  5822. *
  5823. * @sample {highcharts} highcharts/legend/rtl/
  5824. * Symbol to the right
  5825. *
  5826. * @type {boolean}
  5827. * @default false
  5828. * @since 2.2
  5829. * @apioption legend.rtl
  5830. */
  5831. /**
  5832. * CSS styles for the legend area. In the 1.x versions the position
  5833. * of the legend area was determined by CSS. In 2.x, the position is
  5834. * determined by properties like `align`, `verticalAlign`, `x` and `y`,
  5835. * but the styles are still parsed for backwards compatibility.
  5836. *
  5837. * @deprecated
  5838. *
  5839. * @type {Highcharts.CSSObject}
  5840. * @product highcharts highstock
  5841. * @apioption legend.style
  5842. */
  5843. /**
  5844. * CSS styles for each legend item. Only a subset of CSS is supported,
  5845. * notably those options related to text. The default `textOverflow`
  5846. * property makes long texts truncate. Set it to `undefined` to wrap
  5847. * text instead. A `width` property can be added to control the text
  5848. * width.
  5849. *
  5850. * @see In styled mode, the legend items can be styled with the
  5851. * `.highcharts-legend-item` class.
  5852. *
  5853. * @sample {highcharts} highcharts/legend/itemstyle/
  5854. * Bold black text
  5855. * @sample {highmaps} maps/legend/itemstyle/
  5856. * Item text styles
  5857. *
  5858. * @type {Highcharts.CSSObject}
  5859. * @default {"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}
  5860. */
  5861. itemStyle: {
  5862. /**
  5863. * @ignore
  5864. */
  5865. color: palette.neutralColor80,
  5866. /**
  5867. * @ignore
  5868. */
  5869. cursor: 'pointer',
  5870. /**
  5871. * @ignore
  5872. */
  5873. fontSize: '12px',
  5874. /**
  5875. * @ignore
  5876. */
  5877. fontWeight: 'bold',
  5878. /**
  5879. * @ignore
  5880. */
  5881. textOverflow: 'ellipsis'
  5882. },
  5883. /**
  5884. * CSS styles for each legend item in hover mode. Only a subset of
  5885. * CSS is supported, notably those options related to text. Properties
  5886. * are inherited from `style` unless overridden here.
  5887. *
  5888. * @see In styled mode, the hovered legend items can be styled with
  5889. * the `.highcharts-legend-item:hover` pesudo-class.
  5890. *
  5891. * @sample {highcharts} highcharts/legend/itemhoverstyle/
  5892. * Red on hover
  5893. * @sample {highmaps} maps/legend/itemstyle/
  5894. * Item text styles
  5895. *
  5896. * @type {Highcharts.CSSObject}
  5897. * @default {"color": "#000000"}
  5898. */
  5899. itemHoverStyle: {
  5900. /**
  5901. * @ignore
  5902. */
  5903. color: palette.neutralColor100
  5904. },
  5905. /**
  5906. * CSS styles for each legend item when the corresponding series or
  5907. * point is hidden. Only a subset of CSS is supported, notably those
  5908. * options related to text. Properties are inherited from `style`
  5909. * unless overridden here.
  5910. *
  5911. * @see In styled mode, the hidden legend items can be styled with
  5912. * the `.highcharts-legend-item-hidden` class.
  5913. *
  5914. * @sample {highcharts} highcharts/legend/itemhiddenstyle/
  5915. * Darker gray color
  5916. *
  5917. * @type {Highcharts.CSSObject}
  5918. * @default {"color": "#cccccc"}
  5919. */
  5920. itemHiddenStyle: {
  5921. /**
  5922. * @ignore
  5923. */
  5924. color: palette.neutralColor20
  5925. },
  5926. /**
  5927. * Whether to apply a drop shadow to the legend. A `backgroundColor`
  5928. * also needs to be applied for this to take effect. The shadow can be
  5929. * an object configuration containing `color`, `offsetX`, `offsetY`,
  5930. * `opacity` and `width`.
  5931. *
  5932. * @sample {highcharts} highcharts/legend/shadow/
  5933. * White background and drop shadow
  5934. * @sample {highstock} stock/legend/align/
  5935. * Various legend options
  5936. * @sample {highmaps} maps/legend/border-background/
  5937. * Border and background options
  5938. *
  5939. * @type {boolean|Highcharts.CSSObject}
  5940. */
  5941. shadow: false,
  5942. /**
  5943. * Default styling for the checkbox next to a legend item when
  5944. * `showCheckbox` is true.
  5945. *
  5946. * @type {Highcharts.CSSObject}
  5947. * @default {"width": "13px", "height": "13px", "position":"absolute"}
  5948. */
  5949. itemCheckboxStyle: {
  5950. /**
  5951. * @ignore
  5952. */
  5953. position: 'absolute',
  5954. /**
  5955. * @ignore
  5956. */
  5957. width: '13px',
  5958. /**
  5959. * @ignore
  5960. */
  5961. height: '13px'
  5962. },
  5963. // itemWidth: undefined,
  5964. /**
  5965. * When this is true, the legend symbol width will be the same as
  5966. * the symbol height, which in turn defaults to the font size of the
  5967. * legend items.
  5968. *
  5969. * @since 5.0.0
  5970. */
  5971. squareSymbol: true,
  5972. /**
  5973. * The pixel height of the symbol for series types that use a rectangle
  5974. * in the legend. Defaults to the font size of legend items.
  5975. *
  5976. * @productdesc {highmaps}
  5977. * In Highmaps, when the symbol is the gradient of a vertical color
  5978. * axis, the height defaults to 200.
  5979. *
  5980. * @sample {highmaps} maps/legend/layout-vertical-sized/
  5981. * Sized vertical gradient
  5982. * @sample {highmaps} maps/legend/padding-itemmargin/
  5983. * No distance between data classes
  5984. *
  5985. * @type {number}
  5986. * @since 3.0.8
  5987. * @apioption legend.symbolHeight
  5988. */
  5989. /**
  5990. * The border radius of the symbol for series types that use a rectangle
  5991. * in the legend. Defaults to half the `symbolHeight`.
  5992. *
  5993. * @sample {highcharts} highcharts/legend/symbolradius/
  5994. * Round symbols
  5995. * @sample {highstock} highcharts/legend/symbolradius/
  5996. * Round symbols
  5997. * @sample {highmaps} highcharts/legend/symbolradius/
  5998. * Round symbols
  5999. *
  6000. * @type {number}
  6001. * @since 3.0.8
  6002. * @apioption legend.symbolRadius
  6003. */
  6004. /**
  6005. * The pixel width of the legend item symbol. When the `squareSymbol`
  6006. * option is set, this defaults to the `symbolHeight`, otherwise 16.
  6007. *
  6008. * @productdesc {highmaps}
  6009. * In Highmaps, when the symbol is the gradient of a horizontal color
  6010. * axis, the width defaults to 200.
  6011. *
  6012. * @sample {highcharts} highcharts/legend/symbolwidth/
  6013. * Greater symbol width and padding
  6014. * @sample {highmaps} maps/legend/padding-itemmargin/
  6015. * Padding and item margins demonstrated
  6016. * @sample {highmaps} maps/legend/layout-vertical-sized/
  6017. * Sized vertical gradient
  6018. *
  6019. * @type {number}
  6020. * @apioption legend.symbolWidth
  6021. */
  6022. /**
  6023. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  6024. * to render the legend item texts.
  6025. *
  6026. * Prior to 4.1.7, when using HTML, [legend.navigation](
  6027. * #legend.navigation) was disabled.
  6028. *
  6029. * @type {boolean}
  6030. * @default false
  6031. * @apioption legend.useHTML
  6032. */
  6033. /**
  6034. * The width of the legend box. If a number is set, it translates to
  6035. * pixels. Since v7.0.2 it allows setting a percent string of the full
  6036. * chart width, for example `40%`.
  6037. *
  6038. * Defaults to the full chart width for legends below or above the
  6039. * chart, half the chart width for legends to the left and right.
  6040. *
  6041. * @sample {highcharts} highcharts/legend/width/
  6042. * Aligned to the plot area
  6043. * @sample {highcharts} highcharts/legend/width-percent/
  6044. * A percent of the chart width
  6045. *
  6046. * @type {number|string}
  6047. * @since 2.0
  6048. * @apioption legend.width
  6049. */
  6050. /**
  6051. * The pixel padding between the legend item symbol and the legend
  6052. * item text.
  6053. *
  6054. * @sample {highcharts} highcharts/legend/symbolpadding/
  6055. * Greater symbol width and padding
  6056. */
  6057. symbolPadding: 5,
  6058. /**
  6059. * The vertical alignment of the legend box. Can be one of `top`,
  6060. * `middle` or `bottom`. Vertical position can be further determined
  6061. * by the `y` option.
  6062. *
  6063. * In the case that the legend is aligned in a corner position, the
  6064. * `layout` option will determine whether to place it above/below
  6065. * or on the side of the plot area.
  6066. *
  6067. * When the [layout](#legend.layout) option is `proximate`, the
  6068. * `verticalAlign` option doesn't apply.
  6069. *
  6070. * @sample {highcharts} highcharts/legend/verticalalign/
  6071. * Legend 100px from the top of the chart
  6072. * @sample {highstock} stock/legend/align/
  6073. * Various legend options
  6074. * @sample {highmaps} maps/legend/alignment/
  6075. * Legend alignment
  6076. *
  6077. * @type {Highcharts.VerticalAlignValue}
  6078. * @since 2.0
  6079. */
  6080. verticalAlign: 'bottom',
  6081. // width: undefined,
  6082. /**
  6083. * The x offset of the legend relative to its horizontal alignment
  6084. * `align` within chart.spacingLeft and chart.spacingRight. Negative
  6085. * x moves it to the left, positive x moves it to the right.
  6086. *
  6087. * @sample {highcharts} highcharts/legend/width/
  6088. * Aligned to the plot area
  6089. *
  6090. * @since 2.0
  6091. */
  6092. x: 0,
  6093. /**
  6094. * The vertical offset of the legend relative to it's vertical alignment
  6095. * `verticalAlign` within chart.spacingTop and chart.spacingBottom.
  6096. * Negative y moves it up, positive y moves it down.
  6097. *
  6098. * @sample {highcharts} highcharts/legend/verticalalign/
  6099. * Legend 100px from the top of the chart
  6100. * @sample {highstock} stock/legend/align/
  6101. * Various legend options
  6102. * @sample {highmaps} maps/legend/alignment/
  6103. * Legend alignment
  6104. *
  6105. * @since 2.0
  6106. */
  6107. y: 0,
  6108. /**
  6109. * A title to be added on top of the legend.
  6110. *
  6111. * @sample {highcharts} highcharts/legend/title/
  6112. * Legend title
  6113. * @sample {highmaps} maps/legend/alignment/
  6114. * Legend with title
  6115. *
  6116. * @since 3.0
  6117. */
  6118. title: {
  6119. /**
  6120. * A text or HTML string for the title.
  6121. *
  6122. * @type {string}
  6123. * @since 3.0
  6124. * @apioption legend.title.text
  6125. */
  6126. /**
  6127. * Generic CSS styles for the legend title.
  6128. *
  6129. * @see In styled mode, the legend title is styled with the
  6130. * `.highcharts-legend-title` class.
  6131. *
  6132. * @type {Highcharts.CSSObject}
  6133. * @default {"fontWeight": "bold"}
  6134. * @since 3.0
  6135. */
  6136. style: {
  6137. /**
  6138. * @ignore
  6139. */
  6140. fontWeight: 'bold'
  6141. }
  6142. }
  6143. },
  6144. /**
  6145. * The loading options control the appearance of the loading screen
  6146. * that covers the plot area on chart operations. This screen only
  6147. * appears after an explicit call to `chart.showLoading()`. It is a
  6148. * utility for developers to communicate to the end user that something
  6149. * is going on, for example while retrieving new data via an XHR connection.
  6150. * The "Loading..." text itself is not part of this configuration
  6151. * object, but part of the `lang` object.
  6152. */
  6153. loading: {
  6154. /**
  6155. * The duration in milliseconds of the fade out effect.
  6156. *
  6157. * @sample highcharts/loading/hideduration/
  6158. * Fade in and out over a second
  6159. *
  6160. * @type {number}
  6161. * @default 100
  6162. * @since 1.2.0
  6163. * @apioption loading.hideDuration
  6164. */
  6165. /**
  6166. * The duration in milliseconds of the fade in effect.
  6167. *
  6168. * @sample highcharts/loading/hideduration/
  6169. * Fade in and out over a second
  6170. *
  6171. * @type {number}
  6172. * @default 100
  6173. * @since 1.2.0
  6174. * @apioption loading.showDuration
  6175. */
  6176. /**
  6177. * CSS styles for the loading label `span`.
  6178. *
  6179. * @see In styled mode, the loading label is styled with the
  6180. * `.highcharts-loading-inner` class.
  6181. *
  6182. * @sample {highcharts|highmaps} highcharts/loading/labelstyle/
  6183. * Vertically centered
  6184. * @sample {highstock} stock/loading/general/
  6185. * Label styles
  6186. *
  6187. * @type {Highcharts.CSSObject}
  6188. * @default {"fontWeight": "bold", "position": "relative", "top": "45%"}
  6189. * @since 1.2.0
  6190. */
  6191. labelStyle: {
  6192. /**
  6193. * @ignore
  6194. */
  6195. fontWeight: 'bold',
  6196. /**
  6197. * @ignore
  6198. */
  6199. position: 'relative',
  6200. /**
  6201. * @ignore
  6202. */
  6203. top: '45%'
  6204. },
  6205. /**
  6206. * CSS styles for the loading screen that covers the plot area.
  6207. *
  6208. * In styled mode, the loading label is styled with the
  6209. * `.highcharts-loading` class.
  6210. *
  6211. * @sample {highcharts|highmaps} highcharts/loading/style/
  6212. * Gray plot area, white text
  6213. * @sample {highstock} stock/loading/general/
  6214. * Gray plot area, white text
  6215. *
  6216. * @type {Highcharts.CSSObject}
  6217. * @default {"position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center"}
  6218. * @since 1.2.0
  6219. */
  6220. style: {
  6221. /**
  6222. * @ignore
  6223. */
  6224. position: 'absolute',
  6225. /**
  6226. * @ignore
  6227. */
  6228. backgroundColor: palette.backgroundColor,
  6229. /**
  6230. * @ignore
  6231. */
  6232. opacity: 0.5,
  6233. /**
  6234. * @ignore
  6235. */
  6236. textAlign: 'center'
  6237. }
  6238. },
  6239. /**
  6240. * Options for the tooltip that appears when the user hovers over a
  6241. * series or point.
  6242. *
  6243. * @declare Highcharts.TooltipOptions
  6244. */
  6245. tooltip: {
  6246. /**
  6247. * The color of the tooltip border. When `undefined`, the border takes
  6248. * the color of the corresponding series or point.
  6249. *
  6250. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6251. * Follow series by default
  6252. * @sample {highcharts} highcharts/tooltip/bordercolor-black/
  6253. * Black border
  6254. * @sample {highstock} stock/tooltip/general/
  6255. * Styled tooltip
  6256. * @sample {highmaps} maps/tooltip/background-border/
  6257. * Background and border demo
  6258. *
  6259. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6260. * @apioption tooltip.borderColor
  6261. */
  6262. /**
  6263. * A CSS class name to apply to the tooltip's container div,
  6264. * allowing unique CSS styling for each chart.
  6265. *
  6266. * @type {string}
  6267. * @apioption tooltip.className
  6268. */
  6269. /**
  6270. * Since 4.1, the crosshair definitions are moved to the Axis object
  6271. * in order for a better separation from the tooltip. See
  6272. * [xAxis.crosshair](#xAxis.crosshair).
  6273. *
  6274. * @sample {highcharts} highcharts/tooltip/crosshairs-x/
  6275. * Enable a crosshair for the x value
  6276. *
  6277. * @deprecated
  6278. *
  6279. * @type {*}
  6280. * @default true
  6281. * @apioption tooltip.crosshairs
  6282. */
  6283. /**
  6284. * Distance from point to tooltip in pixels.
  6285. *
  6286. * @type {number}
  6287. * @default 16
  6288. * @apioption tooltip.distance
  6289. */
  6290. /**
  6291. * Whether the tooltip should follow the mouse as it moves across
  6292. * columns, pie slices and other point types with an extent.
  6293. * By default it behaves this way for pie, polygon, map, sankey
  6294. * and wordcloud series by override in the `plotOptions`
  6295. * for those series types.
  6296. *
  6297. * Does not apply if [split](#tooltip.split) is `true`.
  6298. *
  6299. * For touch moves to behave the same way, [followTouchMove](
  6300. * #tooltip.followTouchMove) must be `true` also.
  6301. *
  6302. * @type {boolean}
  6303. * @default {highcharts} false
  6304. * @default {highstock} false
  6305. * @default {highmaps} true
  6306. * @since 3.0
  6307. * @apioption tooltip.followPointer
  6308. */
  6309. /**
  6310. * Whether the tooltip should update as the finger moves on a touch
  6311. * device. If this is `true` and [chart.panning](#chart.panning) is
  6312. * set,`followTouchMove` will take over one-finger touches, so the user
  6313. * needs to use two fingers for zooming and panning.
  6314. *
  6315. * Note the difference to [followPointer](#tooltip.followPointer) that
  6316. * only defines the _position_ of the tooltip. If `followPointer` is
  6317. * false in for example a column series, the tooltip will show above or
  6318. * below the column, but as `followTouchMove` is true, the tooltip will
  6319. * jump from column to column as the user swipes across the plot area.
  6320. *
  6321. * @type {boolean}
  6322. * @default {highcharts} true
  6323. * @default {highstock} true
  6324. * @default {highmaps} false
  6325. * @since 3.0.1
  6326. * @apioption tooltip.followTouchMove
  6327. */
  6328. /**
  6329. * Callback function to format the text of the tooltip from scratch. In
  6330. * case of single or [shared](#tooltip.shared) tooltips, a string should
  6331. * be returned. In case of [split](#tooltip.split) tooltips, it should
  6332. * return an array where the first item is the header, and subsequent
  6333. * items are mapped to the points. Return `false` to disable tooltip for
  6334. * a specific point on series.
  6335. *
  6336. * A subset of HTML is supported. Unless `useHTML` is true, the HTML of
  6337. * the tooltip is parsed and converted to SVG, therefore this isn't a
  6338. * complete HTML renderer. The following HTML tags are supported: `b`,
  6339. * `br`, `em`, `i`, `span`, `strong`. Spans can be styled with a `style`
  6340. * attribute, but only text-related CSS, that is shared with SVG, is
  6341. * handled.
  6342. *
  6343. * The available data in the formatter differ a bit depending on whether
  6344. * the tooltip is shared or split, or belongs to a single point. In a
  6345. * shared/split tooltip, all properties except `x`, which is common for
  6346. * all points, are kept in an array, `this.points`.
  6347. *
  6348. * Available data are:
  6349. *
  6350. * - **this.percentage (not shared) /**
  6351. * **this.points[i].percentage (shared)**:
  6352. * Stacked series and pies only. The point's percentage of the total.
  6353. *
  6354. * - **this.point (not shared) / this.points[i].point (shared)**:
  6355. * The point object. The point name, if defined, is available through
  6356. * `this.point.name`.
  6357. *
  6358. * - **this.points**:
  6359. * In a shared tooltip, this is an array containing all other
  6360. * properties for each point.
  6361. *
  6362. * - **this.series (not shared) / this.points[i].series (shared)**:
  6363. * The series object. The series name is available through
  6364. * `this.series.name`.
  6365. *
  6366. * - **this.total (not shared) / this.points[i].total (shared)**:
  6367. * Stacked series only. The total value at this point's x value.
  6368. *
  6369. * - **this.x**:
  6370. * The x value. This property is the same regardless of the tooltip
  6371. * being shared or not.
  6372. *
  6373. * - **this.y (not shared) / this.points[i].y (shared)**:
  6374. * The y value.
  6375. *
  6376. * @sample {highcharts} highcharts/tooltip/formatter-simple/
  6377. * Simple string formatting
  6378. * @sample {highcharts} highcharts/tooltip/formatter-shared/
  6379. * Formatting with shared tooltip
  6380. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6381. * Formatting with split tooltip
  6382. * @sample highcharts/tooltip/formatter-conditional-default/
  6383. * Extending default formatter
  6384. * @sample {highstock} stock/tooltip/formatter/
  6385. * Formatting with shared tooltip
  6386. * @sample {highmaps} maps/tooltip/formatter/
  6387. * String formatting
  6388. *
  6389. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6390. * @apioption tooltip.formatter
  6391. */
  6392. /**
  6393. * Callback function to format the text of the tooltip for
  6394. * visible null points.
  6395. * Works analogously to [formatter](#tooltip.formatter).
  6396. *
  6397. * @sample highcharts/plotoptions/series-nullformat
  6398. * Format data label and tooltip for null point.
  6399. *
  6400. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6401. * @apioption tooltip.nullFormatter
  6402. */
  6403. /**
  6404. * The number of milliseconds to wait until the tooltip is hidden when
  6405. * mouse out from a point or chart.
  6406. *
  6407. * @type {number}
  6408. * @default 500
  6409. * @since 3.0
  6410. * @apioption tooltip.hideDelay
  6411. */
  6412. /**
  6413. * Whether to allow the tooltip to render outside the chart's SVG
  6414. * element box. By default (`false`), the tooltip is rendered within the
  6415. * chart's SVG element, which results in the tooltip being aligned
  6416. * inside the chart area. For small charts, this may result in clipping
  6417. * or overlapping. When `true`, a separate SVG element is created and
  6418. * overlaid on the page, allowing the tooltip to be aligned inside the
  6419. * page itself.
  6420. *
  6421. * Defaults to `true` if `chart.scrollablePlotArea` is activated,
  6422. * otherwise `false`.
  6423. *
  6424. * @sample highcharts/tooltip/outside
  6425. * Small charts with tooltips outside
  6426. *
  6427. * @type {boolean|undefined}
  6428. * @default undefined
  6429. * @since 6.1.1
  6430. * @apioption tooltip.outside
  6431. */
  6432. /**
  6433. * A callback function for formatting the HTML output for a single point
  6434. * in the tooltip. Like the `pointFormat` string, but with more
  6435. * flexibility.
  6436. *
  6437. * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
  6438. * @since 4.1.0
  6439. * @context Highcharts.Point
  6440. * @apioption tooltip.pointFormatter
  6441. */
  6442. /**
  6443. * A callback function to place the tooltip in a default position. The
  6444. * callback receives three parameters: `labelWidth`, `labelHeight` and
  6445. * `point`, where point contains values for `plotX` and `plotY` telling
  6446. * where the reference point is in the plot area. Add `chart.plotLeft`
  6447. * and `chart.plotTop` to get the full coordinates.
  6448. *
  6449. * Since v7, when [tooltip.split](#tooltip.split) option is enabled,
  6450. * positioner is called for each of the boxes separately, including
  6451. * xAxis header. xAxis header is not a point, instead `point` argument
  6452. * contains info:
  6453. * `{ plotX: Number, plotY: Number, isHeader: Boolean }`
  6454. *
  6455. *
  6456. * The return should be an object containing x and y values, for example
  6457. * `{ x: 100, y: 100 }`.
  6458. *
  6459. * @sample {highcharts} highcharts/tooltip/positioner/
  6460. * A fixed tooltip position
  6461. * @sample {highstock} stock/tooltip/positioner/
  6462. * A fixed tooltip position on top of the chart
  6463. * @sample {highmaps} maps/tooltip/positioner/
  6464. * A fixed tooltip position
  6465. * @sample {highstock} stock/tooltip/split-positioner/
  6466. * Split tooltip with fixed positions
  6467. * @sample {highstock} stock/tooltip/positioner-scrollable-plotarea/
  6468. * Scrollable plot area combined with tooltip positioner
  6469. *
  6470. * @type {Highcharts.TooltipPositionerCallbackFunction}
  6471. * @since 2.2.4
  6472. * @apioption tooltip.positioner
  6473. */
  6474. /**
  6475. * The name of a symbol to use for the border around the tooltip. Can
  6476. * be one of: `"callout"`, `"circle"` or `"rect"`. When
  6477. * [tooltip.split](#tooltip.split)
  6478. * option is enabled, shape is applied to all boxes except header, which
  6479. * is controlled by
  6480. * [tooltip.headerShape](#tooltip.headerShape).
  6481. *
  6482. * Custom callbacks for symbol path generation can also be added to
  6483. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6484. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6485. *
  6486. * @type {Highcharts.TooltipShapeValue}
  6487. * @default callout
  6488. * @since 4.0
  6489. * @apioption tooltip.shape
  6490. */
  6491. /**
  6492. * The name of a symbol to use for the border around the tooltip
  6493. * header. Applies only when [tooltip.split](#tooltip.split) is
  6494. * enabled.
  6495. *
  6496. * Custom callbacks for symbol path generation can also be added to
  6497. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6498. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6499. *
  6500. * @see [tooltip.shape](#tooltip.shape)
  6501. *
  6502. * @sample {highstock} stock/tooltip/split-positioner/
  6503. * Different shapes for header and split boxes
  6504. *
  6505. * @type {Highcharts.TooltipShapeValue}
  6506. * @default callout
  6507. * @validvalue ["callout", "square"]
  6508. * @since 7.0
  6509. * @apioption tooltip.headerShape
  6510. */
  6511. /**
  6512. * When the tooltip is shared, the entire plot area will capture mouse
  6513. * movement or touch events. Tooltip texts for series types with ordered
  6514. * data (not pie, scatter, flags etc) will be shown in a single bubble.
  6515. * This is recommended for single series charts and for tablet/mobile
  6516. * optimized charts.
  6517. *
  6518. * See also [tooltip.split](#tooltip.split), that is better suited for
  6519. * charts with many series, especially line-type series. The
  6520. * `tooltip.split` option takes precedence over `tooltip.shared`.
  6521. *
  6522. * @sample {highcharts} highcharts/tooltip/shared-false/
  6523. * False by default
  6524. * @sample {highcharts} highcharts/tooltip/shared-true/
  6525. * True
  6526. * @sample {highcharts} highcharts/tooltip/shared-x-crosshair/
  6527. * True with x axis crosshair
  6528. * @sample {highcharts} highcharts/tooltip/shared-true-mixed-types/
  6529. * True with mixed series types
  6530. *
  6531. * @type {boolean}
  6532. * @default false
  6533. * @since 2.1
  6534. * @product highcharts highstock
  6535. * @apioption tooltip.shared
  6536. */
  6537. /**
  6538. * Split the tooltip into one label per series, with the header close
  6539. * to the axis. This is recommended over [shared](#tooltip.shared)
  6540. * tooltips for charts with multiple line series, generally making them
  6541. * easier to read. This option takes precedence over `tooltip.shared`.
  6542. *
  6543. * @productdesc {highstock} In Highcharts Stock, tooltips are split
  6544. * by default since v6.0.0. Stock charts typically contain
  6545. * multi-dimension points and multiple panes, making split tooltips
  6546. * the preferred layout over
  6547. * the previous `shared` tooltip.
  6548. *
  6549. * @sample highcharts/tooltip/split/
  6550. * Split tooltip
  6551. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6552. * Split tooltip and custom formatter callback
  6553. *
  6554. * @type {boolean}
  6555. * @default {highcharts} false
  6556. * @default {highstock} true
  6557. * @since 5.0.0
  6558. * @product highcharts highstock
  6559. * @apioption tooltip.split
  6560. */
  6561. /**
  6562. * Prevents the tooltip from switching or closing, when touched or
  6563. * pointed.
  6564. *
  6565. * @sample highcharts/tooltip/stickoncontact/
  6566. * Tooltip sticks on pointer contact
  6567. *
  6568. * @type {boolean}
  6569. * @since 8.0.1
  6570. * @apioption tooltip.stickOnContact
  6571. */
  6572. /**
  6573. * Use HTML to render the contents of the tooltip instead of SVG. Using
  6574. * HTML allows advanced formatting like tables and images in the
  6575. * tooltip. It is also recommended for rtl languages as it works around
  6576. * rtl bugs in early Firefox.
  6577. *
  6578. * @sample {highcharts|highstock} highcharts/tooltip/footerformat/
  6579. * A table for value alignment
  6580. * @sample {highcharts|highstock} highcharts/tooltip/fullhtml/
  6581. * Full HTML tooltip
  6582. * @sample {highmaps} maps/tooltip/usehtml/
  6583. * Pure HTML tooltip
  6584. *
  6585. * @type {boolean}
  6586. * @default false
  6587. * @since 2.2
  6588. * @apioption tooltip.useHTML
  6589. */
  6590. /**
  6591. * How many decimals to show in each series' y value. This is
  6592. * overridable in each series' tooltip options object. The default is to
  6593. * preserve all decimals.
  6594. *
  6595. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6596. * Set decimals, prefix and suffix for the value
  6597. * @sample {highmaps} maps/tooltip/valuedecimals/
  6598. * Set decimals, prefix and suffix for the value
  6599. *
  6600. * @type {number}
  6601. * @since 2.2
  6602. * @apioption tooltip.valueDecimals
  6603. */
  6604. /**
  6605. * A string to prepend to each series' y value. Overridable in each
  6606. * series' tooltip options object.
  6607. *
  6608. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6609. * Set decimals, prefix and suffix for the value
  6610. * @sample {highmaps} maps/tooltip/valuedecimals/
  6611. * Set decimals, prefix and suffix for the value
  6612. *
  6613. * @type {string}
  6614. * @since 2.2
  6615. * @apioption tooltip.valuePrefix
  6616. */
  6617. /**
  6618. * A string to append to each series' y value. Overridable in each
  6619. * series' tooltip options object.
  6620. *
  6621. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6622. * Set decimals, prefix and suffix for the value
  6623. * @sample {highmaps} maps/tooltip/valuedecimals/
  6624. * Set decimals, prefix and suffix for the value
  6625. *
  6626. * @type {string}
  6627. * @since 2.2
  6628. * @apioption tooltip.valueSuffix
  6629. */
  6630. /**
  6631. * The format for the date in the tooltip header if the X axis is a
  6632. * datetime axis. The default is a best guess based on the smallest
  6633. * distance between points in the chart.
  6634. *
  6635. * @sample {highcharts} highcharts/tooltip/xdateformat/
  6636. * A different format
  6637. *
  6638. * @type {string}
  6639. * @product highcharts highstock gantt
  6640. * @apioption tooltip.xDateFormat
  6641. */
  6642. /**
  6643. * How many decimals to show for the `point.change` value when the
  6644. * `series.compare` option is set. This is overridable in each series'
  6645. * tooltip options object. The default is to preserve all decimals.
  6646. *
  6647. * @type {number}
  6648. * @since 1.0.1
  6649. * @product highstock
  6650. * @apioption tooltip.changeDecimals
  6651. */
  6652. /**
  6653. * Enable or disable the tooltip.
  6654. *
  6655. * @sample {highcharts} highcharts/tooltip/enabled/
  6656. * Disabled
  6657. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  6658. * Disable tooltip and show values on chart instead
  6659. */
  6660. enabled: true,
  6661. /**
  6662. * Enable or disable animation of the tooltip.
  6663. *
  6664. * @type {boolean}
  6665. * @default true
  6666. * @since 2.3.0
  6667. */
  6668. animation: svg,
  6669. /**
  6670. * The radius of the rounded border corners.
  6671. *
  6672. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6673. * 5px by default
  6674. * @sample {highcharts} highcharts/tooltip/borderradius-0/
  6675. * Square borders
  6676. * @sample {highmaps} maps/tooltip/background-border/
  6677. * Background and border demo
  6678. */
  6679. borderRadius: 3,
  6680. /**
  6681. * For series on datetime axes, the date format in the tooltip's
  6682. * header will by default be guessed based on the closest data points.
  6683. * This member gives the default string representations used for
  6684. * each unit. For an overview of the replacement codes, see
  6685. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  6686. *
  6687. * @see [xAxis.dateTimeLabelFormats](#xAxis.dateTimeLabelFormats)
  6688. *
  6689. * @type {Highcharts.Dictionary<string>}
  6690. * @product highcharts highstock gantt
  6691. */
  6692. dateTimeLabelFormats: {
  6693. /** @internal */
  6694. millisecond: '%A, %b %e, %H:%M:%S.%L',
  6695. /** @internal */
  6696. second: '%A, %b %e, %H:%M:%S',
  6697. /** @internal */
  6698. minute: '%A, %b %e, %H:%M',
  6699. /** @internal */
  6700. hour: '%A, %b %e, %H:%M',
  6701. /** @internal */
  6702. day: '%A, %b %e, %Y',
  6703. /** @internal */
  6704. week: 'Week from %A, %b %e, %Y',
  6705. /** @internal */
  6706. month: '%B %Y',
  6707. /** @internal */
  6708. year: '%Y'
  6709. },
  6710. /**
  6711. * A string to append to the tooltip format.
  6712. *
  6713. * @sample {highcharts} highcharts/tooltip/footerformat/
  6714. * A table for value alignment
  6715. * @sample {highmaps} maps/tooltip/format/
  6716. * Format demo
  6717. *
  6718. * @since 2.2
  6719. */
  6720. footerFormat: '',
  6721. /**
  6722. * Padding inside the tooltip, in pixels.
  6723. *
  6724. * @since 5.0.0
  6725. */
  6726. padding: 8,
  6727. /**
  6728. * Proximity snap for graphs or single points. It defaults to 10 for
  6729. * mouse-powered devices and 25 for touch devices.
  6730. *
  6731. * Note that in most cases the whole plot area captures the mouse
  6732. * movement, and in these cases `tooltip.snap` doesn't make sense. This
  6733. * applies when [stickyTracking](#plotOptions.series.stickyTracking)
  6734. * is `true` (default) and when the tooltip is [shared](#tooltip.shared)
  6735. * or [split](#tooltip.split).
  6736. *
  6737. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6738. * 10 px by default
  6739. * @sample {highcharts} highcharts/tooltip/snap-50/
  6740. * 50 px on graph
  6741. *
  6742. * @type {number}
  6743. * @default 10/25
  6744. * @since 1.2.0
  6745. * @product highcharts highstock
  6746. */
  6747. snap: isTouchDevice ? 25 : 10,
  6748. /**
  6749. * The HTML of the tooltip header line. Variables are enclosed by
  6750. * curly brackets. Available variables are `point.key`, `series.name`,
  6751. * `series.color` and other members from the `point` and `series`
  6752. * objects. The `point.key` variable contains the category name, x
  6753. * value or datetime string depending on the type of axis. For datetime
  6754. * axes, the `point.key` date format can be set using
  6755. * `tooltip.xDateFormat`.
  6756. *
  6757. * @sample {highcharts} highcharts/tooltip/footerformat/
  6758. * An HTML table in the tooltip
  6759. * @sample {highstock} highcharts/tooltip/footerformat/
  6760. * An HTML table in the tooltip
  6761. * @sample {highmaps} maps/tooltip/format/
  6762. * Format demo
  6763. *
  6764. * @type {string}
  6765. * @apioption tooltip.headerFormat
  6766. */
  6767. headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
  6768. /**
  6769. * The HTML of the null point's line in the tooltip. Works analogously
  6770. * to [pointFormat](#tooltip.pointFormat).
  6771. *
  6772. * @sample {highcharts} highcharts/plotoptions/series-nullformat
  6773. * Format data label and tooltip for null point.
  6774. *
  6775. * @type {string}
  6776. * @apioption tooltip.nullFormat
  6777. */
  6778. /**
  6779. * The HTML of the point's line in the tooltip. Variables are enclosed
  6780. * by curly brackets. Available variables are `point.x`, `point.y`,
  6781. * `series.name` and `series.color` and other properties on the same
  6782. * form. Furthermore, `point.y` can be extended by the
  6783. * `tooltip.valuePrefix` and `tooltip.valueSuffix` variables. This can
  6784. * also be overridden for each series, which makes it a good hook for
  6785. * displaying units.
  6786. *
  6787. * In styled mode, the dot is colored by a class name rather
  6788. * than the point color.
  6789. *
  6790. * @sample {highcharts} highcharts/tooltip/pointformat/
  6791. * A different point format with value suffix
  6792. * @sample {highmaps} maps/tooltip/format/
  6793. * Format demo
  6794. *
  6795. * @type {string}
  6796. * @since 2.2
  6797. * @apioption tooltip.pointFormat
  6798. */
  6799. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
  6800. /**
  6801. * The background color or gradient for the tooltip.
  6802. *
  6803. * In styled mode, the stroke width is set in the
  6804. * `.highcharts-tooltip-box` class.
  6805. *
  6806. * @sample {highcharts} highcharts/tooltip/backgroundcolor-solid/
  6807. * Yellowish background
  6808. * @sample {highcharts} highcharts/tooltip/backgroundcolor-gradient/
  6809. * Gradient
  6810. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6811. * Tooltip in styled mode
  6812. * @sample {highstock} stock/tooltip/general/
  6813. * Custom tooltip
  6814. * @sample {highstock} highcharts/css/tooltip-border-background/
  6815. * Tooltip in styled mode
  6816. * @sample {highmaps} maps/tooltip/background-border/
  6817. * Background and border demo
  6818. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6819. * Tooltip in styled mode
  6820. *
  6821. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6822. */
  6823. backgroundColor: color(palette.neutralColor3)
  6824. .setOpacity(0.85).get(),
  6825. /**
  6826. * The pixel width of the tooltip border.
  6827. *
  6828. * In styled mode, the stroke width is set in the
  6829. * `.highcharts-tooltip-box` class.
  6830. *
  6831. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6832. * 2px by default
  6833. * @sample {highcharts} highcharts/tooltip/borderwidth/
  6834. * No border (shadow only)
  6835. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6836. * Tooltip in styled mode
  6837. * @sample {highstock} stock/tooltip/general/
  6838. * Custom tooltip
  6839. * @sample {highstock} highcharts/css/tooltip-border-background/
  6840. * Tooltip in styled mode
  6841. * @sample {highmaps} maps/tooltip/background-border/
  6842. * Background and border demo
  6843. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6844. * Tooltip in styled mode
  6845. */
  6846. borderWidth: 1,
  6847. /**
  6848. * Whether to apply a drop shadow to the tooltip.
  6849. *
  6850. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6851. * True by default
  6852. * @sample {highcharts} highcharts/tooltip/shadow/
  6853. * False
  6854. * @sample {highmaps} maps/tooltip/positioner/
  6855. * Fixed tooltip position, border and shadow disabled
  6856. *
  6857. * @type {boolean|Highcharts.ShadowOptionsObject}
  6858. */
  6859. shadow: true,
  6860. /**
  6861. * CSS styles for the tooltip. The tooltip can also be styled through
  6862. * the CSS class `.highcharts-tooltip`.
  6863. *
  6864. * Note that the default `pointerEvents` style makes the tooltip ignore
  6865. * mouse events, so in order to use clickable tooltips, this value must
  6866. * be set to `auto`.
  6867. *
  6868. * @sample {highcharts} highcharts/tooltip/style/
  6869. * Greater padding, bold text
  6870. *
  6871. * @type {Highcharts.CSSObject}
  6872. */
  6873. style: {
  6874. /** @internal */
  6875. color: palette.neutralColor80,
  6876. /** @internal */
  6877. cursor: 'default',
  6878. /** @internal */
  6879. fontSize: '12px',
  6880. /** @internal */
  6881. whiteSpace: 'nowrap'
  6882. }
  6883. },
  6884. /**
  6885. * Highchart by default puts a credits label in the lower right corner
  6886. * of the chart. This can be changed using these options.
  6887. */
  6888. credits: {
  6889. /**
  6890. * Credits for map source to be concatenated with conventional credit
  6891. * text. By default this is a format string that collects copyright
  6892. * information from the map if available.
  6893. *
  6894. * @see [mapTextFull](#credits.mapTextFull)
  6895. * @see [text](#credits.text)
  6896. *
  6897. * @type {string}
  6898. * @default \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>
  6899. * @since 4.2.2
  6900. * @product highmaps
  6901. * @apioption credits.mapText
  6902. */
  6903. /**
  6904. * Detailed credits for map source to be displayed on hover of credits
  6905. * text. By default this is a format string that collects copyright
  6906. * information from the map if available.
  6907. *
  6908. * @see [mapText](#credits.mapText)
  6909. * @see [text](#credits.text)
  6910. *
  6911. * @type {string}
  6912. * @default {geojson.copyright}
  6913. * @since 4.2.2
  6914. * @product highmaps
  6915. * @apioption credits.mapTextFull
  6916. */
  6917. /**
  6918. * Whether to show the credits text.
  6919. *
  6920. * @sample {highcharts} highcharts/credits/enabled-false/
  6921. * Credits disabled
  6922. * @sample {highstock} stock/credits/enabled/
  6923. * Credits disabled
  6924. * @sample {highmaps} maps/credits/enabled-false/
  6925. * Credits disabled
  6926. */
  6927. enabled: true,
  6928. /**
  6929. * The URL for the credits label.
  6930. *
  6931. * @sample {highcharts} highcharts/credits/href/
  6932. * Custom URL and text
  6933. * @sample {highmaps} maps/credits/customized/
  6934. * Custom URL and text
  6935. */
  6936. href: 'https://www.highcharts.com?credits',
  6937. /**
  6938. * Position configuration for the credits label.
  6939. *
  6940. * @sample {highcharts} highcharts/credits/position-left/
  6941. * Left aligned
  6942. * @sample {highcharts} highcharts/credits/position-left/
  6943. * Left aligned
  6944. * @sample {highmaps} maps/credits/customized/
  6945. * Left aligned
  6946. * @sample {highmaps} maps/credits/customized/
  6947. * Left aligned
  6948. *
  6949. * @type {Highcharts.AlignObject}
  6950. * @since 2.1
  6951. */
  6952. position: {
  6953. /** @internal */
  6954. align: 'right',
  6955. /** @internal */
  6956. x: -10,
  6957. /** @internal */
  6958. verticalAlign: 'bottom',
  6959. /** @internal */
  6960. y: -5
  6961. },
  6962. /**
  6963. * CSS styles for the credits label.
  6964. *
  6965. * @see In styled mode, credits styles can be set with the
  6966. * `.highcharts-credits` class.
  6967. *
  6968. * @type {Highcharts.CSSObject}
  6969. */
  6970. style: {
  6971. /** @internal */
  6972. cursor: 'pointer',
  6973. /** @internal */
  6974. color: palette.neutralColor40,
  6975. /** @internal */
  6976. fontSize: '9px'
  6977. },
  6978. /**
  6979. * The text for the credits label.
  6980. *
  6981. * @productdesc {highmaps}
  6982. * If a map is loaded as GeoJSON, the text defaults to
  6983. * `Highcharts @ {map-credits}`. Otherwise, it defaults to
  6984. * `Highcharts.com`.
  6985. *
  6986. * @sample {highcharts} highcharts/credits/href/
  6987. * Custom URL and text
  6988. * @sample {highmaps} maps/credits/customized/
  6989. * Custom URL and text
  6990. */
  6991. text: 'Highcharts.com'
  6992. }
  6993. };
  6994. /* eslint-disable spaced-comment */
  6995. defaultOptions.chart.styledMode = false;
  6996. '';
  6997. var defaultTime = new Time(merge(defaultOptions.global,
  6998. defaultOptions.time));
  6999. /**
  7000. * Get the updated default options. Until 3.0.7, merely exposing defaultOptions
  7001. * for outside modules wasn't enough because the setOptions method created a new
  7002. * object.
  7003. *
  7004. * @function Highcharts.getOptions
  7005. *
  7006. * @return {Highcharts.Options}
  7007. */
  7008. function getOptions() {
  7009. return defaultOptions;
  7010. }
  7011. /**
  7012. * Merge the default options with custom options and return the new options
  7013. * structure. Commonly used for defining reusable templates.
  7014. *
  7015. * @sample highcharts/global/useutc-false Setting a global option
  7016. * @sample highcharts/members/setoptions Applying a global theme
  7017. *
  7018. * @function Highcharts.setOptions
  7019. *
  7020. * @param {Highcharts.Options} options
  7021. * The new custom chart options.
  7022. *
  7023. * @return {Highcharts.Options}
  7024. * Updated options.
  7025. */
  7026. function setOptions(options) {
  7027. // Copy in the default options
  7028. merge(true, defaultOptions, options);
  7029. // Update the time object
  7030. if (options.time || options.global) {
  7031. if (H.time) {
  7032. H.time.update(merge(defaultOptions.global, defaultOptions.time, options.global, options.time));
  7033. }
  7034. else {
  7035. /**
  7036. * Global `Time` object with default options. Since v6.0.5, time
  7037. * settings can be applied individually for each chart. If no
  7038. * individual settings apply, this `Time` object is shared by all
  7039. * instances.
  7040. *
  7041. * @name Highcharts.time
  7042. * @type {Highcharts.Time}
  7043. */
  7044. H.time = defaultTime;
  7045. }
  7046. }
  7047. return defaultOptions;
  7048. }
  7049. var optionsModule = {
  7050. defaultOptions: defaultOptions,
  7051. defaultTime: defaultTime,
  7052. getOptions: getOptions,
  7053. setOptions: setOptions
  7054. };
  7055. return optionsModule;
  7056. });
  7057. _registerModule(_modules, 'Core/Animation/Fx.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Color, H, U) {
  7058. /* *
  7059. *
  7060. * (c) 2010-2021 Torstein Honsi
  7061. *
  7062. * License: www.highcharts.com/license
  7063. *
  7064. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7065. *
  7066. * */
  7067. var color = Color.parse;
  7068. var win = H.win;
  7069. var isNumber = U.isNumber,
  7070. objectEach = U.objectEach;
  7071. /* eslint-disable no-invalid-this, valid-jsdoc */
  7072. /**
  7073. * An animator object used internally. One instance applies to one property
  7074. * (attribute or style prop) on one element. Animation is always initiated
  7075. * through {@link SVGElement#animate}.
  7076. *
  7077. * @example
  7078. * let rect = renderer.rect(0, 0, 10, 10).add();
  7079. * rect.animate({ width: 100 });
  7080. *
  7081. * @private
  7082. * @class
  7083. * @name Highcharts.Fx
  7084. */
  7085. var Fx = /** @class */ (function () {
  7086. /* *
  7087. *
  7088. * Constructors
  7089. *
  7090. * */
  7091. /**
  7092. *
  7093. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} elem
  7094. * The element to animate.
  7095. *
  7096. * @param {Partial<Highcharts.AnimationOptionsObject>} options
  7097. * Animation options.
  7098. *
  7099. * @param {string} prop
  7100. * The single attribute or CSS property to animate.
  7101. */
  7102. function Fx(elem, options, prop) {
  7103. this.pos = NaN;
  7104. this.options = options;
  7105. this.elem = elem;
  7106. this.prop = prop;
  7107. }
  7108. /* *
  7109. *
  7110. * Functions
  7111. *
  7112. * */
  7113. /**
  7114. * Set the current step of a path definition on SVGElement.
  7115. *
  7116. * @function Highcharts.Fx#dSetter
  7117. *
  7118. * @return {void}
  7119. */
  7120. Fx.prototype.dSetter = function () {
  7121. var paths = this.paths,
  7122. start = paths && paths[0],
  7123. end = paths && paths[1],
  7124. now = this.now || 0;
  7125. var path = [];
  7126. // Land on the final path without adjustment points appended in the ends
  7127. if (now === 1 || !start || !end) {
  7128. path = this.toD || [];
  7129. }
  7130. else if (start.length === end.length && now < 1) {
  7131. for (var i = 0; i < end.length; i++) {
  7132. // Tween between the start segment and the end segment. Start
  7133. // with a copy of the end segment and tween the appropriate
  7134. // numerics
  7135. var startSeg = start[i];
  7136. var endSeg = end[i];
  7137. var tweenSeg = [];
  7138. for (var j = 0; j < endSeg.length; j++) {
  7139. var startItem = startSeg[j];
  7140. var endItem = endSeg[j];
  7141. // Tween numbers
  7142. if (isNumber(startItem) &&
  7143. isNumber(endItem) &&
  7144. // Arc boolean flags
  7145. !(endSeg[0] === 'A' && (j === 4 || j === 5))) {
  7146. tweenSeg[j] = startItem + now * (endItem - startItem);
  7147. // Strings, take directly from the end segment
  7148. }
  7149. else {
  7150. tweenSeg[j] = endItem;
  7151. }
  7152. }
  7153. path.push(tweenSeg);
  7154. }
  7155. // If animation is finished or length not matching, land on right value
  7156. }
  7157. else {
  7158. path = end;
  7159. }
  7160. this.elem.attr('d', path, void 0, true);
  7161. };
  7162. /**
  7163. * Update the element with the current animation step.
  7164. *
  7165. * @function Highcharts.Fx#update
  7166. *
  7167. * @return {void}
  7168. */
  7169. Fx.prototype.update = function () {
  7170. var elem = this.elem,
  7171. prop = this.prop, // if destroyed, it is null
  7172. now = this.now,
  7173. step = this.options.step;
  7174. // Animation setter defined from outside
  7175. if (this[prop + 'Setter']) {
  7176. this[prop + 'Setter']();
  7177. // Other animations on SVGElement
  7178. }
  7179. else if (elem.attr) {
  7180. if (elem.element) {
  7181. elem.attr(prop, now, null, true);
  7182. }
  7183. // HTML styles, raw HTML content like container size
  7184. }
  7185. else {
  7186. elem.style[prop] = now + this.unit;
  7187. }
  7188. if (step) {
  7189. step.call(elem, now, this);
  7190. }
  7191. };
  7192. /**
  7193. * Run an animation.
  7194. *
  7195. * @function Highcharts.Fx#run
  7196. *
  7197. * @param {number} from
  7198. * The current value, value to start from.
  7199. *
  7200. * @param {number} to
  7201. * The end value, value to land on.
  7202. *
  7203. * @param {string} unit
  7204. * The property unit, for example `px`.
  7205. *
  7206. * @return {void}
  7207. */
  7208. Fx.prototype.run = function (from, to, unit) {
  7209. var self = this,
  7210. options = self.options,
  7211. timer = function (gotoEnd) {
  7212. return timer.stopped ? false : self.step(gotoEnd);
  7213. }, requestAnimationFrame = win.requestAnimationFrame ||
  7214. function (step) {
  7215. setTimeout(step, 13);
  7216. }, step = function () {
  7217. for (var i = 0; i < Fx.timers.length; i++) {
  7218. if (!Fx.timers[i]()) {
  7219. Fx.timers.splice(i--, 1);
  7220. }
  7221. }
  7222. if (Fx.timers.length) {
  7223. requestAnimationFrame(step);
  7224. }
  7225. };
  7226. if (from === to && !this.elem['forceAnimate:' + this.prop]) {
  7227. delete options.curAnim[this.prop];
  7228. if (options.complete && Object.keys(options.curAnim).length === 0) {
  7229. options.complete.call(this.elem);
  7230. }
  7231. }
  7232. else { // #7166
  7233. this.startTime = +new Date();
  7234. this.start = from;
  7235. this.end = to;
  7236. this.unit = unit;
  7237. this.now = this.start;
  7238. this.pos = 0;
  7239. timer.elem = this.elem;
  7240. timer.prop = this.prop;
  7241. if (timer() && Fx.timers.push(timer) === 1) {
  7242. requestAnimationFrame(step);
  7243. }
  7244. }
  7245. };
  7246. /**
  7247. * Run a single step in the animation.
  7248. *
  7249. * @function Highcharts.Fx#step
  7250. *
  7251. * @param {boolean} [gotoEnd]
  7252. * Whether to go to the endpoint of the animation after abort.
  7253. *
  7254. * @return {boolean}
  7255. * Returns `true` if animation continues.
  7256. */
  7257. Fx.prototype.step = function (gotoEnd) {
  7258. var t = +new Date(),
  7259. options = this.options,
  7260. elem = this.elem,
  7261. complete = options.complete,
  7262. duration = options.duration,
  7263. curAnim = options.curAnim;
  7264. var ret,
  7265. done;
  7266. if (elem.attr && !elem.element) { // #2616, element is destroyed
  7267. ret = false;
  7268. }
  7269. else if (gotoEnd || t >= duration + this.startTime) {
  7270. this.now = this.end;
  7271. this.pos = 1;
  7272. this.update();
  7273. curAnim[this.prop] = true;
  7274. done = true;
  7275. objectEach(curAnim, function (val) {
  7276. if (val !== true) {
  7277. done = false;
  7278. }
  7279. });
  7280. if (done && complete) {
  7281. complete.call(elem);
  7282. }
  7283. ret = false;
  7284. }
  7285. else {
  7286. this.pos = options.easing((t - this.startTime) / duration);
  7287. this.now = this.start + ((this.end - this.start) * this.pos);
  7288. this.update();
  7289. ret = true;
  7290. }
  7291. return ret;
  7292. };
  7293. /**
  7294. * Prepare start and end values so that the path can be animated one to one.
  7295. *
  7296. * @function Highcharts.Fx#initPath
  7297. *
  7298. * @param {Highcharts.SVGElement} elem
  7299. * The SVGElement item.
  7300. *
  7301. * @param {Highcharts.SVGPathArray|undefined} fromD
  7302. * Starting path definition.
  7303. *
  7304. * @param {Highcharts.SVGPathArray} toD
  7305. * Ending path definition.
  7306. *
  7307. * @return {Array<Highcharts.SVGPathArray,Highcharts.SVGPathArray>}
  7308. * An array containing start and end paths in array form so that
  7309. * they can be animated in parallel.
  7310. */
  7311. Fx.prototype.initPath = function (elem, fromD, toD) {
  7312. var startX = elem.startX,
  7313. endX = elem.endX,
  7314. end = toD.slice(), // copy
  7315. isArea = elem.isArea,
  7316. positionFactor = isArea ? 2 : 1;
  7317. var shift,
  7318. fullLength,
  7319. i,
  7320. reverse,
  7321. start = fromD && fromD.slice(); // copy
  7322. if (!start) {
  7323. return [end,
  7324. end];
  7325. }
  7326. /**
  7327. * If shifting points, prepend a dummy point to the end path.
  7328. * @private
  7329. * @param {Highcharts.SVGPathArray} arr - array
  7330. * @param {Highcharts.SVGPathArray} other - array
  7331. * @return {void}
  7332. */
  7333. function prepend(arr, other) {
  7334. while (arr.length < fullLength) {
  7335. // Move to, line to or curve to?
  7336. var moveSegment = arr[0],
  7337. otherSegment = other[fullLength - arr.length];
  7338. if (otherSegment && moveSegment[0] === 'M') {
  7339. if (otherSegment[0] === 'C') {
  7340. arr[0] = [
  7341. 'C',
  7342. moveSegment[1],
  7343. moveSegment[2],
  7344. moveSegment[1],
  7345. moveSegment[2],
  7346. moveSegment[1],
  7347. moveSegment[2]
  7348. ];
  7349. }
  7350. else {
  7351. arr[0] = ['L', moveSegment[1], moveSegment[2]];
  7352. }
  7353. }
  7354. // Prepend a copy of the first point
  7355. arr.unshift(moveSegment);
  7356. // For areas, the bottom path goes back again to the left, so we
  7357. // need to append a copy of the last point.
  7358. if (isArea) {
  7359. var z = arr.pop();
  7360. arr.push(arr[arr.length - 1], z); // append point and the Z
  7361. }
  7362. }
  7363. }
  7364. /**
  7365. * Copy and append last point until the length matches the end length.
  7366. * @private
  7367. * @param {Highcharts.SVGPathArray} arr - array
  7368. * @param {Highcharts.SVGPathArray} other - array
  7369. * @return {void}
  7370. */
  7371. function append(arr, other) {
  7372. while (arr.length < fullLength) {
  7373. // Pull out the slice that is going to be appended or inserted.
  7374. // In a line graph, the positionFactor is 1, and the last point
  7375. // is sliced out. In an area graph, the positionFactor is 2,
  7376. // causing the middle two points to be sliced out, since an area
  7377. // path starts at left, follows the upper path then turns and
  7378. // follows the bottom back.
  7379. var segmentToAdd = arr[Math.floor(arr.length / positionFactor) - 1].slice();
  7380. // Disable the first control point of curve segments
  7381. if (segmentToAdd[0] === 'C') {
  7382. segmentToAdd[1] = segmentToAdd[5];
  7383. segmentToAdd[2] = segmentToAdd[6];
  7384. }
  7385. if (!isArea) {
  7386. arr.push(segmentToAdd);
  7387. }
  7388. else {
  7389. var lowerSegmentToAdd = arr[Math.floor(arr.length / positionFactor)].slice();
  7390. arr.splice(arr.length / 2, 0, segmentToAdd, lowerSegmentToAdd);
  7391. }
  7392. }
  7393. }
  7394. // For sideways animation, find out how much we need to shift to get the
  7395. // start path Xs to match the end path Xs.
  7396. if (startX && endX && endX.length) {
  7397. for (i = 0; i < startX.length; i++) {
  7398. // Moving left, new points coming in on right
  7399. if (startX[i] === endX[0]) {
  7400. shift = i;
  7401. break;
  7402. // Moving right
  7403. }
  7404. else if (startX[0] ===
  7405. endX[endX.length - startX.length + i]) {
  7406. shift = i;
  7407. reverse = true;
  7408. break;
  7409. // Fixed from the right side, "scaling" left
  7410. }
  7411. else if (startX[startX.length - 1] ===
  7412. endX[endX.length - startX.length + i]) {
  7413. shift = startX.length - i;
  7414. break;
  7415. }
  7416. }
  7417. if (typeof shift === 'undefined') {
  7418. start = [];
  7419. }
  7420. }
  7421. if (start.length && isNumber(shift)) {
  7422. // The common target length for the start and end array, where both
  7423. // arrays are padded in opposite ends
  7424. fullLength = end.length + shift * positionFactor;
  7425. if (!reverse) {
  7426. prepend(end, start);
  7427. append(start, end);
  7428. }
  7429. else {
  7430. prepend(start, end);
  7431. append(end, start);
  7432. }
  7433. }
  7434. return [start, end];
  7435. };
  7436. /**
  7437. * Handle animation of the color attributes directly.
  7438. *
  7439. * @function Highcharts.Fx#fillSetter
  7440. *
  7441. * @return {void}
  7442. */
  7443. Fx.prototype.fillSetter = function () {
  7444. Fx.prototype.strokeSetter.apply(this, arguments);
  7445. };
  7446. /**
  7447. * Handle animation of the color attributes directly.
  7448. *
  7449. * @function Highcharts.Fx#strokeSetter
  7450. *
  7451. * @return {void}
  7452. */
  7453. Fx.prototype.strokeSetter = function () {
  7454. this.elem.attr(this.prop, color(this.start).tweenTo(color(this.end), this.pos), null, true);
  7455. };
  7456. /* *
  7457. *
  7458. * Static properties
  7459. *
  7460. * */
  7461. Fx.timers = [];
  7462. return Fx;
  7463. }());
  7464. /* *
  7465. *
  7466. * Default Export
  7467. *
  7468. * */
  7469. return Fx;
  7470. });
  7471. _registerModule(_modules, 'Core/Animation/AnimationUtilities.js', [_modules['Core/Animation/Fx.js'], _modules['Core/Utilities.js']], function (Fx, U) {
  7472. /* *
  7473. *
  7474. * (c) 2010-2021 Torstein Honsi
  7475. *
  7476. * License: www.highcharts.com/license
  7477. *
  7478. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7479. *
  7480. * */
  7481. var defined = U.defined,
  7482. getStyle = U.getStyle,
  7483. isArray = U.isArray,
  7484. isNumber = U.isNumber,
  7485. isObject = U.isObject,
  7486. merge = U.merge,
  7487. objectEach = U.objectEach,
  7488. pick = U.pick;
  7489. /**
  7490. * Set the global animation to either a given value, or fall back to the given
  7491. * chart's animation option.
  7492. *
  7493. * @function Highcharts.setAnimation
  7494. *
  7495. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>|undefined} animation
  7496. * The animation object.
  7497. *
  7498. * @param {Highcharts.Chart} chart
  7499. * The chart instance.
  7500. *
  7501. * @todo
  7502. * This function always relates to a chart, and sets a property on the renderer,
  7503. * so it should be moved to the SVGRenderer.
  7504. */
  7505. function setAnimation(animation, chart) {
  7506. chart.renderer.globalAnimation = pick(animation, chart.options.chart.animation, true);
  7507. }
  7508. /**
  7509. * Get the animation in object form, where a disabled animation is always
  7510. * returned as `{ duration: 0 }`.
  7511. *
  7512. * @function Highcharts.animObject
  7513. *
  7514. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=0]
  7515. * An animation setting. Can be an object with duration, complete and
  7516. * easing properties, or a boolean to enable or disable.
  7517. *
  7518. * @return {Highcharts.AnimationOptionsObject}
  7519. * An object with at least a duration property.
  7520. */
  7521. function animObject(animation) {
  7522. return isObject(animation) ?
  7523. merge({ duration: 500, defer: 0 }, animation) :
  7524. { duration: animation ? 500 : 0, defer: 0 };
  7525. }
  7526. /**
  7527. * Get the defer as a number value from series animation options.
  7528. *
  7529. * @function Highcharts.getDeferredAnimation
  7530. *
  7531. * @param {Highcharts.Chart} chart
  7532. * The chart instance.
  7533. *
  7534. * @param {boolean|Highcharts.AnimationOptionsObject} animation
  7535. * An animation setting. Can be an object with duration, complete and
  7536. * easing properties, or a boolean to enable or disable.
  7537. *
  7538. * @param {Highcharts.Series} [series]
  7539. * Series to defer animation.
  7540. *
  7541. * @return {number}
  7542. * The numeric value.
  7543. */
  7544. function getDeferredAnimation(chart, animation, series) {
  7545. var labelAnimation = animObject(animation);
  7546. var s = series ? [series] : chart.series;
  7547. var defer = 0;
  7548. var duration = 0;
  7549. s.forEach(function (series) {
  7550. var seriesAnim = animObject(series.options.animation);
  7551. defer = animation && defined(animation.defer) ?
  7552. labelAnimation.defer :
  7553. Math.max(defer, seriesAnim.duration + seriesAnim.defer);
  7554. duration = Math.min(labelAnimation.duration, seriesAnim.duration);
  7555. });
  7556. // Disable defer for exporting
  7557. if (chart.renderer.forExport) {
  7558. defer = 0;
  7559. }
  7560. var anim = {
  7561. defer: Math.max(0,
  7562. defer - duration),
  7563. duration: Math.min(defer,
  7564. duration)
  7565. };
  7566. return anim;
  7567. }
  7568. /**
  7569. * The global animate method, which uses Fx to create individual animators.
  7570. *
  7571. * @function Highcharts.animate
  7572. *
  7573. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} el
  7574. * The element to animate.
  7575. *
  7576. * @param {Highcharts.CSSObject|Highcharts.SVGAttributes} params
  7577. * An object containing key-value pairs of the properties to animate.
  7578. * Supports numeric as pixel-based CSS properties for HTML objects and
  7579. * attributes for SVGElements.
  7580. *
  7581. * @param {Partial<Highcharts.AnimationOptionsObject>} [opt]
  7582. * Animation options.
  7583. *
  7584. * @return {void}
  7585. */
  7586. function animate(el, params, opt) {
  7587. var start,
  7588. unit = '',
  7589. end,
  7590. fx,
  7591. args;
  7592. if (!isObject(opt)) { // Number or undefined/null
  7593. args = arguments;
  7594. opt = {
  7595. duration: args[2],
  7596. easing: args[3],
  7597. complete: args[4]
  7598. };
  7599. }
  7600. if (!isNumber(opt.duration)) {
  7601. opt.duration = 400;
  7602. }
  7603. opt.easing = typeof opt.easing === 'function' ?
  7604. opt.easing :
  7605. (Math[opt.easing] || Math.easeInOutSine);
  7606. opt.curAnim = merge(params);
  7607. objectEach(params, function (val, prop) {
  7608. // Stop current running animation of this property
  7609. stop(el, prop);
  7610. fx = new Fx(el, opt, prop);
  7611. end = void 0;
  7612. if (prop === 'd' && isArray(params.d)) {
  7613. fx.paths = fx.initPath(el, el.pathArray, params.d);
  7614. fx.toD = params.d;
  7615. start = 0;
  7616. end = 1;
  7617. }
  7618. else if (el.attr) {
  7619. start = el.attr(prop);
  7620. }
  7621. else {
  7622. start = parseFloat(getStyle(el, prop)) || 0;
  7623. if (prop !== 'opacity') {
  7624. unit = 'px';
  7625. }
  7626. }
  7627. if (!end) {
  7628. end = val;
  7629. }
  7630. if (typeof end === 'string' && end.match('px')) {
  7631. end = end.replace(/px/g, ''); // #4351
  7632. }
  7633. fx.run(start, end, unit);
  7634. });
  7635. }
  7636. /**
  7637. * Stop running animation.
  7638. *
  7639. * @function Highcharts.stop
  7640. *
  7641. * @param {Highcharts.SVGElement} el
  7642. * The SVGElement to stop animation on.
  7643. *
  7644. * @param {string} [prop]
  7645. * The property to stop animating. If given, the stop method will stop a
  7646. * single property from animating, while others continue.
  7647. *
  7648. * @return {void}
  7649. *
  7650. * @todo
  7651. * A possible extension to this would be to stop a single property, when
  7652. * we want to continue animating others. Then assign the prop to the timer
  7653. * in the Fx.run method, and check for the prop here. This would be an
  7654. * improvement in all cases where we stop the animation from .attr. Instead of
  7655. * stopping everything, we can just stop the actual attributes we're setting.
  7656. */
  7657. function stop(el, prop) {
  7658. var i = Fx.timers.length;
  7659. // Remove timers related to this element (#4519)
  7660. while (i--) {
  7661. if (Fx.timers[i].elem === el && (!prop || prop === Fx.timers[i].prop)) {
  7662. Fx.timers[i].stopped = true; // #4667
  7663. }
  7664. }
  7665. }
  7666. var animationExports = {
  7667. animate: animate,
  7668. animObject: animObject,
  7669. getDeferredAnimation: getDeferredAnimation,
  7670. setAnimation: setAnimation,
  7671. stop: stop
  7672. };
  7673. return animationExports;
  7674. });
  7675. _registerModule(_modules, 'Core/Renderer/HTML/AST.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  7676. /* *
  7677. *
  7678. * (c) 2010-2020 Torstein Honsi
  7679. *
  7680. * License: www.highcharts.com/license
  7681. *
  7682. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7683. *
  7684. * */
  7685. var SVG_NS = H.SVG_NS;
  7686. var attr = U.attr,
  7687. createElement = U.createElement,
  7688. discardElement = U.discardElement,
  7689. error = U.error,
  7690. isString = U.isString,
  7691. objectEach = U.objectEach,
  7692. splat = U.splat;
  7693. /**
  7694. * Serialized form of an SVG/HTML definition, including children.
  7695. *
  7696. * @interface Highcharts.ASTNode
  7697. */ /**
  7698. * @name Highcharts.ASTNode#attributes
  7699. * @type {Highcharts.SVGAttributes|undefined}
  7700. */ /**
  7701. * @name Highcharts.ASTNode#children
  7702. * @type {Array<Highcharts.ASTNode>|undefined}
  7703. */ /**
  7704. * @name Highcharts.ASTNode#tagName
  7705. * @type {string|undefined}
  7706. */ /**
  7707. * @name Highcharts.ASTNode#textContent
  7708. * @type {string|undefined}
  7709. */
  7710. ''; // detach doclets above
  7711. // In IE8, DOMParser is undefined. IE9 and PhantomJS are only able to parse XML.
  7712. var hasValidDOMParser = false;
  7713. try {
  7714. hasValidDOMParser = Boolean(new DOMParser().parseFromString('', 'text/html'));
  7715. }
  7716. catch (e) { } // eslint-disable-line no-empty
  7717. /**
  7718. * The AST class represents an abstract syntax tree of HTML or SVG content. It
  7719. * can take HTML as an argument, parse it, optionally transform it to SVG, then
  7720. * perform sanitation before inserting it into the DOM.
  7721. *
  7722. * @class
  7723. * @name Highcharts.AST
  7724. * @param {string|Highcharts.ASTNode[]} source
  7725. * Either an HTML string or an ASTNode list
  7726. * to populate the tree
  7727. */
  7728. var AST = /** @class */ (function () {
  7729. // Construct an AST from HTML markup, or wrap an array of existing AST nodes
  7730. function AST(source) {
  7731. this.nodes = typeof source === 'string' ?
  7732. this.parseMarkup(source) : source;
  7733. }
  7734. /**
  7735. * Filter an object of SVG or HTML attributes against the allow list.
  7736. *
  7737. * @static
  7738. *
  7739. * @function Highcharts.AST#filterUserAttributes
  7740. *
  7741. * @param {Highcharts.SVGAttributes} attributes The attributes to filter
  7742. *
  7743. * @return {Highcharts.SVGAttributes}
  7744. * The filtered attributes
  7745. */
  7746. AST.filterUserAttributes = function (attributes) {
  7747. objectEach(attributes, function (val, key) {
  7748. var valid = true;
  7749. if (AST.allowedAttributes.indexOf(key) === -1) {
  7750. valid = false;
  7751. }
  7752. if (['background', 'dynsrc', 'href', 'lowsrc', 'src']
  7753. .indexOf(key) !== -1) {
  7754. valid = isString(val) && AST.allowedReferences.some(function (ref) { return val.indexOf(ref) === 0; });
  7755. }
  7756. if (!valid) {
  7757. error("Highcharts warning: Invalid attribute '" + key + "' in config");
  7758. delete attributes[key];
  7759. }
  7760. });
  7761. return attributes;
  7762. };
  7763. /**
  7764. * Utility function to set html content for an element by passing in a
  7765. * markup string. The markup is safely parsed by the AST class to avoid
  7766. * XSS vulnerabilities. This function should be used instead of setting
  7767. * `innerHTML` in all cases where the content is not fully trusted.
  7768. *
  7769. * @static
  7770. *
  7771. * @function Highcharts.AST#setElementHTML
  7772. *
  7773. * @param {SVGDOMElement|HTMLDOMElement} el The node to set content of
  7774. * @param {string} html The markup string
  7775. */
  7776. AST.setElementHTML = function (el, html) {
  7777. el.innerHTML = ''; // Clear previous
  7778. if (html) {
  7779. var ast = new AST(html);
  7780. ast.addToDOM(el);
  7781. }
  7782. };
  7783. /**
  7784. * Add the tree defined as a hierarchical JS structure to the DOM
  7785. *
  7786. * @function Highcharts.AST#addToDOM
  7787. *
  7788. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} parent
  7789. * The node where it should be added
  7790. *
  7791. * @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement}
  7792. * The inserted node.
  7793. */
  7794. AST.prototype.addToDOM = function (parent) {
  7795. /**
  7796. * @private
  7797. * @param {Highcharts.ASTNode} subtree - HTML/SVG definition
  7798. * @param {Element} [subParent] - parent node
  7799. * @return {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} The inserted node.
  7800. */
  7801. function recurse(subtree, subParent) {
  7802. var ret;
  7803. splat(subtree).forEach(function (item) {
  7804. var tagName = item.tagName;
  7805. var textNode = item.textContent ?
  7806. H.doc.createTextNode(item.textContent) :
  7807. void 0;
  7808. var node;
  7809. if (tagName) {
  7810. if (tagName === '#text') {
  7811. node = textNode;
  7812. }
  7813. else if (AST.allowedTags.indexOf(tagName) !== -1) {
  7814. var NS = tagName === 'svg' ?
  7815. SVG_NS :
  7816. (subParent.namespaceURI || SVG_NS);
  7817. var element = H.doc.createElementNS(NS,
  7818. tagName);
  7819. var attributes_1 = item.attributes || {};
  7820. // Apply attributes from root of AST node, legacy from
  7821. // from before TextBuilder
  7822. objectEach(item, function (val, key) {
  7823. if (key !== 'tagName' &&
  7824. key !== 'attributes' &&
  7825. key !== 'children' &&
  7826. key !== 'textContent') {
  7827. attributes_1[key] = val;
  7828. }
  7829. });
  7830. attr(element, AST.filterUserAttributes(attributes_1));
  7831. // Add text content
  7832. if (textNode) {
  7833. element.appendChild(textNode);
  7834. }
  7835. // Recurse
  7836. recurse(item.children || [], element);
  7837. node = element;
  7838. }
  7839. else {
  7840. error("Highcharts warning: Invalid tagName '" + tagName + "' in config");
  7841. }
  7842. }
  7843. // Add to the tree
  7844. if (node) {
  7845. subParent.appendChild(node);
  7846. }
  7847. ret = node;
  7848. });
  7849. // Return last node added (on top level it's the only one)
  7850. return ret;
  7851. }
  7852. return recurse(this.nodes, parent);
  7853. };
  7854. /**
  7855. * Parse HTML/SVG markup into AST Node objects. Used internally from the
  7856. * constructor.
  7857. *
  7858. * @private
  7859. *
  7860. * @function Highcharts.AST#getNodesFromMarkup
  7861. *
  7862. * @param {string} markup The markup string.
  7863. *
  7864. * @return {Array<Highcharts.ASTNode>} The parsed nodes.
  7865. */
  7866. AST.prototype.parseMarkup = function (markup) {
  7867. var nodes = [];
  7868. var doc;
  7869. var body;
  7870. if (hasValidDOMParser) {
  7871. doc = new DOMParser().parseFromString(markup, 'text/html');
  7872. }
  7873. else {
  7874. body = createElement('div');
  7875. body.innerHTML = markup;
  7876. doc = { body: body };
  7877. }
  7878. var appendChildNodes = function (node,
  7879. addTo) {
  7880. var tagName = node.nodeName.toLowerCase();
  7881. // Add allowed tags
  7882. var astNode = {
  7883. tagName: tagName
  7884. };
  7885. if (tagName === '#text') {
  7886. var textContent = node.textContent || '';
  7887. // Whitespace text node, don't append it to the AST
  7888. if (/^[\s]*$/.test(textContent)) {
  7889. return;
  7890. }
  7891. astNode.textContent = textContent;
  7892. }
  7893. var parsedAttributes = node.attributes;
  7894. // Add attributes
  7895. if (parsedAttributes) {
  7896. var attributes_2 = {};
  7897. [].forEach.call(parsedAttributes, function (attrib) {
  7898. attributes_2[attrib.name] = attrib.value;
  7899. });
  7900. astNode.attributes = attributes_2;
  7901. }
  7902. // Handle children
  7903. if (node.childNodes.length) {
  7904. var children_1 = [];
  7905. [].forEach.call(node.childNodes, function (childNode) {
  7906. appendChildNodes(childNode, children_1);
  7907. });
  7908. if (children_1.length) {
  7909. astNode.children = children_1;
  7910. }
  7911. }
  7912. addTo.push(astNode);
  7913. };
  7914. [].forEach.call(doc.body.childNodes, function (childNode) { return appendChildNodes(childNode, nodes); });
  7915. if (body) {
  7916. discardElement(body);
  7917. }
  7918. return nodes;
  7919. };
  7920. /**
  7921. * The list of allowed SVG or HTML tags, used for sanitizing potentially
  7922. * harmful content from the chart configuration before adding to the DOM.
  7923. *
  7924. * @example
  7925. * // Allow a custom, trusted tag
  7926. * Highcharts.AST.allowedTags.push('blink'); // ;)
  7927. *
  7928. * @name Highcharts.AST.allowedTags
  7929. * @static
  7930. */
  7931. AST.allowedTags = [
  7932. 'a',
  7933. 'b',
  7934. 'br',
  7935. 'button',
  7936. 'caption',
  7937. 'circle',
  7938. 'clipPath',
  7939. 'code',
  7940. 'dd',
  7941. 'defs',
  7942. 'div',
  7943. 'dl',
  7944. 'dt',
  7945. 'em',
  7946. 'feComponentTransfer',
  7947. 'feFuncA',
  7948. 'feFuncB',
  7949. 'feFuncG',
  7950. 'feFuncR',
  7951. 'feGaussianBlur',
  7952. 'feOffset',
  7953. 'feMerge',
  7954. 'feMergeNode',
  7955. 'filter',
  7956. 'h1',
  7957. 'h2',
  7958. 'h3',
  7959. 'h4',
  7960. 'h5',
  7961. 'h6',
  7962. 'hr',
  7963. 'i',
  7964. 'img',
  7965. 'li',
  7966. 'linearGradient',
  7967. 'marker',
  7968. 'ol',
  7969. 'p',
  7970. 'path',
  7971. 'pattern',
  7972. 'pre',
  7973. 'rect',
  7974. 'small',
  7975. 'span',
  7976. 'stop',
  7977. 'strong',
  7978. 'style',
  7979. 'sub',
  7980. 'sup',
  7981. 'svg',
  7982. 'table',
  7983. 'text',
  7984. 'thead',
  7985. 'tbody',
  7986. 'tspan',
  7987. 'td',
  7988. 'th',
  7989. 'tr',
  7990. 'u',
  7991. 'ul',
  7992. '#text'
  7993. ];
  7994. /**
  7995. * The list of allowed SVG or HTML attributes, used for sanitizing
  7996. * potentially harmful content from the chart configuration before adding to
  7997. * the DOM.
  7998. *
  7999. * @example
  8000. * // Allow a custom, trusted attribute
  8001. * Highcharts.AST.allowedAttributes.push('data-value');
  8002. *
  8003. * @name Highcharts.AST.allowedAttributes
  8004. * @static
  8005. */
  8006. AST.allowedAttributes = [
  8007. 'aria-controls',
  8008. 'aria-describedby',
  8009. 'aria-expanded',
  8010. 'aria-haspopup',
  8011. 'aria-hidden',
  8012. 'aria-label',
  8013. 'aria-labelledby',
  8014. 'aria-live',
  8015. 'aria-pressed',
  8016. 'aria-readonly',
  8017. 'aria-roledescription',
  8018. 'aria-selected',
  8019. 'class',
  8020. 'clip-path',
  8021. 'color',
  8022. 'colspan',
  8023. 'cx',
  8024. 'cy',
  8025. 'd',
  8026. 'dx',
  8027. 'dy',
  8028. 'disabled',
  8029. 'fill',
  8030. 'height',
  8031. 'href',
  8032. 'id',
  8033. 'in',
  8034. 'markerHeight',
  8035. 'markerWidth',
  8036. 'offset',
  8037. 'opacity',
  8038. 'orient',
  8039. 'padding',
  8040. 'paddingLeft',
  8041. 'patternUnits',
  8042. 'r',
  8043. 'refX',
  8044. 'refY',
  8045. 'role',
  8046. 'scope',
  8047. 'slope',
  8048. 'src',
  8049. 'startOffset',
  8050. 'stdDeviation',
  8051. 'stroke',
  8052. 'stroke-linecap',
  8053. 'stroke-width',
  8054. 'style',
  8055. 'result',
  8056. 'rowspan',
  8057. 'summary',
  8058. 'target',
  8059. 'tabindex',
  8060. 'text-align',
  8061. 'textAnchor',
  8062. 'textLength',
  8063. 'type',
  8064. 'valign',
  8065. 'width',
  8066. 'x',
  8067. 'x1',
  8068. 'x2',
  8069. 'y',
  8070. 'y1',
  8071. 'y2',
  8072. 'zIndex'
  8073. ];
  8074. /**
  8075. * The list of allowed references for referring attributes like `href` and
  8076. * `src`. Attribute values will only be allowed if they start with one of
  8077. * these strings.
  8078. *
  8079. * @example
  8080. * // Allow tel:
  8081. * Highcharts.AST.allowedReferences.push('tel:');
  8082. *
  8083. * @name Highcharts.AST.allowedReferences
  8084. * @static
  8085. */
  8086. AST.allowedReferences = [
  8087. 'https://',
  8088. 'http://',
  8089. 'mailto:',
  8090. '/',
  8091. '../',
  8092. './',
  8093. '#'
  8094. ];
  8095. return AST;
  8096. }());
  8097. return AST;
  8098. });
  8099. _registerModule(_modules, 'Core/FormatUtilities.js', [_modules['Core/Options.js'], _modules['Core/Utilities.js']], function (O, U) {
  8100. /* *
  8101. *
  8102. * (c) 2010-2021 Torstein Honsi
  8103. *
  8104. * License: www.highcharts.com/license
  8105. *
  8106. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8107. *
  8108. * */
  8109. var defaultOptions = O.defaultOptions,
  8110. defaultTime = O.defaultTime;
  8111. var getNestedProperty = U.getNestedProperty,
  8112. isNumber = U.isNumber,
  8113. pick = U.pick,
  8114. pInt = U.pInt;
  8115. /* *
  8116. *
  8117. * Functions
  8118. *
  8119. * */
  8120. /**
  8121. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970) into a
  8122. * human readable date string. The format is a subset of the formats for PHP's
  8123. * [strftime](https://www.php.net/manual/en/function.strftime.php) function.
  8124. * Additional formats can be given in the {@link Highcharts.dateFormats} hook.
  8125. *
  8126. * Since v6.0.5, all internal dates are formatted through the
  8127. * {@link Highcharts.Chart#time} instance to respect chart-level time settings.
  8128. * The `Highcharts.dateFormat` function only reflects global time settings set
  8129. * with `setOptions`.
  8130. *
  8131. * Supported format keys:
  8132. * - `%a`: Short weekday, like 'Mon'
  8133. * - `%A`: Long weekday, like 'Monday'
  8134. * - `%d`: Two digit day of the month, 01 to 31
  8135. * - `%e`: Day of the month, 1 through 31
  8136. * - `%w`: Day of the week, 0 through 6
  8137. * - `%b`: Short month, like 'Jan'
  8138. * - `%B`: Long month, like 'January'
  8139. * - `%m`: Two digit month number, 01 through 12
  8140. * - `%y`: Two digits year, like 09 for 2009
  8141. * - `%Y`: Four digits year, like 2009
  8142. * - `%H`: Two digits hours in 24h format, 00 through 23
  8143. * - `%k`: Hours in 24h format, 0 through 23
  8144. * - `%I`: Two digits hours in 12h format, 00 through 11
  8145. * - `%l`: Hours in 12h format, 1 through 12
  8146. * - `%M`: Two digits minutes, 00 through 59
  8147. * - `%p`: Upper case AM or PM
  8148. * - `%P`: Lower case AM or PM
  8149. * - `%S`: Two digits seconds, 00 through 59
  8150. * - `%L`: Milliseconds (naming from Ruby)
  8151. *
  8152. * @function Highcharts.dateFormat
  8153. *
  8154. * @param {string} format
  8155. * The desired format where various time representations are prefixed
  8156. * with `%`.
  8157. *
  8158. * @param {number} timestamp
  8159. * The JavaScript timestamp.
  8160. *
  8161. * @param {boolean} [capitalize=false]
  8162. * Upper case first letter in the return.
  8163. *
  8164. * @return {string}
  8165. * The formatted date.
  8166. */
  8167. function dateFormat(format, timestamp, capitalize) {
  8168. return defaultTime.dateFormat(format, timestamp, capitalize);
  8169. }
  8170. /**
  8171. * Format a string according to a subset of the rules of Python's String.format
  8172. * method.
  8173. *
  8174. * @example
  8175. * let s = Highcharts.format(
  8176. * 'The {color} fox was {len:.2f} feet long',
  8177. * { color: 'red', len: Math.PI }
  8178. * );
  8179. * // => The red fox was 3.14 feet long
  8180. *
  8181. * @function Highcharts.format
  8182. *
  8183. * @param {string} str
  8184. * The string to format.
  8185. *
  8186. * @param {Record<string, *>} ctx
  8187. * The context, a collection of key-value pairs where each key is
  8188. * replaced by its value.
  8189. *
  8190. * @param {Highcharts.Chart} [chart]
  8191. * A `Chart` instance used to get numberFormatter and time.
  8192. *
  8193. * @return {string}
  8194. * The formatted string.
  8195. */
  8196. function format(str, ctx, chart) {
  8197. var splitter = '{',
  8198. isInside = false,
  8199. segment,
  8200. valueAndFormat,
  8201. val,
  8202. index;
  8203. var floatRegex = /f$/;
  8204. var decRegex = /\.([0-9])/;
  8205. var lang = defaultOptions.lang;
  8206. var time = chart && chart.time || defaultTime;
  8207. var numberFormatter = chart && chart.numberFormatter || numberFormat;
  8208. var ret = [];
  8209. while (str) {
  8210. index = str.indexOf(splitter);
  8211. if (index === -1) {
  8212. break;
  8213. }
  8214. segment = str.slice(0, index);
  8215. if (isInside) { // we're on the closing bracket looking back
  8216. valueAndFormat = segment.split(':');
  8217. val = getNestedProperty(valueAndFormat.shift() || '', ctx);
  8218. // Format the replacement
  8219. if (valueAndFormat.length && typeof val === 'number') {
  8220. segment = valueAndFormat.join(':');
  8221. if (floatRegex.test(segment)) { // float
  8222. var decimals = parseInt((segment.match(decRegex) || ['', '-1'])[1], 10);
  8223. if (val !== null) {
  8224. val = numberFormatter(val, decimals, lang.decimalPoint, segment.indexOf(',') > -1 ? lang.thousandsSep : '');
  8225. }
  8226. }
  8227. else {
  8228. val = time.dateFormat(segment, val);
  8229. }
  8230. }
  8231. // Push the result and advance the cursor
  8232. ret.push(val);
  8233. }
  8234. else {
  8235. ret.push(segment);
  8236. }
  8237. str = str.slice(index + 1); // the rest
  8238. isInside = !isInside; // toggle
  8239. splitter = isInside ? '}' : '{'; // now look for next matching bracket
  8240. }
  8241. ret.push(str);
  8242. return ret.join('');
  8243. }
  8244. /**
  8245. * Format a number and return a string based on input settings.
  8246. *
  8247. * @sample highcharts/members/highcharts-numberformat/
  8248. * Custom number format
  8249. *
  8250. * @function Highcharts.numberFormat
  8251. *
  8252. * @param {number} number
  8253. * The input number to format.
  8254. *
  8255. * @param {number} decimals
  8256. * The amount of decimals. A value of -1 preserves the amount in the
  8257. * input number.
  8258. *
  8259. * @param {string} [decimalPoint]
  8260. * The decimal point, defaults to the one given in the lang options, or
  8261. * a dot.
  8262. *
  8263. * @param {string} [thousandsSep]
  8264. * The thousands separator, defaults to the one given in the lang
  8265. * options, or a space character.
  8266. *
  8267. * @return {string}
  8268. * The formatted number.
  8269. */
  8270. function numberFormat(number, decimals, decimalPoint, thousandsSep) {
  8271. number = +number || 0;
  8272. decimals = +decimals;
  8273. var ret,
  8274. fractionDigits;
  8275. var lang = defaultOptions.lang, origDec = (number.toString().split('.')[1] || '').split('e')[0].length, exponent = number.toString().split('e'), firstDecimals = decimals;
  8276. if (decimals === -1) {
  8277. // Preserve decimals. Not huge numbers (#3793).
  8278. decimals = Math.min(origDec, 20);
  8279. }
  8280. else if (!isNumber(decimals)) {
  8281. decimals = 2;
  8282. }
  8283. else if (decimals && exponent[1] && exponent[1] < 0) {
  8284. // Expose decimals from exponential notation (#7042)
  8285. fractionDigits = decimals + +exponent[1];
  8286. if (fractionDigits >= 0) {
  8287. // remove too small part of the number while keeping the notation
  8288. exponent[0] = (+exponent[0]).toExponential(fractionDigits)
  8289. .split('e')[0];
  8290. decimals = fractionDigits;
  8291. }
  8292. else {
  8293. // fractionDigits < 0
  8294. exponent[0] = exponent[0].split('.')[0] || 0;
  8295. if (decimals < 20) {
  8296. // use number instead of exponential notation (#7405)
  8297. number = (exponent[0] * Math.pow(10, exponent[1]))
  8298. .toFixed(decimals);
  8299. }
  8300. else {
  8301. // or zero
  8302. number = 0;
  8303. }
  8304. exponent[1] = 0;
  8305. }
  8306. }
  8307. // Add another decimal to avoid rounding errors of float numbers. (#4573)
  8308. // Then use toFixed to handle rounding.
  8309. var roundedNumber = (Math.abs(exponent[1] ? exponent[0] : number) +
  8310. Math.pow(10, -Math.max(decimals,
  8311. origDec) - 1)).toFixed(decimals);
  8312. // A string containing the positive integer component of the number
  8313. var strinteger = String(pInt(roundedNumber));
  8314. // Leftover after grouping into thousands. Can be 0, 1 or 2.
  8315. var thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
  8316. // Language
  8317. decimalPoint = pick(decimalPoint, lang.decimalPoint);
  8318. thousandsSep = pick(thousandsSep, lang.thousandsSep);
  8319. // Start building the return
  8320. ret = number < 0 ? '-' : '';
  8321. // Add the leftover after grouping into thousands. For example, in the
  8322. // number 42 000 000, this line adds 42.
  8323. ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
  8324. if (+exponent[1] < 0 && !firstDecimals) {
  8325. ret = '0';
  8326. }
  8327. else {
  8328. // Add the remaining thousands groups, joined by the thousands separator
  8329. ret += strinteger
  8330. .substr(thousands)
  8331. .replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
  8332. }
  8333. // Add the decimal point and the decimal component
  8334. if (decimals) {
  8335. // Get the decimal component
  8336. ret += decimalPoint + roundedNumber.slice(-decimals);
  8337. }
  8338. if (exponent[1] && +ret !== 0) {
  8339. ret += 'e' + exponent[1];
  8340. }
  8341. return ret;
  8342. }
  8343. /* *
  8344. *
  8345. * Default Export
  8346. *
  8347. * */
  8348. var exports = {
  8349. dateFormat: dateFormat,
  8350. format: format,
  8351. numberFormat: numberFormat
  8352. };
  8353. return exports;
  8354. });
  8355. _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) {
  8356. /* *
  8357. *
  8358. * (c) 2010-2021 Torstein Honsi
  8359. *
  8360. * License: www.highcharts.com/license
  8361. *
  8362. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8363. *
  8364. * */
  8365. var animate = A.animate,
  8366. animObject = A.animObject,
  8367. stop = A.stop;
  8368. var deg2rad = H.deg2rad,
  8369. doc = H.doc,
  8370. hasTouch = H.hasTouch,
  8371. noop = H.noop,
  8372. svg = H.svg,
  8373. SVG_NS = H.SVG_NS,
  8374. win = H.win;
  8375. var addEvent = U.addEvent,
  8376. attr = U.attr,
  8377. createElement = U.createElement,
  8378. css = U.css,
  8379. defined = U.defined,
  8380. erase = U.erase,
  8381. extend = U.extend,
  8382. fireEvent = U.fireEvent,
  8383. isArray = U.isArray,
  8384. isFunction = U.isFunction,
  8385. isNumber = U.isNumber,
  8386. isString = U.isString,
  8387. merge = U.merge,
  8388. objectEach = U.objectEach,
  8389. pick = U.pick,
  8390. pInt = U.pInt,
  8391. syncTimeout = U.syncTimeout,
  8392. uniqueKey = U.uniqueKey;
  8393. /* *
  8394. *
  8395. * Class
  8396. *
  8397. * */
  8398. /* eslint-disable no-invalid-this, valid-jsdoc */
  8399. /**
  8400. * The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
  8401. * rendering layer of Highcharts. Combined with the
  8402. * {@link Highcharts.SVGRenderer}
  8403. * object, these prototypes allow freeform annotation in the charts or even in
  8404. * HTML pages without instanciating a chart. The SVGElement can also wrap HTML
  8405. * labels, when `text` or `label` elements are created with the `useHTML`
  8406. * parameter.
  8407. *
  8408. * The SVGElement instances are created through factory functions on the
  8409. * {@link Highcharts.SVGRenderer}
  8410. * object, like
  8411. * {@link Highcharts.SVGRenderer#rect|rect},
  8412. * {@link Highcharts.SVGRenderer#path|path},
  8413. * {@link Highcharts.SVGRenderer#text|text},
  8414. * {@link Highcharts.SVGRenderer#label|label},
  8415. * {@link Highcharts.SVGRenderer#g|g}
  8416. * and more.
  8417. *
  8418. * @class
  8419. * @name Highcharts.SVGElement
  8420. */
  8421. var SVGElement = /** @class */ (function () {
  8422. function SVGElement() {
  8423. /* *
  8424. *
  8425. * Properties
  8426. *
  8427. * */
  8428. this.element = void 0;
  8429. this.onEvents = {};
  8430. this.opacity = 1; // Default base for animation
  8431. this.renderer = void 0;
  8432. this.SVG_NS = SVG_NS;
  8433. // Custom attributes used for symbols, these should be filtered out when
  8434. // setting SVGElement attributes (#9375).
  8435. this.symbolCustomAttribs = [
  8436. 'x',
  8437. 'y',
  8438. 'width',
  8439. 'height',
  8440. 'r',
  8441. 'start',
  8442. 'end',
  8443. 'innerR',
  8444. 'anchorX',
  8445. 'anchorY',
  8446. 'rounded'
  8447. ];
  8448. }
  8449. // @todo public zIndex?: number;
  8450. /* *
  8451. *
  8452. * Functions
  8453. *
  8454. * */
  8455. /**
  8456. * Get the current value of an attribute or pseudo attribute,
  8457. * used mainly for animation. Called internally from
  8458. * the {@link Highcharts.SVGRenderer#attr} function.
  8459. *
  8460. * @private
  8461. * @function Highcharts.SVGElement#_defaultGetter
  8462. *
  8463. * @param {string} key
  8464. * Property key.
  8465. *
  8466. * @return {number|string}
  8467. * Property value.
  8468. */
  8469. SVGElement.prototype._defaultGetter = function (key) {
  8470. var ret = pick(this[key + 'Value'], // align getter
  8471. this[key],
  8472. this.element ? this.element.getAttribute(key) : null, 0);
  8473. if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
  8474. ret = parseFloat(ret);
  8475. }
  8476. return ret;
  8477. };
  8478. /**
  8479. * @private
  8480. * @function Highcharts.SVGElement#_defaultSetter
  8481. *
  8482. * @param {string} value
  8483. *
  8484. * @param {string} key
  8485. *
  8486. * @param {Highcharts.SVGDOMElement} element
  8487. *
  8488. * @return {void}
  8489. */
  8490. SVGElement.prototype._defaultSetter = function (value, key, element) {
  8491. element.setAttribute(key, value);
  8492. };
  8493. /**
  8494. * Add the element to the DOM. All elements must be added this way.
  8495. *
  8496. * @sample highcharts/members/renderer-g
  8497. * Elements added to a group
  8498. *
  8499. * @function Highcharts.SVGElement#add
  8500. *
  8501. * @param {Highcharts.SVGElement} [parent]
  8502. * The parent item to add it to. If undefined, the element is added
  8503. * to the {@link Highcharts.SVGRenderer.box}.
  8504. *
  8505. * @return {Highcharts.SVGElement}
  8506. * Returns the SVGElement for chaining.
  8507. */
  8508. SVGElement.prototype.add = function (parent) {
  8509. var renderer = this.renderer,
  8510. element = this.element;
  8511. var inserted;
  8512. if (parent) {
  8513. this.parentGroup = parent;
  8514. }
  8515. // Mark as inverted
  8516. this.parentInverted = parent && parent.inverted;
  8517. // Build formatted text
  8518. if (typeof this.textStr !== 'undefined' &&
  8519. this.element.nodeName === 'text' // Not for SVGLabel instances
  8520. ) {
  8521. renderer.buildText(this);
  8522. }
  8523. // Mark as added
  8524. this.added = true;
  8525. // If we're adding to renderer root, or other elements in the group
  8526. // have a z index, we need to handle it
  8527. if (!parent || parent.handleZ || this.zIndex) {
  8528. inserted = this.zIndexSetter();
  8529. }
  8530. // If zIndex is not handled, append at the end
  8531. if (!inserted) {
  8532. (parent ?
  8533. parent.element :
  8534. renderer.box).appendChild(element);
  8535. }
  8536. // fire an event for internal hooks
  8537. if (this.onAdd) {
  8538. this.onAdd();
  8539. }
  8540. return this;
  8541. };
  8542. /**
  8543. * Add a class name to an element.
  8544. *
  8545. * @function Highcharts.SVGElement#addClass
  8546. *
  8547. * @param {string} className
  8548. * The new class name to add.
  8549. *
  8550. * @param {boolean} [replace=false]
  8551. * When true, the existing class name(s) will be overwritten with the new
  8552. * one. When false, the new one is added.
  8553. *
  8554. * @return {Highcharts.SVGElement}
  8555. * Return the SVG element for chainability.
  8556. */
  8557. SVGElement.prototype.addClass = function (className, replace) {
  8558. var currentClassName = replace ? '' : (this.attr('class') || '');
  8559. // Trim the string and remove duplicates
  8560. className = (className || '')
  8561. .split(/ /g)
  8562. .reduce(function (newClassName, name) {
  8563. if (currentClassName.indexOf(name) === -1) {
  8564. newClassName.push(name);
  8565. }
  8566. return newClassName;
  8567. }, (currentClassName ?
  8568. [currentClassName] :
  8569. []))
  8570. .join(' ');
  8571. if (className !== currentClassName) {
  8572. this.attr('class', className);
  8573. }
  8574. return this;
  8575. };
  8576. /**
  8577. * This method is executed in the end of `attr()`, after setting all
  8578. * attributes in the hash. In can be used to efficiently consolidate
  8579. * multiple attributes in one SVG property -- e.g., translate, rotate and
  8580. * scale are merged in one "transform" attribute in the SVG node.
  8581. *
  8582. * @private
  8583. * @function Highcharts.SVGElement#afterSetters
  8584. */
  8585. SVGElement.prototype.afterSetters = function () {
  8586. // Update transform. Do this outside the loop to prevent redundant
  8587. // updating for batch setting of attributes.
  8588. if (this.doTransform) {
  8589. this.updateTransform();
  8590. this.doTransform = false;
  8591. }
  8592. };
  8593. /**
  8594. * Align the element relative to the chart or another box.
  8595. *
  8596. * @function Highcharts.SVGElement#align
  8597. *
  8598. * @param {Highcharts.AlignObject} [alignOptions]
  8599. * The alignment options. The function can be called without this
  8600. * parameter in order to re-align an element after the box has been
  8601. * updated.
  8602. *
  8603. * @param {boolean} [alignByTranslate]
  8604. * Align element by translation.
  8605. *
  8606. * @param {string|Highcharts.BBoxObject} [box]
  8607. * The box to align to, needs a width and height. When the box is a
  8608. * string, it refers to an object in the Renderer. For example, when
  8609. * box is `spacingBox`, it refers to `Renderer.spacingBox` which
  8610. * holds `width`, `height`, `x` and `y` properties.
  8611. *
  8612. * @return {Highcharts.SVGElement} Returns the SVGElement for chaining.
  8613. */
  8614. SVGElement.prototype.align = function (alignOptions, alignByTranslate, box) {
  8615. var attribs = {},
  8616. renderer = this.renderer,
  8617. alignedObjects = renderer.alignedObjects;
  8618. var x,
  8619. y,
  8620. alignTo,
  8621. alignFactor,
  8622. vAlignFactor;
  8623. // First call on instanciate
  8624. if (alignOptions) {
  8625. this.alignOptions = alignOptions;
  8626. this.alignByTranslate = alignByTranslate;
  8627. if (!box || isString(box)) {
  8628. this.alignTo = alignTo = box || 'renderer';
  8629. // prevent duplicates, like legendGroup after resize
  8630. erase(alignedObjects, this);
  8631. alignedObjects.push(this);
  8632. box = void 0; // reassign it below
  8633. }
  8634. // When called on resize, no arguments are supplied
  8635. }
  8636. else {
  8637. alignOptions = this.alignOptions;
  8638. alignByTranslate = this.alignByTranslate;
  8639. alignTo = this.alignTo;
  8640. }
  8641. box = pick(box, renderer[alignTo], alignTo === 'scrollablePlotBox' ? renderer.plotBox : void 0, renderer);
  8642. // Assign variables
  8643. var align = alignOptions.align,
  8644. vAlign = alignOptions.verticalAlign;
  8645. // default: left align
  8646. x = (box.x || 0) + (alignOptions.x || 0);
  8647. // default: top align
  8648. y = (box.y || 0) + (alignOptions.y || 0);
  8649. // Align
  8650. if (align === 'right') {
  8651. alignFactor = 1;
  8652. }
  8653. else if (align === 'center') {
  8654. alignFactor = 2;
  8655. }
  8656. if (alignFactor) {
  8657. x += (box.width - (alignOptions.width || 0)) /
  8658. alignFactor;
  8659. }
  8660. attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
  8661. // Vertical align
  8662. if (vAlign === 'bottom') {
  8663. vAlignFactor = 1;
  8664. }
  8665. else if (vAlign === 'middle') {
  8666. vAlignFactor = 2;
  8667. }
  8668. if (vAlignFactor) {
  8669. y += (box.height - (alignOptions.height || 0)) /
  8670. vAlignFactor;
  8671. }
  8672. attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
  8673. // Animate only if already placed
  8674. this[this.placed ? 'animate' : 'attr'](attribs);
  8675. this.placed = true;
  8676. this.alignAttr = attribs;
  8677. return this;
  8678. };
  8679. /**
  8680. * @private
  8681. * @function Highcharts.SVGElement#alignSetter
  8682. * @param {"left"|"center"|"right"} value
  8683. */
  8684. SVGElement.prototype.alignSetter = function (value) {
  8685. var convert = {
  8686. left: 'start',
  8687. center: 'middle',
  8688. right: 'end'
  8689. };
  8690. if (convert[value]) {
  8691. this.alignValue = value;
  8692. this.element.setAttribute('text-anchor', convert[value]);
  8693. }
  8694. };
  8695. /**
  8696. * Animate to given attributes or CSS properties.
  8697. *
  8698. * @sample highcharts/members/element-on/
  8699. * Setting some attributes by animation
  8700. *
  8701. * @function Highcharts.SVGElement#animate
  8702. *
  8703. * @param {Highcharts.SVGAttributes} params
  8704. * SVG attributes or CSS to animate.
  8705. *
  8706. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [options]
  8707. * Animation options.
  8708. *
  8709. * @param {Function} [complete]
  8710. * Function to perform at the end of animation.
  8711. *
  8712. * @return {Highcharts.SVGElement}
  8713. * Returns the SVGElement for chaining.
  8714. */
  8715. SVGElement.prototype.animate = function (params, options, complete) {
  8716. var _this = this;
  8717. var animOptions = animObject(pick(options,
  8718. this.renderer.globalAnimation,
  8719. true)),
  8720. deferTime = animOptions.defer;
  8721. // When the page is hidden save resources in the background by not
  8722. // running animation at all (#9749).
  8723. if (pick(doc.hidden, doc.msHidden, doc.webkitHidden, false)) {
  8724. animOptions.duration = 0;
  8725. }
  8726. if (animOptions.duration !== 0) {
  8727. // allows using a callback with the global animation without
  8728. // overwriting it
  8729. if (complete) {
  8730. animOptions.complete = complete;
  8731. }
  8732. // If defer option is defined delay the animation #12901
  8733. syncTimeout(function () {
  8734. if (_this.element) {
  8735. animate(_this, params, animOptions);
  8736. }
  8737. }, deferTime);
  8738. }
  8739. else {
  8740. this.attr(params, void 0, complete);
  8741. // Call the end step synchronously
  8742. objectEach(params, function (val, prop) {
  8743. if (animOptions.step) {
  8744. animOptions.step.call(this, val, { prop: prop, pos: 1, elem: this });
  8745. }
  8746. }, this);
  8747. }
  8748. return this;
  8749. };
  8750. /**
  8751. * Apply a text outline through a custom CSS property, by copying the text
  8752. * element and apply stroke to the copy. Used internally. Contrast checks at
  8753. * [example](https://jsfiddle.net/highcharts/43soe9m1/2/).
  8754. *
  8755. * @example
  8756. * // Specific color
  8757. * text.css({
  8758. * textOutline: '1px black'
  8759. * });
  8760. * // Automatic contrast
  8761. * text.css({
  8762. * color: '#000000', // black text
  8763. * textOutline: '1px contrast' // => white outline
  8764. * });
  8765. *
  8766. * @private
  8767. * @function Highcharts.SVGElement#applyTextOutline
  8768. *
  8769. * @param {string} textOutline
  8770. * A custom CSS `text-outline` setting, defined by `width color`.
  8771. */
  8772. SVGElement.prototype.applyTextOutline = function (textOutline) {
  8773. var elem = this.element,
  8774. hasContrast = textOutline.indexOf('contrast') !== -1,
  8775. styles = {};
  8776. // When the text shadow is set to contrast, use dark stroke for light
  8777. // text and vice versa.
  8778. if (hasContrast) {
  8779. styles.textOutline = textOutline = textOutline.replace(/contrast/g, this.renderer.getContrast(elem.style.fill));
  8780. }
  8781. // Extract the stroke width and color
  8782. var parts = textOutline.split(' ');
  8783. var color = parts[parts.length - 1];
  8784. var strokeWidth = parts[0];
  8785. if (strokeWidth && strokeWidth !== 'none' && H.svg) {
  8786. this.fakeTS = true; // Fake text shadow
  8787. // In order to get the right y position of the clone,
  8788. // copy over the y setter
  8789. this.ySetter = this.xSetter;
  8790. // Since the stroke is applied on center of the actual outline, we
  8791. // need to double it to get the correct stroke-width outside the
  8792. // glyphs.
  8793. strokeWidth = strokeWidth.replace(/(^[\d\.]+)(.*?)$/g, function (match, digit, unit) {
  8794. return (2 * Number(digit)) + unit;
  8795. });
  8796. // Remove shadows from previous runs.
  8797. this.removeTextOutline();
  8798. var outline_1 = doc.createElementNS(SVG_NS, 'tspan');
  8799. attr(outline_1, {
  8800. 'class': 'highcharts-text-outline',
  8801. fill: color,
  8802. stroke: color,
  8803. 'stroke-width': strokeWidth,
  8804. 'stroke-linejoin': 'round'
  8805. });
  8806. // For each of the tspans and text nodes, create a copy in the
  8807. // outline.
  8808. [].forEach.call(elem.childNodes, function (childNode) {
  8809. var clone = childNode.cloneNode(true);
  8810. if (clone.removeAttribute) {
  8811. ['fill', 'stroke', 'stroke-width', 'stroke'].forEach(function (prop) { return clone.removeAttribute(prop); });
  8812. }
  8813. outline_1.appendChild(clone);
  8814. });
  8815. // Insert an absolutely positioned break before the original text
  8816. // to keep it in place
  8817. var br_1 = doc.createElementNS(SVG_NS, 'tspan');
  8818. br_1.textContent = '\u200B';
  8819. // Copy x and y if not null
  8820. ['x', 'y'].forEach(function (key) {
  8821. var value = elem.getAttribute(key);
  8822. if (value) {
  8823. br_1.setAttribute(key, value);
  8824. }
  8825. });
  8826. // Insert the outline
  8827. outline_1.appendChild(br_1);
  8828. elem.insertBefore(outline_1, elem.firstChild);
  8829. }
  8830. };
  8831. /**
  8832. * @function Highcharts.SVGElement#attr
  8833. * @param {string} key
  8834. * @return {number|string}
  8835. */ /**
  8836. * Apply native and custom attributes to the SVG elements.
  8837. *
  8838. * In order to set the rotation center for rotation, set x and y to 0 and
  8839. * use `translateX` and `translateY` attributes to position the element
  8840. * instead.
  8841. *
  8842. * Attributes frequently used in Highcharts are `fill`, `stroke`,
  8843. * `stroke-width`.
  8844. *
  8845. * @sample highcharts/members/renderer-rect/
  8846. * Setting some attributes
  8847. *
  8848. * @example
  8849. * // Set multiple attributes
  8850. * element.attr({
  8851. * stroke: 'red',
  8852. * fill: 'blue',
  8853. * x: 10,
  8854. * y: 10
  8855. * });
  8856. *
  8857. * // Set a single attribute
  8858. * element.attr('stroke', 'red');
  8859. *
  8860. * // Get an attribute
  8861. * element.attr('stroke'); // => 'red'
  8862. *
  8863. * @function Highcharts.SVGElement#attr
  8864. *
  8865. * @param {string|Highcharts.SVGAttributes} [hash]
  8866. * The native and custom SVG attributes.
  8867. *
  8868. * @param {number|string|Highcharts.SVGPathArray} [val]
  8869. * If the type of the first argument is `string`, the second can be a
  8870. * value, which will serve as a single attribute setter. If the first
  8871. * argument is a string and the second is undefined, the function
  8872. * serves as a getter and the current value of the property is
  8873. * returned.
  8874. *
  8875. * @param {Function} [complete]
  8876. * A callback function to execute after setting the attributes. This
  8877. * makes the function compliant and interchangeable with the
  8878. * {@link SVGElement#animate} function.
  8879. *
  8880. * @param {boolean} [continueAnimation=true]
  8881. * Used internally when `.attr` is called as part of an animation
  8882. * step. Otherwise, calling `.attr` for an attribute will stop
  8883. * animation for that attribute.
  8884. *
  8885. * @return {Highcharts.SVGElement}
  8886. * If used as a setter, it returns the current
  8887. * {@link Highcharts.SVGElement} so the calls can be chained. If
  8888. * used as a getter, the current value of the attribute is returned.
  8889. */
  8890. SVGElement.prototype.attr = function (hash, val, complete, continueAnimation) {
  8891. var element = this.element,
  8892. symbolCustomAttribs = this.symbolCustomAttribs;
  8893. var key,
  8894. hasSetSymbolSize,
  8895. ret = this,
  8896. skipAttr,
  8897. setter;
  8898. // single key-value pair
  8899. if (typeof hash === 'string' && typeof val !== 'undefined') {
  8900. key = hash;
  8901. hash = {};
  8902. hash[key] = val;
  8903. }
  8904. // used as a getter: first argument is a string, second is undefined
  8905. if (typeof hash === 'string') {
  8906. ret = (this[hash + 'Getter'] ||
  8907. this._defaultGetter).call(this, hash, element);
  8908. // setter
  8909. }
  8910. else {
  8911. objectEach(hash, function eachAttribute(val, key) {
  8912. skipAttr = false;
  8913. // Unless .attr is from the animator update, stop current
  8914. // running animation of this property
  8915. if (!continueAnimation) {
  8916. stop(this, key);
  8917. }
  8918. // Special handling of symbol attributes
  8919. if (this.symbolName &&
  8920. symbolCustomAttribs.indexOf(key) !== -1) {
  8921. if (!hasSetSymbolSize) {
  8922. this.symbolAttr(hash);
  8923. hasSetSymbolSize = true;
  8924. }
  8925. skipAttr = true;
  8926. }
  8927. if (this.rotation && (key === 'x' || key === 'y')) {
  8928. this.doTransform = true;
  8929. }
  8930. if (!skipAttr) {
  8931. setter = (this[key + 'Setter'] ||
  8932. this._defaultSetter);
  8933. setter.call(this, val, key, element);
  8934. // Let the shadow follow the main element
  8935. if (!this.styledMode &&
  8936. this.shadows &&
  8937. /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
  8938. this.updateShadows(key, val, setter);
  8939. }
  8940. }
  8941. }, this);
  8942. this.afterSetters();
  8943. }
  8944. // In accordance with animate, run a complete callback
  8945. if (complete) {
  8946. complete.call(this);
  8947. }
  8948. return ret;
  8949. };
  8950. /**
  8951. * Apply a clipping rectangle to this element.
  8952. *
  8953. * @function Highcharts.SVGElement#clip
  8954. *
  8955. * @param {Highcharts.ClipRectElement} [clipRect]
  8956. * The clipping rectangle. If skipped, the current clip is removed.
  8957. *
  8958. * @return {Highcharts.SVGElement}
  8959. * Returns the SVG element to allow chaining.
  8960. */
  8961. SVGElement.prototype.clip = function (clipRect) {
  8962. return this.attr('clip-path', clipRect ?
  8963. 'url(' + this.renderer.url + '#' + clipRect.id + ')' :
  8964. 'none');
  8965. };
  8966. /**
  8967. * Calculate the coordinates needed for drawing a rectangle crisply and
  8968. * return the calculated attributes.
  8969. *
  8970. * @function Highcharts.SVGElement#crisp
  8971. *
  8972. * @param {Highcharts.RectangleObject} rect
  8973. * Rectangle to crisp.
  8974. *
  8975. * @param {number} [strokeWidth]
  8976. * The stroke width to consider when computing crisp positioning. It can
  8977. * also be set directly on the rect parameter.
  8978. *
  8979. * @return {Highcharts.RectangleObject}
  8980. * The modified rectangle arguments.
  8981. */
  8982. SVGElement.prototype.crisp = function (rect, strokeWidth) {
  8983. var wrapper = this;
  8984. strokeWidth = strokeWidth || rect.strokeWidth || 0;
  8985. // Math.round because strokeWidth can sometimes have roundoff errors
  8986. var normalizer = Math.round(strokeWidth) % 2 / 2;
  8987. // normalize for crisp edges
  8988. rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
  8989. rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
  8990. rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
  8991. rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
  8992. if (defined(rect.strokeWidth)) {
  8993. rect.strokeWidth = strokeWidth;
  8994. }
  8995. return rect;
  8996. };
  8997. /**
  8998. * Build and apply an SVG gradient out of a common JavaScript configuration
  8999. * object. This function is called from the attribute setters. An event
  9000. * hook is added for supporting other complex color types.
  9001. *
  9002. * @private
  9003. * @function Highcharts.SVGElement#complexColor
  9004. *
  9005. * @param {Highcharts.GradientColorObject|Highcharts.PatternObject} colorOptions
  9006. * The gradient or pattern options structure.
  9007. *
  9008. * @param {string} prop
  9009. * The property to apply, can either be `fill` or `stroke`.
  9010. *
  9011. * @param {Highcharts.SVGDOMElement} elem
  9012. * SVG element to apply the gradient on.
  9013. */
  9014. SVGElement.prototype.complexColor = function (colorOptions, prop, elem) {
  9015. var renderer = this.renderer;
  9016. var colorObject,
  9017. gradName,
  9018. gradAttr,
  9019. radAttr,
  9020. gradients,
  9021. stops,
  9022. stopColor,
  9023. stopOpacity,
  9024. radialReference,
  9025. id,
  9026. key = [],
  9027. value;
  9028. fireEvent(this.renderer, 'complexColor', {
  9029. args: arguments
  9030. }, function () {
  9031. // Apply linear or radial gradients
  9032. if (colorOptions.radialGradient) {
  9033. gradName = 'radialGradient';
  9034. }
  9035. else if (colorOptions.linearGradient) {
  9036. gradName = 'linearGradient';
  9037. }
  9038. if (gradName) {
  9039. gradAttr = colorOptions[gradName];
  9040. gradients = renderer.gradients;
  9041. stops = colorOptions.stops;
  9042. radialReference = elem.radialReference;
  9043. // Keep < 2.2 kompatibility
  9044. if (isArray(gradAttr)) {
  9045. colorOptions[gradName] = gradAttr = {
  9046. x1: gradAttr[0],
  9047. y1: gradAttr[1],
  9048. x2: gradAttr[2],
  9049. y2: gradAttr[3],
  9050. gradientUnits: 'userSpaceOnUse'
  9051. };
  9052. }
  9053. // Correct the radial gradient for the radial reference system
  9054. if (gradName === 'radialGradient' &&
  9055. radialReference &&
  9056. !defined(gradAttr.gradientUnits)) {
  9057. // Save the radial attributes for updating
  9058. radAttr = gradAttr;
  9059. gradAttr = merge(gradAttr, renderer.getRadialAttr(radialReference, radAttr), { gradientUnits: 'userSpaceOnUse' });
  9060. }
  9061. // Build the unique key to detect whether we need to create a
  9062. // new element (#1282)
  9063. objectEach(gradAttr, function (value, n) {
  9064. if (n !== 'id') {
  9065. key.push(n, value);
  9066. }
  9067. });
  9068. objectEach(stops, function (val) {
  9069. key.push(val);
  9070. });
  9071. key = key.join(',');
  9072. // Check if a gradient object with the same config object is
  9073. // created within this renderer
  9074. if (gradients[key]) {
  9075. id = gradients[key].attr('id');
  9076. }
  9077. else {
  9078. // Set the id and create the element
  9079. gradAttr.id = id = uniqueKey();
  9080. var gradientObject_1 = gradients[key] =
  9081. renderer.createElement(gradName)
  9082. .attr(gradAttr)
  9083. .add(renderer.defs);
  9084. gradientObject_1.radAttr = radAttr;
  9085. // The gradient needs to keep a list of stops to be able to
  9086. // destroy them
  9087. gradientObject_1.stops = [];
  9088. stops.forEach(function (stop) {
  9089. if (stop[1].indexOf('rgba') === 0) {
  9090. colorObject = Color.parse(stop[1]);
  9091. stopColor = colorObject.get('rgb');
  9092. stopOpacity = colorObject.get('a');
  9093. }
  9094. else {
  9095. stopColor = stop[1];
  9096. stopOpacity = 1;
  9097. }
  9098. var stopObject = renderer.createElement('stop').attr({
  9099. offset: stop[0],
  9100. 'stop-color': stopColor,
  9101. 'stop-opacity': stopOpacity
  9102. }).add(gradientObject_1);
  9103. // Add the stop element to the gradient
  9104. gradientObject_1.stops.push(stopObject);
  9105. });
  9106. }
  9107. // Set the reference to the gradient object
  9108. value = 'url(' + renderer.url + '#' + id + ')';
  9109. elem.setAttribute(prop, value);
  9110. elem.gradient = key;
  9111. // Allow the color to be concatenated into tooltips formatters
  9112. // etc. (#2995)
  9113. colorOptions.toString = function () {
  9114. return value;
  9115. };
  9116. }
  9117. });
  9118. };
  9119. /**
  9120. * Set styles for the element. In addition to CSS styles supported by
  9121. * native SVG and HTML elements, there are also some custom made for
  9122. * Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
  9123. * elements.
  9124. *
  9125. * @sample highcharts/members/renderer-text-on-chart/
  9126. * Styled text
  9127. *
  9128. * @function Highcharts.SVGElement#css
  9129. *
  9130. * @param {Highcharts.CSSObject} styles
  9131. * The new CSS styles.
  9132. *
  9133. * @return {Highcharts.SVGElement}
  9134. * Return the SVG element for chaining.
  9135. */
  9136. SVGElement.prototype.css = function (styles) {
  9137. var oldStyles = this.styles, newStyles = {}, elem = this.element,
  9138. // These CSS properties are interpreted internally by the SVG
  9139. // renderer, but are not supported by SVG and should not be added to
  9140. // the DOM. In styled mode, no CSS should find its way to the DOM
  9141. // whatsoever (#6173, #6474).
  9142. svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
  9143. var textWidth,
  9144. serializedCss = '',
  9145. hyphenate,
  9146. hasNew = !oldStyles;
  9147. // convert legacy
  9148. if (styles && styles.color) {
  9149. styles.fill = styles.color;
  9150. }
  9151. // Filter out existing styles to increase performance (#2640)
  9152. if (oldStyles) {
  9153. objectEach(styles, function (style, n) {
  9154. if (oldStyles && oldStyles[n] !== style) {
  9155. newStyles[n] = style;
  9156. hasNew = true;
  9157. }
  9158. });
  9159. }
  9160. if (hasNew) {
  9161. // Merge the new styles with the old ones
  9162. if (oldStyles) {
  9163. styles = extend(oldStyles, newStyles);
  9164. }
  9165. // Get the text width from style
  9166. if (styles) {
  9167. // Previously set, unset it (#8234)
  9168. if (styles.width === null || styles.width === 'auto') {
  9169. delete this.textWidth;
  9170. // Apply new
  9171. }
  9172. else if (elem.nodeName.toLowerCase() === 'text' &&
  9173. styles.width) {
  9174. textWidth = this.textWidth = pInt(styles.width);
  9175. }
  9176. }
  9177. // store object
  9178. this.styles = styles;
  9179. if (textWidth && (!svg && this.renderer.forExport)) {
  9180. delete styles.width;
  9181. }
  9182. // Serialize and set style attribute
  9183. if (elem.namespaceURI === this.SVG_NS) { // #7633
  9184. hyphenate = function (a, b) {
  9185. return '-' + b.toLowerCase();
  9186. };
  9187. objectEach(styles, function (style, n) {
  9188. if (svgPseudoProps.indexOf(n) === -1) {
  9189. serializedCss +=
  9190. n.replace(/([A-Z])/g, hyphenate) + ':' +
  9191. style + ';';
  9192. }
  9193. });
  9194. if (serializedCss) {
  9195. attr(elem, 'style', serializedCss); // #1881
  9196. }
  9197. }
  9198. else {
  9199. css(elem, styles);
  9200. }
  9201. if (this.added) {
  9202. // Rebuild text after added. Cache mechanisms in the buildText
  9203. // will prevent building if there are no significant changes.
  9204. if (this.element.nodeName === 'text') {
  9205. this.renderer.buildText(this);
  9206. }
  9207. // Apply text outline after added
  9208. if (styles && styles.textOutline) {
  9209. this.applyTextOutline(styles.textOutline);
  9210. }
  9211. }
  9212. }
  9213. return this;
  9214. };
  9215. /**
  9216. * @private
  9217. * @function Highcharts.SVGElement#dashstyleSetter
  9218. * @param {string} value
  9219. */
  9220. SVGElement.prototype.dashstyleSetter = function (value) {
  9221. var i,
  9222. strokeWidth = this['stroke-width'];
  9223. // If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new
  9224. // strokeWidth function, we should be able to use that instead.
  9225. if (strokeWidth === 'inherit') {
  9226. strokeWidth = 1;
  9227. }
  9228. value = value && value.toLowerCase();
  9229. if (value) {
  9230. var v = value
  9231. .replace('shortdashdotdot', '3,1,1,1,1,1,')
  9232. .replace('shortdashdot', '3,1,1,1')
  9233. .replace('shortdot', '1,1,')
  9234. .replace('shortdash', '3,1,')
  9235. .replace('longdash', '8,3,')
  9236. .replace(/dot/g, '1,3,')
  9237. .replace('dash', '4,3,')
  9238. .replace(/,$/, '')
  9239. .split(','); // ending comma
  9240. i = v.length;
  9241. while (i--) {
  9242. v[i] = '' + (pInt(v[i]) * pick(strokeWidth, NaN));
  9243. }
  9244. value = v.join(',').replace(/NaN/g, 'none'); // #3226
  9245. this.element.setAttribute('stroke-dasharray', value);
  9246. }
  9247. };
  9248. /**
  9249. * Destroy the element and element wrapper and clear up the DOM and event
  9250. * hooks.
  9251. *
  9252. * @function Highcharts.SVGElement#destroy
  9253. */
  9254. SVGElement.prototype.destroy = function () {
  9255. var wrapper = this,
  9256. element = wrapper.element || {},
  9257. renderer = wrapper.renderer,
  9258. ownerSVGElement = element.ownerSVGElement;
  9259. var parentToClean = (renderer.isSVG &&
  9260. element.nodeName === 'SPAN' &&
  9261. wrapper.parentGroup ||
  9262. void 0),
  9263. grandParent,
  9264. i;
  9265. // remove events
  9266. element.onclick = element.onmouseout = element.onmouseover =
  9267. element.onmousemove = element.point = null;
  9268. stop(wrapper); // stop running animations
  9269. if (wrapper.clipPath && ownerSVGElement) {
  9270. var clipPath_1 = wrapper.clipPath;
  9271. // Look for existing references to this clipPath and remove them
  9272. // before destroying the element (#6196).
  9273. // The upper case version is for Edge
  9274. [].forEach.call(ownerSVGElement.querySelectorAll('[clip-path],[CLIP-PATH]'), function (el) {
  9275. if (el.getAttribute('clip-path').indexOf(clipPath_1.element.id) > -1) {
  9276. el.removeAttribute('clip-path');
  9277. }
  9278. });
  9279. wrapper.clipPath = clipPath_1.destroy();
  9280. }
  9281. // Destroy stops in case this is a gradient object @todo old code?
  9282. if (wrapper.stops) {
  9283. for (i = 0; i < wrapper.stops.length; i++) {
  9284. wrapper.stops[i].destroy();
  9285. }
  9286. wrapper.stops.length = 0;
  9287. wrapper.stops = void 0;
  9288. }
  9289. // remove element
  9290. wrapper.safeRemoveChild(element);
  9291. if (!renderer.styledMode) {
  9292. wrapper.destroyShadows();
  9293. }
  9294. // In case of useHTML, clean up empty containers emulating SVG groups
  9295. // (#1960, #2393, #2697).
  9296. while (parentToClean &&
  9297. parentToClean.div &&
  9298. parentToClean.div.childNodes.length === 0) {
  9299. grandParent = parentToClean.parentGroup;
  9300. wrapper.safeRemoveChild(parentToClean.div);
  9301. delete parentToClean.div;
  9302. parentToClean = grandParent;
  9303. }
  9304. // remove from alignObjects
  9305. if (wrapper.alignTo) {
  9306. erase(renderer.alignedObjects, wrapper);
  9307. }
  9308. objectEach(wrapper, function (val, key) {
  9309. // Destroy child elements of a group
  9310. if (wrapper[key] &&
  9311. wrapper[key].parentGroup === wrapper &&
  9312. wrapper[key].destroy) {
  9313. wrapper[key].destroy();
  9314. }
  9315. // Delete all properties
  9316. delete wrapper[key];
  9317. });
  9318. return;
  9319. };
  9320. /**
  9321. * Destroy shadows on the element.
  9322. *
  9323. * @private
  9324. * @function Highcharts.SVGElement#destroyShadows
  9325. *
  9326. * @return {void}
  9327. */
  9328. SVGElement.prototype.destroyShadows = function () {
  9329. (this.shadows || []).forEach(function (shadow) {
  9330. this.safeRemoveChild(shadow);
  9331. }, this);
  9332. this.shadows = void 0;
  9333. };
  9334. /**
  9335. * @private
  9336. */
  9337. SVGElement.prototype.destroyTextPath = function (elem, path) {
  9338. var textElement = elem.getElementsByTagName('text')[0];
  9339. var childNodes;
  9340. if (textElement) {
  9341. // Remove textPath attributes
  9342. textElement.removeAttribute('dx');
  9343. textElement.removeAttribute('dy');
  9344. // Remove ID's:
  9345. path.element.setAttribute('id', '');
  9346. // Check if textElement includes textPath,
  9347. if (this.textPathWrapper &&
  9348. textElement.getElementsByTagName('textPath').length) {
  9349. // Move nodes to <text>
  9350. childNodes = this.textPathWrapper.element.childNodes;
  9351. // Now move all <tspan>'s and text nodes to the <textPath> node
  9352. while (childNodes.length) {
  9353. textElement.appendChild(childNodes[0]);
  9354. }
  9355. // Remove <textPath> from the DOM
  9356. textElement.removeChild(this.textPathWrapper.element);
  9357. }
  9358. }
  9359. else if (elem.getAttribute('dx') || elem.getAttribute('dy')) {
  9360. // Remove textPath attributes from elem
  9361. // to get correct text-outline position
  9362. elem.removeAttribute('dx');
  9363. elem.removeAttribute('dy');
  9364. }
  9365. if (this.textPathWrapper) {
  9366. // Set textPathWrapper to undefined and destroy it
  9367. this.textPathWrapper = this.textPathWrapper.destroy();
  9368. }
  9369. };
  9370. /**
  9371. * @private
  9372. * @function Highcharts.SVGElement#dSettter
  9373. * @param {number|string|Highcharts.SVGPathArray} value
  9374. * @param {string} key
  9375. * @param {Highcharts.SVGDOMElement} element
  9376. */
  9377. SVGElement.prototype.dSetter = function (value, key, element) {
  9378. if (isArray(value)) {
  9379. // Backwards compatibility, convert one-dimensional array into an
  9380. // array of segments
  9381. if (typeof value[0] === 'string') {
  9382. value = this.renderer.pathToSegments(value);
  9383. }
  9384. this.pathArray = value;
  9385. value = value.reduce(function (acc, seg, i) {
  9386. if (!seg || !seg.join) {
  9387. return (seg || '').toString();
  9388. }
  9389. return (i ? acc + ' ' : '') + seg.join(' ');
  9390. }, '');
  9391. }
  9392. if (/(NaN| {2}|^$)/.test(value)) {
  9393. value = 'M 0 0';
  9394. }
  9395. // Check for cache before resetting. Resetting causes disturbance in the
  9396. // DOM, causing flickering in some cases in Edge/IE (#6747). Also
  9397. // possible performance gain.
  9398. if (this[key] !== value) {
  9399. element.setAttribute(key, value);
  9400. this[key] = value;
  9401. }
  9402. };
  9403. /**
  9404. * Fade out an element by animating its opacity down to 0, and hide it on
  9405. * complete. Used internally for the tooltip.
  9406. *
  9407. * @function Highcharts.SVGElement#fadeOut
  9408. *
  9409. * @param {number} [duration=150]
  9410. * The fade duration in milliseconds.
  9411. */
  9412. SVGElement.prototype.fadeOut = function (duration) {
  9413. var elemWrapper = this;
  9414. elemWrapper.animate({
  9415. opacity: 0
  9416. }, {
  9417. duration: pick(duration, 150),
  9418. complete: function () {
  9419. // #3088, assuming we're only using this for tooltips
  9420. elemWrapper.attr({ y: -9999 }).hide();
  9421. }
  9422. });
  9423. };
  9424. /**
  9425. * @private
  9426. * @function Highcharts.SVGElement#fillSetter
  9427. * @param {Highcharts.ColorType} value
  9428. * @param {string} key
  9429. * @param {Highcharts.SVGDOMElement} element
  9430. */
  9431. SVGElement.prototype.fillSetter = function (value, key, element) {
  9432. if (typeof value === 'string') {
  9433. element.setAttribute(key, value);
  9434. }
  9435. else if (value) {
  9436. this.complexColor(value, key, element);
  9437. }
  9438. };
  9439. /**
  9440. * Get the bounding box (width, height, x and y) for the element. Generally
  9441. * used to get rendered text size. Since this is called a lot in charts,
  9442. * the results are cached based on text properties, in order to save DOM
  9443. * traffic. The returned bounding box includes the rotation, so for example
  9444. * a single text line of rotation 90 will report a greater height, and a
  9445. * width corresponding to the line-height.
  9446. *
  9447. * @sample highcharts/members/renderer-on-chart/
  9448. * Draw a rectangle based on a text's bounding box
  9449. *
  9450. * @function Highcharts.SVGElement#getBBox
  9451. *
  9452. * @param {boolean} [reload]
  9453. * Skip the cache and get the updated DOM bouding box.
  9454. *
  9455. * @param {number} [rot]
  9456. * Override the element's rotation. This is internally used on axis
  9457. * labels with a value of 0 to find out what the bounding box would
  9458. * be have been if it were not rotated.
  9459. *
  9460. * @return {Highcharts.BBoxObject}
  9461. * The bounding box with `x`, `y`, `width` and `height` properties.
  9462. */
  9463. SVGElement.prototype.getBBox = function (reload, rot) {
  9464. var wrapper = this,
  9465. renderer = wrapper.renderer,
  9466. element = wrapper.element,
  9467. styles = wrapper.styles,
  9468. textStr = wrapper.textStr,
  9469. cache = renderer.cache,
  9470. cacheKeys = renderer.cacheKeys,
  9471. isSVG = element.namespaceURI === wrapper.SVG_NS,
  9472. rotation = pick(rot,
  9473. wrapper.rotation, 0),
  9474. fontSize = renderer.styledMode ? (element &&
  9475. SVGElement.prototype.getStyle.call(element, 'font-size')) : (styles && styles.fontSize);
  9476. var bBox, // = wrapper.bBox,
  9477. width,
  9478. height,
  9479. toggleTextShadowShim,
  9480. cacheKey;
  9481. // Avoid undefined and null (#7316)
  9482. if (defined(textStr)) {
  9483. cacheKey = textStr.toString();
  9484. // Since numbers are monospaced, and numerical labels appear a lot
  9485. // in a chart, we assume that a label of n characters has the same
  9486. // bounding box as others of the same length. Unless there is inner
  9487. // HTML in the label. In that case, leave the numbers as is (#5899).
  9488. if (cacheKey.indexOf('<') === -1) {
  9489. cacheKey = cacheKey.replace(/[0-9]/g, '0');
  9490. }
  9491. // Properties that affect bounding box
  9492. cacheKey += [
  9493. '',
  9494. rotation,
  9495. fontSize,
  9496. wrapper.textWidth,
  9497. styles && styles.textOverflow,
  9498. styles && styles.fontWeight // #12163
  9499. ].join(',');
  9500. }
  9501. if (cacheKey && !reload) {
  9502. bBox = cache[cacheKey];
  9503. }
  9504. // No cache found
  9505. if (!bBox) {
  9506. // SVG elements
  9507. if (isSVG || renderer.forExport) {
  9508. try { // Fails in Firefox if the container has display: none.
  9509. // When the text shadow shim is used, we need to hide the
  9510. // fake shadows to get the correct bounding box (#3872)
  9511. toggleTextShadowShim = this.fakeTS && function (display) {
  9512. var outline = element.querySelector('.highcharts-text-outline');
  9513. if (outline) {
  9514. css(outline, { display: display });
  9515. }
  9516. };
  9517. // Workaround for #3842, Firefox reporting wrong bounding
  9518. // box for shadows
  9519. if (isFunction(toggleTextShadowShim)) {
  9520. toggleTextShadowShim('none');
  9521. }
  9522. bBox = element.getBBox ?
  9523. // SVG: use extend because IE9 is not allowed to change
  9524. // width and height in case of rotation (below)
  9525. extend({}, element.getBBox()) : {
  9526. // Legacy IE in export mode
  9527. width: element.offsetWidth,
  9528. height: element.offsetHeight
  9529. };
  9530. // #3842
  9531. if (isFunction(toggleTextShadowShim)) {
  9532. toggleTextShadowShim('');
  9533. }
  9534. }
  9535. catch (e) {
  9536. '';
  9537. }
  9538. // If the bBox is not set, the try-catch block above failed. The
  9539. // other condition is for Opera that returns a width of
  9540. // -Infinity on hidden elements.
  9541. if (!bBox || bBox.width < 0) {
  9542. bBox = { width: 0, height: 0 };
  9543. }
  9544. // VML Renderer or useHTML within SVG
  9545. }
  9546. else {
  9547. bBox = wrapper.htmlGetBBox();
  9548. }
  9549. // True SVG elements as well as HTML elements in modern browsers
  9550. // using the .useHTML option need to compensated for rotation
  9551. if (renderer.isSVG) {
  9552. width = bBox.width;
  9553. height = bBox.height;
  9554. // Workaround for wrong bounding box in IE, Edge and Chrome on
  9555. // Windows. With Highcharts' default font, IE and Edge report
  9556. // a box height of 16.899 and Chrome rounds it to 17. If this
  9557. // stands uncorrected, it results in more padding added below
  9558. // the text than above when adding a label border or background.
  9559. // Also vertical positioning is affected.
  9560. // https://jsfiddle.net/highcharts/em37nvuj/
  9561. // (#1101, #1505, #1669, #2568, #6213).
  9562. if (isSVG) {
  9563. bBox.height = height = ({
  9564. '11px,17': 14,
  9565. '13px,20': 16
  9566. }[styles &&
  9567. styles.fontSize + ',' + Math.round(height)] ||
  9568. height);
  9569. }
  9570. // Adjust for rotated text
  9571. if (rotation) {
  9572. var rad = rotation * deg2rad;
  9573. bBox.width = Math.abs(height * Math.sin(rad)) +
  9574. Math.abs(width * Math.cos(rad));
  9575. bBox.height = Math.abs(height * Math.cos(rad)) +
  9576. Math.abs(width * Math.sin(rad));
  9577. }
  9578. }
  9579. // Cache it. When loading a chart in a hidden iframe in Firefox and
  9580. // IE/Edge, the bounding box height is 0, so don't cache it (#5620).
  9581. if (cacheKey && bBox.height > 0) {
  9582. // Rotate (#4681)
  9583. while (cacheKeys.length > 250) {
  9584. delete cache[cacheKeys.shift()];
  9585. }
  9586. if (!cache[cacheKey]) {
  9587. cacheKeys.push(cacheKey);
  9588. }
  9589. cache[cacheKey] = bBox;
  9590. }
  9591. }
  9592. return bBox;
  9593. };
  9594. /**
  9595. * Get the computed style. Only in styled mode.
  9596. *
  9597. * @example
  9598. * chart.series[0].points[0].graphic.getStyle('stroke-width'); // => '1px'
  9599. *
  9600. * @function Highcharts.SVGElement#getStyle
  9601. *
  9602. * @param {string} prop
  9603. * The property name to check for.
  9604. *
  9605. * @return {string}
  9606. * The current computed value.
  9607. */
  9608. SVGElement.prototype.getStyle = function (prop) {
  9609. return win
  9610. .getComputedStyle(this.element || this, '')
  9611. .getPropertyValue(prop);
  9612. };
  9613. /**
  9614. * Check if an element has the given class name.
  9615. *
  9616. * @function Highcharts.SVGElement#hasClass
  9617. *
  9618. * @param {string} className
  9619. * The class name to check for.
  9620. *
  9621. * @return {boolean}
  9622. * Whether the class name is found.
  9623. */
  9624. SVGElement.prototype.hasClass = function (className) {
  9625. return ('' + this.attr('class'))
  9626. .split(' ')
  9627. .indexOf(className) !== -1;
  9628. };
  9629. /**
  9630. * Hide the element, similar to setting the `visibility` attribute to
  9631. * `hidden`.
  9632. *
  9633. * @function Highcharts.SVGElement#hide
  9634. *
  9635. * @param {boolean} [hideByTranslation=false]
  9636. * The flag to determine if element should be hidden by moving out
  9637. * of the viewport. Used for example for dataLabels.
  9638. *
  9639. * @return {Highcharts.SVGElement}
  9640. * Returns the SVGElement for chaining.
  9641. */
  9642. SVGElement.prototype.hide = function (hideByTranslation) {
  9643. if (hideByTranslation) {
  9644. this.attr({ y: -9999 });
  9645. }
  9646. else {
  9647. this.attr({ visibility: 'hidden' });
  9648. }
  9649. return this;
  9650. };
  9651. /**
  9652. * @private
  9653. */
  9654. SVGElement.prototype.htmlGetBBox = function () {
  9655. return { height: 0, width: 0, x: 0, y: 0 };
  9656. };
  9657. /**
  9658. * Initialize the SVG element. This function only exists to make the
  9659. * initialization process overridable. It should not be called directly.
  9660. *
  9661. * @function Highcharts.SVGElement#init
  9662. *
  9663. * @param {Highcharts.SVGRenderer} renderer
  9664. * The SVGRenderer instance to initialize to.
  9665. *
  9666. * @param {string} nodeName
  9667. * The SVG node name.
  9668. */
  9669. SVGElement.prototype.init = function (renderer, nodeName) {
  9670. /**
  9671. * The primary DOM node. Each `SVGElement` instance wraps a main DOM
  9672. * node, but may also represent more nodes.
  9673. *
  9674. * @name Highcharts.SVGElement#element
  9675. * @type {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement}
  9676. */
  9677. this.element = nodeName === 'span' ?
  9678. createElement(nodeName) :
  9679. doc.createElementNS(this.SVG_NS, nodeName);
  9680. /**
  9681. * The renderer that the SVGElement belongs to.
  9682. *
  9683. * @name Highcharts.SVGElement#renderer
  9684. * @type {Highcharts.SVGRenderer}
  9685. */
  9686. this.renderer = renderer;
  9687. fireEvent(this, 'afterInit');
  9688. };
  9689. /**
  9690. * Invert a group, rotate and flip. This is used internally on inverted
  9691. * charts, where the points and graphs are drawn as if not inverted, then
  9692. * the series group elements are inverted.
  9693. *
  9694. * @function Highcharts.SVGElement#invert
  9695. *
  9696. * @param {boolean} inverted
  9697. * Whether to invert or not. An inverted shape can be un-inverted by
  9698. * setting it to false.
  9699. *
  9700. * @return {Highcharts.SVGElement}
  9701. * Return the SVGElement for chaining.
  9702. */
  9703. SVGElement.prototype.invert = function (inverted) {
  9704. this.inverted = inverted;
  9705. this.updateTransform();
  9706. return this;
  9707. };
  9708. /**
  9709. * Add an event listener. This is a simple setter that replaces the
  9710. * previous event of the same type added by this function, as opposed to
  9711. * the {@link Highcharts#addEvent} function.
  9712. *
  9713. * @sample highcharts/members/element-on/
  9714. * A clickable rectangle
  9715. *
  9716. * @function Highcharts.SVGElement#on
  9717. *
  9718. * @param {string} eventType
  9719. * The event type.
  9720. *
  9721. * @param {Function} handler
  9722. * The handler callback.
  9723. *
  9724. * @return {Highcharts.SVGElement}
  9725. * The SVGElement for chaining.
  9726. */
  9727. SVGElement.prototype.on = function (eventType, handler) {
  9728. var onEvents = this.onEvents;
  9729. if (onEvents[eventType]) {
  9730. // Unbind existing event
  9731. onEvents[eventType]();
  9732. }
  9733. onEvents[eventType] = addEvent(this.element, eventType, handler);
  9734. return this;
  9735. };
  9736. /**
  9737. * @private
  9738. * @function Highcharts.SVGElement#opacitySetter
  9739. * @param {string} value
  9740. * @param {string} key
  9741. * @param {Highcharts.SVGDOMElement} element
  9742. */
  9743. SVGElement.prototype.opacitySetter = function (value, key, element) {
  9744. // Round off to avoid float errors, like tests where opacity lands on
  9745. // 9.86957e-06 instead of 0
  9746. var opacity = Number(Number(value).toFixed(3));
  9747. this.opacity = opacity;
  9748. element.setAttribute(key, opacity);
  9749. };
  9750. /**
  9751. * Remove a class name from the element.
  9752. *
  9753. * @function Highcharts.SVGElement#removeClass
  9754. *
  9755. * @param {string|RegExp} className
  9756. * The class name to remove.
  9757. *
  9758. * @return {Highcharts.SVGElement} Returns the SVG element for chainability.
  9759. */
  9760. SVGElement.prototype.removeClass = function (className) {
  9761. return this.attr('class', ('' + this.attr('class'))
  9762. .replace(isString(className) ?
  9763. new RegExp("(^| )" + className + "( |$)") : // #12064, #13590
  9764. className, ' ')
  9765. .replace(/ +/g, ' ')
  9766. .trim());
  9767. };
  9768. /**
  9769. *
  9770. * @private
  9771. */
  9772. SVGElement.prototype.removeTextOutline = function () {
  9773. var outline = this.element
  9774. .querySelector('tspan.highcharts-text-outline');
  9775. if (outline) {
  9776. this.safeRemoveChild(outline);
  9777. }
  9778. };
  9779. /**
  9780. * Removes an element from the DOM.
  9781. *
  9782. * @private
  9783. * @function Highcharts.SVGElement#safeRemoveChild
  9784. *
  9785. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  9786. * The DOM node to remove.
  9787. */
  9788. SVGElement.prototype.safeRemoveChild = function (element) {
  9789. var parentNode = element.parentNode;
  9790. if (parentNode) {
  9791. parentNode.removeChild(element);
  9792. }
  9793. };
  9794. /**
  9795. * Set the coordinates needed to draw a consistent radial gradient across
  9796. * a shape regardless of positioning inside the chart. Used on pie slices
  9797. * to make all the slices have the same radial reference point.
  9798. *
  9799. * @function Highcharts.SVGElement#setRadialReference
  9800. *
  9801. * @param {Array<number>} coordinates
  9802. * The center reference. The format is `[centerX, centerY, diameter]` in
  9803. * pixels.
  9804. *
  9805. * @return {Highcharts.SVGElement}
  9806. * Returns the SVGElement for chaining.
  9807. */
  9808. SVGElement.prototype.setRadialReference = function (coordinates) {
  9809. var existingGradient = (this.element.gradient &&
  9810. this.renderer.gradients[this.element.gradient]);
  9811. this.element.radialReference = coordinates;
  9812. // On redrawing objects with an existing gradient, the gradient needs
  9813. // to be repositioned (#3801)
  9814. if (existingGradient && existingGradient.radAttr) {
  9815. existingGradient.animate(this.renderer.getRadialAttr(coordinates, existingGradient.radAttr));
  9816. }
  9817. return this;
  9818. };
  9819. /**
  9820. * @private
  9821. * @function Highcharts.SVGElement#setTextPath
  9822. * @param {Highcharts.SVGElement} path
  9823. * Path to follow.
  9824. * @param {Highcharts.DataLabelsTextPathOptionsObject} textPathOptions
  9825. * Options.
  9826. * @return {Highcharts.SVGElement}
  9827. * Returns the SVGElement for chaining.
  9828. */
  9829. SVGElement.prototype.setTextPath = function (path, textPathOptions) {
  9830. var elem = this.element,
  9831. textNode = this.text ? this.text.element : elem,
  9832. attribsMap = {
  9833. textAnchor: 'text-anchor'
  9834. };
  9835. var adder = false,
  9836. textPathElement,
  9837. textPathId,
  9838. textPathWrapper = this.textPathWrapper,
  9839. firstTime = !textPathWrapper;
  9840. // Defaults
  9841. textPathOptions = merge(true, {
  9842. enabled: true,
  9843. attributes: {
  9844. dy: -5,
  9845. startOffset: '50%',
  9846. textAnchor: 'middle'
  9847. }
  9848. }, textPathOptions);
  9849. var attrs = AST.filterUserAttributes(textPathOptions.attributes);
  9850. if (path && textPathOptions && textPathOptions.enabled) {
  9851. // In case of fixed width for a text, string is rebuilt
  9852. // (e.g. ellipsis is applied), so we need to rebuild textPath too
  9853. if (textPathWrapper &&
  9854. textPathWrapper.element.parentNode === null) {
  9855. // When buildText functionality was triggered again
  9856. // and deletes textPathWrapper parentNode
  9857. firstTime = true;
  9858. textPathWrapper = textPathWrapper.destroy();
  9859. }
  9860. else if (textPathWrapper) {
  9861. // Case after drillup when spans were added into
  9862. // the DOM outside the textPathWrapper parentGroup
  9863. this.removeTextOutline.call(textPathWrapper.parentGroup);
  9864. }
  9865. // label() has padding, text() doesn't
  9866. if (this.options && this.options.padding) {
  9867. attrs.dx = -this.options.padding;
  9868. }
  9869. if (!textPathWrapper) {
  9870. // Create <textPath>, defer the DOM adder
  9871. this.textPathWrapper = textPathWrapper =
  9872. this.renderer.createElement('textPath');
  9873. adder = true;
  9874. }
  9875. textPathElement = textPathWrapper.element;
  9876. // Set ID for the path
  9877. textPathId = path.element.getAttribute('id');
  9878. if (!textPathId) {
  9879. path.element.setAttribute('id', textPathId = uniqueKey());
  9880. }
  9881. // Change DOM structure, by placing <textPath> tag in <text>
  9882. if (firstTime) {
  9883. // Adjust the position
  9884. textNode.setAttribute('y', 0); // Firefox
  9885. if (isNumber(attrs.dx)) {
  9886. textNode.setAttribute('x', -attrs.dx);
  9887. }
  9888. // Move all <tspan>'s and text nodes to the <textPath> node. Do
  9889. // not move other elements like <title> or <path>
  9890. var childNodes = [].slice.call(textNode.childNodes);
  9891. for (var i = 0; i < childNodes.length; i++) {
  9892. var childNode = childNodes[i];
  9893. if (childNode.nodeType === Node.TEXT_NODE ||
  9894. childNode.nodeName === 'tspan') {
  9895. textPathElement.appendChild(childNode);
  9896. }
  9897. }
  9898. }
  9899. // Add <textPath> to the DOM
  9900. if (adder && textPathWrapper) {
  9901. textPathWrapper.add({ element: textNode });
  9902. }
  9903. // Set basic options:
  9904. // Use `setAttributeNS` because Safari needs this..
  9905. textPathElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.renderer.url + '#' + textPathId);
  9906. // Presentation attributes:
  9907. // dx/dy options must by set on <text> (parent),
  9908. // the rest should be set on <textPath>
  9909. if (defined(attrs.dy)) {
  9910. textPathElement.parentNode
  9911. .setAttribute('dy', attrs.dy);
  9912. delete attrs.dy;
  9913. }
  9914. if (defined(attrs.dx)) {
  9915. textPathElement.parentNode
  9916. .setAttribute('dx', attrs.dx);
  9917. delete attrs.dx;
  9918. }
  9919. // Additional attributes
  9920. objectEach(attrs, function (val, key) {
  9921. textPathElement.setAttribute(attribsMap[key] || key, val);
  9922. });
  9923. // Remove translation, text that follows path does not need that
  9924. elem.removeAttribute('transform');
  9925. // Remove shadows and text outlines
  9926. this.removeTextOutline.call(textPathWrapper);
  9927. // Remove background and border for label(), see #10545
  9928. // Alternatively, we can disable setting background rects in
  9929. // series.drawDataLabels()
  9930. if (this.text && !this.renderer.styledMode) {
  9931. this.attr({
  9932. fill: 'none',
  9933. 'stroke-width': 0
  9934. });
  9935. }
  9936. // Disable some functions
  9937. this.updateTransform = noop;
  9938. this.applyTextOutline = noop;
  9939. }
  9940. else if (textPathWrapper) {
  9941. // Reset to prototype
  9942. delete this.updateTransform;
  9943. delete this.applyTextOutline;
  9944. // Restore DOM structure:
  9945. this.destroyTextPath(elem, path);
  9946. // Bring attributes back
  9947. this.updateTransform();
  9948. // Set textOutline back for text()
  9949. if (this.options && this.options.rotation) {
  9950. this.applyTextOutline(this.options.style.textOutline);
  9951. }
  9952. }
  9953. return this;
  9954. };
  9955. /**
  9956. * Add a shadow to the element. Must be called after the element is added to
  9957. * the DOM. In styled mode, this method is not used, instead use `defs` and
  9958. * filters.
  9959. *
  9960. * @example
  9961. * renderer.rect(10, 100, 100, 100)
  9962. * .attr({ fill: 'red' })
  9963. * .shadow(true);
  9964. *
  9965. * @function Highcharts.SVGElement#shadow
  9966. *
  9967. * @param {boolean|Highcharts.ShadowOptionsObject} [shadowOptions]
  9968. * The shadow options. If `true`, the default options are applied. If
  9969. * `false`, the current shadow will be removed.
  9970. *
  9971. * @param {Highcharts.SVGElement} [group]
  9972. * The SVG group element where the shadows will be applied. The
  9973. * default is to add it to the same parent as the current element.
  9974. * Internally, this is ised for pie slices, where all the shadows are
  9975. * added to an element behind all the slices.
  9976. *
  9977. * @param {boolean} [cutOff]
  9978. * Used internally for column shadows.
  9979. *
  9980. * @return {Highcharts.SVGElement}
  9981. * Returns the SVGElement for chaining.
  9982. */
  9983. SVGElement.prototype.shadow = function (shadowOptions, group, cutOff) {
  9984. var shadows = [],
  9985. element = this.element,
  9986. oldShadowOptions = this.oldShadowOptions,
  9987. defaultShadowOptions = {
  9988. color: palette.neutralColor100,
  9989. offsetX: 1,
  9990. offsetY: 1,
  9991. opacity: 0.15,
  9992. width: 3
  9993. };
  9994. var i,
  9995. shadow,
  9996. strokeWidth,
  9997. shadowElementOpacity,
  9998. update = false,
  9999. // compensate for inverted plot area
  10000. transform,
  10001. options;
  10002. if (shadowOptions === true) {
  10003. options = defaultShadowOptions;
  10004. }
  10005. else if (typeof shadowOptions === 'object') {
  10006. options = extend(defaultShadowOptions, shadowOptions);
  10007. }
  10008. // Update shadow when options change (#12091).
  10009. if (options) {
  10010. // Go over each key to look for change
  10011. if (options && oldShadowOptions) {
  10012. objectEach(options, function (value, key) {
  10013. if (value !== oldShadowOptions[key]) {
  10014. update = true;
  10015. }
  10016. });
  10017. }
  10018. if (update) {
  10019. this.destroyShadows();
  10020. }
  10021. this.oldShadowOptions = options;
  10022. }
  10023. if (!options) {
  10024. this.destroyShadows();
  10025. }
  10026. else if (!this.shadows) {
  10027. shadowElementOpacity = options.opacity / options.width;
  10028. transform = this.parentInverted ?
  10029. 'translate(-1,-1)' :
  10030. "translate(" + options.offsetX + ", " + options.offsetY + ")";
  10031. for (i = 1; i <= options.width; i++) {
  10032. shadow = element.cloneNode(false);
  10033. strokeWidth = (options.width * 2) + 1 - (2 * i);
  10034. attr(shadow, {
  10035. stroke: (shadowOptions.color ||
  10036. palette.neutralColor100),
  10037. 'stroke-opacity': shadowElementOpacity * i,
  10038. 'stroke-width': strokeWidth,
  10039. transform: transform,
  10040. fill: 'none'
  10041. });
  10042. shadow.setAttribute('class', (shadow.getAttribute('class') || '') + ' highcharts-shadow');
  10043. if (cutOff) {
  10044. attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
  10045. shadow.cutHeight = strokeWidth;
  10046. }
  10047. if (group) {
  10048. group.element.appendChild(shadow);
  10049. }
  10050. else if (element.parentNode) {
  10051. element.parentNode.insertBefore(shadow, element);
  10052. }
  10053. shadows.push(shadow);
  10054. }
  10055. this.shadows = shadows;
  10056. }
  10057. return this;
  10058. };
  10059. /**
  10060. * Show the element after it has been hidden.
  10061. *
  10062. * @function Highcharts.SVGElement#show
  10063. *
  10064. * @param {boolean} [inherit=false]
  10065. * Set the visibility attribute to `inherit` rather than `visible`.
  10066. * The difference is that an element with `visibility="visible"`
  10067. * will be visible even if the parent is hidden.
  10068. *
  10069. * @return {Highcharts.SVGElement}
  10070. * Returns the SVGElement for chaining.
  10071. */
  10072. SVGElement.prototype.show = function (inherit) {
  10073. return this.attr({ visibility: inherit ? 'inherit' : 'visible' });
  10074. };
  10075. /**
  10076. * WebKit and Batik have problems with a stroke-width of zero, so in this
  10077. * case we remove the stroke attribute altogether. #1270, #1369, #3065,
  10078. * #3072.
  10079. *
  10080. * @private
  10081. * @function Highcharts.SVGElement#strokeSetter
  10082. * @param {number|string} value
  10083. * @param {string} key
  10084. * @param {Highcharts.SVGDOMElement} element
  10085. */
  10086. SVGElement.prototype.strokeSetter = function (value, key, element) {
  10087. this[key] = value;
  10088. // Only apply the stroke attribute if the stroke width is defined and
  10089. // larger than 0
  10090. if (this.stroke && this['stroke-width']) {
  10091. // Use prototype as instance may be overridden
  10092. SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element);
  10093. element.setAttribute('stroke-width', this['stroke-width']);
  10094. this.hasStroke = true;
  10095. }
  10096. else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
  10097. element.removeAttribute('stroke');
  10098. this.hasStroke = false;
  10099. }
  10100. else if (this.renderer.styledMode && this['stroke-width']) {
  10101. element.setAttribute('stroke-width', this['stroke-width']);
  10102. this.hasStroke = true;
  10103. }
  10104. };
  10105. /**
  10106. * Get the computed stroke width in pixel values. This is used extensively
  10107. * when drawing shapes to ensure the shapes are rendered crisp and
  10108. * positioned correctly relative to each other. Using
  10109. * `shape-rendering: crispEdges` leaves us less control over positioning,
  10110. * for example when we want to stack columns next to each other, or position
  10111. * things pixel-perfectly within the plot box.
  10112. *
  10113. * The common pattern when placing a shape is:
  10114. * - Create the SVGElement and add it to the DOM. In styled mode, it will
  10115. * now receive a stroke width from the style sheet. In classic mode we
  10116. * will add the `stroke-width` attribute.
  10117. * - Read the computed `elem.strokeWidth()`.
  10118. * - Place it based on the stroke width.
  10119. *
  10120. * @function Highcharts.SVGElement#strokeWidth
  10121. *
  10122. * @return {number}
  10123. * The stroke width in pixels. Even if the given stroke widtch (in CSS or by
  10124. * attributes) is based on `em` or other units, the pixel size is returned.
  10125. */
  10126. SVGElement.prototype.strokeWidth = function () {
  10127. // In non-styled mode, read the stroke width as set by .attr
  10128. if (!this.renderer.styledMode) {
  10129. return this['stroke-width'] || 0;
  10130. }
  10131. // In styled mode, read computed stroke width
  10132. var val = this.getStyle('stroke-width');
  10133. var ret = 0,
  10134. dummy;
  10135. // Read pixel values directly
  10136. if (val.indexOf('px') === val.length - 2) {
  10137. ret = pInt(val);
  10138. // Other values like em, pt etc need to be measured
  10139. }
  10140. else if (val !== '') {
  10141. dummy = doc.createElementNS(SVG_NS, 'rect');
  10142. attr(dummy, {
  10143. width: val,
  10144. 'stroke-width': 0
  10145. });
  10146. this.element.parentNode.appendChild(dummy);
  10147. ret = dummy.getBBox().width;
  10148. dummy.parentNode.removeChild(dummy);
  10149. }
  10150. return ret;
  10151. };
  10152. /**
  10153. * If one of the symbol size affecting parameters are changed,
  10154. * check all the others only once for each call to an element's
  10155. * .attr() method
  10156. *
  10157. * @private
  10158. * @function Highcharts.SVGElement#symbolAttr
  10159. *
  10160. * @param {Highcharts.SVGAttributes} hash
  10161. * The attributes to set.
  10162. */
  10163. SVGElement.prototype.symbolAttr = function (hash) {
  10164. var wrapper = this;
  10165. [
  10166. 'x',
  10167. 'y',
  10168. 'r',
  10169. 'start',
  10170. 'end',
  10171. 'width',
  10172. 'height',
  10173. 'innerR',
  10174. 'anchorX',
  10175. 'anchorY',
  10176. 'clockwise'
  10177. ].forEach(function (key) {
  10178. wrapper[key] = pick(hash[key], wrapper[key]);
  10179. });
  10180. wrapper.attr({
  10181. d: wrapper.renderer.symbols[wrapper.symbolName](wrapper.x, wrapper.y, wrapper.width, wrapper.height, wrapper)
  10182. });
  10183. };
  10184. /**
  10185. * @private
  10186. * @function Highcharts.SVGElement#textSetter
  10187. * @param {string} value
  10188. */
  10189. SVGElement.prototype.textSetter = function (value) {
  10190. if (value !== this.textStr) {
  10191. // Delete size caches when the text changes
  10192. // delete this.bBox; // old code in series-label
  10193. delete this.textPxLength;
  10194. this.textStr = value;
  10195. if (this.added) {
  10196. this.renderer.buildText(this);
  10197. }
  10198. }
  10199. };
  10200. /**
  10201. * @private
  10202. * @function Highcharts.SVGElement#titleSetter
  10203. * @param {string} value
  10204. */
  10205. SVGElement.prototype.titleSetter = function (value) {
  10206. var el = this.element;
  10207. var titleNode = el.getElementsByTagName('title')[0] ||
  10208. doc.createElementNS(this.SVG_NS, 'title');
  10209. // Move to first child
  10210. if (el.insertBefore) {
  10211. el.insertBefore(titleNode, el.firstChild);
  10212. }
  10213. else {
  10214. el.appendChild(titleNode);
  10215. }
  10216. // Replace text content and escape markup
  10217. titleNode.textContent =
  10218. // #3276, #3895
  10219. String(pick(value, ''))
  10220. .replace(/<[^>]*>/g, '')
  10221. .replace(/&lt;/g, '<')
  10222. .replace(/&gt;/g, '>');
  10223. };
  10224. /**
  10225. * Bring the element to the front. Alternatively, a new zIndex can be set.
  10226. *
  10227. * @sample highcharts/members/element-tofront/
  10228. * Click an element to bring it to front
  10229. *
  10230. * @function Highcharts.SVGElement#toFront
  10231. *
  10232. * @return {Highcharts.SVGElement}
  10233. * Returns the SVGElement for chaining.
  10234. */
  10235. SVGElement.prototype.toFront = function () {
  10236. var element = this.element;
  10237. element.parentNode.appendChild(element);
  10238. return this;
  10239. };
  10240. /**
  10241. * Move an object and its children by x and y values.
  10242. *
  10243. * @function Highcharts.SVGElement#translate
  10244. *
  10245. * @param {number} x
  10246. * The x value.
  10247. *
  10248. * @param {number} y
  10249. * The y value.
  10250. *
  10251. * @return {Highcharts.SVGElement}
  10252. */
  10253. SVGElement.prototype.translate = function (x, y) {
  10254. return this.attr({
  10255. translateX: x,
  10256. translateY: y
  10257. });
  10258. };
  10259. /**
  10260. * Update the shadow elements with new attributes.
  10261. *
  10262. * @private
  10263. * @function Highcharts.SVGElement#updateShadows
  10264. *
  10265. * @param {string} key
  10266. * The attribute name.
  10267. *
  10268. * @param {number} value
  10269. * The value of the attribute.
  10270. *
  10271. * @param {Function} setter
  10272. * The setter function, inherited from the parent wrapper.
  10273. */
  10274. SVGElement.prototype.updateShadows = function (key, value, setter) {
  10275. var shadows = this.shadows;
  10276. if (shadows) {
  10277. var i = shadows.length;
  10278. while (i--) {
  10279. setter.call(shadows[i], key === 'height' ?
  10280. Math.max(value - (shadows[i].cutHeight || 0), 0) :
  10281. key === 'd' ? this.d : value, key, shadows[i]);
  10282. }
  10283. }
  10284. };
  10285. /**
  10286. * Update the transform attribute based on internal properties. Deals with
  10287. * the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
  10288. * attributes and updates the SVG `transform` attribute.
  10289. *
  10290. * @private
  10291. * @function Highcharts.SVGElement#updateTransform
  10292. */
  10293. SVGElement.prototype.updateTransform = function () {
  10294. var wrapper = this,
  10295. scaleX = wrapper.scaleX,
  10296. scaleY = wrapper.scaleY,
  10297. inverted = wrapper.inverted,
  10298. rotation = wrapper.rotation,
  10299. matrix = wrapper.matrix,
  10300. element = wrapper.element;
  10301. var translateX = wrapper.translateX || 0,
  10302. translateY = wrapper.translateY || 0;
  10303. // Flipping affects translate as adjustment for flipping around the
  10304. // group's axis
  10305. if (inverted) {
  10306. translateX += wrapper.width;
  10307. translateY += wrapper.height;
  10308. }
  10309. // Apply translate. Nearly all transformed elements have translation,
  10310. // so instead of checking for translate = 0, do it always (#1767,
  10311. // #1846).
  10312. var transform = ['translate(' + translateX + ',' + translateY + ')'];
  10313. // apply matrix
  10314. if (defined(matrix)) {
  10315. transform.push('matrix(' + matrix.join(',') + ')');
  10316. }
  10317. // apply rotation
  10318. if (inverted) {
  10319. transform.push('rotate(90) scale(-1,1)');
  10320. }
  10321. else if (rotation) { // text rotation
  10322. transform.push('rotate(' + rotation + ' ' +
  10323. pick(this.rotationOriginX, element.getAttribute('x'), 0) +
  10324. ' ' +
  10325. pick(this.rotationOriginY, element.getAttribute('y') || 0) + ')');
  10326. }
  10327. // apply scale
  10328. if (defined(scaleX) || defined(scaleY)) {
  10329. transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
  10330. }
  10331. if (transform.length) {
  10332. element.setAttribute('transform', transform.join(' '));
  10333. }
  10334. };
  10335. /**
  10336. * @private
  10337. * @function Highcharts.SVGElement#visibilitySetter
  10338. *
  10339. * @param {string} value
  10340. *
  10341. * @param {string} key
  10342. *
  10343. * @param {Highcharts.SVGDOMElement} element
  10344. *
  10345. * @return {void}
  10346. */
  10347. SVGElement.prototype.visibilitySetter = function (value, key, element) {
  10348. // IE9-11 doesn't handle visibilty:inherit well, so we remove the
  10349. // attribute instead (#2881, #3909)
  10350. if (value === 'inherit') {
  10351. element.removeAttribute(key);
  10352. }
  10353. else if (this[key] !== value) { // #6747
  10354. element.setAttribute(key, value);
  10355. }
  10356. this[key] = value;
  10357. };
  10358. /**
  10359. * @private
  10360. * @function Highcharts.SVGElement#xGetter
  10361. *
  10362. * @param {string} key
  10363. *
  10364. * @return {number|string|null}
  10365. */
  10366. SVGElement.prototype.xGetter = function (key) {
  10367. if (this.element.nodeName === 'circle') {
  10368. if (key === 'x') {
  10369. key = 'cx';
  10370. }
  10371. else if (key === 'y') {
  10372. key = 'cy';
  10373. }
  10374. }
  10375. return this._defaultGetter(key);
  10376. };
  10377. /**
  10378. * @private
  10379. * @function Highcharts.SVGElement#zIndexSetter
  10380. * @param {number} [value]
  10381. * @param {string} [key]
  10382. * @return {boolean}
  10383. */
  10384. SVGElement.prototype.zIndexSetter = function (value, key) {
  10385. var renderer = this.renderer,
  10386. parentGroup = this.parentGroup,
  10387. parentWrapper = parentGroup || renderer,
  10388. parentNode = parentWrapper.element || renderer.box,
  10389. element = this.element,
  10390. svgParent = parentNode === renderer.box;
  10391. var childNodes,
  10392. otherElement,
  10393. otherZIndex,
  10394. inserted = false,
  10395. undefinedOtherZIndex,
  10396. run = this.added,
  10397. i;
  10398. if (defined(value)) {
  10399. // So we can read it for other elements in the group
  10400. element.setAttribute('data-z-index', value);
  10401. value = +value;
  10402. if (this[key] === value) {
  10403. // Only update when needed (#3865)
  10404. run = false;
  10405. }
  10406. }
  10407. else if (defined(this[key])) {
  10408. element.removeAttribute('data-z-index');
  10409. }
  10410. this[key] = value;
  10411. // Insert according to this and other elements' zIndex. Before .add() is
  10412. // called, nothing is done. Then on add, or by later calls to
  10413. // zIndexSetter, the node is placed on the right place in the DOM.
  10414. if (run) {
  10415. value = this.zIndex;
  10416. if (value && parentGroup) {
  10417. parentGroup.handleZ = true;
  10418. }
  10419. childNodes = parentNode.childNodes;
  10420. for (i = childNodes.length - 1; i >= 0 && !inserted; i--) {
  10421. otherElement = childNodes[i];
  10422. otherZIndex = otherElement.getAttribute('data-z-index');
  10423. undefinedOtherZIndex = !defined(otherZIndex);
  10424. if (otherElement !== element) {
  10425. if (
  10426. // Negative zIndex versus no zIndex:
  10427. // On all levels except the highest. If the parent is
  10428. // <svg>, then we don't want to put items before <desc>
  10429. // or <defs>
  10430. value < 0 &&
  10431. undefinedOtherZIndex &&
  10432. !svgParent &&
  10433. !i) {
  10434. parentNode.insertBefore(element, childNodes[i]);
  10435. inserted = true;
  10436. }
  10437. else if (
  10438. // Insert after the first element with a lower zIndex
  10439. pInt(otherZIndex) <= value ||
  10440. // If negative zIndex, add this before first undefined
  10441. // zIndex element
  10442. (undefinedOtherZIndex &&
  10443. (!defined(value) || value >= 0))) {
  10444. parentNode.insertBefore(element, childNodes[i + 1] || null // null for oldIE export
  10445. );
  10446. inserted = true;
  10447. }
  10448. }
  10449. }
  10450. if (!inserted) {
  10451. parentNode.insertBefore(element, childNodes[svgParent ? 3 : 0] || null // null for oldIE
  10452. );
  10453. inserted = true;
  10454. }
  10455. }
  10456. return inserted;
  10457. };
  10458. return SVGElement;
  10459. }());
  10460. // Some shared setters and getters
  10461. SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter;
  10462. SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
  10463. SVGElement.prototype.matrixSetter =
  10464. SVGElement.prototype.rotationOriginXSetter =
  10465. SVGElement.prototype.rotationOriginYSetter =
  10466. SVGElement.prototype.rotationSetter =
  10467. SVGElement.prototype.scaleXSetter =
  10468. SVGElement.prototype.scaleYSetter =
  10469. SVGElement.prototype.translateXSetter =
  10470. SVGElement.prototype.translateYSetter =
  10471. SVGElement.prototype.verticalAlignSetter = function (value, key) {
  10472. this[key] = value;
  10473. this.doTransform = true;
  10474. };
  10475. /* *
  10476. *
  10477. * API Declarations
  10478. *
  10479. * */
  10480. /**
  10481. * Reference to the global SVGElement class as a workaround for a name conflict
  10482. * in the Highcharts namespace.
  10483. *
  10484. * @global
  10485. * @typedef {global.SVGElement} GlobalSVGElement
  10486. *
  10487. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10488. */
  10489. /**
  10490. * The horizontal alignment of an element.
  10491. *
  10492. * @typedef {"center"|"left"|"right"} Highcharts.AlignValue
  10493. */
  10494. /**
  10495. * Options to align the element relative to the chart or another box.
  10496. *
  10497. * @interface Highcharts.AlignObject
  10498. */ /**
  10499. * Horizontal alignment. Can be one of `left`, `center` and `right`.
  10500. *
  10501. * @name Highcharts.AlignObject#align
  10502. * @type {Highcharts.AlignValue|undefined}
  10503. *
  10504. * @default left
  10505. */ /**
  10506. * Vertical alignment. Can be one of `top`, `middle` and `bottom`.
  10507. *
  10508. * @name Highcharts.AlignObject#verticalAlign
  10509. * @type {Highcharts.VerticalAlignValue|undefined}
  10510. *
  10511. * @default top
  10512. */ /**
  10513. * Horizontal pixel offset from alignment.
  10514. *
  10515. * @name Highcharts.AlignObject#x
  10516. * @type {number|undefined}
  10517. *
  10518. * @default 0
  10519. */ /**
  10520. * Vertical pixel offset from alignment.
  10521. *
  10522. * @name Highcharts.AlignObject#y
  10523. * @type {number|undefined}
  10524. *
  10525. * @default 0
  10526. */ /**
  10527. * Use the `transform` attribute with translateX and translateY custom
  10528. * attributes to align this elements rather than `x` and `y` attributes.
  10529. *
  10530. * @name Highcharts.AlignObject#alignByTranslate
  10531. * @type {boolean|undefined}
  10532. *
  10533. * @default false
  10534. */
  10535. /**
  10536. * Bounding box of an element.
  10537. *
  10538. * @interface Highcharts.BBoxObject
  10539. * @extends Highcharts.PositionObject
  10540. */ /**
  10541. * Height of the bounding box.
  10542. *
  10543. * @name Highcharts.BBoxObject#height
  10544. * @type {number}
  10545. */ /**
  10546. * Width of the bounding box.
  10547. *
  10548. * @name Highcharts.BBoxObject#width
  10549. * @type {number}
  10550. */ /**
  10551. * Horizontal position of the bounding box.
  10552. *
  10553. * @name Highcharts.BBoxObject#x
  10554. * @type {number}
  10555. */ /**
  10556. * Vertical position of the bounding box.
  10557. *
  10558. * @name Highcharts.BBoxObject#y
  10559. * @type {number}
  10560. */
  10561. /**
  10562. * An object of key-value pairs for SVG attributes. Attributes in Highcharts
  10563. * elements for the most parts correspond to SVG, but some are specific to
  10564. * Highcharts, like `zIndex`, `rotation`, `rotationOriginX`,
  10565. * `rotationOriginY`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
  10566. * attributes containing a hyphen are _not_ camel-cased, they should be
  10567. * quoted to preserve the hyphen.
  10568. *
  10569. * @example
  10570. * {
  10571. * 'stroke': '#ff0000', // basic
  10572. * 'stroke-width': 2, // hyphenated
  10573. * 'rotation': 45 // custom
  10574. * 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
  10575. * }
  10576. *
  10577. * @interface Highcharts.SVGAttributes
  10578. */ /**
  10579. * @name Highcharts.SVGAttributes#[key:string]
  10580. * @type {*}
  10581. */ /**
  10582. * @name Highcharts.SVGAttributes#d
  10583. * @type {string|Highcharts.SVGPathArray|undefined}
  10584. */ /**
  10585. * @name Highcharts.SVGAttributes#fill
  10586. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10587. */ /**
  10588. * @name Highcharts.SVGAttributes#inverted
  10589. * @type {boolean|undefined}
  10590. */ /**
  10591. * @name Highcharts.SVGAttributes#matrix
  10592. * @type {Array<number>|undefined}
  10593. */ /**
  10594. * @name Highcharts.SVGAttributes#rotation
  10595. * @type {number|undefined}
  10596. */ /**
  10597. * @name Highcharts.SVGAttributes#rotationOriginX
  10598. * @type {number|undefined}
  10599. */ /**
  10600. * @name Highcharts.SVGAttributes#rotationOriginY
  10601. * @type {number|undefined}
  10602. */ /**
  10603. * @name Highcharts.SVGAttributes#scaleX
  10604. * @type {number|undefined}
  10605. */ /**
  10606. * @name Highcharts.SVGAttributes#scaleY
  10607. * @type {number|undefined}
  10608. */ /**
  10609. * @name Highcharts.SVGAttributes#stroke
  10610. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10611. */ /**
  10612. * @name Highcharts.SVGAttributes#style
  10613. * @type {string|Highcharts.CSSObject|undefined}
  10614. */ /**
  10615. * @name Highcharts.SVGAttributes#translateX
  10616. * @type {number|undefined}
  10617. */ /**
  10618. * @name Highcharts.SVGAttributes#translateY
  10619. * @type {number|undefined}
  10620. */ /**
  10621. * @name Highcharts.SVGAttributes#zIndex
  10622. * @type {number|undefined}
  10623. */
  10624. /**
  10625. * An SVG DOM element. The type is a reference to the regular SVGElement in the
  10626. * global scope.
  10627. *
  10628. * @typedef {globals.GlobalSVGElement} Highcharts.SVGDOMElement
  10629. *
  10630. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10631. */
  10632. /**
  10633. * The vertical alignment of an element.
  10634. *
  10635. * @typedef {"bottom"|"middle"|"top"} Highcharts.VerticalAlignValue
  10636. */
  10637. ''; // detach doclets above
  10638. return SVGElement;
  10639. });
  10640. _registerModule(_modules, 'Core/Renderer/SVG/SVGLabel.js', [_modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (SVGElement, U) {
  10641. /* *
  10642. *
  10643. * (c) 2010-2021 Torstein Honsi
  10644. *
  10645. * License: www.highcharts.com/license
  10646. *
  10647. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10648. *
  10649. * */
  10650. var __extends = (this && this.__extends) || (function () {
  10651. var extendStatics = function (d,
  10652. b) {
  10653. extendStatics = Object.setPrototypeOf ||
  10654. ({ __proto__: [] } instanceof Array && function (d,
  10655. b) { d.__proto__ = b; }) ||
  10656. function (d,
  10657. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10658. return extendStatics(d, b);
  10659. };
  10660. return function (d, b) {
  10661. extendStatics(d, b);
  10662. function __() { this.constructor = d; }
  10663. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10664. };
  10665. })();
  10666. var defined = U.defined,
  10667. extend = U.extend,
  10668. isNumber = U.isNumber,
  10669. merge = U.merge,
  10670. pick = U.pick,
  10671. removeEvent = U.removeEvent;
  10672. /* eslint require-jsdoc: 0, no-invalid-this: 0 */
  10673. function paddingSetter(value, key) {
  10674. if (!isNumber(value)) {
  10675. this[key] = void 0;
  10676. }
  10677. else if (value !== this[key]) {
  10678. this[key] = value;
  10679. this.updateTextPadding();
  10680. }
  10681. }
  10682. /**
  10683. * SVG label to render text.
  10684. * @private
  10685. * @class
  10686. * @name Highcharts.SVGLabel
  10687. * @augments Highcharts.SVGElement
  10688. */
  10689. var SVGLabel = /** @class */ (function (_super) {
  10690. __extends(SVGLabel, _super);
  10691. /* *
  10692. *
  10693. * Constructors
  10694. *
  10695. * */
  10696. function SVGLabel(renderer, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  10697. var _this = _super.call(this) || this;
  10698. _this.paddingSetter = paddingSetter;
  10699. _this.paddingLeftSetter = paddingSetter;
  10700. _this.paddingRightSetter = paddingSetter;
  10701. _this.init(renderer, 'g');
  10702. _this.textStr = str;
  10703. _this.x = x;
  10704. _this.y = y;
  10705. _this.anchorX = anchorX;
  10706. _this.anchorY = anchorY;
  10707. _this.baseline = baseline;
  10708. _this.className = className;
  10709. if (className !== 'button') {
  10710. _this.addClass('highcharts-label');
  10711. }
  10712. if (className) {
  10713. _this.addClass('highcharts-' + className);
  10714. }
  10715. _this.text = renderer.text('', 0, 0, useHTML).attr({ zIndex: 1 });
  10716. // Validate the shape argument
  10717. var hasBGImage;
  10718. if (typeof shape === 'string') {
  10719. hasBGImage = /^url\((.*?)\)$/.test(shape);
  10720. if (_this.renderer.symbols[shape] || hasBGImage) {
  10721. _this.symbolKey = shape;
  10722. }
  10723. }
  10724. _this.bBox = SVGLabel.emptyBBox;
  10725. _this.padding = 3;
  10726. _this.baselineOffset = 0;
  10727. _this.needsBox = renderer.styledMode || hasBGImage;
  10728. _this.deferredAttr = {};
  10729. _this.alignFactor = 0;
  10730. return _this;
  10731. }
  10732. /* *
  10733. *
  10734. * Functions
  10735. *
  10736. * */
  10737. SVGLabel.prototype.alignSetter = function (value) {
  10738. var alignFactor = ({
  10739. left: 0,
  10740. center: 0.5,
  10741. right: 1
  10742. })[value];
  10743. if (alignFactor !== this.alignFactor) {
  10744. this.alignFactor = alignFactor;
  10745. // Bounding box exists, means we're dynamically changing
  10746. if (this.bBox && isNumber(this.xSetting)) {
  10747. this.attr({ x: this.xSetting }); // #5134
  10748. }
  10749. }
  10750. };
  10751. SVGLabel.prototype.anchorXSetter = function (value, key) {
  10752. this.anchorX = value;
  10753. this.boxAttr(key, Math.round(value) - this.getCrispAdjust() - this.xSetting);
  10754. };
  10755. SVGLabel.prototype.anchorYSetter = function (value, key) {
  10756. this.anchorY = value;
  10757. this.boxAttr(key, value - this.ySetting);
  10758. };
  10759. /*
  10760. * Set a box attribute, or defer it if the box is not yet created
  10761. */
  10762. SVGLabel.prototype.boxAttr = function (key, value) {
  10763. if (this.box) {
  10764. this.box.attr(key, value);
  10765. }
  10766. else {
  10767. this.deferredAttr[key] = value;
  10768. }
  10769. };
  10770. /*
  10771. * Pick up some properties and apply them to the text instead of the
  10772. * wrapper.
  10773. */
  10774. SVGLabel.prototype.css = function (styles) {
  10775. if (styles) {
  10776. var textStyles_1 = {},
  10777. isWidth = void 0,
  10778. isFontStyle = void 0;
  10779. // Create a copy to avoid altering the original object
  10780. // (#537)
  10781. styles = merge(styles);
  10782. SVGLabel.textProps.forEach(function (prop) {
  10783. if (typeof styles[prop] !== 'undefined') {
  10784. textStyles_1[prop] = styles[prop];
  10785. delete styles[prop];
  10786. }
  10787. });
  10788. this.text.css(textStyles_1);
  10789. isWidth = 'width' in textStyles_1;
  10790. isFontStyle = 'fontSize' in textStyles_1 ||
  10791. 'fontWeight' in textStyles_1;
  10792. // Update existing text, box (#9400, #12163)
  10793. if (isFontStyle) {
  10794. this.updateTextPadding();
  10795. }
  10796. else if (isWidth) {
  10797. this.updateBoxSize();
  10798. }
  10799. }
  10800. return SVGElement.prototype.css.call(this, styles);
  10801. };
  10802. /*
  10803. * Destroy and release memory.
  10804. */
  10805. SVGLabel.prototype.destroy = function () {
  10806. // Added by button implementation
  10807. removeEvent(this.element, 'mouseenter');
  10808. removeEvent(this.element, 'mouseleave');
  10809. if (this.text) {
  10810. this.text.destroy();
  10811. }
  10812. if (this.box) {
  10813. this.box = this.box.destroy();
  10814. }
  10815. // Call base implementation to destroy the rest
  10816. SVGElement.prototype.destroy.call(this);
  10817. return void 0;
  10818. };
  10819. SVGLabel.prototype.fillSetter = function (value, key) {
  10820. if (value) {
  10821. this.needsBox = true;
  10822. }
  10823. // for animation getter (#6776)
  10824. this.fill = value;
  10825. this.boxAttr(key, value);
  10826. };
  10827. /*
  10828. * Return the bounding box of the box, not the group.
  10829. */
  10830. SVGLabel.prototype.getBBox = function () {
  10831. // If we have a text string and the DOM bBox was 0, it typically means
  10832. // that the label was first rendered hidden, so we need to update the
  10833. // bBox (#15246)
  10834. if (this.textStr && this.bBox.width === 0 && this.bBox.height === 0) {
  10835. this.updateBoxSize();
  10836. }
  10837. var padding = this.padding;
  10838. var paddingLeft = pick(this.paddingLeft,
  10839. padding);
  10840. return {
  10841. width: this.width,
  10842. height: this.height,
  10843. x: this.bBox.x - paddingLeft,
  10844. y: this.bBox.y - padding
  10845. };
  10846. };
  10847. SVGLabel.prototype.getCrispAdjust = function () {
  10848. return this.renderer.styledMode && this.box ?
  10849. this.box.strokeWidth() % 2 / 2 :
  10850. (this['stroke-width'] ? parseInt(this['stroke-width'], 10) : 0) % 2 / 2;
  10851. };
  10852. SVGLabel.prototype.heightSetter = function (value) {
  10853. this.heightSetting = value;
  10854. };
  10855. // Event handling. In case of useHTML, we need to make sure that events
  10856. // are captured on the span as well, and that mouseenter/mouseleave
  10857. // between the SVG group and the HTML span are not treated as real
  10858. // enter/leave events. #13310.
  10859. SVGLabel.prototype.on = function (eventType, handler) {
  10860. var label = this;
  10861. var text = label.text;
  10862. var span = text && text.element.tagName === 'SPAN' ? text : void 0;
  10863. var selectiveHandler;
  10864. if (span) {
  10865. selectiveHandler = function (e) {
  10866. if ((eventType === 'mouseenter' ||
  10867. eventType === 'mouseleave') &&
  10868. e.relatedTarget instanceof Element &&
  10869. (
  10870. // #14110
  10871. label.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY ||
  10872. span.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY)) {
  10873. return;
  10874. }
  10875. handler.call(label.element, e);
  10876. };
  10877. span.on(eventType, selectiveHandler);
  10878. }
  10879. SVGElement.prototype.on.call(label, eventType, selectiveHandler || handler);
  10880. return label;
  10881. };
  10882. /*
  10883. * After the text element is added, get the desired size of the border
  10884. * box and add it before the text in the DOM.
  10885. */
  10886. SVGLabel.prototype.onAdd = function () {
  10887. var str = this.textStr;
  10888. this.text.add(this);
  10889. this.attr({
  10890. // Alignment is available now (#3295, 0 not rendered if given
  10891. // as a value)
  10892. text: (defined(str) ? str : ''),
  10893. x: this.x,
  10894. y: this.y
  10895. });
  10896. if (this.box && defined(this.anchorX)) {
  10897. this.attr({
  10898. anchorX: this.anchorX,
  10899. anchorY: this.anchorY
  10900. });
  10901. }
  10902. };
  10903. SVGLabel.prototype.rSetter = function (value, key) {
  10904. this.boxAttr(key, value);
  10905. };
  10906. SVGLabel.prototype.shadow = function (b) {
  10907. if (b && !this.renderer.styledMode) {
  10908. this.updateBoxSize();
  10909. if (this.box) {
  10910. this.box.shadow(b);
  10911. }
  10912. }
  10913. return this;
  10914. };
  10915. SVGLabel.prototype.strokeSetter = function (value, key) {
  10916. // for animation getter (#6776)
  10917. this.stroke = value;
  10918. this.boxAttr(key, value);
  10919. };
  10920. SVGLabel.prototype['stroke-widthSetter'] = function (value, key) {
  10921. if (value) {
  10922. this.needsBox = true;
  10923. }
  10924. this['stroke-width'] = value;
  10925. this.boxAttr(key, value);
  10926. };
  10927. SVGLabel.prototype['text-alignSetter'] = function (value) {
  10928. this.textAlign = value;
  10929. };
  10930. SVGLabel.prototype.textSetter = function (text) {
  10931. if (typeof text !== 'undefined') {
  10932. // Must use .attr to ensure transforms are done (#10009)
  10933. this.text.attr({ text: text });
  10934. }
  10935. this.updateTextPadding();
  10936. };
  10937. /*
  10938. * This function runs after the label is added to the DOM (when the bounding
  10939. * box is available), and after the text of the label is updated to detect
  10940. * the new bounding box and reflect it in the border box.
  10941. */
  10942. SVGLabel.prototype.updateBoxSize = function () {
  10943. var style = this.text.element.style,
  10944. crispAdjust,
  10945. attribs = {};
  10946. var padding = this.padding;
  10947. // #12165 error when width is null (auto)
  10948. // #12163 when fontweight: bold, recalculate bBox withot cache
  10949. // #3295 && 3514 box failure when string equals 0
  10950. var bBox = this.bBox = ((!isNumber(this.widthSetting) || !isNumber(this.heightSetting) || this.textAlign) &&
  10951. defined(this.text.textStr)) ?
  10952. this.text.getBBox() : SVGLabel.emptyBBox;
  10953. this.width = this.getPaddedWidth();
  10954. this.height = (this.heightSetting || bBox.height || 0) + 2 * padding;
  10955. // Update the label-scoped y offset. Math.min because of inline
  10956. // style (#9400)
  10957. this.baselineOffset = padding + Math.min(this.renderer.fontMetrics(style && style.fontSize, this.text).b,
  10958. // When the height is 0, there is no bBox, so go with the font
  10959. // metrics. Highmaps CSS demos.
  10960. bBox.height || Infinity);
  10961. if (this.needsBox) {
  10962. // Create the border box if it is not already present
  10963. if (!this.box) {
  10964. // Symbol definition exists (#5324)
  10965. var box = this.box = this.symbolKey ?
  10966. this.renderer.symbol(this.symbolKey) :
  10967. this.renderer.rect();
  10968. box.addClass(// Don't use label className for buttons
  10969. (this.className === 'button' ? '' : 'highcharts-label-box') +
  10970. (this.className ? ' highcharts-' + this.className + '-box' : ''));
  10971. box.add(this);
  10972. }
  10973. crispAdjust = this.getCrispAdjust();
  10974. attribs.x = crispAdjust;
  10975. attribs.y = (this.baseline ? -this.baselineOffset : 0) + crispAdjust;
  10976. // Apply the box attributes
  10977. attribs.width = Math.round(this.width);
  10978. attribs.height = Math.round(this.height);
  10979. this.box.attr(extend(attribs, this.deferredAttr));
  10980. this.deferredAttr = {};
  10981. }
  10982. };
  10983. /*
  10984. * This function runs after setting text or padding, but only if padding
  10985. * is changed.
  10986. */
  10987. SVGLabel.prototype.updateTextPadding = function () {
  10988. var text = this.text;
  10989. this.updateBoxSize();
  10990. // Determine y based on the baseline
  10991. var textY = this.baseline ? 0 : this.baselineOffset;
  10992. var textX = pick(this.paddingLeft,
  10993. this.padding);
  10994. // compensate for alignment
  10995. if (defined(this.widthSetting) &&
  10996. this.bBox &&
  10997. (this.textAlign === 'center' || this.textAlign === 'right')) {
  10998. textX += { center: 0.5, right: 1 }[this.textAlign] *
  10999. (this.widthSetting - this.bBox.width);
  11000. }
  11001. // update if anything changed
  11002. if (textX !== text.x || textY !== text.y) {
  11003. text.attr('x', textX);
  11004. // #8159 - prevent misplaced data labels in treemap
  11005. // (useHTML: true)
  11006. if (text.hasBoxWidthChanged) {
  11007. this.bBox = text.getBBox(true);
  11008. }
  11009. if (typeof textY !== 'undefined') {
  11010. text.attr('y', textY);
  11011. }
  11012. }
  11013. // record current values
  11014. text.x = textX;
  11015. text.y = textY;
  11016. };
  11017. SVGLabel.prototype.widthSetter = function (value) {
  11018. // width:auto => null
  11019. this.widthSetting = isNumber(value) ? value : void 0;
  11020. };
  11021. SVGLabel.prototype.getPaddedWidth = function () {
  11022. var padding = this.padding;
  11023. var paddingLeft = pick(this.paddingLeft,
  11024. padding);
  11025. var paddingRight = pick(this.paddingRight,
  11026. padding);
  11027. return (this.widthSetting || this.bBox.width || 0) + paddingLeft + paddingRight;
  11028. };
  11029. SVGLabel.prototype.xSetter = function (value) {
  11030. this.x = value; // for animation getter
  11031. if (this.alignFactor) {
  11032. value -= this.alignFactor * this.getPaddedWidth();
  11033. // Force animation even when setting to the same value (#7898)
  11034. this['forceAnimate:x'] = true;
  11035. }
  11036. this.xSetting = Math.round(value);
  11037. this.attr('translateX', this.xSetting);
  11038. };
  11039. SVGLabel.prototype.ySetter = function (value) {
  11040. this.ySetting = this.y = Math.round(value);
  11041. this.attr('translateY', this.ySetting);
  11042. };
  11043. /* *
  11044. *
  11045. * Static Properties
  11046. *
  11047. * */
  11048. SVGLabel.emptyBBox = { width: 0, height: 0, x: 0, y: 0 };
  11049. /**
  11050. * For labels, these CSS properties are applied to the `text` node directly.
  11051. *
  11052. * @private
  11053. * @name Highcharts.SVGLabel#textProps
  11054. * @type {Array<string>}
  11055. */
  11056. SVGLabel.textProps = [
  11057. 'color', 'direction', 'fontFamily', 'fontSize', 'fontStyle',
  11058. 'fontWeight', 'lineHeight', 'textAlign', 'textDecoration',
  11059. 'textOutline', 'textOverflow', 'width'
  11060. ];
  11061. return SVGLabel;
  11062. }(SVGElement));
  11063. return SVGLabel;
  11064. });
  11065. _registerModule(_modules, 'Core/Renderer/SVG/TextBuilder.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Core/Renderer/HTML/AST.js']], function (H, U, AST) {
  11066. /* *
  11067. *
  11068. * (c) 2010-2020 Torstein Honsi
  11069. *
  11070. * License: www.highcharts.com/license
  11071. *
  11072. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11073. *
  11074. * */
  11075. var doc = H.doc,
  11076. SVG_NS = H.SVG_NS;
  11077. var attr = U.attr,
  11078. erase = U.erase,
  11079. isString = U.isString,
  11080. objectEach = U.objectEach,
  11081. pick = U.pick;
  11082. /**
  11083. * SVG Text Builder
  11084. * @private
  11085. * @class
  11086. * @name Highcharts.TextBuilder
  11087. */
  11088. var TextBuilder = /** @class */ (function () {
  11089. function TextBuilder(svgElement) {
  11090. var textStyles = svgElement.styles;
  11091. this.renderer = svgElement.renderer;
  11092. this.svgElement = svgElement;
  11093. this.width = svgElement.textWidth;
  11094. this.textLineHeight = textStyles && textStyles.lineHeight;
  11095. this.textOutline = textStyles && textStyles.textOutline;
  11096. this.ellipsis = Boolean(textStyles && textStyles.textOverflow === 'ellipsis');
  11097. this.noWrap = Boolean(textStyles && textStyles.whiteSpace === 'nowrap');
  11098. this.fontSize = textStyles && textStyles.fontSize;
  11099. }
  11100. /**
  11101. * Build an SVG representation of the pseudo HTML given in the object's
  11102. * svgElement.
  11103. *
  11104. * @private
  11105. *
  11106. * @return {void}.
  11107. */
  11108. TextBuilder.prototype.buildSVG = function () {
  11109. var wrapper = this.svgElement;
  11110. 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;
  11111. var regexMatchBreaks = /<br.*?>/g;
  11112. // The buildText code is quite heavy, so if we're not changing something
  11113. // that affects the text, skip it (#6113).
  11114. textCache = [
  11115. textStr,
  11116. this.ellipsis,
  11117. this.noWrap,
  11118. this.textLineHeight,
  11119. this.textOutline,
  11120. this.fontSize,
  11121. this.width
  11122. ].join(',');
  11123. if (textCache === wrapper.textCache) {
  11124. return;
  11125. }
  11126. wrapper.textCache = textCache;
  11127. delete wrapper.actualWidth;
  11128. // Remove old text
  11129. while (i--) {
  11130. textNode.removeChild(childNodes[i]);
  11131. }
  11132. // Simple strings, add text directly and return
  11133. if (!hasMarkup &&
  11134. !this.ellipsis &&
  11135. !this.width &&
  11136. (textStr.indexOf(' ') === -1 ||
  11137. (this.noWrap && !regexMatchBreaks.test(textStr)))) {
  11138. textNode.appendChild(doc.createTextNode(this.unescapeEntities(textStr)));
  11139. // Complex strings, add more logic
  11140. }
  11141. else if (textStr !== '') {
  11142. if (tempParent) {
  11143. // attach it to the DOM to read offset width
  11144. tempParent.appendChild(textNode);
  11145. }
  11146. // Step 1. Parse the markup safely and directly into a tree
  11147. // structure.
  11148. var ast = new AST(textStr);
  11149. // Step 2. Do as many as we can of the modifications to the tree
  11150. // structure before it is added to the DOM
  11151. this.modifyTree(ast.nodes);
  11152. ast.addToDOM(wrapper.element);
  11153. // Step 3. Some modifications can't be done until the structure is
  11154. // in the DOM, because we need to read computed metrics.
  11155. this.modifyDOM();
  11156. // Add title if an ellipsis was added
  11157. if (this.ellipsis &&
  11158. (textNode.textContent || '').indexOf('\u2026') !== -1) {
  11159. wrapper.attr('title', this.unescapeEntities(wrapper.textStr || '', ['&lt;', '&gt;']) // #7179
  11160. );
  11161. }
  11162. if (tempParent) {
  11163. tempParent.removeChild(textNode);
  11164. }
  11165. }
  11166. // Apply the text outline
  11167. if (isString(this.textOutline) && wrapper.applyTextOutline) {
  11168. wrapper.applyTextOutline(this.textOutline);
  11169. }
  11170. };
  11171. /**
  11172. * Modify the DOM of the generated SVG structure. This function only does
  11173. * operations that cannot be done until the elements are attached to the
  11174. * DOM, like doing layout based on rendered metrics of the added elements.
  11175. *
  11176. * @private
  11177. *
  11178. * @return {void}
  11179. */
  11180. TextBuilder.prototype.modifyDOM = function () {
  11181. var _this = this;
  11182. var wrapper = this.svgElement;
  11183. var x = attr(wrapper.element, 'x');
  11184. // Modify hard line breaks by applying the rendered line height
  11185. [].forEach.call(wrapper.element.querySelectorAll('tspan.highcharts-br'), function (br) {
  11186. if (br.nextSibling && br.previousSibling) { // #5261
  11187. attr(br, {
  11188. // Since the break is inserted in front of the next
  11189. // line, we need to use the next sibling for the line
  11190. // height
  11191. dy: _this.getLineHeight(br.nextSibling),
  11192. x: x
  11193. });
  11194. }
  11195. });
  11196. // Constrain the line width, either by ellipsis or wrapping
  11197. var width = this.width || 0;
  11198. if (!width) {
  11199. return;
  11200. }
  11201. // Insert soft line breaks into each text node
  11202. var modifyTextNode = function (textNode,
  11203. parentElement) {
  11204. var text = textNode.textContent || '';
  11205. var words = text
  11206. .replace(/([^\^])-/g, '$1- ') // Split on hyphens
  11207. // .trim()
  11208. .split(' '); // #1273
  11209. var hasWhiteSpace = !_this.noWrap && (words.length > 1 || wrapper.element.childNodes.length > 1);
  11210. var dy = _this.getLineHeight(parentElement);
  11211. var lineNo = 0;
  11212. var startAt = wrapper.actualWidth;
  11213. if (_this.ellipsis) {
  11214. if (text) {
  11215. _this.truncate(textNode, text, void 0, 0,
  11216. // Target width
  11217. Math.max(0,
  11218. // Substract the font face to make room for the
  11219. // ellipsis itself
  11220. width - parseInt(_this.fontSize || 12, 10)),
  11221. // Build the text to test for
  11222. function (text, currentIndex) {
  11223. return text.substring(0, currentIndex) + '\u2026';
  11224. });
  11225. }
  11226. }
  11227. else if (hasWhiteSpace) {
  11228. var lines = [];
  11229. // Remove preceding siblings in order to make the text length
  11230. // calculation correct in the truncate function
  11231. var precedingSiblings = [];
  11232. while (parentElement.firstChild &&
  11233. parentElement.firstChild !== textNode) {
  11234. precedingSiblings.push(parentElement.firstChild);
  11235. parentElement.removeChild(parentElement.firstChild);
  11236. }
  11237. while (words.length) {
  11238. // Apply the previous line
  11239. if (words.length && !_this.noWrap && lineNo > 0) {
  11240. lines.push(textNode.textContent || '');
  11241. textNode.textContent = words.join(' ')
  11242. .replace(/- /g, '-');
  11243. }
  11244. // For each line, truncate the remaining
  11245. // words into the line length.
  11246. _this.truncate(textNode, void 0, words, lineNo === 0 ? (startAt || 0) : 0, width,
  11247. // Build the text to test for
  11248. function (t, currentIndex) {
  11249. return words
  11250. .slice(0, currentIndex)
  11251. .join(' ')
  11252. .replace(/- /g, '-');
  11253. });
  11254. startAt = wrapper.actualWidth;
  11255. lineNo++;
  11256. }
  11257. // Reinsert the preceding child nodes
  11258. precedingSiblings.forEach(function (childNode) {
  11259. parentElement.insertBefore(childNode, textNode);
  11260. });
  11261. // Insert the previous lines before the original text node
  11262. lines.forEach(function (line) {
  11263. // Insert the line
  11264. parentElement.insertBefore(doc.createTextNode(line), textNode);
  11265. // Insert a break
  11266. var br = doc.createElementNS(SVG_NS, 'tspan');
  11267. br.textContent = '\u200B'; // zero-width space
  11268. attr(br, { dy: dy, x: x });
  11269. parentElement.insertBefore(br, textNode);
  11270. });
  11271. }
  11272. };
  11273. // Recurse down the DOM tree and handle line breaks for each text node
  11274. var modifyChildren = (function (node) {
  11275. var childNodes = [].slice.call(node.childNodes);
  11276. childNodes.forEach(function (childNode) {
  11277. if (childNode.nodeType === Node.TEXT_NODE) {
  11278. modifyTextNode(childNode, node);
  11279. }
  11280. else {
  11281. // Reset word-wrap width readings after hard breaks
  11282. if (childNode.className.baseVal
  11283. .indexOf('highcharts-br') !== -1) {
  11284. wrapper.actualWidth = 0;
  11285. }
  11286. // Recurse down to child node
  11287. modifyChildren(childNode);
  11288. }
  11289. });
  11290. });
  11291. modifyChildren(wrapper.element);
  11292. };
  11293. /**
  11294. * Get the rendered line height of a <text>, <tspan> or pure text node.
  11295. *
  11296. * @param {DOMElementType|Text} node The node to check for
  11297. *
  11298. * @return {number} The rendered line height
  11299. */
  11300. TextBuilder.prototype.getLineHeight = function (node) {
  11301. var fontSizeStyle;
  11302. // If the node is a text node, use its parent
  11303. var element = node.nodeType === Node.TEXT_NODE ?
  11304. node.parentElement :
  11305. node;
  11306. if (!this.renderer.styledMode) {
  11307. fontSizeStyle =
  11308. element && /(px|em)$/.test(element.style.fontSize) ?
  11309. element.style.fontSize :
  11310. (this.fontSize || this.renderer.style.fontSize || 12);
  11311. }
  11312. return this.textLineHeight ?
  11313. parseInt(this.textLineHeight.toString(), 10) :
  11314. this.renderer.fontMetrics(fontSizeStyle, element || this.svgElement.element).h;
  11315. };
  11316. /**
  11317. * Transform a pseudo HTML AST node tree into an SVG structure. We do as
  11318. * much heavy lifting as we can here, before doing the final processing in
  11319. * the modifyDOM function. The original data is mutated.
  11320. *
  11321. * @private
  11322. *
  11323. * @param {ASTNode[]} nodes The AST nodes
  11324. *
  11325. * @return {void}
  11326. */
  11327. TextBuilder.prototype.modifyTree = function (nodes) {
  11328. var _this = this;
  11329. var modifyChild = function (node,
  11330. i) {
  11331. var tagName = node.tagName;
  11332. var styledMode = _this.renderer.styledMode;
  11333. var attributes = node.attributes || {};
  11334. // Apply styling to text tags
  11335. if (tagName === 'b' || tagName === 'strong') {
  11336. if (styledMode) {
  11337. attributes['class'] = 'highcharts-strong'; // eslint-disable-line dot-notation
  11338. }
  11339. else {
  11340. attributes.style = 'font-weight:bold;' + (attributes.style || '');
  11341. }
  11342. }
  11343. else if (tagName === 'i' || tagName === 'em') {
  11344. if (styledMode) {
  11345. attributes['class'] = 'highcharts-emphasized'; // eslint-disable-line dot-notation
  11346. }
  11347. else {
  11348. attributes.style = 'font-style:italic;' + (attributes.style || '');
  11349. }
  11350. }
  11351. // Modify attributes
  11352. if (isString(attributes.style)) {
  11353. attributes.style = attributes.style.replace(/(;| |^)color([ :])/, '$1fill$2');
  11354. }
  11355. if (tagName === 'br') {
  11356. attributes['class'] = 'highcharts-br'; // eslint-disable-line dot-notation
  11357. node.textContent = '\u200B'; // zero-width space
  11358. // Trim whitespace off the beginning of new lines
  11359. var nextNode = nodes[i + 1];
  11360. if (nextNode && nextNode.textContent) {
  11361. nextNode.textContent =
  11362. nextNode.textContent.replace(/^ +/gm, '');
  11363. }
  11364. }
  11365. if (tagName !== '#text' && tagName !== 'a') {
  11366. node.tagName = 'tspan';
  11367. }
  11368. node.attributes = attributes;
  11369. // Recurse
  11370. if (node.children) {
  11371. node.children
  11372. .filter(function (c) { return c.tagName !== '#text'; })
  11373. .forEach(modifyChild);
  11374. }
  11375. };
  11376. nodes.forEach(modifyChild);
  11377. // Remove empty spans from the beginning because SVG's getBBox doesn't
  11378. // count empty lines. The use case is tooltip where the header is empty.
  11379. while (nodes[0]) {
  11380. if (nodes[0].tagName === 'tspan' && !nodes[0].children) {
  11381. nodes.splice(0, 1);
  11382. }
  11383. else {
  11384. break;
  11385. }
  11386. }
  11387. };
  11388. /*
  11389. * Truncate the text node contents to a given length. Used when the css
  11390. * width is set. If the `textOverflow` is `ellipsis`, the text is truncated
  11391. * character by character to the given length. If not, the text is
  11392. * word-wrapped line by line.
  11393. */
  11394. TextBuilder.prototype.truncate = function (textNode, text, words, startAt, width, getString) {
  11395. var svgElement = this.svgElement;
  11396. var renderer = svgElement.renderer,
  11397. rotation = svgElement.rotation;
  11398. // Cache the lengths to avoid checking the same twice
  11399. var lengths = [];
  11400. // Word wrap can not be truncated to shorter than one word, ellipsis
  11401. // text can be completely blank.
  11402. var minIndex = words ? 1 : 0;
  11403. var maxIndex = (text || words || '').length;
  11404. var currentIndex = maxIndex;
  11405. var str;
  11406. var actualWidth;
  11407. var getSubStringLength = function (charEnd,
  11408. concatenatedEnd) {
  11409. // charEnd is used when finding the character-by-character
  11410. // break for ellipsis, concatenatedEnd is used for word-by-word
  11411. // break for word wrapping.
  11412. var end = concatenatedEnd || charEnd;
  11413. var parentNode = textNode.parentNode;
  11414. if (parentNode && typeof lengths[end] === 'undefined') {
  11415. // Modern browsers
  11416. if (parentNode.getSubStringLength) {
  11417. // Fails with DOM exception on unit-tests/legend/members
  11418. // of unknown reason. Desired width is 0, text content
  11419. // is "5" and end is 1.
  11420. try {
  11421. lengths[end] = startAt +
  11422. parentNode.getSubStringLength(0, words ? end + 1 : end);
  11423. }
  11424. catch (e) {
  11425. '';
  11426. }
  11427. // Legacy
  11428. }
  11429. else if (renderer.getSpanWidth) { // #9058 jsdom
  11430. textNode.textContent = getString(text || words, charEnd);
  11431. lengths[end] = startAt +
  11432. renderer.getSpanWidth(svgElement, textNode);
  11433. }
  11434. }
  11435. return lengths[end];
  11436. };
  11437. svgElement.rotation = 0; // discard rotation when computing box
  11438. actualWidth = getSubStringLength(textNode.textContent.length);
  11439. if (startAt + actualWidth > width) {
  11440. // Do a binary search for the index where to truncate the text
  11441. while (minIndex <= maxIndex) {
  11442. currentIndex = Math.ceil((minIndex + maxIndex) / 2);
  11443. // When checking words for word-wrap, we need to build the
  11444. // string and measure the subStringLength at the concatenated
  11445. // word length.
  11446. if (words) {
  11447. str = getString(words, currentIndex);
  11448. }
  11449. actualWidth = getSubStringLength(currentIndex, str && str.length - 1);
  11450. if (minIndex === maxIndex) {
  11451. // Complete
  11452. minIndex = maxIndex + 1;
  11453. }
  11454. else if (actualWidth > width) {
  11455. // Too large. Set max index to current.
  11456. maxIndex = currentIndex - 1;
  11457. }
  11458. else {
  11459. // Within width. Set min index to current.
  11460. minIndex = currentIndex;
  11461. }
  11462. }
  11463. // If max index was 0 it means the shortest possible text was also
  11464. // too large. For ellipsis that means only the ellipsis, while for
  11465. // word wrap it means the whole first word.
  11466. if (maxIndex === 0) {
  11467. // Remove ellipsis
  11468. textNode.textContent = '';
  11469. // If the new text length is one less than the original, we don't
  11470. // need the ellipsis
  11471. }
  11472. else if (!(text && maxIndex === text.length - 1)) {
  11473. textNode.textContent = str || getString(text || words, currentIndex);
  11474. }
  11475. }
  11476. // When doing line wrapping, prepare for the next line by removing the
  11477. // items from this line.
  11478. if (words) {
  11479. words.splice(0, currentIndex);
  11480. }
  11481. svgElement.actualWidth = actualWidth;
  11482. svgElement.rotation = rotation; // Apply rotation again.
  11483. };
  11484. /*
  11485. * Un-escape HTML entities based on the public `renderer.escapes` list
  11486. *
  11487. * @private
  11488. *
  11489. * @param {string} inputStr The string to unescape
  11490. * @param {Array<string>} [except] Exceptions
  11491. *
  11492. * @return {string} The processed string
  11493. */
  11494. TextBuilder.prototype.unescapeEntities = function (inputStr, except) {
  11495. objectEach(this.renderer.escapes, function (value, key) {
  11496. if (!except || except.indexOf(value) === -1) {
  11497. inputStr = inputStr.toString().replace(new RegExp(value, 'g'), key);
  11498. }
  11499. });
  11500. return inputStr;
  11501. };
  11502. return TextBuilder;
  11503. }());
  11504. return TextBuilder;
  11505. });
  11506. _registerModule(_modules, 'Core/Renderer/SVG/SVGRenderer.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGLabel.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/Renderer/SVG/TextBuilder.js'], _modules['Core/Utilities.js']], function (Color, H, palette, SVGElement, SVGLabel, AST, TextBuilder, U) {
  11507. /* *
  11508. *
  11509. * (c) 2010-2021 Torstein Honsi
  11510. *
  11511. * License: www.highcharts.com/license
  11512. *
  11513. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11514. *
  11515. * */
  11516. var addEvent = U.addEvent,
  11517. attr = U.attr,
  11518. createElement = U.createElement,
  11519. css = U.css,
  11520. defined = U.defined,
  11521. destroyObjectProperties = U.destroyObjectProperties,
  11522. extend = U.extend,
  11523. isArray = U.isArray,
  11524. isNumber = U.isNumber,
  11525. isObject = U.isObject,
  11526. isString = U.isString,
  11527. merge = U.merge,
  11528. pick = U.pick,
  11529. pInt = U.pInt,
  11530. uniqueKey = U.uniqueKey;
  11531. /**
  11532. * A clipping rectangle that can be applied to one or more {@link SVGElement}
  11533. * instances. It is instanciated with the {@link SVGRenderer#clipRect} function
  11534. * and applied with the {@link SVGElement#clip} function.
  11535. *
  11536. * @example
  11537. * let circle = renderer.circle(100, 100, 100)
  11538. * .attr({ fill: 'red' })
  11539. * .add();
  11540. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  11541. *
  11542. * // Leave only the lower right quarter visible
  11543. * circle.clip(clipRect);
  11544. *
  11545. * @typedef {Highcharts.SVGElement} Highcharts.ClipRectElement
  11546. */
  11547. /**
  11548. * The font metrics.
  11549. *
  11550. * @interface Highcharts.FontMetricsObject
  11551. */ /**
  11552. * The baseline relative to the top of the box.
  11553. *
  11554. * @name Highcharts.FontMetricsObject#b
  11555. * @type {number}
  11556. */ /**
  11557. * The font size.
  11558. *
  11559. * @name Highcharts.FontMetricsObject#f
  11560. * @type {number}
  11561. */ /**
  11562. * The line height.
  11563. *
  11564. * @name Highcharts.FontMetricsObject#h
  11565. * @type {number}
  11566. */
  11567. /**
  11568. * An object containing `x` and `y` properties for the position of an element.
  11569. *
  11570. * @interface Highcharts.PositionObject
  11571. */ /**
  11572. * X position of the element.
  11573. * @name Highcharts.PositionObject#x
  11574. * @type {number}
  11575. */ /**
  11576. * Y position of the element.
  11577. * @name Highcharts.PositionObject#y
  11578. * @type {number}
  11579. */
  11580. /**
  11581. * A rectangle.
  11582. *
  11583. * @interface Highcharts.RectangleObject
  11584. */ /**
  11585. * Height of the rectangle.
  11586. * @name Highcharts.RectangleObject#height
  11587. * @type {number}
  11588. */ /**
  11589. * Width of the rectangle.
  11590. * @name Highcharts.RectangleObject#width
  11591. * @type {number}
  11592. */ /**
  11593. * Horizontal position of the rectangle.
  11594. * @name Highcharts.RectangleObject#x
  11595. * @type {number}
  11596. */ /**
  11597. * Vertical position of the rectangle.
  11598. * @name Highcharts.RectangleObject#y
  11599. * @type {number}
  11600. */
  11601. /**
  11602. * The shadow options.
  11603. *
  11604. * @interface Highcharts.ShadowOptionsObject
  11605. */ /**
  11606. * The shadow color.
  11607. * @name Highcharts.ShadowOptionsObject#color
  11608. * @type {Highcharts.ColorString|undefined}
  11609. * @default ${palette.neutralColor100}
  11610. */ /**
  11611. * The horizontal offset from the element.
  11612. *
  11613. * @name Highcharts.ShadowOptionsObject#offsetX
  11614. * @type {number|undefined}
  11615. * @default 1
  11616. */ /**
  11617. * The vertical offset from the element.
  11618. * @name Highcharts.ShadowOptionsObject#offsetY
  11619. * @type {number|undefined}
  11620. * @default 1
  11621. */ /**
  11622. * The shadow opacity.
  11623. *
  11624. * @name Highcharts.ShadowOptionsObject#opacity
  11625. * @type {number|undefined}
  11626. * @default 0.15
  11627. */ /**
  11628. * The shadow width or distance from the element.
  11629. * @name Highcharts.ShadowOptionsObject#width
  11630. * @type {number|undefined}
  11631. * @default 3
  11632. */
  11633. /**
  11634. * @interface Highcharts.SizeObject
  11635. */ /**
  11636. * @name Highcharts.SizeObject#height
  11637. * @type {number}
  11638. */ /**
  11639. * @name Highcharts.SizeObject#width
  11640. * @type {number}
  11641. */
  11642. /**
  11643. * Array of path commands, that will go into the `d` attribute of an SVG
  11644. * element.
  11645. *
  11646. * @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
  11647. */
  11648. /**
  11649. * Possible path commands in an SVG path array. Valid values are `A`, `C`, `H`,
  11650. * `L`, `M`, `Q`, `S`, `T`, `V`, `Z`.
  11651. *
  11652. * @typedef {string} Highcharts.SVGPathCommand
  11653. * @validvalue ["a","c","h","l","m","q","s","t","v","z","A","C","H","L","M","Q","S","T","V","Z"]
  11654. */
  11655. /**
  11656. * An extendable collection of functions for defining symbol paths. Symbols are
  11657. * used internally for point markers, button and label borders and backgrounds,
  11658. * or custom shapes. Extendable by adding to {@link SVGRenderer#symbols}.
  11659. *
  11660. * @interface Highcharts.SymbolDictionary
  11661. */ /**
  11662. * @name Highcharts.SymbolDictionary#[key:string]
  11663. * @type {Function|undefined}
  11664. */ /**
  11665. * @name Highcharts.SymbolDictionary#arc
  11666. * @type {Function|undefined}
  11667. */ /**
  11668. * @name Highcharts.SymbolDictionary#callout
  11669. * @type {Function|undefined}
  11670. */ /**
  11671. * @name Highcharts.SymbolDictionary#circle
  11672. * @type {Function|undefined}
  11673. */ /**
  11674. * @name Highcharts.SymbolDictionary#diamond
  11675. * @type {Function|undefined}
  11676. */ /**
  11677. * @name Highcharts.SymbolDictionary#square
  11678. * @type {Function|undefined}
  11679. */ /**
  11680. * @name Highcharts.SymbolDictionary#triangle
  11681. * @type {Function|undefined}
  11682. */
  11683. /**
  11684. * Can be one of `arc`, `callout`, `circle`, `diamond`, `square`, `triangle`,
  11685. * and `triangle-down`. Symbols are used internally for point markers, button
  11686. * and label borders and backgrounds, or custom shapes. Extendable by adding to
  11687. * {@link SVGRenderer#symbols}.
  11688. *
  11689. * @typedef {"arc"|"callout"|"circle"|"diamond"|"square"|"triangle"|"triangle-down"} Highcharts.SymbolKeyValue
  11690. */
  11691. /**
  11692. * Additional options, depending on the actual symbol drawn.
  11693. *
  11694. * @interface Highcharts.SymbolOptionsObject
  11695. */ /**
  11696. * The anchor X position for the `callout` symbol. This is where the chevron
  11697. * points to.
  11698. *
  11699. * @name Highcharts.SymbolOptionsObject#anchorX
  11700. * @type {number|undefined}
  11701. */ /**
  11702. * The anchor Y position for the `callout` symbol. This is where the chevron
  11703. * points to.
  11704. *
  11705. * @name Highcharts.SymbolOptionsObject#anchorY
  11706. * @type {number|undefined}
  11707. */ /**
  11708. * The end angle of an `arc` symbol.
  11709. *
  11710. * @name Highcharts.SymbolOptionsObject#end
  11711. * @type {number|undefined}
  11712. */ /**
  11713. * Whether to draw `arc` symbol open or closed.
  11714. *
  11715. * @name Highcharts.SymbolOptionsObject#open
  11716. * @type {boolean|undefined}
  11717. */ /**
  11718. * The radius of an `arc` symbol, or the border radius for the `callout` symbol.
  11719. *
  11720. * @name Highcharts.SymbolOptionsObject#r
  11721. * @type {number|undefined}
  11722. */ /**
  11723. * The start angle of an `arc` symbol.
  11724. *
  11725. * @name Highcharts.SymbolOptionsObject#start
  11726. * @type {number|undefined}
  11727. */
  11728. /* eslint-disable no-invalid-this, valid-jsdoc */
  11729. var charts = H.charts,
  11730. deg2rad = H.deg2rad,
  11731. doc = H.doc,
  11732. isFirefox = H.isFirefox,
  11733. isMS = H.isMS,
  11734. isWebKit = H.isWebKit,
  11735. noop = H.noop,
  11736. SVG_NS = H.SVG_NS,
  11737. symbolSizes = H.symbolSizes,
  11738. win = H.win,
  11739. hasInternalReferenceBug;
  11740. /**
  11741. * Allows direct access to the Highcharts rendering layer in order to draw
  11742. * primitive shapes like circles, rectangles, paths or text directly on a chart,
  11743. * or independent from any chart. The SVGRenderer represents a wrapper object
  11744. * for SVG in modern browsers. Through the VMLRenderer, part of the `oldie.js`
  11745. * module, it also brings vector graphics to IE <= 8.
  11746. *
  11747. * An existing chart's renderer can be accessed through {@link Chart.renderer}.
  11748. * The renderer can also be used completely decoupled from a chart.
  11749. *
  11750. * @sample highcharts/members/renderer-on-chart
  11751. * Annotating a chart programmatically.
  11752. * @sample highcharts/members/renderer-basic
  11753. * Independent SVG drawing.
  11754. *
  11755. * @example
  11756. * // Use directly without a chart object.
  11757. * let renderer = new Highcharts.Renderer(parentNode, 600, 400);
  11758. *
  11759. * @class
  11760. * @name Highcharts.SVGRenderer
  11761. *
  11762. * @param {Highcharts.HTMLDOMElement} container
  11763. * Where to put the SVG in the web page.
  11764. *
  11765. * @param {number} width
  11766. * The width of the SVG.
  11767. *
  11768. * @param {number} height
  11769. * The height of the SVG.
  11770. *
  11771. * @param {Highcharts.CSSObject} [style]
  11772. * The box style, if not in styleMode
  11773. *
  11774. * @param {boolean} [forExport=false]
  11775. * Whether the rendered content is intended for export.
  11776. *
  11777. * @param {boolean} [allowHTML=true]
  11778. * Whether the renderer is allowed to include HTML text, which will be
  11779. * projected on top of the SVG.
  11780. *
  11781. * @param {boolean} [styledMode=false]
  11782. * Whether the renderer belongs to a chart that is in styled mode.
  11783. * If it does, it will avoid setting presentational attributes in
  11784. * some cases, but not when set explicitly through `.attr` and `.css`
  11785. * etc.
  11786. */
  11787. var SVGRenderer = /** @class */ (function () {
  11788. /* *
  11789. *
  11790. * Constructors
  11791. *
  11792. * */
  11793. function SVGRenderer(container, width, height, style, forExport, allowHTML, styledMode) {
  11794. /* *
  11795. *
  11796. * Properties
  11797. *
  11798. * */
  11799. this.alignedObjects = void 0;
  11800. /**
  11801. * The root `svg` node of the renderer.
  11802. *
  11803. * @name Highcharts.SVGRenderer#box
  11804. * @type {Highcharts.SVGDOMElement}
  11805. */
  11806. this.box = void 0;
  11807. /**
  11808. * The wrapper for the root `svg` node of the renderer.
  11809. *
  11810. * @name Highcharts.SVGRenderer#boxWrapper
  11811. * @type {Highcharts.SVGElement}
  11812. */
  11813. this.boxWrapper = void 0;
  11814. this.cache = void 0;
  11815. this.cacheKeys = void 0;
  11816. this.chartIndex = void 0;
  11817. /**
  11818. * A pointer to the `defs` node of the root SVG.
  11819. *
  11820. * @name Highcharts.SVGRenderer#defs
  11821. * @type {Highcharts.SVGElement}
  11822. */
  11823. this.defs = void 0;
  11824. this.globalAnimation = void 0;
  11825. this.gradients = void 0;
  11826. this.height = void 0;
  11827. this.imgCount = void 0;
  11828. this.isSVG = void 0;
  11829. this.style = void 0;
  11830. /**
  11831. * Page url used for internal references.
  11832. *
  11833. * @private
  11834. * @name Highcharts.SVGRenderer#url
  11835. * @type {string}
  11836. */
  11837. this.url = void 0;
  11838. this.width = void 0;
  11839. this.init(container, width, height, style, forExport, allowHTML, styledMode);
  11840. }
  11841. /* *
  11842. *
  11843. * Functions
  11844. *
  11845. * */
  11846. /**
  11847. * Initialize the SVGRenderer. Overridable initializer function that takes
  11848. * the same parameters as the constructor.
  11849. *
  11850. * @function Highcharts.SVGRenderer#init
  11851. *
  11852. * @param {Highcharts.HTMLDOMElement} container
  11853. * Where to put the SVG in the web page.
  11854. *
  11855. * @param {number} width
  11856. * The width of the SVG.
  11857. *
  11858. * @param {number} height
  11859. * The height of the SVG.
  11860. *
  11861. * @param {Highcharts.CSSObject} [style]
  11862. * The box style, if not in styleMode
  11863. *
  11864. * @param {boolean} [forExport=false]
  11865. * Whether the rendered content is intended for export.
  11866. *
  11867. * @param {boolean} [allowHTML=true]
  11868. * Whether the renderer is allowed to include HTML text, which will be
  11869. * projected on top of the SVG.
  11870. *
  11871. * @param {boolean} [styledMode=false]
  11872. * Whether the renderer belongs to a chart that is in styled mode. If it
  11873. * does, it will avoid setting presentational attributes in some cases, but
  11874. * not when set explicitly through `.attr` and `.css` etc.
  11875. */
  11876. SVGRenderer.prototype.init = function (container, width, height, style, forExport, allowHTML, styledMode) {
  11877. var renderer = this,
  11878. boxWrapper,
  11879. element,
  11880. desc;
  11881. boxWrapper = renderer.createElement('svg')
  11882. .attr({
  11883. version: '1.1',
  11884. 'class': 'highcharts-root'
  11885. });
  11886. if (!styledMode) {
  11887. boxWrapper.css(this.getStyle(style));
  11888. }
  11889. element = boxWrapper.element;
  11890. container.appendChild(element);
  11891. // Always use ltr on the container, otherwise text-anchor will be
  11892. // flipped and text appear outside labels, buttons, tooltip etc (#3482)
  11893. attr(container, 'dir', 'ltr');
  11894. // For browsers other than IE, add the namespace attribute (#1978)
  11895. if (container.innerHTML.indexOf('xmlns') === -1) {
  11896. attr(element, 'xmlns', this.SVG_NS);
  11897. }
  11898. // object properties
  11899. renderer.isSVG = true;
  11900. this.box = element;
  11901. this.boxWrapper = boxWrapper;
  11902. renderer.alignedObjects = [];
  11903. this.url = this.getReferenceURL();
  11904. // Add description
  11905. desc = this.createElement('desc').add();
  11906. desc.element.appendChild(doc.createTextNode('Created with Highcharts 9.1.0'));
  11907. renderer.defs = this.createElement('defs').add();
  11908. renderer.allowHTML = allowHTML;
  11909. renderer.forExport = forExport;
  11910. renderer.styledMode = styledMode;
  11911. renderer.gradients = {}; // Object where gradient SvgElements are stored
  11912. renderer.cache = {}; // Cache for numerical bounding boxes
  11913. renderer.cacheKeys = [];
  11914. renderer.imgCount = 0;
  11915. renderer.setSize(width, height, false);
  11916. // Issue 110 workaround:
  11917. // In Firefox, if a div is positioned by percentage, its pixel position
  11918. // may land between pixels. The container itself doesn't display this,
  11919. // but an SVG element inside this container will be drawn at subpixel
  11920. // precision. In order to draw sharp lines, this must be compensated
  11921. // for. This doesn't seem to work inside iframes though (like in
  11922. // jsFiddle).
  11923. var subPixelFix,
  11924. rect;
  11925. if (isFirefox && container.getBoundingClientRect) {
  11926. subPixelFix = function () {
  11927. css(container, { left: 0, top: 0 });
  11928. rect = container.getBoundingClientRect();
  11929. css(container, {
  11930. left: (Math.ceil(rect.left) - rect.left) + 'px',
  11931. top: (Math.ceil(rect.top) - rect.top) + 'px'
  11932. });
  11933. };
  11934. // run the fix now
  11935. subPixelFix();
  11936. // run it on resize
  11937. renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
  11938. }
  11939. };
  11940. /**
  11941. * General method for adding a definition to the SVG `defs` tag. Can be used
  11942. * for gradients, fills, filters etc. Styled mode only. A hook for adding
  11943. * general definitions to the SVG's defs tag. Definitions can be referenced
  11944. * from the CSS by its `id`. Read more in
  11945. * [gradients, shadows and patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns).
  11946. * Styled mode only.
  11947. *
  11948. * @function Highcharts.SVGRenderer#definition
  11949. *
  11950. * @param {Highcharts.ASTNode} def
  11951. * A serialized form of an SVG definition, including children.
  11952. *
  11953. * @return {Highcharts.SVGElement}
  11954. * The inserted node.
  11955. */
  11956. SVGRenderer.prototype.definition = function (def) {
  11957. var ast = new AST([def]);
  11958. return ast.addToDOM(this.defs.element);
  11959. };
  11960. /**
  11961. * Get the prefix needed for internal URL references to work in certain
  11962. * cases. Some older browser versions had a bug where internal url
  11963. * references in SVG attributes, on the form `url(#some-id)`, would fail if
  11964. * a base tag was present in the page. There were also issues with
  11965. * `history.pushState` related to this prefix.
  11966. *
  11967. * Related issues: #24, #672, #1070, #5244.
  11968. *
  11969. * The affected browsers are:
  11970. * - Chrome <= 53 (May 2018)
  11971. * - Firefox <= 51 (January 2017)
  11972. * - Safari/Mac <= 12.1 (2018 or 2019)
  11973. * - Safari/iOS <= 13
  11974. *
  11975. * @todo Remove this hack when time has passed. All the affected browsers
  11976. * are evergreens, so it is increasingly unlikely that users are affected by
  11977. * the bug.
  11978. *
  11979. * @return {string}
  11980. * The prefix to use. An empty string for modern browsers.
  11981. */
  11982. SVGRenderer.prototype.getReferenceURL = function () {
  11983. if ((isFirefox || isWebKit) &&
  11984. doc.getElementsByTagName('base').length) {
  11985. // Detect if a clip path is taking effect by performing a hit test
  11986. // outside the clipped area. If the hit element is the rectangle
  11987. // that was supposed to be clipped, the bug is present. This only
  11988. // has to be performed once per page load, so we store the result
  11989. // locally in the module.
  11990. if (!defined(hasInternalReferenceBug)) {
  11991. var id = uniqueKey();
  11992. var ast = new AST([{
  11993. tagName: 'svg',
  11994. attributes: {
  11995. width: 8,
  11996. height: 8
  11997. },
  11998. children: [{
  11999. tagName: 'defs',
  12000. children: [{
  12001. tagName: 'clipPath',
  12002. attributes: {
  12003. id: id
  12004. },
  12005. children: [{
  12006. tagName: 'rect',
  12007. attributes: {
  12008. width: 4,
  12009. height: 4
  12010. }
  12011. }]
  12012. }]
  12013. }, {
  12014. tagName: 'rect',
  12015. attributes: {
  12016. id: 'hitme',
  12017. width: 8,
  12018. height: 8,
  12019. 'clip-path': "url(#" + id + ")",
  12020. fill: 'rgba(0,0,0,0.001)'
  12021. }
  12022. }]
  12023. }]);
  12024. var svg = ast.addToDOM(doc.body);
  12025. css(svg, {
  12026. position: 'fixed',
  12027. top: 0,
  12028. left: 0,
  12029. zIndex: 9e5
  12030. });
  12031. var hitElement = doc.elementFromPoint(6, 6);
  12032. hasInternalReferenceBug =
  12033. (hitElement && hitElement.id) === 'hitme';
  12034. doc.body.removeChild(svg);
  12035. }
  12036. if (hasInternalReferenceBug) {
  12037. return win.location.href
  12038. .split('#')[0] // remove the hash
  12039. .replace(/<[^>]*>/g, '') // wing cut HTML
  12040. // escape parantheses and quotes
  12041. .replace(/([\('\)])/g, '\\$1')
  12042. // replace spaces (needed for Safari only)
  12043. .replace(/ /g, '%20');
  12044. }
  12045. }
  12046. return '';
  12047. };
  12048. /**
  12049. * Get the global style setting for the renderer.
  12050. *
  12051. * @private
  12052. * @function Highcharts.SVGRenderer#getStyle
  12053. *
  12054. * @param {Highcharts.CSSObject} style
  12055. * Style settings.
  12056. *
  12057. * @return {Highcharts.CSSObject}
  12058. * The style settings mixed with defaults.
  12059. */
  12060. SVGRenderer.prototype.getStyle = function (style) {
  12061. this.style = extend({
  12062. fontFamily: '"Lucida Grande", "Lucida Sans Unicode", ' +
  12063. 'Arial, Helvetica, sans-serif',
  12064. fontSize: '12px'
  12065. }, style);
  12066. return this.style;
  12067. };
  12068. /**
  12069. * Apply the global style on the renderer, mixed with the default styles.
  12070. *
  12071. * @function Highcharts.SVGRenderer#setStyle
  12072. *
  12073. * @param {Highcharts.CSSObject} style
  12074. * CSS to apply.
  12075. */
  12076. SVGRenderer.prototype.setStyle = function (style) {
  12077. this.boxWrapper.css(this.getStyle(style));
  12078. };
  12079. /**
  12080. * Detect whether the renderer is hidden. This happens when one of the
  12081. * parent elements has `display: none`. Used internally to detect when we
  12082. * needto render preliminarily in another div to get the text bounding boxes
  12083. * right.
  12084. *
  12085. * @function Highcharts.SVGRenderer#isHidden
  12086. *
  12087. * @return {boolean}
  12088. * True if it is hidden.
  12089. */
  12090. SVGRenderer.prototype.isHidden = function () {
  12091. return !this.boxWrapper.getBBox().width;
  12092. };
  12093. /**
  12094. * Destroys the renderer and its allocated members.
  12095. *
  12096. * @function Highcharts.SVGRenderer#destroy
  12097. *
  12098. * @return {null}
  12099. */
  12100. SVGRenderer.prototype.destroy = function () {
  12101. var renderer = this,
  12102. rendererDefs = renderer.defs;
  12103. renderer.box = null;
  12104. renderer.boxWrapper = renderer.boxWrapper.destroy();
  12105. // Call destroy on all gradient elements
  12106. destroyObjectProperties(renderer.gradients || {});
  12107. renderer.gradients = null;
  12108. // Defs are null in VMLRenderer
  12109. // Otherwise, destroy them here.
  12110. if (rendererDefs) {
  12111. renderer.defs = rendererDefs.destroy();
  12112. }
  12113. // Remove sub pixel fix handler (#982)
  12114. if (renderer.unSubPixelFix) {
  12115. renderer.unSubPixelFix();
  12116. }
  12117. renderer.alignedObjects = null;
  12118. return null;
  12119. };
  12120. /**
  12121. * Create a wrapper for an SVG element. Serves as a factory for
  12122. * {@link SVGElement}, but this function is itself mostly called from
  12123. * primitive factories like {@link SVGRenderer#path}, {@link
  12124. * SVGRenderer#rect} or {@link SVGRenderer#text}.
  12125. *
  12126. * @function Highcharts.SVGRenderer#createElement
  12127. *
  12128. * @param {string} nodeName
  12129. * The node name, for example `rect`, `g` etc.
  12130. *
  12131. * @return {Highcharts.SVGElement}
  12132. * The generated SVGElement.
  12133. */
  12134. SVGRenderer.prototype.createElement = function (nodeName) {
  12135. var wrapper = new this.Element();
  12136. wrapper.init(this, nodeName);
  12137. return wrapper;
  12138. };
  12139. /**
  12140. * Get converted radial gradient attributes according to the radial
  12141. * reference. Used internally from the {@link SVGElement#colorGradient}
  12142. * function.
  12143. *
  12144. * @private
  12145. * @function Highcharts.SVGRenderer#getRadialAttr
  12146. */
  12147. SVGRenderer.prototype.getRadialAttr = function (radialReference, gradAttr) {
  12148. return {
  12149. cx: (radialReference[0] - radialReference[2] / 2) +
  12150. (gradAttr.cx || 0) * radialReference[2],
  12151. cy: (radialReference[1] - radialReference[2] / 2) +
  12152. (gradAttr.cy || 0) * radialReference[2],
  12153. r: (gradAttr.r || 0) * radialReference[2]
  12154. };
  12155. };
  12156. /**
  12157. * Parse a simple HTML string into SVG tspans. Called internally when text
  12158. * is set on an SVGElement. The function supports a subset of HTML tags, CSS
  12159. * text features like `width`, `text-overflow`, `white-space`, and also
  12160. * attributes like `href` and `style`.
  12161. *
  12162. * @private
  12163. * @function Highcharts.SVGRenderer#buildText
  12164. *
  12165. * @param {Highcharts.SVGElement} wrapper
  12166. * The parent SVGElement.
  12167. */
  12168. SVGRenderer.prototype.buildText = function (wrapper) {
  12169. new TextBuilder(wrapper).buildSVG();
  12170. };
  12171. /**
  12172. * Returns white for dark colors and black for bright colors.
  12173. *
  12174. * @function Highcharts.SVGRenderer#getContrast
  12175. *
  12176. * @param {Highcharts.ColorString} rgba
  12177. * The color to get the contrast for.
  12178. *
  12179. * @return {Highcharts.ColorString}
  12180. * The contrast color, either `#000000` or `#FFFFFF`.
  12181. */
  12182. SVGRenderer.prototype.getContrast = function (rgba) {
  12183. rgba = Color.parse(rgba).rgba;
  12184. // The threshold may be discussed. Here's a proposal for adding
  12185. // different weight to the color channels (#6216)
  12186. rgba[0] *= 1; // red
  12187. rgba[1] *= 1.2; // green
  12188. rgba[2] *= 0.5; // blue
  12189. return rgba[0] + rgba[1] + rgba[2] >
  12190. 1.8 * 255 ?
  12191. '#000000' :
  12192. '#FFFFFF';
  12193. };
  12194. /**
  12195. * Create a button with preset states.
  12196. *
  12197. * @function Highcharts.SVGRenderer#button
  12198. *
  12199. * @param {string} text
  12200. * The text or HTML to draw.
  12201. *
  12202. * @param {number} x
  12203. * The x position of the button's left side.
  12204. *
  12205. * @param {number} y
  12206. * The y position of the button's top side.
  12207. *
  12208. * @param {Highcharts.EventCallbackFunction<Highcharts.SVGElement>} callback
  12209. * The function to execute on button click or touch.
  12210. *
  12211. * @param {Highcharts.SVGAttributes} [theme]
  12212. * SVG attributes for the normal state.
  12213. *
  12214. * @param {Highcharts.SVGAttributes} [hoverState]
  12215. * SVG attributes for the hover state.
  12216. *
  12217. * @param {Highcharts.SVGAttributes} [pressedState]
  12218. * SVG attributes for the pressed state.
  12219. *
  12220. * @param {Highcharts.SVGAttributes} [disabledState]
  12221. * SVG attributes for the disabled state.
  12222. *
  12223. * @param {Highcharts.SymbolKeyValue} [shape=rect]
  12224. * The shape type.
  12225. *
  12226. * @param {boolean} [useHTML=false]
  12227. * Wether to use HTML to render the label.
  12228. *
  12229. * @return {Highcharts.SVGElement}
  12230. * The button element.
  12231. */
  12232. SVGRenderer.prototype.button = function (text, x, y, callback, theme, hoverState, pressedState, disabledState, shape, useHTML) {
  12233. var label = this.label(text,
  12234. x,
  12235. y,
  12236. shape,
  12237. void 0,
  12238. void 0,
  12239. useHTML,
  12240. void 0, 'button'),
  12241. curState = 0,
  12242. styledMode = this.styledMode,
  12243. // Make a copy of normalState (#13798)
  12244. // (reference to options.rangeSelector.buttonTheme)
  12245. normalState = theme ? merge(theme) : {},
  12246. userNormalStyle = normalState && normalState.style || {};
  12247. // Remove stylable attributes
  12248. normalState = AST.filterUserAttributes(normalState);
  12249. // Default, non-stylable attributes
  12250. label.attr(merge({ padding: 8, r: 2 }, normalState));
  12251. // Presentational
  12252. var normalStyle,
  12253. hoverStyle,
  12254. pressedStyle,
  12255. disabledStyle;
  12256. if (!styledMode) {
  12257. // Normal state - prepare the attributes
  12258. normalState = merge({
  12259. fill: palette.neutralColor3,
  12260. stroke: palette.neutralColor20,
  12261. 'stroke-width': 1,
  12262. style: {
  12263. color: palette.neutralColor80,
  12264. cursor: 'pointer',
  12265. fontWeight: 'normal'
  12266. }
  12267. }, {
  12268. style: userNormalStyle
  12269. }, normalState);
  12270. normalStyle = normalState.style;
  12271. delete normalState.style;
  12272. // Hover state
  12273. hoverState = merge(normalState, {
  12274. fill: palette.neutralColor10
  12275. }, AST.filterUserAttributes(hoverState || {}));
  12276. hoverStyle = hoverState.style;
  12277. delete hoverState.style;
  12278. // Pressed state
  12279. pressedState = merge(normalState, {
  12280. fill: palette.highlightColor10,
  12281. style: {
  12282. color: palette.neutralColor100,
  12283. fontWeight: 'bold'
  12284. }
  12285. }, AST.filterUserAttributes(pressedState || {}));
  12286. pressedStyle = pressedState.style;
  12287. delete pressedState.style;
  12288. // Disabled state
  12289. disabledState = merge(normalState, {
  12290. style: {
  12291. color: palette.neutralColor20
  12292. }
  12293. }, AST.filterUserAttributes(disabledState || {}));
  12294. disabledStyle = disabledState.style;
  12295. delete disabledState.style;
  12296. }
  12297. // Add the events. IE9 and IE10 need mouseover and mouseout to funciton
  12298. // (#667).
  12299. addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function () {
  12300. if (curState !== 3) {
  12301. label.setState(1);
  12302. }
  12303. });
  12304. addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function () {
  12305. if (curState !== 3) {
  12306. label.setState(curState);
  12307. }
  12308. });
  12309. label.setState = function (state) {
  12310. // Hover state is temporary, don't record it
  12311. if (state !== 1) {
  12312. label.state = curState = state;
  12313. }
  12314. // Update visuals
  12315. label
  12316. .removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
  12317. .addClass('highcharts-button-' +
  12318. ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
  12319. if (!styledMode) {
  12320. label
  12321. .attr([
  12322. normalState,
  12323. hoverState,
  12324. pressedState,
  12325. disabledState
  12326. ][state || 0])
  12327. .css([
  12328. normalStyle,
  12329. hoverStyle,
  12330. pressedStyle,
  12331. disabledStyle
  12332. ][state || 0]);
  12333. }
  12334. };
  12335. // Presentational attributes
  12336. if (!styledMode) {
  12337. label
  12338. .attr(normalState)
  12339. .css(extend({ cursor: 'default' }, normalStyle));
  12340. }
  12341. return label
  12342. .on('touchstart', function (e) { return e.stopPropagation(); })
  12343. .on('click', function (e) {
  12344. if (curState !== 3) {
  12345. callback.call(label, e);
  12346. }
  12347. });
  12348. };
  12349. /**
  12350. * Make a straight line crisper by not spilling out to neighbour pixels.
  12351. *
  12352. * @function Highcharts.SVGRenderer#crispLine
  12353. *
  12354. * @param {Highcharts.SVGPathArray} points
  12355. * The original points on the format `[['M', 0, 0], ['L', 100, 0]]`.
  12356. *
  12357. * @param {number} width
  12358. * The width of the line.
  12359. *
  12360. * @param {string} roundingFunction
  12361. * The rounding function name on the `Math` object, can be one of
  12362. * `round`, `floor` or `ceil`.
  12363. *
  12364. * @return {Highcharts.SVGPathArray}
  12365. * The original points array, but modified to render crisply.
  12366. */
  12367. SVGRenderer.prototype.crispLine = function (points, width, roundingFunction) {
  12368. if (roundingFunction === void 0) { roundingFunction = 'round'; }
  12369. var start = points[0];
  12370. var end = points[1];
  12371. // Normalize to a crisp line
  12372. if (start[1] === end[1]) {
  12373. // Substract due to #1129. Now bottom and left axis gridlines behave
  12374. // the same.
  12375. start[1] = end[1] =
  12376. Math[roundingFunction](start[1]) - (width % 2 / 2);
  12377. }
  12378. if (start[2] === end[2]) {
  12379. start[2] = end[2] =
  12380. Math[roundingFunction](start[2]) + (width % 2 / 2);
  12381. }
  12382. return points;
  12383. };
  12384. /**
  12385. * Draw a path, wraps the SVG `path` element.
  12386. *
  12387. * @sample highcharts/members/renderer-path-on-chart/
  12388. * Draw a path in a chart
  12389. * @sample highcharts/members/renderer-path/
  12390. * Draw a path independent from a chart
  12391. *
  12392. * @example
  12393. * let path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
  12394. * .attr({ stroke: '#ff00ff' })
  12395. * .add();
  12396. *
  12397. * @function Highcharts.SVGRenderer#path
  12398. *
  12399. * @param {Highcharts.SVGPathArray} [path]
  12400. * An SVG path definition in array form.
  12401. *
  12402. * @return {Highcharts.SVGElement}
  12403. * The generated wrapper element.
  12404. *
  12405. */ /**
  12406. * Draw a path, wraps the SVG `path` element.
  12407. *
  12408. * @function Highcharts.SVGRenderer#path
  12409. *
  12410. * @param {Highcharts.SVGAttributes} [attribs]
  12411. * The initial attributes.
  12412. *
  12413. * @return {Highcharts.SVGElement}
  12414. * The generated wrapper element.
  12415. */
  12416. SVGRenderer.prototype.path = function (path) {
  12417. var attribs = (this.styledMode ? {} : {
  12418. fill: 'none'
  12419. });
  12420. if (isArray(path)) {
  12421. attribs.d = path;
  12422. }
  12423. else if (isObject(path)) { // attributes
  12424. extend(attribs, path);
  12425. }
  12426. return this.createElement('path').attr(attribs);
  12427. };
  12428. /**
  12429. * Draw a circle, wraps the SVG `circle` element.
  12430. *
  12431. * @sample highcharts/members/renderer-circle/
  12432. * Drawing a circle
  12433. *
  12434. * @function Highcharts.SVGRenderer#circle
  12435. *
  12436. * @param {number} [x]
  12437. * The center x position.
  12438. *
  12439. * @param {number} [y]
  12440. * The center y position.
  12441. *
  12442. * @param {number} [r]
  12443. * The radius.
  12444. *
  12445. * @return {Highcharts.SVGElement}
  12446. * The generated wrapper element.
  12447. */ /**
  12448. * Draw a circle, wraps the SVG `circle` element.
  12449. *
  12450. * @function Highcharts.SVGRenderer#circle
  12451. *
  12452. * @param {Highcharts.SVGAttributes} [attribs]
  12453. * The initial attributes.
  12454. *
  12455. * @return {Highcharts.SVGElement}
  12456. * The generated wrapper element.
  12457. */
  12458. SVGRenderer.prototype.circle = function (x, y, r) {
  12459. var attribs = (isObject(x) ?
  12460. x :
  12461. typeof x === 'undefined' ? {} : { x: x, y: y, r: r }), wrapper = this.createElement('circle');
  12462. // Setting x or y translates to cx and cy
  12463. wrapper.xSetter = wrapper.ySetter = function (value, key, element) {
  12464. element.setAttribute('c' + key, value);
  12465. };
  12466. return wrapper.attr(attribs);
  12467. };
  12468. /**
  12469. * Draw and return an arc.
  12470. *
  12471. * @sample highcharts/members/renderer-arc/
  12472. * Drawing an arc
  12473. *
  12474. * @function Highcharts.SVGRenderer#arc
  12475. *
  12476. * @param {number} [x=0]
  12477. * Center X position.
  12478. *
  12479. * @param {number} [y=0]
  12480. * Center Y position.
  12481. *
  12482. * @param {number} [r=0]
  12483. * The outer radius' of the arc.
  12484. *
  12485. * @param {number} [innerR=0]
  12486. * Inner radius like used in donut charts.
  12487. *
  12488. * @param {number} [start=0]
  12489. * The starting angle of the arc in radians, where 0 is to the right and
  12490. * `-Math.PI/2` is up.
  12491. *
  12492. * @param {number} [end=0]
  12493. * The ending angle of the arc in radians, where 0 is to the right and
  12494. * `-Math.PI/2` is up.
  12495. *
  12496. * @return {Highcharts.SVGElement}
  12497. * The generated wrapper element.
  12498. */ /**
  12499. * Draw and return an arc. Overloaded function that takes arguments object.
  12500. *
  12501. * @function Highcharts.SVGRenderer#arc
  12502. *
  12503. * @param {Highcharts.SVGAttributes} attribs
  12504. * Initial SVG attributes.
  12505. *
  12506. * @return {Highcharts.SVGElement}
  12507. * The generated wrapper element.
  12508. */
  12509. SVGRenderer.prototype.arc = function (x, y, r, innerR, start, end) {
  12510. var arc,
  12511. options;
  12512. if (isObject(x)) {
  12513. options = x;
  12514. y = options.y;
  12515. r = options.r;
  12516. innerR = options.innerR;
  12517. start = options.start;
  12518. end = options.end;
  12519. x = options.x;
  12520. }
  12521. else {
  12522. options = {
  12523. innerR: innerR,
  12524. start: start,
  12525. end: end
  12526. };
  12527. }
  12528. // Arcs are defined as symbols for the ability to set
  12529. // attributes in attr and animate
  12530. arc = this.symbol('arc', x, y, r, r, options);
  12531. arc.r = r; // #959
  12532. return arc;
  12533. };
  12534. /**
  12535. * Draw and return a rectangle.
  12536. *
  12537. * @function Highcharts.SVGRenderer#rect
  12538. *
  12539. * @param {number} [x]
  12540. * Left position.
  12541. *
  12542. * @param {number} [y]
  12543. * Top position.
  12544. *
  12545. * @param {number} [width]
  12546. * Width of the rectangle.
  12547. *
  12548. * @param {number} [height]
  12549. * Height of the rectangle.
  12550. *
  12551. * @param {number} [r]
  12552. * Border corner radius.
  12553. *
  12554. * @param {number} [strokeWidth]
  12555. * A stroke width can be supplied to allow crisp drawing.
  12556. *
  12557. * @return {Highcharts.SVGElement}
  12558. * The generated wrapper element.
  12559. */ /**
  12560. * Draw and return a rectangle.
  12561. *
  12562. * @sample highcharts/members/renderer-rect-on-chart/
  12563. * Draw a rectangle in a chart
  12564. * @sample highcharts/members/renderer-rect/
  12565. * Draw a rectangle independent from a chart
  12566. *
  12567. * @function Highcharts.SVGRenderer#rect
  12568. *
  12569. * @param {Highcharts.SVGAttributes} [attributes]
  12570. * General SVG attributes for the rectangle.
  12571. *
  12572. * @return {Highcharts.SVGElement}
  12573. * The generated wrapper element.
  12574. */
  12575. SVGRenderer.prototype.rect = function (x, y, width, height, r, strokeWidth) {
  12576. r = isObject(x) ? x.r : r;
  12577. var wrapper = this.createElement('rect'),
  12578. attribs = isObject(x) ?
  12579. x :
  12580. typeof x === 'undefined' ?
  12581. {} :
  12582. {
  12583. x: x,
  12584. y: y,
  12585. width: Math.max(width, 0),
  12586. height: Math.max(height, 0)
  12587. };
  12588. if (!this.styledMode) {
  12589. if (typeof strokeWidth !== 'undefined') {
  12590. attribs['stroke-width'] = strokeWidth;
  12591. attribs = wrapper.crisp(attribs);
  12592. }
  12593. attribs.fill = 'none';
  12594. }
  12595. if (r) {
  12596. attribs.r = r;
  12597. }
  12598. wrapper.rSetter = function (value, key, element) {
  12599. wrapper.r = value;
  12600. attr(element, {
  12601. rx: value,
  12602. ry: value
  12603. });
  12604. };
  12605. wrapper.rGetter = function () {
  12606. return wrapper.r || 0;
  12607. };
  12608. return wrapper.attr(attribs);
  12609. };
  12610. /**
  12611. * Resize the {@link SVGRenderer#box} and re-align all aligned child
  12612. * elements.
  12613. *
  12614. * @sample highcharts/members/renderer-g/
  12615. * Show and hide grouped objects
  12616. *
  12617. * @function Highcharts.SVGRenderer#setSize
  12618. *
  12619. * @param {number} width
  12620. * The new pixel width.
  12621. *
  12622. * @param {number} height
  12623. * The new pixel height.
  12624. *
  12625. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animate=true]
  12626. * Whether and how to animate.
  12627. */
  12628. SVGRenderer.prototype.setSize = function (width, height, animate) {
  12629. var renderer = this;
  12630. renderer.width = width;
  12631. renderer.height = height;
  12632. renderer.boxWrapper.animate({
  12633. width: width,
  12634. height: height
  12635. }, {
  12636. step: function () {
  12637. this.attr({
  12638. viewBox: '0 0 ' + this.attr('width') + ' ' +
  12639. this.attr('height')
  12640. });
  12641. },
  12642. duration: pick(animate, true) ? void 0 : 0
  12643. });
  12644. renderer.alignElements();
  12645. };
  12646. /**
  12647. * Create and return an svg group element. Child
  12648. * {@link Highcharts.SVGElement} objects are added to the group by using the
  12649. * group as the first parameter in {@link Highcharts.SVGElement#add|add()}.
  12650. *
  12651. * @function Highcharts.SVGRenderer#g
  12652. *
  12653. * @param {string} [name]
  12654. * The group will be given a class name of `highcharts-{name}`. This
  12655. * can be used for styling and scripting.
  12656. *
  12657. * @return {Highcharts.SVGElement}
  12658. * The generated wrapper element.
  12659. */
  12660. SVGRenderer.prototype.g = function (name) {
  12661. var elem = this.createElement('g');
  12662. return name ?
  12663. elem.attr({ 'class': 'highcharts-' + name }) :
  12664. elem;
  12665. };
  12666. /**
  12667. * Display an image.
  12668. *
  12669. * @sample highcharts/members/renderer-image-on-chart/
  12670. * Add an image in a chart
  12671. * @sample highcharts/members/renderer-image/
  12672. * Add an image independent of a chart
  12673. *
  12674. * @function Highcharts.SVGRenderer#image
  12675. *
  12676. * @param {string} src
  12677. * The image source.
  12678. *
  12679. * @param {number} [x]
  12680. * The X position.
  12681. *
  12682. * @param {number} [y]
  12683. * The Y position.
  12684. *
  12685. * @param {number} [width]
  12686. * The image width. If omitted, it defaults to the image file width.
  12687. *
  12688. * @param {number} [height]
  12689. * The image height. If omitted it defaults to the image file
  12690. * height.
  12691. *
  12692. * @param {Function} [onload]
  12693. * Event handler for image load.
  12694. *
  12695. * @return {Highcharts.SVGElement}
  12696. * The generated wrapper element.
  12697. */
  12698. SVGRenderer.prototype.image = function (src, x, y, width, height, onload) {
  12699. var attribs = { preserveAspectRatio: 'none' }, elemWrapper, dummy, setSVGImageSource = function (el, src) {
  12700. // Set the href in the xlink namespace
  12701. if (el.setAttributeNS) {
  12702. el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', src);
  12703. }
  12704. else {
  12705. // could be exporting in IE
  12706. // using href throws "not supported" in ie7 and under,
  12707. // requries regex shim to fix later
  12708. el.setAttribute('hc-svg-href', src);
  12709. }
  12710. }, onDummyLoad = function (e) {
  12711. setSVGImageSource(elemWrapper.element, src);
  12712. onload.call(elemWrapper, e);
  12713. };
  12714. // optional properties
  12715. if (arguments.length > 1) {
  12716. extend(attribs, {
  12717. x: x,
  12718. y: y,
  12719. width: width,
  12720. height: height
  12721. });
  12722. }
  12723. elemWrapper = this.createElement('image').attr(attribs);
  12724. // Add load event if supplied
  12725. if (onload) {
  12726. // We have to use a dummy HTML image since IE support for SVG image
  12727. // load events is very buggy. First set a transparent src, wait for
  12728. // dummy to load, and then add the real src to the SVG image.
  12729. setSVGImageSource(elemWrapper.element, 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' /* eslint-disable-line */);
  12730. dummy = new win.Image();
  12731. addEvent(dummy, 'load', onDummyLoad);
  12732. dummy.src = src;
  12733. if (dummy.complete) {
  12734. onDummyLoad({});
  12735. }
  12736. }
  12737. else {
  12738. setSVGImageSource(elemWrapper.element, src);
  12739. }
  12740. return elemWrapper;
  12741. };
  12742. /**
  12743. * Draw a symbol out of pre-defined shape paths from
  12744. * {@link SVGRenderer#symbols}.
  12745. * It is used in Highcharts for point makers, which cake a `symbol` option,
  12746. * and label and button backgrounds like in the tooltip and stock flags.
  12747. *
  12748. * @function Highcharts.SVGRenderer#symbol
  12749. *
  12750. * @param {string} symbol
  12751. * The symbol name.
  12752. *
  12753. * @param {number} [x]
  12754. * The X coordinate for the top left position.
  12755. *
  12756. * @param {number} [y]
  12757. * The Y coordinate for the top left position.
  12758. *
  12759. * @param {number} [width]
  12760. * The pixel width.
  12761. *
  12762. * @param {number} [height]
  12763. * The pixel height.
  12764. *
  12765. * @param {Highcharts.SymbolOptionsObject} [options]
  12766. * Additional options, depending on the actual symbol drawn.
  12767. *
  12768. * @return {Highcharts.SVGElement}
  12769. */
  12770. SVGRenderer.prototype.symbol = function (symbol, x, y, width, height, options) {
  12771. var ren = this,
  12772. obj,
  12773. imageRegex = /^url\((.*?)\)$/,
  12774. isImage = imageRegex.test(symbol),
  12775. sym = (!isImage && (this.symbols[symbol] ? symbol : 'circle')),
  12776. // get the symbol definition function
  12777. symbolFn = (sym && this.symbols[sym]),
  12778. path,
  12779. imageSrc,
  12780. centerImage;
  12781. if (symbolFn) {
  12782. // Check if there's a path defined for this symbol
  12783. if (typeof x === 'number') {
  12784. path = symbolFn.call(this.symbols, Math.round(x || 0), Math.round(y || 0), width || 0, height || 0, options);
  12785. }
  12786. obj = this.path(path);
  12787. if (!ren.styledMode) {
  12788. obj.attr('fill', 'none');
  12789. }
  12790. // expando properties for use in animate and attr
  12791. extend(obj, {
  12792. symbolName: sym,
  12793. x: x,
  12794. y: y,
  12795. width: width,
  12796. height: height
  12797. });
  12798. if (options) {
  12799. extend(obj, options);
  12800. }
  12801. // Image symbols
  12802. }
  12803. else if (isImage) {
  12804. imageSrc = symbol.match(imageRegex)[1];
  12805. // Create the image synchronously, add attribs async
  12806. obj = this.image(imageSrc);
  12807. // The image width is not always the same as the symbol width. The
  12808. // image may be centered within the symbol, as is the case when
  12809. // image shapes are used as label backgrounds, for example in flags.
  12810. obj.imgwidth = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].width, options && options.width);
  12811. obj.imgheight = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].height, options && options.height);
  12812. /**
  12813. * Set the size and position
  12814. */
  12815. centerImage = function () {
  12816. obj.attr({
  12817. width: obj.width,
  12818. height: obj.height
  12819. });
  12820. };
  12821. /**
  12822. * Width and height setters that take both the image's physical size
  12823. * and the label size into consideration, and translates the image
  12824. * to center within the label.
  12825. */
  12826. ['width', 'height'].forEach(function (key) {
  12827. obj[key + 'Setter'] = function (value, key) {
  12828. var imgSize = this['img' + key];
  12829. this[key] = value;
  12830. if (defined(imgSize)) {
  12831. // Scale and center the image within its container.
  12832. // The name `backgroundSize` is taken from the CSS spec,
  12833. // but the value `within` is made up. Other possible
  12834. // values in the spec, `cover` and `contain`, can be
  12835. // implemented if needed.
  12836. if (options &&
  12837. options.backgroundSize === 'within' &&
  12838. this.width &&
  12839. this.height) {
  12840. imgSize = Math.round(imgSize * Math.min(this.width / this.imgwidth, this.height / this.imgheight));
  12841. }
  12842. if (this.element) {
  12843. this.element.setAttribute(key, imgSize);
  12844. }
  12845. if (!this.alignByTranslate) {
  12846. var translate = ((this[key] || 0) - imgSize) / 2;
  12847. var attribs = key === 'width' ?
  12848. { translateX: translate } :
  12849. { translateY: translate };
  12850. this.attr(attribs);
  12851. }
  12852. }
  12853. };
  12854. });
  12855. if (defined(x)) {
  12856. obj.attr({
  12857. x: x,
  12858. y: y
  12859. });
  12860. }
  12861. obj.isImg = true;
  12862. if (defined(obj.imgwidth) && defined(obj.imgheight)) {
  12863. centerImage();
  12864. }
  12865. else {
  12866. // Initialize image to be 0 size so export will still function
  12867. // if there's no cached sizes.
  12868. obj.attr({ width: 0, height: 0 });
  12869. // Create a dummy JavaScript image to get the width and height.
  12870. createElement('img', {
  12871. onload: function () {
  12872. var chart = charts[ren.chartIndex];
  12873. // Special case for SVGs on IE11, the width is not
  12874. // accessible until the image is part of the DOM
  12875. // (#2854).
  12876. if (this.width === 0) {
  12877. css(this, {
  12878. position: 'absolute',
  12879. top: '-999em'
  12880. });
  12881. doc.body.appendChild(this);
  12882. }
  12883. // Center the image
  12884. symbolSizes[imageSrc] = {
  12885. width: this.width,
  12886. height: this.height
  12887. };
  12888. obj.imgwidth = this.width;
  12889. obj.imgheight = this.height;
  12890. if (obj.element) {
  12891. centerImage();
  12892. }
  12893. // Clean up after #2854 workaround.
  12894. if (this.parentNode) {
  12895. this.parentNode.removeChild(this);
  12896. }
  12897. // Fire the load event when all external images are
  12898. // loaded
  12899. ren.imgCount--;
  12900. if (!ren.imgCount && chart && !chart.hasLoaded) {
  12901. chart.onload();
  12902. }
  12903. },
  12904. src: imageSrc
  12905. });
  12906. this.imgCount++;
  12907. }
  12908. }
  12909. return obj;
  12910. };
  12911. /**
  12912. * Define a clipping rectangle. The clipping rectangle is later applied
  12913. * to {@link SVGElement} objects through the {@link SVGElement#clip}
  12914. * function.
  12915. *
  12916. * @example
  12917. * let circle = renderer.circle(100, 100, 100)
  12918. * .attr({ fill: 'red' })
  12919. * .add();
  12920. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  12921. *
  12922. * // Leave only the lower right quarter visible
  12923. * circle.clip(clipRect);
  12924. *
  12925. * @function Highcharts.SVGRenderer#clipRect
  12926. *
  12927. * @param {number} [x]
  12928. *
  12929. * @param {number} [y]
  12930. *
  12931. * @param {number} [width]
  12932. *
  12933. * @param {number} [height]
  12934. *
  12935. * @return {Highcharts.ClipRectElement}
  12936. * A clipping rectangle.
  12937. */
  12938. SVGRenderer.prototype.clipRect = function (x, y, width, height) {
  12939. var wrapper,
  12940. // Add a hyphen at the end to avoid confusion in testing indexes
  12941. // -1 and -10, -11 etc (#6550)
  12942. id = uniqueKey() + '-', clipPath = this.createElement('clipPath').attr({
  12943. id: id
  12944. }).add(this.defs);
  12945. wrapper = this.rect(x, y, width, height, 0).add(clipPath);
  12946. wrapper.id = id;
  12947. wrapper.clipPath = clipPath;
  12948. wrapper.count = 0;
  12949. return wrapper;
  12950. };
  12951. /**
  12952. * Draw text. The text can contain a subset of HTML, like spans and anchors
  12953. * and some basic text styling of these. For more advanced features like
  12954. * border and background, use {@link Highcharts.SVGRenderer#label} instead.
  12955. * To update the text after render, run `text.attr({ text: 'New text' })`.
  12956. *
  12957. * @sample highcharts/members/renderer-text-on-chart/
  12958. * Annotate the chart freely
  12959. * @sample highcharts/members/renderer-on-chart/
  12960. * Annotate with a border and in response to the data
  12961. * @sample highcharts/members/renderer-text/
  12962. * Formatted text
  12963. *
  12964. * @function Highcharts.SVGRenderer#text
  12965. *
  12966. * @param {string} [str]
  12967. * The text of (subset) HTML to draw.
  12968. *
  12969. * @param {number} [x]
  12970. * The x position of the text's lower left corner.
  12971. *
  12972. * @param {number} [y]
  12973. * The y position of the text's lower left corner.
  12974. *
  12975. * @param {boolean} [useHTML=false]
  12976. * Use HTML to render the text.
  12977. *
  12978. * @return {Highcharts.SVGElement}
  12979. * The text object.
  12980. */
  12981. SVGRenderer.prototype.text = function (str, x, y, useHTML) {
  12982. // declare variables
  12983. var renderer = this,
  12984. wrapper,
  12985. attribs = {};
  12986. if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
  12987. return renderer.html(str, x, y);
  12988. }
  12989. attribs.x = Math.round(x || 0); // X always needed for line-wrap logic
  12990. if (y) {
  12991. attribs.y = Math.round(y);
  12992. }
  12993. if (defined(str)) {
  12994. attribs.text = str;
  12995. }
  12996. wrapper = renderer.createElement('text')
  12997. .attr(attribs);
  12998. if (!useHTML) {
  12999. wrapper.xSetter = function (value, key, element) {
  13000. var tspans = element.getElementsByTagName('tspan'),
  13001. tspan,
  13002. parentVal = element.getAttribute(key),
  13003. i;
  13004. for (i = 0; i < tspans.length; i++) {
  13005. tspan = tspans[i];
  13006. // If the x values are equal, the tspan represents a
  13007. // linebreak
  13008. if (tspan.getAttribute(key) === parentVal) {
  13009. tspan.setAttribute(key, value);
  13010. }
  13011. }
  13012. element.setAttribute(key, value);
  13013. };
  13014. }
  13015. return wrapper;
  13016. };
  13017. /**
  13018. * Utility to return the baseline offset and total line height from the font
  13019. * size.
  13020. *
  13021. * @function Highcharts.SVGRenderer#fontMetrics
  13022. *
  13023. * @param {number|string} [fontSize]
  13024. * The current font size to inspect. If not given, the font size
  13025. * will be found from the DOM element.
  13026. *
  13027. * @param {Highcharts.SVGElement|Highcharts.SVGDOMElement} [elem]
  13028. * The element to inspect for a current font size.
  13029. *
  13030. * @return {Highcharts.FontMetricsObject}
  13031. * The font metrics.
  13032. */
  13033. SVGRenderer.prototype.fontMetrics = function (fontSize, elem) {
  13034. var lineHeight,
  13035. baseline;
  13036. if ((this.styledMode || !/px/.test(fontSize)) &&
  13037. win.getComputedStyle // old IE doesn't support it
  13038. ) {
  13039. fontSize = elem && SVGElement.prototype.getStyle.call(elem, 'font-size');
  13040. }
  13041. else {
  13042. fontSize = fontSize ||
  13043. // When the elem is a DOM element (#5932)
  13044. (elem && elem.style && elem.style.fontSize) ||
  13045. // Fall back on the renderer style default
  13046. (this.style && this.style.fontSize);
  13047. }
  13048. // Handle different units
  13049. if (/px/.test(fontSize)) {
  13050. fontSize = pInt(fontSize);
  13051. }
  13052. else {
  13053. fontSize = 12;
  13054. }
  13055. // Empirical values found by comparing font size and bounding box
  13056. // height. Applies to the default font family.
  13057. // https://jsfiddle.net/highcharts/7xvn7/
  13058. lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
  13059. baseline = Math.round(lineHeight * 0.8);
  13060. return {
  13061. h: lineHeight,
  13062. b: baseline,
  13063. f: fontSize
  13064. };
  13065. };
  13066. /**
  13067. * Correct X and Y positioning of a label for rotation (#1764).
  13068. *
  13069. * @private
  13070. * @function Highcharts.SVGRenderer#rotCorr
  13071. *
  13072. * @param {number} baseline
  13073. *
  13074. * @param {number} rotation
  13075. *
  13076. * @param {boolean} [alterY]
  13077. *
  13078. * @param {Highcharts.PositionObject}
  13079. */
  13080. SVGRenderer.prototype.rotCorr = function (baseline, rotation, alterY) {
  13081. var y = baseline;
  13082. if (rotation && alterY) {
  13083. y = Math.max(y * Math.cos(rotation * deg2rad), 4);
  13084. }
  13085. return {
  13086. x: (-baseline / 3) * Math.sin(rotation * deg2rad),
  13087. y: y
  13088. };
  13089. };
  13090. /**
  13091. * Compatibility function to convert the legacy one-dimensional path array
  13092. * into an array of segments.
  13093. *
  13094. * It is used in maps to parse the `path` option, and in SVGRenderer.dSetter
  13095. * to support legacy paths from demos.
  13096. *
  13097. * @private
  13098. * @function Highcharts.SVGRenderer#pathToSegments
  13099. */
  13100. SVGRenderer.prototype.pathToSegments = function (path) {
  13101. var ret = [];
  13102. var segment = [];
  13103. var commandLength = {
  13104. A: 8,
  13105. C: 7,
  13106. H: 2,
  13107. L: 3,
  13108. M: 3,
  13109. Q: 5,
  13110. S: 5,
  13111. T: 3,
  13112. V: 2
  13113. };
  13114. // Short, non-typesafe parsing of the one-dimensional array. It splits
  13115. // the path on any string. This is not type checked against the tuple
  13116. // types, but is shorter, and doesn't require specific checks for any
  13117. // command type in SVG.
  13118. for (var i = 0; i < path.length; i++) {
  13119. // Command skipped, repeat previous or insert L/l for M/m
  13120. if (isString(segment[0]) &&
  13121. isNumber(path[i]) &&
  13122. segment.length === commandLength[(segment[0].toUpperCase())]) {
  13123. path.splice(i, 0, segment[0].replace('M', 'L').replace('m', 'l'));
  13124. }
  13125. // Split on string
  13126. if (typeof path[i] === 'string') {
  13127. if (segment.length) {
  13128. ret.push(segment.slice(0));
  13129. }
  13130. segment.length = 0;
  13131. }
  13132. segment.push(path[i]);
  13133. }
  13134. ret.push(segment.slice(0));
  13135. return ret;
  13136. /*
  13137. // Fully type-safe version where each tuple type is checked. The
  13138. // downside is filesize and a lack of flexibility for unsupported
  13139. // commands
  13140. const ret: SVGPath = [],
  13141. commands = {
  13142. A: 7,
  13143. C: 6,
  13144. H: 1,
  13145. L: 2,
  13146. M: 2,
  13147. Q: 4,
  13148. S: 4,
  13149. T: 2,
  13150. V: 1,
  13151. Z: 0
  13152. };
  13153. let i = 0,
  13154. lastI = 0,
  13155. lastCommand;
  13156. while (i < path.length) {
  13157. const item = path[i];
  13158. let command;
  13159. if (typeof item === 'string') {
  13160. command = item;
  13161. i += 1;
  13162. } else {
  13163. command = lastCommand || 'M';
  13164. }
  13165. // Upper case
  13166. const commandUC = command.toUpperCase();
  13167. if (commandUC in commands) {
  13168. // No numeric parameters
  13169. if (command === 'Z' || command === 'z') {
  13170. ret.push([command]);
  13171. // One numeric parameter
  13172. } else {
  13173. const val0 = path[i];
  13174. if (typeof val0 === 'number') {
  13175. // Horizontal line to
  13176. if (command === 'H' || command === 'h') {
  13177. ret.push([command, val0]);
  13178. i += 1;
  13179. // Vertical line to
  13180. } else if (command === 'V' || command === 'v') {
  13181. ret.push([command, val0]);
  13182. i += 1;
  13183. // Two numeric parameters
  13184. } else {
  13185. const val1 = path[i + 1];
  13186. if (typeof val1 === 'number') {
  13187. // lineTo
  13188. if (command === 'L' || command === 'l') {
  13189. ret.push([command, val0, val1]);
  13190. i += 2;
  13191. // moveTo
  13192. } else if (command === 'M' || command === 'm') {
  13193. ret.push([command, val0, val1]);
  13194. i += 2;
  13195. // Smooth quadratic bezier
  13196. } else if (command === 'T' || command === 't') {
  13197. ret.push([command, val0, val1]);
  13198. i += 2;
  13199. // Four numeric parameters
  13200. } else {
  13201. const val2 = path[i + 2],
  13202. val3 = path[i + 3];
  13203. if (
  13204. typeof val2 === 'number' &&
  13205. typeof val3 === 'number'
  13206. ) {
  13207. // Quadratic bezier to
  13208. if (
  13209. command === 'Q' ||
  13210. command === 'q'
  13211. ) {
  13212. ret.push([
  13213. command,
  13214. val0,
  13215. val1,
  13216. val2,
  13217. val3
  13218. ]);
  13219. i += 4;
  13220. // Smooth cubic bezier to
  13221. } else if (
  13222. command === 'S' ||
  13223. command === 's'
  13224. ) {
  13225. ret.push([
  13226. command,
  13227. val0,
  13228. val1,
  13229. val2,
  13230. val3
  13231. ]);
  13232. i += 4;
  13233. // Six numeric parameters
  13234. } else {
  13235. const val4 = path[i + 4],
  13236. val5 = path[i + 5];
  13237. if (
  13238. typeof val4 === 'number' &&
  13239. typeof val5 === 'number'
  13240. ) {
  13241. // Curve to
  13242. if (
  13243. command === 'C' ||
  13244. command === 'c'
  13245. ) {
  13246. ret.push([
  13247. command,
  13248. val0,
  13249. val1,
  13250. val2,
  13251. val3,
  13252. val4,
  13253. val5
  13254. ]);
  13255. i += 6;
  13256. // Seven numeric parameters
  13257. } else {
  13258. const val6 = path[i + 6];
  13259. // Arc to
  13260. if (
  13261. typeof val6 ===
  13262. 'number' &&
  13263. (
  13264. command === 'A' ||
  13265. command === 'a'
  13266. )
  13267. ) {
  13268. ret.push([
  13269. command,
  13270. val0,
  13271. val1,
  13272. val2,
  13273. val3,
  13274. val4,
  13275. val5,
  13276. val6
  13277. ]);
  13278. i += 7;
  13279. }
  13280. }
  13281. }
  13282. }
  13283. }
  13284. }
  13285. }
  13286. }
  13287. }
  13288. }
  13289. }
  13290. // An unmarked command following a moveTo is a lineTo
  13291. lastCommand = command === 'M' ? 'L' : command;
  13292. if (i === lastI) {
  13293. break;
  13294. }
  13295. lastI = i;
  13296. }
  13297. return ret;
  13298. */
  13299. };
  13300. /**
  13301. * Draw a label, which is an extended text element with support for border
  13302. * and background. Highcharts creates a `g` element with a text and a `path`
  13303. * or `rect` inside, to make it behave somewhat like a HTML div. Border and
  13304. * background are set through `stroke`, `stroke-width` and `fill` attributes
  13305. * using the {@link Highcharts.SVGElement#attr|attr} method. To update the
  13306. * text after render, run `label.attr({ text: 'New text' })`.
  13307. *
  13308. * @sample highcharts/members/renderer-label-on-chart/
  13309. * A label on the chart
  13310. *
  13311. * @function Highcharts.SVGRenderer#label
  13312. *
  13313. * @param {string} str
  13314. * The initial text string or (subset) HTML to render.
  13315. *
  13316. * @param {number} x
  13317. * The x position of the label's left side.
  13318. *
  13319. * @param {number} [y]
  13320. * The y position of the label's top side or baseline, depending on
  13321. * the `baseline` parameter.
  13322. *
  13323. * @param {string} [shape='rect']
  13324. * The shape of the label's border/background, if any. Defaults to
  13325. * `rect`. Other possible values are `callout` or other shapes
  13326. * defined in {@link Highcharts.SVGRenderer#symbols}.
  13327. *
  13328. * @param {number} [anchorX]
  13329. * In case the `shape` has a pointer, like a flag, this is the
  13330. * coordinates it should be pinned to.
  13331. *
  13332. * @param {number} [anchorY]
  13333. * In case the `shape` has a pointer, like a flag, this is the
  13334. * coordinates it should be pinned to.
  13335. *
  13336. * @param {boolean} [useHTML=false]
  13337. * Wether to use HTML to render the label.
  13338. *
  13339. * @param {boolean} [baseline=false]
  13340. * Whether to position the label relative to the text baseline,
  13341. * like {@link Highcharts.SVGRenderer#text|renderer.text}, or to the
  13342. * upper border of the rectangle.
  13343. *
  13344. * @param {string} [className]
  13345. * Class name for the group.
  13346. *
  13347. * @return {Highcharts.SVGElement}
  13348. * The generated label.
  13349. */
  13350. SVGRenderer.prototype.label = function (str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  13351. return new SVGLabel(this, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className);
  13352. };
  13353. /**
  13354. * Re-align all aligned elements.
  13355. *
  13356. * @private
  13357. * @function Highcharts.SVGRenderer#alignElements
  13358. * @return {void}
  13359. */
  13360. SVGRenderer.prototype.alignElements = function () {
  13361. this.alignedObjects.forEach(function (el) { return el.align(); });
  13362. };
  13363. return SVGRenderer;
  13364. }());
  13365. /**
  13366. * A pointer to the renderer's associated Element class. The VMLRenderer
  13367. * will have a pointer to VMLElement here.
  13368. *
  13369. * @name Highcharts.SVGRenderer#Element
  13370. * @type {Highcharts.SVGElement}
  13371. */
  13372. SVGRenderer.prototype.Element = SVGElement;
  13373. /**
  13374. * @private
  13375. */
  13376. SVGRenderer.prototype.SVG_NS = SVG_NS;
  13377. /**
  13378. * Dummy function for plugins, called every time the renderer is updated.
  13379. * Prior to Highcharts 5, this was used for the canvg renderer.
  13380. *
  13381. * @deprecated
  13382. * @function Highcharts.SVGRenderer#draw
  13383. */
  13384. SVGRenderer.prototype.draw = noop;
  13385. /**
  13386. * A collection of characters mapped to HTML entities. When `useHTML` on an
  13387. * element is true, these entities will be rendered correctly by HTML. In
  13388. * the SVG pseudo-HTML, they need to be unescaped back to simple characters,
  13389. * so for example `&lt;` will render as `<`.
  13390. *
  13391. * @example
  13392. * // Add support for unescaping quotes
  13393. * Highcharts.SVGRenderer.prototype.escapes['"'] = '&quot;';
  13394. *
  13395. * @name Highcharts.SVGRenderer#escapes
  13396. * @type {Highcharts.Dictionary<string>}
  13397. */
  13398. SVGRenderer.prototype.escapes = {
  13399. '&': '&amp;',
  13400. '<': '&lt;',
  13401. '>': '&gt;',
  13402. "'": '&#39;',
  13403. '"': '&quot;'
  13404. };
  13405. var roundedRect = function (x,
  13406. y,
  13407. w,
  13408. h,
  13409. options) {
  13410. var r = (options && options.r) || 0;
  13411. return [
  13412. ['M', x + r, y],
  13413. ['L', x + w - r, y],
  13414. ['C', x + w, y, x + w, y, x + w, y + r],
  13415. ['L', x + w, y + h - r],
  13416. ['C', x + w, y + h, x + w, y + h, x + w - r, y + h],
  13417. ['L', x + r, y + h],
  13418. ['C', x, y + h, x, y + h, x, y + h - r],
  13419. ['L', x, y + r],
  13420. ['C', x, y, x, y, x + r, y] // top-left corner
  13421. ];
  13422. };
  13423. // #15291
  13424. var rect = function (x,
  13425. y,
  13426. w,
  13427. h,
  13428. options) {
  13429. if (options && options.r) {
  13430. return roundedRect(x,
  13431. y,
  13432. w,
  13433. h,
  13434. options);
  13435. }
  13436. return [
  13437. ['M', x, y],
  13438. ['L', x + w, y],
  13439. ['L', x + w, y + h],
  13440. ['L', x, y + h],
  13441. ['Z']
  13442. ];
  13443. };
  13444. /**
  13445. * An extendable collection of functions for defining symbol paths.
  13446. *
  13447. * @name Highcharts.SVGRenderer#symbols
  13448. * @type {Highcharts.SymbolDictionary}
  13449. */
  13450. SVGRenderer.prototype.symbols = {
  13451. circle: function (x, y, w, h) {
  13452. // Return a full arc
  13453. return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
  13454. start: Math.PI * 0.5,
  13455. end: Math.PI * 2.5,
  13456. open: false
  13457. });
  13458. },
  13459. rect: rect,
  13460. square: rect,
  13461. triangle: function (x, y, w, h) {
  13462. return [
  13463. ['M', x + w / 2, y],
  13464. ['L', x + w, y + h],
  13465. ['L', x, y + h],
  13466. ['Z']
  13467. ];
  13468. },
  13469. 'triangle-down': function (x, y, w, h) {
  13470. return [
  13471. ['M', x, y],
  13472. ['L', x + w, y],
  13473. ['L', x + w / 2, y + h],
  13474. ['Z']
  13475. ];
  13476. },
  13477. diamond: function (x, y, w, h) {
  13478. return [
  13479. ['M', x + w / 2, y],
  13480. ['L', x + w, y + h / 2],
  13481. ['L', x + w / 2, y + h],
  13482. ['L', x, y + h / 2],
  13483. ['Z']
  13484. ];
  13485. },
  13486. arc: function (x, y, w, h, options) {
  13487. var arc = [];
  13488. if (options) {
  13489. var start = options.start || 0,
  13490. rx = pick(options.r,
  13491. w),
  13492. ry = pick(options.r,
  13493. h || w),
  13494. proximity = 0.001,
  13495. fullCircle = (Math.abs((options.end || 0) - start - 2 * Math.PI) <
  13496. proximity),
  13497. // Substract a small number to prevent cos and sin of start and
  13498. // end from becoming equal on 360 arcs (related: #1561)
  13499. end = (options.end || 0) - proximity,
  13500. innerRadius = options.innerR,
  13501. open_1 = pick(options.open,
  13502. fullCircle),
  13503. cosStart = Math.cos(start),
  13504. sinStart = Math.sin(start),
  13505. cosEnd = Math.cos(end),
  13506. sinEnd = Math.sin(end),
  13507. // Proximity takes care of rounding errors around PI (#6971)
  13508. longArc = pick(options.longArc,
  13509. end - start - Math.PI < proximity ? 0 : 1);
  13510. arc.push([
  13511. 'M',
  13512. x + rx * cosStart,
  13513. y + ry * sinStart
  13514. ], [
  13515. 'A',
  13516. rx,
  13517. ry,
  13518. 0,
  13519. longArc,
  13520. pick(options.clockwise, 1),
  13521. x + rx * cosEnd,
  13522. y + ry * sinEnd
  13523. ]);
  13524. if (defined(innerRadius)) {
  13525. arc.push(open_1 ?
  13526. [
  13527. 'M',
  13528. x + innerRadius * cosEnd,
  13529. y + innerRadius * sinEnd
  13530. ] : [
  13531. 'L',
  13532. x + innerRadius * cosEnd,
  13533. y + innerRadius * sinEnd
  13534. ], [
  13535. 'A',
  13536. innerRadius,
  13537. innerRadius,
  13538. 0,
  13539. longArc,
  13540. // Clockwise - opposite to the outer arc clockwise
  13541. defined(options.clockwise) ? 1 - options.clockwise : 0,
  13542. x + innerRadius * cosStart,
  13543. y + innerRadius * sinStart
  13544. ]);
  13545. }
  13546. if (!open_1) {
  13547. arc.push(['Z']);
  13548. }
  13549. }
  13550. return arc;
  13551. },
  13552. /**
  13553. * Callout shape used for default tooltips, also used for rounded
  13554. * rectangles in VML
  13555. */
  13556. callout: function (x, y, w, h, options) {
  13557. var arrowLength = 6,
  13558. halfDistance = 6,
  13559. r = Math.min((options && options.r) || 0,
  13560. w,
  13561. h),
  13562. safeDistance = r + halfDistance,
  13563. anchorX = options && options.anchorX,
  13564. anchorY = options && options.anchorY || 0;
  13565. var path = roundedRect(x,
  13566. y,
  13567. w,
  13568. h, { r: r });
  13569. if (!isNumber(anchorX)) {
  13570. return path;
  13571. }
  13572. // Anchor on right side
  13573. if (x + anchorX >= w) {
  13574. // Chevron
  13575. if (anchorY > y + safeDistance &&
  13576. anchorY < y + h - safeDistance) {
  13577. 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]);
  13578. // Simple connector
  13579. }
  13580. else {
  13581. path.splice(3, 1, ['L', x + w, h / 2], ['L', anchorX, anchorY], ['L', x + w, h / 2], ['L', x + w, y + h - r]);
  13582. }
  13583. // Anchor on left side
  13584. }
  13585. else if (x + anchorX <= 0) {
  13586. // Chevron
  13587. if (anchorY > y + safeDistance &&
  13588. anchorY < y + h - safeDistance) {
  13589. path.splice(7, 1, ['L', x, anchorY + halfDistance], ['L', x - arrowLength, anchorY], ['L', x, anchorY - halfDistance], ['L', x, y + r]);
  13590. // Simple connector
  13591. }
  13592. else {
  13593. path.splice(7, 1, ['L', x, h / 2], ['L', anchorX, anchorY], ['L', x, h / 2], ['L', x, y + r]);
  13594. }
  13595. }
  13596. else if ( // replace bottom
  13597. anchorY &&
  13598. anchorY > h &&
  13599. anchorX > x + safeDistance &&
  13600. anchorX < x + w - safeDistance) {
  13601. path.splice(5, 1, ['L', anchorX + halfDistance, y + h], ['L', anchorX, y + h + arrowLength], ['L', anchorX - halfDistance, y + h], ['L', x + r, y + h]);
  13602. }
  13603. else if ( // replace top
  13604. anchorY &&
  13605. anchorY < 0 &&
  13606. anchorX > x + safeDistance &&
  13607. anchorX < x + w - safeDistance) {
  13608. path.splice(1, 1, ['L', anchorX - halfDistance, y], ['L', anchorX, y - arrowLength], ['L', anchorX + halfDistance, y], ['L', w - r, y]);
  13609. }
  13610. return path;
  13611. }
  13612. };
  13613. H.SVGRenderer = SVGRenderer;
  13614. H.Renderer = H.SVGRenderer;
  13615. return H.Renderer;
  13616. });
  13617. _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) {
  13618. /* *
  13619. *
  13620. * (c) 2010-2021 Torstein Honsi
  13621. *
  13622. * License: www.highcharts.com/license
  13623. *
  13624. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  13625. *
  13626. * */
  13627. var isFirefox = H.isFirefox,
  13628. isMS = H.isMS,
  13629. isWebKit = H.isWebKit,
  13630. win = H.win;
  13631. var css = U.css,
  13632. defined = U.defined,
  13633. extend = U.extend,
  13634. pick = U.pick,
  13635. pInt = U.pInt;
  13636. /**
  13637. * Element placebo
  13638. * @private
  13639. */
  13640. var HTMLElement = SVGElement;
  13641. /* eslint-disable valid-jsdoc */
  13642. // Extend SvgElement for useHTML option.
  13643. extend(HTMLElement.prototype, /** @lends SVGElement.prototype */ {
  13644. /**
  13645. * Apply CSS to HTML elements. This is used in text within SVG rendering and
  13646. * by the VML renderer
  13647. *
  13648. * @private
  13649. * @function Highcharts.SVGElement#htmlCss
  13650. *
  13651. * @param {Highcharts.CSSObject} styles
  13652. *
  13653. * @return {Highcharts.SVGElement}
  13654. */
  13655. htmlCss: function (styles) {
  13656. var wrapper = this,
  13657. element = wrapper.element,
  13658. // When setting or unsetting the width style, we need to update
  13659. // transform (#8809)
  13660. isSettingWidth = (element.tagName === 'SPAN' &&
  13661. styles &&
  13662. 'width' in styles),
  13663. textWidth = pick(isSettingWidth && styles.width,
  13664. void 0),
  13665. doTransform;
  13666. if (isSettingWidth) {
  13667. delete styles.width;
  13668. wrapper.textWidth = textWidth;
  13669. doTransform = true;
  13670. }
  13671. if (styles && styles.textOverflow === 'ellipsis') {
  13672. styles.whiteSpace = 'nowrap';
  13673. styles.overflow = 'hidden';
  13674. }
  13675. wrapper.styles = extend(wrapper.styles, styles);
  13676. css(wrapper.element, styles);
  13677. // Now that all styles are applied, to the transform
  13678. if (doTransform) {
  13679. wrapper.htmlUpdateTransform();
  13680. }
  13681. return wrapper;
  13682. },
  13683. /**
  13684. * VML and useHTML method for calculating the bounding box based on offsets.
  13685. *
  13686. * @private
  13687. * @function Highcharts.SVGElement#htmlGetBBox
  13688. *
  13689. * @param {boolean} refresh
  13690. * Whether to force a fresh value from the DOM or to use the cached
  13691. * value.
  13692. *
  13693. * @return {Highcharts.BBoxObject}
  13694. * A hash containing values for x, y, width and height.
  13695. */
  13696. htmlGetBBox: function () {
  13697. var wrapper = this,
  13698. element = wrapper.element;
  13699. return {
  13700. x: element.offsetLeft,
  13701. y: element.offsetTop,
  13702. width: element.offsetWidth,
  13703. height: element.offsetHeight
  13704. };
  13705. },
  13706. /**
  13707. * VML override private method to update elements based on internal
  13708. * properties based on SVG transform.
  13709. *
  13710. * @private
  13711. * @function Highcharts.SVGElement#htmlUpdateTransform
  13712. * @return {void}
  13713. */
  13714. htmlUpdateTransform: function () {
  13715. // aligning non added elements is expensive
  13716. if (!this.added) {
  13717. this.alignOnAdd = true;
  13718. return;
  13719. }
  13720. var wrapper = this,
  13721. renderer = wrapper.renderer,
  13722. elem = wrapper.element,
  13723. translateX = wrapper.translateX || 0,
  13724. translateY = wrapper.translateY || 0,
  13725. x = wrapper.x || 0,
  13726. y = wrapper.y || 0,
  13727. align = wrapper.textAlign || 'left',
  13728. alignCorrection = {
  13729. left: 0,
  13730. center: 0.5,
  13731. right: 1
  13732. }[align],
  13733. styles = wrapper.styles,
  13734. whiteSpace = styles && styles.whiteSpace;
  13735. /**
  13736. * @private
  13737. * @return {number}
  13738. */
  13739. function getTextPxLength() {
  13740. // Reset multiline/ellipsis in order to read width (#4928,
  13741. // #5417)
  13742. css(elem, {
  13743. width: '',
  13744. whiteSpace: whiteSpace || 'nowrap'
  13745. });
  13746. return elem.offsetWidth;
  13747. }
  13748. // apply translate
  13749. css(elem, {
  13750. marginLeft: translateX,
  13751. marginTop: translateY
  13752. });
  13753. if (!renderer.styledMode && wrapper.shadows) { // used in labels/tooltip
  13754. wrapper.shadows.forEach(function (shadow) {
  13755. css(shadow, {
  13756. marginLeft: translateX + 1,
  13757. marginTop: translateY + 1
  13758. });
  13759. });
  13760. }
  13761. // apply inversion
  13762. if (wrapper.inverted) { // wrapper is a group
  13763. [].forEach.call(elem.childNodes, function (child) {
  13764. renderer.invertChild(child, elem);
  13765. });
  13766. }
  13767. if (elem.tagName === 'SPAN') {
  13768. var rotation = wrapper.rotation, baseline = void 0, textWidth = wrapper.textWidth && pInt(wrapper.textWidth), currentTextTransform = [
  13769. rotation,
  13770. align,
  13771. elem.innerHTML,
  13772. wrapper.textWidth,
  13773. wrapper.textAlign
  13774. ].join(',');
  13775. // Update textWidth. Use the memoized textPxLength if possible, to
  13776. // avoid the getTextPxLength function using elem.offsetWidth.
  13777. // Calling offsetWidth affects rendering time as it forces layout
  13778. // (#7656).
  13779. if (textWidth !== wrapper.oldTextWidth &&
  13780. ((textWidth > wrapper.oldTextWidth) ||
  13781. (wrapper.textPxLength || getTextPxLength()) > textWidth) && (
  13782. // Only set the width if the text is able to word-wrap, or
  13783. // text-overflow is ellipsis (#9537)
  13784. /[ \-]/.test(elem.textContent || elem.innerText) ||
  13785. elem.style.textOverflow === 'ellipsis')) { // #983, #1254
  13786. css(elem, {
  13787. width: textWidth + 'px',
  13788. display: 'block',
  13789. whiteSpace: whiteSpace || 'normal' // #3331
  13790. });
  13791. wrapper.oldTextWidth = textWidth;
  13792. wrapper.hasBoxWidthChanged = true; // #8159
  13793. }
  13794. else {
  13795. wrapper.hasBoxWidthChanged = false; // #8159
  13796. }
  13797. // Do the calculations and DOM access only if properties changed
  13798. if (currentTextTransform !== wrapper.cTT) {
  13799. baseline = renderer.fontMetrics(elem.style.fontSize, elem).b;
  13800. // Renderer specific handling of span rotation, but only if we
  13801. // have something to update.
  13802. if (defined(rotation) &&
  13803. ((rotation !== (wrapper.oldRotation || 0)) ||
  13804. (align !== wrapper.oldAlign))) {
  13805. wrapper.setSpanRotation(rotation, alignCorrection, baseline);
  13806. }
  13807. wrapper.getSpanCorrection(
  13808. // Avoid elem.offsetWidth if we can, it affects rendering
  13809. // time heavily (#7656)
  13810. ((!defined(rotation) && wrapper.textPxLength) || // #7920
  13811. elem.offsetWidth), baseline, alignCorrection, rotation, align);
  13812. }
  13813. // apply position with correction
  13814. css(elem, {
  13815. left: (x + (wrapper.xCorr || 0)) + 'px',
  13816. top: (y + (wrapper.yCorr || 0)) + 'px'
  13817. });
  13818. // record current text transform
  13819. wrapper.cTT = currentTextTransform;
  13820. wrapper.oldRotation = rotation;
  13821. wrapper.oldAlign = align;
  13822. }
  13823. },
  13824. /**
  13825. * Set the rotation of an individual HTML span.
  13826. *
  13827. * @private
  13828. * @function Highcharts.SVGElement#setSpanRotation
  13829. * @param {number} rotation
  13830. * @param {number} alignCorrection
  13831. * @param {number} baseline
  13832. * @return {void}
  13833. */
  13834. setSpanRotation: function (rotation, alignCorrection, baseline) {
  13835. var getTransformKey = function () { return (isMS &&
  13836. !/Edge/.test(win.navigator.userAgent) ?
  13837. '-ms-transform' :
  13838. isWebKit ?
  13839. '-webkit-transform' :
  13840. isFirefox ?
  13841. 'MozTransform' :
  13842. win.opera ?
  13843. '-o-transform' :
  13844. void 0); };
  13845. var rotationStyle = {},
  13846. cssTransformKey = getTransformKey();
  13847. if (cssTransformKey) {
  13848. rotationStyle[cssTransformKey] = rotationStyle.transform =
  13849. 'rotate(' + rotation + 'deg)';
  13850. rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] = rotationStyle.transformOrigin =
  13851. (alignCorrection * 100) + '% ' + baseline + 'px';
  13852. css(this.element, rotationStyle);
  13853. }
  13854. },
  13855. /**
  13856. * Get the correction in X and Y positioning as the element is rotated.
  13857. *
  13858. * @private
  13859. * @function Highcharts.SVGElement#getSpanCorrection
  13860. * @param {number} width
  13861. * @param {number} baseline
  13862. * @param {number} alignCorrection
  13863. * @return {void}
  13864. */
  13865. getSpanCorrection: function (width, baseline, alignCorrection) {
  13866. this.xCorr = -width * alignCorrection;
  13867. this.yCorr = -baseline;
  13868. }
  13869. });
  13870. return HTMLElement;
  13871. });
  13872. _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) {
  13873. /* *
  13874. *
  13875. * (c) 2010-2021 Torstein Honsi
  13876. *
  13877. * License: www.highcharts.com/license
  13878. *
  13879. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  13880. *
  13881. * */
  13882. var attr = U.attr,
  13883. createElement = U.createElement,
  13884. extend = U.extend,
  13885. pick = U.pick;
  13886. /**
  13887. * Renderer placebo
  13888. * @private
  13889. */
  13890. var HTMLRenderer = SVGRenderer;
  13891. /* eslint-disable valid-jsdoc */
  13892. // Extend SvgRenderer for useHTML option.
  13893. extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {
  13894. /**
  13895. * Create HTML text node. This is used by the VML renderer as well as the
  13896. * SVG renderer through the useHTML option.
  13897. *
  13898. * @private
  13899. * @function Highcharts.SVGRenderer#html
  13900. *
  13901. * @param {string} str
  13902. * The text of (subset) HTML to draw.
  13903. *
  13904. * @param {number} x
  13905. * The x position of the text's lower left corner.
  13906. *
  13907. * @param {number} y
  13908. * The y position of the text's lower left corner.
  13909. *
  13910. * @return {Highcharts.HTMLDOMElement}
  13911. */
  13912. html: function (str, x, y) {
  13913. var wrapper = this.createElement('span'), element = wrapper.element, renderer = wrapper.renderer, isSVG = renderer.isSVG, addSetters = function (gWrapper, style) {
  13914. // These properties are set as attributes on the SVG group, and
  13915. // as identical CSS properties on the div. (#3542)
  13916. ['opacity', 'visibility'].forEach(function (prop) {
  13917. gWrapper[prop + 'Setter'] = function (value, key, elem) {
  13918. var styleObject = gWrapper.div ?
  13919. gWrapper.div.style :
  13920. style;
  13921. SVGElement.prototype[prop + 'Setter']
  13922. .call(this, value, key, elem);
  13923. if (styleObject) {
  13924. styleObject[key] = value;
  13925. }
  13926. };
  13927. });
  13928. gWrapper.addedSetters = true;
  13929. };
  13930. // Text setter
  13931. wrapper.textSetter = function (value) {
  13932. if (value !== this.textStr) {
  13933. delete this.bBox;
  13934. delete this.oldTextWidth;
  13935. AST.setElementHTML(this.element, pick(value, ''));
  13936. this.textStr = value;
  13937. wrapper.doTransform = true;
  13938. }
  13939. };
  13940. // Add setters for the element itself (#4938)
  13941. if (isSVG) { // #4938, only for HTML within SVG
  13942. addSetters(wrapper, wrapper.element.style);
  13943. }
  13944. // Various setters which rely on update transform
  13945. wrapper.xSetter =
  13946. wrapper.ySetter =
  13947. wrapper.alignSetter =
  13948. wrapper.rotationSetter =
  13949. function (value, key) {
  13950. if (key === 'align') {
  13951. // Do not overwrite the SVGElement.align method. Same as VML.
  13952. wrapper.alignValue = wrapper.textAlign = value;
  13953. }
  13954. else {
  13955. wrapper[key] = value;
  13956. }
  13957. wrapper.doTransform = true;
  13958. };
  13959. // Runs at the end of .attr()
  13960. wrapper.afterSetters = function () {
  13961. // Update transform. Do this outside the loop to prevent redundant
  13962. // updating for batch setting of attributes.
  13963. if (this.doTransform) {
  13964. this.htmlUpdateTransform();
  13965. this.doTransform = false;
  13966. }
  13967. };
  13968. // Set the default attributes
  13969. wrapper
  13970. .attr({
  13971. text: str,
  13972. x: Math.round(x),
  13973. y: Math.round(y)
  13974. })
  13975. .css({
  13976. position: 'absolute'
  13977. });
  13978. if (!renderer.styledMode) {
  13979. wrapper.css({
  13980. fontFamily: this.style.fontFamily,
  13981. fontSize: this.style.fontSize
  13982. });
  13983. }
  13984. // Keep the whiteSpace style outside the wrapper.styles collection
  13985. element.style.whiteSpace = 'nowrap';
  13986. // Use the HTML specific .css method
  13987. wrapper.css = wrapper.htmlCss;
  13988. // This is specific for HTML within SVG
  13989. if (isSVG) {
  13990. wrapper.add = function (svgGroupWrapper) {
  13991. var htmlGroup,
  13992. container = renderer.box.parentNode,
  13993. parentGroup,
  13994. parents = [];
  13995. this.parentGroup = svgGroupWrapper;
  13996. // Create a mock group to hold the HTML elements
  13997. if (svgGroupWrapper) {
  13998. htmlGroup = svgGroupWrapper.div;
  13999. if (!htmlGroup) {
  14000. // Read the parent chain into an array and read from top
  14001. // down
  14002. parentGroup = svgGroupWrapper;
  14003. while (parentGroup) {
  14004. parents.push(parentGroup);
  14005. // Move up to the next parent group
  14006. parentGroup = parentGroup.parentGroup;
  14007. }
  14008. // Ensure dynamically updating position when any parent
  14009. // is translated
  14010. parents.reverse().forEach(function (parentGroup) {
  14011. var htmlGroupStyle,
  14012. cls = attr(parentGroup.element, 'class');
  14013. /**
  14014. * Common translate setter for X and Y on the HTML
  14015. * group. Reverted the fix for #6957 du to
  14016. * positioning problems and offline export (#7254,
  14017. * #7280, #7529)
  14018. * @private
  14019. * @param {*} value
  14020. * @param {string} key
  14021. * @return {void}
  14022. */
  14023. function translateSetter(value, key) {
  14024. parentGroup[key] = value;
  14025. if (key === 'translateX') {
  14026. htmlGroupStyle.left = value + 'px';
  14027. }
  14028. else {
  14029. htmlGroupStyle.top = value + 'px';
  14030. }
  14031. parentGroup.doTransform = true;
  14032. }
  14033. // Create a HTML div and append it to the parent div
  14034. // to emulate the SVG group structure
  14035. var parentGroupStyles = parentGroup.styles || {};
  14036. htmlGroup =
  14037. parentGroup.div =
  14038. parentGroup.div || createElement('div', cls ? { className: cls } : void 0, {
  14039. position: 'absolute',
  14040. left: (parentGroup.translateX || 0) + 'px',
  14041. top: (parentGroup.translateY || 0) + 'px',
  14042. display: parentGroup.display,
  14043. opacity: parentGroup.opacity,
  14044. cursor: parentGroupStyles.cursor,
  14045. pointerEvents: parentGroupStyles.pointerEvents // #5595
  14046. // the top group is appended to container
  14047. }, htmlGroup || container);
  14048. // Shortcut
  14049. htmlGroupStyle = htmlGroup.style;
  14050. // Set listeners to update the HTML div's position
  14051. // whenever the SVG group position is changed.
  14052. extend(parentGroup, {
  14053. // (#7287) Pass htmlGroup to use
  14054. // the related group
  14055. classSetter: (function (htmlGroup) {
  14056. return function (value) {
  14057. this.element.setAttribute('class', value);
  14058. htmlGroup.className = value;
  14059. };
  14060. }(htmlGroup)),
  14061. on: function () {
  14062. if (parents[0].div) { // #6418
  14063. wrapper.on.apply({
  14064. element: parents[0].div,
  14065. onEvents: wrapper.onEvents
  14066. }, arguments);
  14067. }
  14068. return parentGroup;
  14069. },
  14070. translateXSetter: translateSetter,
  14071. translateYSetter: translateSetter
  14072. });
  14073. if (!parentGroup.addedSetters) {
  14074. addSetters(parentGroup);
  14075. }
  14076. });
  14077. }
  14078. }
  14079. else {
  14080. htmlGroup = container;
  14081. }
  14082. htmlGroup.appendChild(element);
  14083. // Shared with VML:
  14084. wrapper.added = true;
  14085. if (wrapper.alignOnAdd) {
  14086. wrapper.htmlUpdateTransform();
  14087. }
  14088. return wrapper;
  14089. };
  14090. }
  14091. return wrapper;
  14092. }
  14093. });
  14094. return HTMLRenderer;
  14095. });
  14096. _registerModule(_modules, 'Core/Axis/Tick.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (F, H, U) {
  14097. /* *
  14098. *
  14099. * (c) 2010-2021 Torstein Honsi
  14100. *
  14101. * License: www.highcharts.com/license
  14102. *
  14103. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14104. *
  14105. * */
  14106. var deg2rad = H.deg2rad;
  14107. var clamp = U.clamp,
  14108. correctFloat = U.correctFloat,
  14109. defined = U.defined,
  14110. destroyObjectProperties = U.destroyObjectProperties,
  14111. extend = U.extend,
  14112. fireEvent = U.fireEvent,
  14113. isNumber = U.isNumber,
  14114. merge = U.merge,
  14115. objectEach = U.objectEach,
  14116. pick = U.pick;
  14117. /**
  14118. * Optional parameters for the tick.
  14119. * @private
  14120. * @interface Highcharts.TickParametersObject
  14121. */ /**
  14122. * Set category for the tick.
  14123. * @name Highcharts.TickParametersObject#category
  14124. * @type {string|undefined}
  14125. */ /**
  14126. * @name Highcharts.TickParametersObject#options
  14127. * @type {Highcharts.Dictionary<any>|undefined}
  14128. */ /**
  14129. * Set tickmarkOffset for the tick.
  14130. * @name Highcharts.TickParametersObject#tickmarkOffset
  14131. * @type {number|undefined}
  14132. */
  14133. /**
  14134. * Additonal time tick information.
  14135. *
  14136. * @interface Highcharts.TimeTicksInfoObject
  14137. * @extends Highcharts.TimeNormalizedObject
  14138. */ /**
  14139. * @name Highcharts.TimeTicksInfoObject#higherRanks
  14140. * @type {Array<string>}
  14141. */ /**
  14142. * @name Highcharts.TimeTicksInfoObject#totalRange
  14143. * @type {number}
  14144. */
  14145. ''; // detach doclets above
  14146. /* eslint-disable no-invalid-this, valid-jsdoc */
  14147. /**
  14148. * The Tick class.
  14149. *
  14150. * @class
  14151. * @name Highcharts.Tick
  14152. *
  14153. * @param {Highcharts.Axis} axis
  14154. * The axis of the tick.
  14155. *
  14156. * @param {number} pos
  14157. * The position of the tick on the axis in terms of axis values.
  14158. *
  14159. * @param {string} [type]
  14160. * The type of tick, either 'minor' or an empty string
  14161. *
  14162. * @param {boolean} [noLabel=false]
  14163. * Whether to disable the label or not. Defaults to false.
  14164. *
  14165. * @param {object} [parameters]
  14166. * Optional parameters for the tick.
  14167. */
  14168. var Tick = /** @class */ (function () {
  14169. /* *
  14170. *
  14171. * Constructors
  14172. *
  14173. * */
  14174. function Tick(axis, pos, type, noLabel, parameters) {
  14175. this.isNew = true;
  14176. this.isNewLabel = true;
  14177. /**
  14178. * The related axis of the tick.
  14179. * @name Highcharts.Tick#axis
  14180. * @type {Highcharts.Axis}
  14181. */
  14182. this.axis = axis;
  14183. /**
  14184. * The logical position of the tick on the axis in terms of axis values.
  14185. * @name Highcharts.Tick#pos
  14186. * @type {number}
  14187. */
  14188. this.pos = pos;
  14189. /**
  14190. * The tick type, which can be `"minor"`, or an empty string.
  14191. * @name Highcharts.Tick#type
  14192. * @type {string}
  14193. */
  14194. this.type = type || '';
  14195. this.parameters = parameters || {};
  14196. /**
  14197. * The mark offset of the tick on the axis. Usually `undefined`, numeric
  14198. * for grid axes.
  14199. * @name Highcharts.Tick#tickmarkOffset
  14200. * @type {number|undefined}
  14201. */
  14202. this.tickmarkOffset = this.parameters.tickmarkOffset;
  14203. this.options = this.parameters.options;
  14204. fireEvent(this, 'init');
  14205. if (!type && !noLabel) {
  14206. this.addLabel();
  14207. }
  14208. }
  14209. /* *
  14210. *
  14211. * Functions
  14212. *
  14213. * */
  14214. /**
  14215. * Write the tick label.
  14216. *
  14217. * @private
  14218. * @function Highcharts.Tick#addLabel
  14219. * @return {void}
  14220. */
  14221. Tick.prototype.addLabel = function () {
  14222. var tick = this,
  14223. axis = tick.axis,
  14224. options = axis.options,
  14225. chart = axis.chart,
  14226. categories = axis.categories,
  14227. log = axis.logarithmic,
  14228. names = axis.names,
  14229. pos = tick.pos,
  14230. labelOptions = pick(tick.options && tick.options.labels,
  14231. options.labels),
  14232. str,
  14233. tickPositions = axis.tickPositions,
  14234. isFirst = pos === tickPositions[0],
  14235. isLast = pos === tickPositions[tickPositions.length - 1],
  14236. label = tick.label,
  14237. animateLabels = (!labelOptions.step || labelOptions.step === 1) &&
  14238. axis.tickInterval === 1,
  14239. tickPositionInfo = tickPositions.info,
  14240. dateTimeLabelFormat,
  14241. dateTimeLabelFormats,
  14242. i,
  14243. list;
  14244. // The context value
  14245. var value = this.parameters.category || (categories ?
  14246. pick(categories[pos],
  14247. names[pos],
  14248. pos) :
  14249. pos);
  14250. if (log && isNumber(value)) {
  14251. value = correctFloat(log.lin2log(value));
  14252. }
  14253. // Set the datetime label format. If a higher rank is set for this
  14254. // position, use that. If not, use the general format.
  14255. if (axis.dateTime && tickPositionInfo) {
  14256. dateTimeLabelFormats = chart.time.resolveDTLFormat(options.dateTimeLabelFormats[(!options.grid &&
  14257. tickPositionInfo.higherRanks[pos]) ||
  14258. tickPositionInfo.unitName]);
  14259. dateTimeLabelFormat = dateTimeLabelFormats.main;
  14260. }
  14261. // set properties for access in render method
  14262. /**
  14263. * True if the tick is the first one on the axis.
  14264. * @name Highcharts.Tick#isFirst
  14265. * @readonly
  14266. * @type {boolean|undefined}
  14267. */
  14268. tick.isFirst = isFirst;
  14269. /**
  14270. * True if the tick is the last one on the axis.
  14271. * @name Highcharts.Tick#isLast
  14272. * @readonly
  14273. * @type {boolean|undefined}
  14274. */
  14275. tick.isLast = isLast;
  14276. // Get the string
  14277. var ctx = {
  14278. axis: axis,
  14279. chart: chart,
  14280. dateTimeLabelFormat: dateTimeLabelFormat,
  14281. isFirst: isFirst,
  14282. isLast: isLast,
  14283. pos: pos,
  14284. tick: tick,
  14285. tickPositionInfo: tickPositionInfo,
  14286. value: value
  14287. };
  14288. // Fire an event that allows modifying the context for use in
  14289. // `labels.format` and `labels.formatter`.
  14290. fireEvent(this, 'labelFormat', ctx);
  14291. // Label formatting. When `labels.format` is given, we first run the
  14292. // defaultFormatter and append the result to the context as `text`.
  14293. // Handy for adding prefix or suffix while keeping default number
  14294. // formatting.
  14295. var labelFormatter = function (ctx) {
  14296. if (labelOptions.formatter) {
  14297. return labelOptions.formatter.call(ctx,
  14298. ctx);
  14299. }
  14300. if (labelOptions.format) {
  14301. ctx.text = axis.defaultLabelFormatter.call(ctx);
  14302. return F.format(labelOptions.format, ctx, chart);
  14303. }
  14304. return axis.defaultLabelFormatter.call(ctx, ctx);
  14305. };
  14306. str = labelFormatter.call(ctx, ctx);
  14307. // Set up conditional formatting based on the format list if existing.
  14308. list = dateTimeLabelFormats && dateTimeLabelFormats.list;
  14309. if (list) {
  14310. tick.shortenLabel = function () {
  14311. for (i = 0; i < list.length; i++) {
  14312. extend(ctx, { dateTimeLabelFormat: list[i] });
  14313. label.attr({
  14314. text: labelFormatter.call(ctx, ctx)
  14315. });
  14316. if (label.getBBox().width <
  14317. axis.getSlotWidth(tick) - 2 *
  14318. labelOptions.padding) {
  14319. return;
  14320. }
  14321. }
  14322. label.attr({
  14323. text: ''
  14324. });
  14325. };
  14326. }
  14327. // Call only after first render
  14328. if (animateLabels && axis._addedPlotLB) {
  14329. tick.moveLabel(str, labelOptions);
  14330. }
  14331. // First call
  14332. if (!defined(label) && !tick.movedLabel) {
  14333. /**
  14334. * The rendered text label of the tick.
  14335. * @name Highcharts.Tick#label
  14336. * @type {Highcharts.SVGElement|undefined}
  14337. */
  14338. tick.label = label = tick.createLabel({ x: 0, y: 0 }, str, labelOptions);
  14339. // Base value to detect change for new calls to getBBox
  14340. tick.rotation = 0;
  14341. // update
  14342. }
  14343. else if (label && label.textStr !== str && !animateLabels) {
  14344. // When resetting text, also reset the width if dynamically set
  14345. // (#8809)
  14346. if (label.textWidth &&
  14347. !labelOptions.style.width &&
  14348. !label.styles.width) {
  14349. label.css({ width: null });
  14350. }
  14351. label.attr({ text: str });
  14352. label.textPxLength = label.getBBox().width;
  14353. }
  14354. };
  14355. /**
  14356. * Render and return the label of the tick.
  14357. *
  14358. * @private
  14359. * @function Highcharts.Tick#createLabel
  14360. * @param {Highcharts.PositionObject} xy
  14361. * @param {string} str
  14362. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  14363. * @return {Highcharts.SVGElement|undefined}
  14364. */
  14365. Tick.prototype.createLabel = function (xy, str, labelOptions) {
  14366. var axis = this.axis,
  14367. chart = axis.chart,
  14368. label = defined(str) && labelOptions.enabled ?
  14369. chart.renderer
  14370. .text(str,
  14371. xy.x,
  14372. xy.y,
  14373. labelOptions.useHTML)
  14374. .add(axis.labelGroup) :
  14375. null;
  14376. // Un-rotated length
  14377. if (label) {
  14378. // Without position absolute, IE export sometimes is wrong
  14379. if (!chart.styledMode) {
  14380. label.css(merge(labelOptions.style));
  14381. }
  14382. label.textPxLength = label.getBBox().width;
  14383. }
  14384. return label;
  14385. };
  14386. /**
  14387. * Destructor for the tick prototype
  14388. *
  14389. * @private
  14390. * @function Highcharts.Tick#destroy
  14391. * @return {void}
  14392. */
  14393. Tick.prototype.destroy = function () {
  14394. destroyObjectProperties(this, this.axis);
  14395. };
  14396. /**
  14397. * Gets the x and y positions for ticks in terms of pixels.
  14398. *
  14399. * @private
  14400. * @function Highcharts.Tick#getPosition
  14401. *
  14402. * @param {boolean} horiz
  14403. * Whether the tick is on an horizontal axis or not.
  14404. *
  14405. * @param {number} tickPos
  14406. * Position of the tick.
  14407. *
  14408. * @param {number} tickmarkOffset
  14409. * Tickmark offset for all ticks.
  14410. *
  14411. * @param {boolean} [old]
  14412. * Whether the axis has changed or not.
  14413. *
  14414. * @return {Highcharts.PositionObject}
  14415. * The tick position.
  14416. *
  14417. * @fires Highcharts.Tick#event:afterGetPosition
  14418. */
  14419. Tick.prototype.getPosition = function (horiz, tickPos, tickmarkOffset, old) {
  14420. var axis = this.axis,
  14421. chart = axis.chart,
  14422. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  14423. pos;
  14424. pos = {
  14425. x: horiz ?
  14426. correctFloat(axis.translate(tickPos + tickmarkOffset, null, null, old) +
  14427. axis.transB) :
  14428. (axis.left +
  14429. axis.offset +
  14430. (axis.opposite ?
  14431. (((old && chart.oldChartWidth) ||
  14432. chart.chartWidth) -
  14433. axis.right -
  14434. axis.left) :
  14435. 0)),
  14436. y: horiz ?
  14437. (cHeight -
  14438. axis.bottom +
  14439. axis.offset -
  14440. (axis.opposite ? axis.height : 0)) :
  14441. correctFloat(cHeight -
  14442. axis.translate(tickPos + tickmarkOffset, null, null, old) -
  14443. axis.transB)
  14444. };
  14445. // Chrome workaround for #10516
  14446. pos.y = clamp(pos.y, -1e5, 1e5);
  14447. fireEvent(this, 'afterGetPosition', { pos: pos });
  14448. return pos;
  14449. };
  14450. /**
  14451. * Get the x, y position of the tick label
  14452. *
  14453. * @private
  14454. * @return {Highcharts.PositionObject}
  14455. */
  14456. Tick.prototype.getLabelPosition = function (x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
  14457. var axis = this.axis,
  14458. transA = axis.transA,
  14459. reversed = ( // #7911
  14460. axis.isLinked && axis.linkedParent ?
  14461. axis.linkedParent.reversed :
  14462. axis.reversed),
  14463. staggerLines = axis.staggerLines,
  14464. rotCorr = axis.tickRotCorr || { x: 0,
  14465. y: 0 },
  14466. yOffset = labelOptions.y,
  14467. // Adjust for label alignment if we use reserveSpace: true (#5286)
  14468. labelOffsetCorrection = (!horiz && !axis.reserveSpaceDefault ?
  14469. -axis.labelOffset * (axis.labelAlign === 'center' ? 0.5 : 1) :
  14470. 0),
  14471. line,
  14472. pos = {};
  14473. if (!defined(yOffset)) {
  14474. if (axis.side === 0) {
  14475. yOffset = label.rotation ? -8 : -label.getBBox().height;
  14476. }
  14477. else if (axis.side === 2) {
  14478. yOffset = rotCorr.y + 8;
  14479. }
  14480. else {
  14481. // #3140, #3140
  14482. yOffset = Math.cos(label.rotation * deg2rad) *
  14483. (rotCorr.y - label.getBBox(false, 0).height / 2);
  14484. }
  14485. }
  14486. x = x +
  14487. labelOptions.x +
  14488. labelOffsetCorrection +
  14489. rotCorr.x -
  14490. (tickmarkOffset && horiz ?
  14491. tickmarkOffset * transA * (reversed ? -1 : 1) :
  14492. 0);
  14493. y = y + yOffset - (tickmarkOffset && !horiz ?
  14494. tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
  14495. // Correct for staggered labels
  14496. if (staggerLines) {
  14497. line = (index / (step || 1) % staggerLines);
  14498. if (axis.opposite) {
  14499. line = staggerLines - line - 1;
  14500. }
  14501. y += line * (axis.labelOffset / staggerLines);
  14502. }
  14503. pos.x = x;
  14504. pos.y = Math.round(y);
  14505. fireEvent(this, 'afterGetLabelPosition', { pos: pos, tickmarkOffset: tickmarkOffset, index: index });
  14506. return pos;
  14507. };
  14508. /**
  14509. * Get the offset height or width of the label
  14510. *
  14511. * @private
  14512. * @function Highcharts.Tick#getLabelSize
  14513. * @return {number}
  14514. */
  14515. Tick.prototype.getLabelSize = function () {
  14516. return this.label ?
  14517. this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
  14518. 0;
  14519. };
  14520. /**
  14521. * Extendible method to return the path of the marker
  14522. *
  14523. * @private
  14524. *
  14525. */
  14526. Tick.prototype.getMarkPath = function (x, y, tickLength, tickWidth, horiz, renderer) {
  14527. return renderer.crispLine([[
  14528. 'M',
  14529. x,
  14530. y
  14531. ], [
  14532. 'L',
  14533. x + (horiz ? 0 : -tickLength),
  14534. y + (horiz ? tickLength : 0)
  14535. ]], tickWidth);
  14536. };
  14537. /**
  14538. * Handle the label overflow by adjusting the labels to the left and right
  14539. * edge, or hide them if they collide into the neighbour label.
  14540. *
  14541. * @private
  14542. * @function Highcharts.Tick#handleOverflow
  14543. * @param {Highcharts.PositionObject} xy
  14544. * @return {void}
  14545. */
  14546. Tick.prototype.handleOverflow = function (xy) {
  14547. var tick = this,
  14548. axis = this.axis,
  14549. labelOptions = axis.options.labels,
  14550. pxPos = xy.x,
  14551. chartWidth = axis.chart.chartWidth,
  14552. spacing = axis.chart.spacing,
  14553. leftBound = pick(axis.labelLeft,
  14554. Math.min(axis.pos,
  14555. spacing[3])),
  14556. rightBound = pick(axis.labelRight,
  14557. Math.max(!axis.isRadial ? axis.pos + axis.len : 0,
  14558. chartWidth - spacing[1])),
  14559. label = this.label,
  14560. rotation = this.rotation,
  14561. factor = {
  14562. left: 0,
  14563. center: 0.5,
  14564. right: 1
  14565. }[axis.labelAlign || label.attr('align')],
  14566. labelWidth = label.getBBox().width,
  14567. slotWidth = axis.getSlotWidth(tick),
  14568. modifiedSlotWidth = slotWidth,
  14569. xCorrection = factor,
  14570. goRight = 1,
  14571. leftPos,
  14572. rightPos,
  14573. textWidth,
  14574. css = {};
  14575. // Check if the label overshoots the chart spacing box. If it does, move
  14576. // it. If it now overshoots the slotWidth, add ellipsis.
  14577. if (!rotation && labelOptions.overflow === 'justify') {
  14578. leftPos = pxPos - factor * labelWidth;
  14579. rightPos = pxPos + (1 - factor) * labelWidth;
  14580. if (leftPos < leftBound) {
  14581. modifiedSlotWidth =
  14582. xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
  14583. }
  14584. else if (rightPos > rightBound) {
  14585. modifiedSlotWidth =
  14586. rightBound - xy.x + modifiedSlotWidth * factor;
  14587. goRight = -1;
  14588. }
  14589. modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
  14590. if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
  14591. xy.x += (goRight *
  14592. (slotWidth -
  14593. modifiedSlotWidth -
  14594. xCorrection * (slotWidth - Math.min(labelWidth, modifiedSlotWidth))));
  14595. }
  14596. // If the label width exceeds the available space, set a text width
  14597. // to be picked up below. Also, if a width has been set before, we
  14598. // need to set a new one because the reported labelWidth will be
  14599. // limited by the box (#3938).
  14600. if (labelWidth > modifiedSlotWidth ||
  14601. (axis.autoRotation && (label.styles || {}).width)) {
  14602. textWidth = modifiedSlotWidth;
  14603. }
  14604. // Add ellipsis to prevent rotated labels to be clipped against the edge
  14605. // of the chart
  14606. }
  14607. else if (rotation < 0 &&
  14608. pxPos - factor * labelWidth < leftBound) {
  14609. textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
  14610. }
  14611. else if (rotation > 0 &&
  14612. pxPos + factor * labelWidth > rightBound) {
  14613. textWidth = Math.round((chartWidth - pxPos) /
  14614. Math.cos(rotation * deg2rad));
  14615. }
  14616. if (textWidth) {
  14617. if (tick.shortenLabel) {
  14618. tick.shortenLabel();
  14619. }
  14620. else {
  14621. css.width = Math.floor(textWidth) + 'px';
  14622. if (!(labelOptions.style || {}).textOverflow) {
  14623. css.textOverflow = 'ellipsis';
  14624. }
  14625. label.css(css);
  14626. }
  14627. }
  14628. };
  14629. /**
  14630. * Try to replace the label if the same one already exists.
  14631. *
  14632. * @private
  14633. * @function Highcharts.Tick#moveLabel
  14634. * @param {string} str
  14635. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  14636. *
  14637. * @return {void}
  14638. */
  14639. Tick.prototype.moveLabel = function (str, labelOptions) {
  14640. var tick = this,
  14641. label = tick.label,
  14642. moved = false,
  14643. axis = tick.axis,
  14644. labelPos,
  14645. reversed = axis.reversed,
  14646. xPos,
  14647. yPos;
  14648. if (label && label.textStr === str) {
  14649. tick.movedLabel = label;
  14650. moved = true;
  14651. delete tick.label;
  14652. }
  14653. else { // Find a label with the same string
  14654. objectEach(axis.ticks, function (currentTick) {
  14655. if (!moved &&
  14656. !currentTick.isNew &&
  14657. currentTick !== tick &&
  14658. currentTick.label &&
  14659. currentTick.label.textStr === str) {
  14660. tick.movedLabel = currentTick.label;
  14661. moved = true;
  14662. currentTick.labelPos = tick.movedLabel.xy;
  14663. delete currentTick.label;
  14664. }
  14665. });
  14666. }
  14667. // Create new label if the actual one is moved
  14668. if (!moved && (tick.labelPos || label)) {
  14669. labelPos = tick.labelPos || label.xy;
  14670. xPos = axis.horiz ?
  14671. (reversed ? 0 : axis.width + axis.left) : labelPos.x;
  14672. yPos = axis.horiz ?
  14673. labelPos.y : (reversed ? (axis.width + axis.left) : 0);
  14674. tick.movedLabel = tick.createLabel({ x: xPos, y: yPos }, str, labelOptions);
  14675. if (tick.movedLabel) {
  14676. tick.movedLabel.attr({ opacity: 0 });
  14677. }
  14678. }
  14679. };
  14680. /**
  14681. * Put everything in place
  14682. *
  14683. * @private
  14684. * @param {number} index
  14685. * @param {boolean} [old]
  14686. * Use old coordinates to prepare an animation into new position
  14687. * @param {number} [opacity]
  14688. * @return {voids}
  14689. */
  14690. Tick.prototype.render = function (index, old, opacity) {
  14691. var tick = this,
  14692. axis = tick.axis,
  14693. horiz = axis.horiz,
  14694. pos = tick.pos,
  14695. tickmarkOffset = pick(tick.tickmarkOffset,
  14696. axis.tickmarkOffset),
  14697. xy = tick.getPosition(horiz,
  14698. pos,
  14699. tickmarkOffset,
  14700. old),
  14701. x = xy.x,
  14702. y = xy.y,
  14703. reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
  14704. (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
  14705. var labelOpacity = pick(opacity,
  14706. tick.label && tick.label.newOpacity, // #15528
  14707. 1);
  14708. opacity = pick(opacity, 1);
  14709. this.isActive = true;
  14710. // Create the grid line
  14711. this.renderGridLine(old, opacity, reverseCrisp);
  14712. // create the tick mark
  14713. this.renderMark(xy, opacity, reverseCrisp);
  14714. // the label is created on init - now move it into place
  14715. this.renderLabel(xy, old, labelOpacity, index);
  14716. tick.isNew = false;
  14717. fireEvent(this, 'afterRender');
  14718. };
  14719. /**
  14720. * Renders the gridLine.
  14721. *
  14722. * @private
  14723. * @param {boolean} old Whether or not the tick is old
  14724. * @param {number} opacity The opacity of the grid line
  14725. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  14726. * @return {void}
  14727. */
  14728. Tick.prototype.renderGridLine = function (old, opacity, reverseCrisp) {
  14729. var tick = this,
  14730. axis = tick.axis,
  14731. options = axis.options,
  14732. gridLine = tick.gridLine,
  14733. gridLinePath,
  14734. attribs = {},
  14735. pos = tick.pos,
  14736. type = tick.type,
  14737. tickmarkOffset = pick(tick.tickmarkOffset,
  14738. axis.tickmarkOffset),
  14739. renderer = axis.chart.renderer,
  14740. gridLineWidth = options.gridLineWidth,
  14741. gridLineColor = options.gridLineColor,
  14742. dashStyle = options.gridLineDashStyle;
  14743. if (tick.type === 'minor') {
  14744. gridLineWidth = options.minorGridLineWidth;
  14745. gridLineColor = options.minorGridLineColor;
  14746. dashStyle = options.minorGridLineDashStyle;
  14747. }
  14748. if (!gridLine) {
  14749. if (!axis.chart.styledMode) {
  14750. attribs.stroke = gridLineColor;
  14751. attribs['stroke-width'] = gridLineWidth || 0;
  14752. attribs.dashstyle = dashStyle;
  14753. }
  14754. if (!type) {
  14755. attribs.zIndex = 1;
  14756. }
  14757. if (old) {
  14758. opacity = 0;
  14759. }
  14760. /**
  14761. * The rendered grid line of the tick.
  14762. * @name Highcharts.Tick#gridLine
  14763. * @type {Highcharts.SVGElement|undefined}
  14764. */
  14765. tick.gridLine = gridLine = renderer.path()
  14766. .attr(attribs)
  14767. .addClass('highcharts-' + (type ? type + '-' : '') + 'grid-line')
  14768. .add(axis.gridGroup);
  14769. }
  14770. if (gridLine) {
  14771. gridLinePath = axis.getPlotLinePath({
  14772. value: pos + tickmarkOffset,
  14773. lineWidth: gridLine.strokeWidth() * reverseCrisp,
  14774. force: 'pass',
  14775. old: old
  14776. });
  14777. // If the parameter 'old' is set, the current call will be followed
  14778. // by another call, therefore do not do any animations this time
  14779. if (gridLinePath) {
  14780. gridLine[old || tick.isNew ? 'attr' : 'animate']({
  14781. d: gridLinePath,
  14782. opacity: opacity
  14783. });
  14784. }
  14785. }
  14786. };
  14787. /**
  14788. * Renders the tick mark.
  14789. *
  14790. * @private
  14791. * @param {Highcharts.PositionObject} xy The position vector of the mark
  14792. * @param {number} opacity The opacity of the mark
  14793. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  14794. * @return {void}
  14795. */
  14796. Tick.prototype.renderMark = function (xy, opacity, reverseCrisp) {
  14797. var tick = this, axis = tick.axis, options = axis.options, renderer = axis.chart.renderer, type = tick.type, tickSize = axis.tickSize(type ? type + 'Tick' : 'tick'), mark = tick.mark, isNewMark = !mark, x = xy.x, y = xy.y, tickWidth = pick(options[type !== 'minor' ? 'tickWidth' : 'minorTickWidth'], !type && axis.isXAxis ? 1 : 0), // X axis defaults to 1
  14798. tickColor = options[type !== 'minor' ? 'tickColor' : 'minorTickColor'];
  14799. if (tickSize) {
  14800. // negate the length
  14801. if (axis.opposite) {
  14802. tickSize[0] = -tickSize[0];
  14803. }
  14804. // First time, create it
  14805. if (isNewMark) {
  14806. /**
  14807. * The rendered mark of the tick.
  14808. * @name Highcharts.Tick#mark
  14809. * @type {Highcharts.SVGElement|undefined}
  14810. */
  14811. tick.mark = mark = renderer.path()
  14812. .addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
  14813. .add(axis.axisGroup);
  14814. if (!axis.chart.styledMode) {
  14815. mark.attr({
  14816. stroke: tickColor,
  14817. 'stroke-width': tickWidth
  14818. });
  14819. }
  14820. }
  14821. mark[isNewMark ? 'attr' : 'animate']({
  14822. d: tick.getMarkPath(x, y, tickSize[0], mark.strokeWidth() * reverseCrisp, axis.horiz, renderer),
  14823. opacity: opacity
  14824. });
  14825. }
  14826. };
  14827. /**
  14828. * Renders the tick label.
  14829. * Note: The label should already be created in init(), so it should only
  14830. * have to be moved into place.
  14831. *
  14832. * @private
  14833. * @param {Highcharts.PositionObject} xy The position vector of the label
  14834. * @param {boolean} old Whether or not the tick is old
  14835. * @param {number} opacity The opacity of the label
  14836. * @param {number} index The index of the tick
  14837. * @return {void}
  14838. */
  14839. Tick.prototype.renderLabel = function (xy, old, opacity, index) {
  14840. var tick = this,
  14841. axis = tick.axis,
  14842. horiz = axis.horiz,
  14843. options = axis.options,
  14844. label = tick.label,
  14845. labelOptions = options.labels,
  14846. step = labelOptions.step,
  14847. tickmarkOffset = pick(tick.tickmarkOffset,
  14848. axis.tickmarkOffset),
  14849. show = true,
  14850. x = xy.x,
  14851. y = xy.y;
  14852. if (label && isNumber(x)) {
  14853. label.xy = xy = tick.getLabelPosition(x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
  14854. // Apply show first and show last. If the tick is both first and
  14855. // last, it is a single centered tick, in which case we show the
  14856. // label anyway (#2100).
  14857. if ((tick.isFirst &&
  14858. !tick.isLast &&
  14859. !options.showFirstLabel) ||
  14860. (tick.isLast &&
  14861. !tick.isFirst &&
  14862. !options.showLastLabel)) {
  14863. show = false;
  14864. // Handle label overflow and show or hide accordingly
  14865. }
  14866. else if (horiz &&
  14867. !labelOptions.step &&
  14868. !labelOptions.rotation &&
  14869. !old &&
  14870. opacity !== 0) {
  14871. tick.handleOverflow(xy);
  14872. }
  14873. // apply step
  14874. if (step && index % step) {
  14875. // show those indices dividable by step
  14876. show = false;
  14877. }
  14878. // Set the new position, and show or hide
  14879. if (show && isNumber(xy.y)) {
  14880. xy.opacity = opacity;
  14881. label[tick.isNewLabel ? 'attr' : 'animate'](xy);
  14882. tick.isNewLabel = false;
  14883. }
  14884. else {
  14885. label.attr('y', -9999); // #1338
  14886. tick.isNewLabel = true;
  14887. }
  14888. }
  14889. };
  14890. /**
  14891. * Replace labels with the moved ones to perform animation. Additionally
  14892. * destroy unused labels.
  14893. *
  14894. * @private
  14895. * @function Highcharts.Tick#replaceMovedLabel
  14896. * @return {void}
  14897. */
  14898. Tick.prototype.replaceMovedLabel = function () {
  14899. var tick = this,
  14900. label = tick.label,
  14901. axis = tick.axis,
  14902. reversed = axis.reversed,
  14903. x,
  14904. y;
  14905. // Animate and destroy
  14906. if (label && !tick.isNew) {
  14907. x = axis.horiz ? (reversed ? axis.left : axis.width + axis.left) : label.xy.x;
  14908. y = axis.horiz ?
  14909. label.xy.y :
  14910. (reversed ? axis.width + axis.top : axis.top);
  14911. label.animate({ x: x, y: y, opacity: 0 }, void 0, label.destroy);
  14912. delete tick.label;
  14913. }
  14914. axis.isDirty = true;
  14915. tick.label = tick.movedLabel;
  14916. delete tick.movedLabel;
  14917. };
  14918. return Tick;
  14919. }());
  14920. H.Tick = Tick;
  14921. return H.Tick;
  14922. });
  14923. _registerModule(_modules, 'Core/Axis/Axis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Options.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Utilities.js']], function (A, Color, H, palette, O, Tick, U) {
  14924. /* *
  14925. *
  14926. * (c) 2010-2021 Torstein Honsi
  14927. *
  14928. * License: www.highcharts.com/license
  14929. *
  14930. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14931. *
  14932. * */
  14933. var animObject = A.animObject;
  14934. var defaultOptions = O.defaultOptions;
  14935. var addEvent = U.addEvent,
  14936. arrayMax = U.arrayMax,
  14937. arrayMin = U.arrayMin,
  14938. clamp = U.clamp,
  14939. correctFloat = U.correctFloat,
  14940. defined = U.defined,
  14941. destroyObjectProperties = U.destroyObjectProperties,
  14942. erase = U.erase,
  14943. error = U.error,
  14944. extend = U.extend,
  14945. fireEvent = U.fireEvent,
  14946. getMagnitude = U.getMagnitude,
  14947. isArray = U.isArray,
  14948. isFunction = U.isFunction,
  14949. isNumber = U.isNumber,
  14950. isString = U.isString,
  14951. merge = U.merge,
  14952. normalizeTickInterval = U.normalizeTickInterval,
  14953. objectEach = U.objectEach,
  14954. pick = U.pick,
  14955. relativeLength = U.relativeLength,
  14956. removeEvent = U.removeEvent,
  14957. splat = U.splat,
  14958. syncTimeout = U.syncTimeout;
  14959. /**
  14960. * Options for the path on the Axis to be calculated.
  14961. * @interface Highcharts.AxisPlotLinePathOptionsObject
  14962. */ /**
  14963. * Axis value.
  14964. * @name Highcharts.AxisPlotLinePathOptionsObject#value
  14965. * @type {number|undefined}
  14966. */ /**
  14967. * Line width used for calculation crisp line coordinates. Defaults to 1.
  14968. * @name Highcharts.AxisPlotLinePathOptionsObject#lineWidth
  14969. * @type {number|undefined}
  14970. */ /**
  14971. * If `false`, the function will return null when it falls outside the axis
  14972. * bounds. If `true`, the function will return a path aligned to the plot area
  14973. * sides if it falls outside. If `pass`, it will return a path outside.
  14974. * @name Highcharts.AxisPlotLinePathOptionsObject#force
  14975. * @type {string|boolean|undefined}
  14976. */ /**
  14977. * Used in Highcharts Stock. When `true`, plot paths
  14978. * (crosshair, plotLines, gridLines)
  14979. * will be rendered on all axes when defined on the first axis.
  14980. * @name Highcharts.AxisPlotLinePathOptionsObject#acrossPanes
  14981. * @type {boolean|undefined}
  14982. */ /**
  14983. * Use old coordinates (for resizing and rescaling).
  14984. * If not set, defaults to `false`.
  14985. * @name Highcharts.AxisPlotLinePathOptionsObject#old
  14986. * @type {boolean|undefined}
  14987. */ /**
  14988. * If given, return the plot line path of a pixel position on the axis.
  14989. * @name Highcharts.AxisPlotLinePathOptionsObject#translatedValue
  14990. * @type {number|undefined}
  14991. */ /**
  14992. * Used in Polar axes. Reverse the positions for concatenation of polygonal
  14993. * plot bands
  14994. * @name Highcharts.AxisPlotLinePathOptionsObject#reverse
  14995. * @type {boolean|undefined}
  14996. */
  14997. /**
  14998. * Options for crosshairs on axes.
  14999. *
  15000. * @product highstock
  15001. *
  15002. * @typedef {Highcharts.XAxisCrosshairOptions|Highcharts.YAxisCrosshairOptions} Highcharts.AxisCrosshairOptions
  15003. */
  15004. /**
  15005. * @typedef {"navigator"|"pan"|"rangeSelectorButton"|"rangeSelectorInput"|"scrollbar"|"traverseUpButton"|"zoom"} Highcharts.AxisExtremesTriggerValue
  15006. */
  15007. /**
  15008. * @callback Highcharts.AxisEventCallbackFunction
  15009. *
  15010. * @param {Highcharts.Axis} this
  15011. */
  15012. /**
  15013. * @callback Highcharts.AxisLabelsFormatterCallbackFunction
  15014. *
  15015. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  15016. *
  15017. * @param {Highcharts.AxisLabelsFormatterContextObject} ctx
  15018. *
  15019. * @return {string}
  15020. */
  15021. /**
  15022. * @interface Highcharts.AxisLabelsFormatterContextObject
  15023. */ /**
  15024. * The axis item of the label
  15025. * @name Highcharts.AxisLabelsFormatterContextObject#axis
  15026. * @type {Highcharts.Axis}
  15027. */ /**
  15028. * The chart instance.
  15029. * @name Highcharts.AxisLabelsFormatterContextObject#chart
  15030. * @type {Highcharts.Chart}
  15031. */ /**
  15032. * Whether the label belongs to the first tick on the axis.
  15033. * @name Highcharts.AxisLabelsFormatterContextObject#isFirst
  15034. * @type {boolean}
  15035. */ /**
  15036. * Whether the label belongs to the last tick on the axis.
  15037. * @name Highcharts.AxisLabelsFormatterContextObject#isLast
  15038. * @type {boolean}
  15039. */ /**
  15040. * The position on the axis in terms of axis values. For category axes, a
  15041. * zero-based index. For datetime axes, the JavaScript time in milliseconds
  15042. * since 1970.
  15043. * @name Highcharts.AxisLabelsFormatterContextObject#pos
  15044. * @type {number}
  15045. */ /**
  15046. * The preformatted text as the result of the default formatting. For example
  15047. * dates will be formatted as strings, and numbers with language-specific comma
  15048. * separators, thousands separators and numeric symbols like `k` or `M`.
  15049. * @name Highcharts.AxisLabelsFormatterContextObject#text
  15050. * @type {string}
  15051. */ /**
  15052. * The Tick instance.
  15053. * @name Highcharts.AxisLabelsFormatterContextObject#tick
  15054. * @type {Highcharts.Tick}
  15055. */ /**
  15056. * This can be either a numeric value or a category string.
  15057. * @name Highcharts.AxisLabelsFormatterContextObject#value
  15058. * @type {number|string}
  15059. */
  15060. /**
  15061. * Options for axes.
  15062. *
  15063. * @typedef {Highcharts.XAxisOptions|Highcharts.YAxisOptions|Highcharts.ZAxisOptions} Highcharts.AxisOptions
  15064. */
  15065. /**
  15066. * @callback Highcharts.AxisPointBreakEventCallbackFunction
  15067. *
  15068. * @param {Highcharts.Axis} this
  15069. *
  15070. * @param {Highcharts.AxisPointBreakEventObject} evt
  15071. */
  15072. /**
  15073. * @interface Highcharts.AxisPointBreakEventObject
  15074. */ /**
  15075. * @name Highcharts.AxisPointBreakEventObject#brk
  15076. * @type {Highcharts.Dictionary<number>}
  15077. */ /**
  15078. * @name Highcharts.AxisPointBreakEventObject#point
  15079. * @type {Highcharts.Point}
  15080. */ /**
  15081. * @name Highcharts.AxisPointBreakEventObject#preventDefault
  15082. * @type {Function}
  15083. */ /**
  15084. * @name Highcharts.AxisPointBreakEventObject#target
  15085. * @type {Highcharts.SVGElement}
  15086. */ /**
  15087. * @name Highcharts.AxisPointBreakEventObject#type
  15088. * @type {"pointBreak"|"pointInBreak"}
  15089. */
  15090. /**
  15091. * @callback Highcharts.AxisSetExtremesEventCallbackFunction
  15092. *
  15093. * @param {Highcharts.Axis} this
  15094. *
  15095. * @param {Highcharts.AxisSetExtremesEventObject} evt
  15096. */
  15097. /**
  15098. * @interface Highcharts.AxisSetExtremesEventObject
  15099. * @extends Highcharts.ExtremesObject
  15100. */ /**
  15101. * @name Highcharts.AxisSetExtremesEventObject#preventDefault
  15102. * @type {Function}
  15103. */ /**
  15104. * @name Highcharts.AxisSetExtremesEventObject#target
  15105. * @type {Highcharts.SVGElement}
  15106. */ /**
  15107. * @name Highcharts.AxisSetExtremesEventObject#trigger
  15108. * @type {Highcharts.AxisExtremesTriggerValue|string}
  15109. */ /**
  15110. * @name Highcharts.AxisSetExtremesEventObject#type
  15111. * @type {"setExtremes"}
  15112. */
  15113. /**
  15114. * @callback Highcharts.AxisTickPositionerCallbackFunction
  15115. *
  15116. * @param {Highcharts.Axis} this
  15117. *
  15118. * @return {Highcharts.AxisTickPositionsArray}
  15119. */
  15120. /**
  15121. * @interface Highcharts.AxisTickPositionsArray
  15122. * @augments Array<number>
  15123. */
  15124. /**
  15125. * @typedef {"high"|"low"|"middle"} Highcharts.AxisTitleAlignValue
  15126. */
  15127. /**
  15128. * @typedef {Highcharts.XAxisTitleOptions|Highcharts.YAxisTitleOptions|Highcharts.ZAxisTitleOptions} Highcharts.AxisTitleOptions
  15129. */
  15130. /**
  15131. * @typedef {"linear"|"logarithmic"|"datetime"|"category"|"treegrid"} Highcharts.AxisTypeValue
  15132. */
  15133. /**
  15134. * The returned object literal from the {@link Highcharts.Axis#getExtremes}
  15135. * function.
  15136. *
  15137. * @interface Highcharts.ExtremesObject
  15138. */ /**
  15139. * The maximum value of the axis' associated series.
  15140. * @name Highcharts.ExtremesObject#dataMax
  15141. * @type {number}
  15142. */ /**
  15143. * The minimum value of the axis' associated series.
  15144. * @name Highcharts.ExtremesObject#dataMin
  15145. * @type {number}
  15146. */ /**
  15147. * The maximum axis value, either automatic or set manually. If the `max` option
  15148. * is not set, `maxPadding` is 0 and `endOnTick` is false, this value will be
  15149. * the same as `dataMax`.
  15150. * @name Highcharts.ExtremesObject#max
  15151. * @type {number}
  15152. */ /**
  15153. * The minimum axis value, either automatic or set manually. If the `min` option
  15154. * is not set, `minPadding` is 0 and `startOnTick` is false, this value will be
  15155. * the same as `dataMin`.
  15156. * @name Highcharts.ExtremesObject#min
  15157. * @type {number}
  15158. */ /**
  15159. * The user defined maximum, either from the `max` option or from a zoom or
  15160. * `setExtremes` action.
  15161. * @name Highcharts.ExtremesObject#userMax
  15162. * @type {number}
  15163. */ /**
  15164. * The user defined minimum, either from the `min` option or from a zoom or
  15165. * `setExtremes` action.
  15166. * @name Highcharts.ExtremesObject#userMin
  15167. * @type {number}
  15168. */
  15169. /**
  15170. * Formatter function for the text of a crosshair label.
  15171. *
  15172. * @callback Highcharts.XAxisCrosshairLabelFormatterCallbackFunction
  15173. *
  15174. * @param {Highcharts.Axis} this
  15175. * Axis context
  15176. *
  15177. * @param {number} value
  15178. * Y value of the data point
  15179. *
  15180. * @return {string}
  15181. */
  15182. ''; // detach doclets above
  15183. var deg2rad = H.deg2rad;
  15184. /**
  15185. * Create a new axis object. Called internally when instanciating a new chart or
  15186. * adding axes by {@link Highcharts.Chart#addAxis}.
  15187. *
  15188. * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
  15189. * series cartesian chart, there is one X axis and one Y axis.
  15190. *
  15191. * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
  15192. * an array of Axis objects. If there is only one axis, it can be referenced
  15193. * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
  15194. * pattern goes for Y axes.
  15195. *
  15196. * If you need to get the axes from a series object, use the `series.xAxis` and
  15197. * `series.yAxis` properties. These are not arrays, as one series can only be
  15198. * associated to one X and one Y axis.
  15199. *
  15200. * A third way to reference the axis programmatically is by `id`. Add an `id` in
  15201. * the axis configuration options, and get the axis by
  15202. * {@link Highcharts.Chart#get}.
  15203. *
  15204. * Configuration options for the axes are given in options.xAxis and
  15205. * options.yAxis.
  15206. *
  15207. * @class
  15208. * @name Highcharts.Axis
  15209. *
  15210. * @param {Highcharts.Chart} chart
  15211. * The Chart instance to apply the axis on.
  15212. *
  15213. * @param {Highcharts.AxisOptions} userOptions
  15214. * Axis options.
  15215. */
  15216. var Axis = /** @class */ (function () {
  15217. /* *
  15218. *
  15219. * Constructors
  15220. *
  15221. * */
  15222. function Axis(chart, userOptions) {
  15223. this.alternateBands = void 0;
  15224. this.bottom = void 0;
  15225. this.categories = void 0;
  15226. this.chart = void 0;
  15227. this.closestPointRange = void 0;
  15228. this.coll = void 0;
  15229. this.hasNames = void 0;
  15230. this.hasVisibleSeries = void 0;
  15231. this.height = void 0;
  15232. this.isLinked = void 0;
  15233. this.labelEdge = void 0; // @todo
  15234. this.labelFormatter = void 0;
  15235. this.left = void 0;
  15236. this.len = void 0;
  15237. this.max = void 0;
  15238. this.maxLabelLength = void 0;
  15239. this.min = void 0;
  15240. this.minorTickInterval = void 0;
  15241. this.minorTicks = void 0;
  15242. this.minPixelPadding = void 0;
  15243. this.names = void 0;
  15244. this.offset = void 0;
  15245. this.options = void 0;
  15246. this.overlap = void 0;
  15247. this.paddedTicks = void 0;
  15248. this.plotLinesAndBands = void 0;
  15249. this.plotLinesAndBandsGroups = void 0;
  15250. this.pointRange = void 0;
  15251. this.pointRangePadding = void 0;
  15252. this.pos = void 0;
  15253. this.positiveValuesOnly = void 0;
  15254. this.right = void 0;
  15255. this.series = void 0;
  15256. this.side = void 0;
  15257. this.tickAmount = void 0;
  15258. this.tickInterval = void 0;
  15259. this.tickmarkOffset = void 0;
  15260. this.tickPositions = void 0;
  15261. this.tickRotCorr = void 0;
  15262. this.ticks = void 0;
  15263. this.top = void 0;
  15264. this.transA = void 0;
  15265. this.transB = void 0;
  15266. this.translationSlope = void 0;
  15267. this.userOptions = void 0;
  15268. this.visible = void 0;
  15269. this.width = void 0;
  15270. this.zoomEnabled = void 0;
  15271. this.init(chart, userOptions);
  15272. }
  15273. /* *
  15274. *
  15275. * Functions
  15276. *
  15277. * */
  15278. /**
  15279. * Overrideable function to initialize the axis.
  15280. *
  15281. * @see {@link Axis}
  15282. *
  15283. * @function Highcharts.Axis#init
  15284. *
  15285. * @param {Highcharts.Chart} chart
  15286. * The Chart instance to apply the axis on.
  15287. *
  15288. * @param {Highcharts.AxisOptions} userOptions
  15289. * Axis options.
  15290. *
  15291. * @fires Highcharts.Axis#event:afterInit
  15292. * @fires Highcharts.Axis#event:init
  15293. */
  15294. Axis.prototype.init = function (chart, userOptions) {
  15295. var isXAxis = userOptions.isX,
  15296. axis = this;
  15297. /**
  15298. * The Chart that the axis belongs to.
  15299. *
  15300. * @name Highcharts.Axis#chart
  15301. * @type {Highcharts.Chart}
  15302. */
  15303. axis.chart = chart;
  15304. /**
  15305. * Whether the axis is horizontal.
  15306. *
  15307. * @name Highcharts.Axis#horiz
  15308. * @type {boolean|undefined}
  15309. */
  15310. axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;
  15311. /**
  15312. * Whether the axis is the x-axis.
  15313. *
  15314. * @name Highcharts.Axis#isXAxis
  15315. * @type {boolean|undefined}
  15316. */
  15317. axis.isXAxis = isXAxis;
  15318. /**
  15319. * The collection where the axis belongs, for example `xAxis`, `yAxis`
  15320. * or `colorAxis`. Corresponds to properties on Chart, for example
  15321. * {@link Chart.xAxis}.
  15322. *
  15323. * @name Highcharts.Axis#coll
  15324. * @type {string}
  15325. */
  15326. axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
  15327. fireEvent(this, 'init', { userOptions: userOptions });
  15328. axis.opposite = pick(userOptions.opposite, axis.opposite); // needed in setOptions
  15329. /**
  15330. * The side on which the axis is rendered. 0 is top, 1 is right, 2
  15331. * is bottom and 3 is left.
  15332. *
  15333. * @name Highcharts.Axis#side
  15334. * @type {number}
  15335. */
  15336. axis.side = pick(userOptions.side, axis.side, (axis.horiz ?
  15337. (axis.opposite ? 0 : 2) : // top : bottom
  15338. (axis.opposite ? 1 : 3)) // right : left
  15339. );
  15340. /**
  15341. * Current options for the axis after merge of defaults and user's
  15342. * options.
  15343. *
  15344. * @name Highcharts.Axis#options
  15345. * @type {Highcharts.AxisOptions}
  15346. */
  15347. axis.setOptions(userOptions);
  15348. var options = this.options,
  15349. labelsOptions = options.labels,
  15350. type = options.type;
  15351. /**
  15352. * User's options for this axis without defaults.
  15353. *
  15354. * @name Highcharts.Axis#userOptions
  15355. * @type {Highcharts.AxisOptions}
  15356. */
  15357. axis.userOptions = userOptions;
  15358. axis.minPixelPadding = 0;
  15359. /**
  15360. * Whether the axis is reversed. Based on the `axis.reversed`,
  15361. * option, but inverted charts have reversed xAxis by default.
  15362. *
  15363. * @name Highcharts.Axis#reversed
  15364. * @type {boolean}
  15365. */
  15366. axis.reversed = pick(options.reversed, axis.reversed);
  15367. axis.visible = options.visible;
  15368. axis.zoomEnabled = options.zoomEnabled;
  15369. // Initial categories
  15370. axis.hasNames =
  15371. type === 'category' || options.categories === true;
  15372. /**
  15373. * If categories are present for the axis, names are used instead of
  15374. * numbers for that axis.
  15375. *
  15376. * Since Highcharts 3.0, categories can also be extracted by giving each
  15377. * point a name and setting axis type to `category`. However, if you
  15378. * have multiple series, best practice remains defining the `categories`
  15379. * array.
  15380. *
  15381. * @see [xAxis.categories](/highcharts/xAxis.categories)
  15382. *
  15383. * @name Highcharts.Axis#categories
  15384. * @type {Array<string>}
  15385. * @readonly
  15386. */
  15387. axis.categories = options.categories || axis.hasNames;
  15388. if (!axis.names) { // Preserve on update (#3830)
  15389. axis.names = [];
  15390. axis.names.keys = {};
  15391. }
  15392. // Placeholder for plotlines and plotbands groups
  15393. axis.plotLinesAndBandsGroups = {};
  15394. // Shorthand types
  15395. axis.positiveValuesOnly = !!axis.logarithmic;
  15396. // Flag, if axis is linked to another axis
  15397. axis.isLinked = defined(options.linkedTo);
  15398. /**
  15399. * List of major ticks mapped by postition on axis.
  15400. *
  15401. * @see {@link Highcharts.Tick}
  15402. *
  15403. * @name Highcharts.Axis#ticks
  15404. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  15405. */
  15406. axis.ticks = {};
  15407. axis.labelEdge = [];
  15408. /**
  15409. * List of minor ticks mapped by position on the axis.
  15410. *
  15411. * @see {@link Highcharts.Tick}
  15412. *
  15413. * @name Highcharts.Axis#minorTicks
  15414. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  15415. */
  15416. axis.minorTicks = {};
  15417. // List of plotLines/Bands
  15418. axis.plotLinesAndBands = [];
  15419. // Alternate bands
  15420. axis.alternateBands = {};
  15421. // Axis metrics
  15422. axis.len = 0;
  15423. axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
  15424. axis.range = options.range;
  15425. axis.offset = options.offset || 0;
  15426. /**
  15427. * The maximum value of the axis. In a logarithmic axis, this is the
  15428. * logarithm of the real value, and the real value can be obtained from
  15429. * {@link Axis#getExtremes}.
  15430. *
  15431. * @name Highcharts.Axis#max
  15432. * @type {number|null}
  15433. */
  15434. axis.max = null;
  15435. /**
  15436. * The minimum value of the axis. In a logarithmic axis, this is the
  15437. * logarithm of the real value, and the real value can be obtained from
  15438. * {@link Axis#getExtremes}.
  15439. *
  15440. * @name Highcharts.Axis#min
  15441. * @type {number|null}
  15442. */
  15443. axis.min = null;
  15444. /**
  15445. * The processed crosshair options.
  15446. *
  15447. * @name Highcharts.Axis#crosshair
  15448. * @type {boolean|Highcharts.AxisCrosshairOptions}
  15449. */
  15450. var crosshair = pick(options.crosshair,
  15451. splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1]);
  15452. axis.crosshair = crosshair === true ? {} : crosshair;
  15453. var events = axis.options.events;
  15454. // Register. Don't add it again on Axis.update().
  15455. if (chart.axes.indexOf(axis) === -1) { //
  15456. if (isXAxis) { // #2713
  15457. chart.axes.splice(chart.xAxis.length, 0, axis);
  15458. }
  15459. else {
  15460. chart.axes.push(axis);
  15461. }
  15462. chart[axis.coll].push(axis);
  15463. }
  15464. /**
  15465. * All series associated to the axis.
  15466. *
  15467. * @name Highcharts.Axis#series
  15468. * @type {Array<Highcharts.Series>}
  15469. */
  15470. axis.series = axis.series || []; // populated by Series
  15471. // Reversed axis
  15472. if (chart.inverted &&
  15473. !axis.isZAxis &&
  15474. isXAxis &&
  15475. typeof axis.reversed === 'undefined') {
  15476. axis.reversed = true;
  15477. }
  15478. axis.labelRotation = isNumber(labelsOptions.rotation) ?
  15479. labelsOptions.rotation :
  15480. void 0;
  15481. // register event listeners
  15482. objectEach(events, function (event, eventType) {
  15483. if (isFunction(event)) {
  15484. addEvent(axis, eventType, event);
  15485. }
  15486. });
  15487. fireEvent(this, 'afterInit');
  15488. };
  15489. /**
  15490. * Merge and set options.
  15491. *
  15492. * @private
  15493. * @function Highcharts.Axis#setOptions
  15494. *
  15495. * @param {Highcharts.AxisOptions} userOptions
  15496. * Axis options.
  15497. *
  15498. * @fires Highcharts.Axis#event:afterSetOptions
  15499. */
  15500. Axis.prototype.setOptions = function (userOptions) {
  15501. this.options = merge(Axis.defaultOptions, (this.coll === 'yAxis') && Axis.defaultYAxisOptions, [
  15502. Axis.defaultTopAxisOptions,
  15503. Axis.defaultRightAxisOptions,
  15504. Axis.defaultBottomAxisOptions,
  15505. Axis.defaultLeftAxisOptions
  15506. ][this.side], merge(
  15507. // if set in setOptions (#1053):
  15508. defaultOptions[this.coll], userOptions));
  15509. fireEvent(this, 'afterSetOptions', { userOptions: userOptions });
  15510. };
  15511. /**
  15512. * The default label formatter. The context is a special config object for
  15513. * the label. In apps, use the
  15514. * [labels.formatter](https://api.highcharts.com/highcharts/xAxis.labels.formatter)
  15515. * instead, except when a modification is needed.
  15516. *
  15517. * @function Highcharts.Axis#defaultLabelFormatter
  15518. *
  15519. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  15520. * Formatter context of axis label.
  15521. *
  15522. * @return {string}
  15523. * The formatted label content.
  15524. */
  15525. Axis.prototype.defaultLabelFormatter = function () {
  15526. var axis = this.axis,
  15527. value = isNumber(this.value) ? this.value : NaN,
  15528. time = axis.chart.time,
  15529. categories = axis.categories,
  15530. dateTimeLabelFormat = this.dateTimeLabelFormat,
  15531. lang = defaultOptions.lang,
  15532. numericSymbols = lang.numericSymbols,
  15533. numSymMagnitude = lang.numericSymbolMagnitude || 1000,
  15534. i = numericSymbols && numericSymbols.length,
  15535. multi,
  15536. ret,
  15537. // make sure the same symbol is added for all labels on a linear
  15538. // axis
  15539. numericSymbolDetector = axis.logarithmic ?
  15540. Math.abs(value) :
  15541. axis.tickInterval;
  15542. var chart = this.chart;
  15543. var numberFormatter = chart.numberFormatter;
  15544. if (categories) {
  15545. ret = "" + this.value;
  15546. }
  15547. else if (dateTimeLabelFormat) { // datetime axis
  15548. ret = time.dateFormat(dateTimeLabelFormat, value);
  15549. }
  15550. else if (i && numericSymbolDetector >= 1000) {
  15551. // Decide whether we should add a numeric symbol like k (thousands)
  15552. // or M (millions). If we are to enable this in tooltip or other
  15553. // places as well, we can move this logic to the numberFormatter and
  15554. // enable it by a parameter.
  15555. while (i-- && typeof ret === 'undefined') {
  15556. multi = Math.pow(numSymMagnitude, i + 1);
  15557. if (
  15558. // Only accept a numeric symbol when the distance is more
  15559. // than a full unit. So for example if the symbol is k, we
  15560. // don't accept numbers like 0.5k.
  15561. numericSymbolDetector >= multi &&
  15562. // Accept one decimal before the symbol. Accepts 0.5k but
  15563. // not 0.25k. How does this work with the previous?
  15564. (value * 10) % multi === 0 &&
  15565. numericSymbols[i] !== null &&
  15566. value !== 0) { // #5480
  15567. ret = numberFormatter(value / multi, -1) + numericSymbols[i];
  15568. }
  15569. }
  15570. }
  15571. if (typeof ret === 'undefined') {
  15572. if (Math.abs(value) >= 10000) { // add thousands separators
  15573. ret = numberFormatter(value, -1);
  15574. }
  15575. else { // small numbers
  15576. ret = numberFormatter(value, -1, void 0, ''); // #2466
  15577. }
  15578. }
  15579. return ret;
  15580. };
  15581. /**
  15582. * Get the minimum and maximum for the series of each axis. The function
  15583. * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
  15584. *
  15585. * @private
  15586. * @function Highcharts.Axis#getSeriesExtremes
  15587. *
  15588. * @fires Highcharts.Axis#event:afterGetSeriesExtremes
  15589. * @fires Highcharts.Axis#event:getSeriesExtremes
  15590. */
  15591. Axis.prototype.getSeriesExtremes = function () {
  15592. var axis = this,
  15593. chart = axis.chart,
  15594. xExtremes;
  15595. fireEvent(this, 'getSeriesExtremes', null, function () {
  15596. axis.hasVisibleSeries = false;
  15597. // Reset properties in case we're redrawing (#3353)
  15598. axis.dataMin = axis.dataMax = axis.threshold = null;
  15599. axis.softThreshold = !axis.isXAxis;
  15600. if (axis.stacking) {
  15601. axis.stacking.buildStacks();
  15602. }
  15603. // loop through this axis' series
  15604. axis.series.forEach(function (series) {
  15605. if (series.visible ||
  15606. !chart.options.chart.ignoreHiddenSeries) {
  15607. var seriesOptions = series.options,
  15608. xData = void 0,
  15609. threshold = seriesOptions.threshold,
  15610. seriesDataMin = void 0,
  15611. seriesDataMax = void 0;
  15612. axis.hasVisibleSeries = true;
  15613. // Validate threshold in logarithmic axes
  15614. if (axis.positiveValuesOnly && threshold <= 0) {
  15615. threshold = null;
  15616. }
  15617. // Get dataMin and dataMax for X axes
  15618. if (axis.isXAxis) {
  15619. xData = series.xData;
  15620. if (xData.length) {
  15621. var isPositive = function (number) { return number > 0; };
  15622. xData = axis.logarithmic ?
  15623. xData.filter(axis.validatePositiveValue) :
  15624. xData;
  15625. xExtremes = series.getXExtremes(xData);
  15626. // If xData contains values which is not numbers,
  15627. // then filter them out. To prevent performance hit,
  15628. // we only do this after we have already found
  15629. // seriesDataMin because in most cases all data is
  15630. // valid. #5234.
  15631. seriesDataMin = xExtremes.min;
  15632. seriesDataMax = xExtremes.max;
  15633. if (!isNumber(seriesDataMin) &&
  15634. // #5010:
  15635. !(seriesDataMin instanceof Date)) {
  15636. xData = xData.filter(isNumber);
  15637. xExtremes = series.getXExtremes(xData);
  15638. // Do it again with valid data
  15639. seriesDataMin = xExtremes.min;
  15640. seriesDataMax = xExtremes.max;
  15641. }
  15642. if (xData.length) {
  15643. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  15644. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  15645. }
  15646. }
  15647. // Get dataMin and dataMax for Y axes, as well as handle
  15648. // stacking and processed data
  15649. }
  15650. else {
  15651. // Get this particular series extremes
  15652. var dataExtremes = series.applyExtremes();
  15653. // Get the dataMin and dataMax so far. If percentage is
  15654. // used, the min and max are always 0 and 100. If
  15655. // seriesDataMin and seriesDataMax is null, then series
  15656. // doesn't have active y data, we continue with nulls
  15657. if (isNumber(dataExtremes.dataMin)) {
  15658. seriesDataMin = dataExtremes.dataMin;
  15659. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  15660. }
  15661. if (isNumber(dataExtremes.dataMax)) {
  15662. seriesDataMax = dataExtremes.dataMax;
  15663. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  15664. }
  15665. // Adjust to threshold
  15666. if (defined(threshold)) {
  15667. axis.threshold = threshold;
  15668. }
  15669. // If any series has a hard threshold, it takes
  15670. // precedence
  15671. if (!seriesOptions.softThreshold ||
  15672. axis.positiveValuesOnly) {
  15673. axis.softThreshold = false;
  15674. }
  15675. }
  15676. }
  15677. });
  15678. });
  15679. fireEvent(this, 'afterGetSeriesExtremes');
  15680. };
  15681. /**
  15682. * Translate from axis value to pixel position on the chart, or back. Use
  15683. * the `toPixels` and `toValue` functions in applications.
  15684. *
  15685. * @private
  15686. * @function Highcharts.Axis#translate
  15687. *
  15688. * @param {number} val
  15689. * TO-DO: parameter description
  15690. *
  15691. * @param {boolean|null} [backwards]
  15692. * TO-DO: parameter description
  15693. *
  15694. * @param {boolean|null} [cvsCoord]
  15695. * TO-DO: parameter description
  15696. *
  15697. * @param {boolean|null} [old]
  15698. * TO-DO: parameter description
  15699. *
  15700. * @param {boolean} [handleLog]
  15701. * TO-DO: parameter description
  15702. *
  15703. * @param {number} [pointPlacement]
  15704. * TO-DO: parameter description
  15705. *
  15706. * @return {number|undefined}
  15707. */
  15708. Axis.prototype.translate = function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
  15709. var axis = this.linkedParent || this, // #1417
  15710. sign = 1,
  15711. cvsOffset = 0,
  15712. localA = old && axis.old ? axis.old.transA : axis.transA,
  15713. localMin = old && axis.old ? axis.old.min : axis.min,
  15714. returnValue = 0,
  15715. minPixelPadding = axis.minPixelPadding,
  15716. doPostTranslate = (axis.isOrdinal ||
  15717. axis.brokenAxis && axis.brokenAxis.hasBreaks ||
  15718. (axis.logarithmic && handleLog)) && axis.lin2val;
  15719. if (!localA) {
  15720. localA = axis.transA;
  15721. }
  15722. // In vertical axes, the canvas coordinates start from 0 at the top like
  15723. // in SVG.
  15724. if (cvsCoord) {
  15725. sign *= -1; // canvas coordinates inverts the value
  15726. cvsOffset = axis.len;
  15727. }
  15728. // Handle reversed axis
  15729. if (axis.reversed) {
  15730. sign *= -1;
  15731. cvsOffset -= sign * (axis.sector || axis.len);
  15732. }
  15733. // From pixels to value
  15734. if (backwards) { // reverse translation
  15735. val = val * sign + cvsOffset;
  15736. val -= minPixelPadding;
  15737. // from chart pixel to value:
  15738. returnValue = val / localA + localMin;
  15739. if (doPostTranslate) { // log and ordinal axes
  15740. returnValue = axis.lin2val(returnValue);
  15741. }
  15742. // From value to pixels
  15743. }
  15744. else {
  15745. if (doPostTranslate) { // log and ordinal axes
  15746. val = axis.val2lin(val);
  15747. }
  15748. returnValue = isNumber(localMin) ?
  15749. (sign * (val - localMin) * localA +
  15750. cvsOffset +
  15751. (sign * minPixelPadding) +
  15752. (isNumber(pointPlacement) ?
  15753. localA * pointPlacement :
  15754. 0)) :
  15755. void 0;
  15756. }
  15757. return returnValue;
  15758. };
  15759. /**
  15760. * Translate a value in terms of axis units into pixels within the chart.
  15761. *
  15762. * @function Highcharts.Axis#toPixels
  15763. *
  15764. * @param {number} value
  15765. * A value in terms of axis units.
  15766. *
  15767. * @param {boolean} paneCoordinates
  15768. * Whether to return the pixel coordinate relative to the chart or just the
  15769. * axis/pane itself.
  15770. *
  15771. * @return {number}
  15772. * Pixel position of the value on the chart or axis.
  15773. */
  15774. Axis.prototype.toPixels = function (value, paneCoordinates) {
  15775. return this.translate(value, false, !this.horiz, null, true) +
  15776. (paneCoordinates ? 0 : this.pos);
  15777. };
  15778. /**
  15779. * Translate a pixel position along the axis to a value in terms of axis
  15780. * units.
  15781. *
  15782. * @function Highcharts.Axis#toValue
  15783. *
  15784. * @param {number} pixel
  15785. * The pixel value coordinate.
  15786. *
  15787. * @param {boolean} [paneCoordinates=false]
  15788. * Whether the input pixel is relative to the chart or just the axis/pane
  15789. * itself.
  15790. *
  15791. * @return {number}
  15792. * The axis value.
  15793. */
  15794. Axis.prototype.toValue = function (pixel, paneCoordinates) {
  15795. return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
  15796. };
  15797. /**
  15798. * Create the path for a plot line that goes from the given value on
  15799. * this axis, across the plot to the opposite side. Also used internally for
  15800. * grid lines and crosshairs.
  15801. *
  15802. * @function Highcharts.Axis#getPlotLinePath
  15803. *
  15804. * @param {Highcharts.AxisPlotLinePathOptionsObject} options
  15805. * Options for the path.
  15806. *
  15807. * @return {Highcharts.SVGPathArray|null}
  15808. * The SVG path definition for the plot line.
  15809. */
  15810. Axis.prototype.getPlotLinePath = function (options) {
  15811. var axis = this,
  15812. chart = axis.chart,
  15813. axisLeft = axis.left,
  15814. axisTop = axis.top,
  15815. old = options.old,
  15816. value = options.value,
  15817. translatedValue = options.translatedValue,
  15818. lineWidth = options.lineWidth,
  15819. force = options.force,
  15820. x1,
  15821. y1,
  15822. x2,
  15823. y2,
  15824. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  15825. cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
  15826. skip,
  15827. transB = axis.transB,
  15828. evt;
  15829. // eslint-disable-next-line valid-jsdoc
  15830. /**
  15831. * Check if x is between a and b. If not, either move to a/b
  15832. * or skip, depending on the force parameter.
  15833. * @private
  15834. */
  15835. function between(x, a, b) {
  15836. if (force !== 'pass' && x < a || x > b) {
  15837. if (force) {
  15838. x = clamp(x, a, b);
  15839. }
  15840. else {
  15841. skip = true;
  15842. }
  15843. }
  15844. return x;
  15845. }
  15846. evt = {
  15847. value: value,
  15848. lineWidth: lineWidth,
  15849. old: old,
  15850. force: force,
  15851. acrossPanes: options.acrossPanes,
  15852. translatedValue: translatedValue
  15853. };
  15854. fireEvent(this, 'getPlotLinePath', evt, function (e) {
  15855. translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
  15856. // Keep the translated value within sane bounds, and avoid Infinity
  15857. // to fail the isNumber test (#7709).
  15858. translatedValue = clamp(translatedValue, -1e5, 1e5);
  15859. x1 = x2 = Math.round(translatedValue + transB);
  15860. y1 = y2 = Math.round(cHeight - translatedValue - transB);
  15861. if (!isNumber(translatedValue)) { // no min or max
  15862. skip = true;
  15863. force = false; // #7175, don't force it when path is invalid
  15864. }
  15865. else if (axis.horiz) {
  15866. y1 = axisTop;
  15867. y2 = cHeight - axis.bottom;
  15868. x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
  15869. }
  15870. else {
  15871. x1 = axisLeft;
  15872. x2 = cWidth - axis.right;
  15873. y1 = y2 = between(y1, axisTop, axisTop + axis.height);
  15874. }
  15875. e.path = skip && !force ?
  15876. null :
  15877. chart.renderer.crispLine([['M', x1, y1], ['L', x2, y2]], lineWidth || 1);
  15878. });
  15879. return evt.path;
  15880. };
  15881. /**
  15882. * Internal function to get the tick positions of a linear axis to round
  15883. * values like whole tens or every five.
  15884. *
  15885. * @function Highcharts.Axis#getLinearTickPositions
  15886. *
  15887. * @param {number} tickInterval
  15888. * The normalized tick interval.
  15889. *
  15890. * @param {number} min
  15891. * Axis minimum.
  15892. *
  15893. * @param {number} max
  15894. * Axis maximum.
  15895. *
  15896. * @return {Array<number>}
  15897. * An array of axis values where ticks should be placed.
  15898. */
  15899. Axis.prototype.getLinearTickPositions = function (tickInterval, min, max) {
  15900. var pos,
  15901. lastPos,
  15902. roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
  15903. roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
  15904. tickPositions = [],
  15905. precision;
  15906. // When the precision is higher than what we filter out in
  15907. // correctFloat, skip it (#6183).
  15908. if (correctFloat(roundedMin + tickInterval) === roundedMin) {
  15909. precision = 20;
  15910. }
  15911. // For single points, add a tick regardless of the relative position
  15912. // (#2662, #6274)
  15913. if (this.single) {
  15914. return [min];
  15915. }
  15916. // Populate the intermediate values
  15917. pos = roundedMin;
  15918. while (pos <= roundedMax) {
  15919. // Place the tick on the rounded value
  15920. tickPositions.push(pos);
  15921. // Always add the raw tickInterval, not the corrected one.
  15922. pos = correctFloat(pos + tickInterval, precision);
  15923. // If the interval is not big enough in the current min - max range
  15924. // to actually increase the loop variable, we need to break out to
  15925. // prevent endless loop. Issue #619
  15926. if (pos === lastPos) {
  15927. break;
  15928. }
  15929. // Record the last value
  15930. lastPos = pos;
  15931. }
  15932. return tickPositions;
  15933. };
  15934. /**
  15935. * Resolve the new minorTicks/minorTickInterval options into the legacy
  15936. * loosely typed minorTickInterval option.
  15937. *
  15938. * @function Highcharts.Axis#getMinorTickInterval
  15939. *
  15940. * @return {number|"auto"|null}
  15941. */
  15942. Axis.prototype.getMinorTickInterval = function () {
  15943. var options = this.options;
  15944. if (options.minorTicks === true) {
  15945. return pick(options.minorTickInterval, 'auto');
  15946. }
  15947. if (options.minorTicks === false) {
  15948. return null;
  15949. }
  15950. return options.minorTickInterval;
  15951. };
  15952. /**
  15953. * Internal function to return the minor tick positions. For logarithmic
  15954. * axes, the same logic as for major ticks is reused.
  15955. *
  15956. * @function Highcharts.Axis#getMinorTickPositions
  15957. *
  15958. * @return {Array<number>}
  15959. * An array of axis values where ticks should be placed.
  15960. */
  15961. Axis.prototype.getMinorTickPositions = function () {
  15962. var axis = this,
  15963. options = axis.options,
  15964. tickPositions = axis.tickPositions,
  15965. minorTickInterval = axis.minorTickInterval,
  15966. minorTickPositions = [],
  15967. pos,
  15968. pointRangePadding = axis.pointRangePadding || 0,
  15969. min = axis.min - pointRangePadding, // #1498
  15970. max = axis.max + pointRangePadding, // #1498
  15971. range = max - min;
  15972. // If minor ticks get too dense, they are hard to read, and may cause
  15973. // long running script. So we don't draw them.
  15974. if (range && range / minorTickInterval < axis.len / 3) { // #3875
  15975. var logarithmic_1 = axis.logarithmic;
  15976. if (logarithmic_1) {
  15977. // For each interval in the major ticks, compute the minor ticks
  15978. // separately.
  15979. this.paddedTicks.forEach(function (_pos, i, paddedTicks) {
  15980. if (i) {
  15981. minorTickPositions.push.apply(minorTickPositions, logarithmic_1.getLogTickPositions(minorTickInterval, paddedTicks[i - 1], paddedTicks[i], true));
  15982. }
  15983. });
  15984. }
  15985. else if (axis.dateTime &&
  15986. this.getMinorTickInterval() === 'auto') { // #1314
  15987. minorTickPositions = minorTickPositions.concat(axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(minorTickInterval), min, max, options.startOfWeek));
  15988. }
  15989. else {
  15990. for (pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval) {
  15991. // Very, very, tight grid lines (#5771)
  15992. if (pos === minorTickPositions[0]) {
  15993. break;
  15994. }
  15995. minorTickPositions.push(pos);
  15996. }
  15997. }
  15998. }
  15999. if (minorTickPositions.length !== 0) {
  16000. axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
  16001. }
  16002. return minorTickPositions;
  16003. };
  16004. /**
  16005. * Adjust the min and max for the minimum range. Keep in mind that the
  16006. * series data is not yet processed, so we don't have information on data
  16007. * cropping and grouping, or updated `axis.pointRange` or
  16008. * `series.pointRange`. The data can't be processed until we have finally
  16009. * established min and max.
  16010. *
  16011. * @private
  16012. * @function Highcharts.Axis#adjustForMinRange
  16013. */
  16014. Axis.prototype.adjustForMinRange = function () {
  16015. var axis = this,
  16016. options = axis.options,
  16017. min = axis.min,
  16018. max = axis.max,
  16019. log = axis.logarithmic,
  16020. zoomOffset,
  16021. spaceAvailable,
  16022. closestDataRange = 0,
  16023. i,
  16024. distance,
  16025. xData,
  16026. loopLength,
  16027. minArgs,
  16028. maxArgs,
  16029. minRange;
  16030. // Set the automatic minimum range based on the closest point distance
  16031. if (axis.isXAxis &&
  16032. typeof axis.minRange === 'undefined' &&
  16033. !log) {
  16034. if (defined(options.min) || defined(options.max)) {
  16035. axis.minRange = null; // don't do this again
  16036. }
  16037. else {
  16038. // Find the closest distance between raw data points, as opposed
  16039. // to closestPointRange that applies to processed points
  16040. // (cropped and grouped)
  16041. axis.series.forEach(function (series) {
  16042. xData = series.xData;
  16043. loopLength = series.xIncrement ? 1 : xData.length - 1;
  16044. if (xData.length > 1) {
  16045. for (i = loopLength; i > 0; i--) {
  16046. distance = xData[i] - xData[i - 1];
  16047. if (!closestDataRange || distance < closestDataRange) {
  16048. closestDataRange = distance;
  16049. }
  16050. }
  16051. }
  16052. });
  16053. axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
  16054. }
  16055. }
  16056. // if minRange is exceeded, adjust
  16057. if (max - min < axis.minRange) {
  16058. spaceAvailable =
  16059. axis.dataMax - axis.dataMin >=
  16060. axis.minRange;
  16061. minRange = axis.minRange;
  16062. zoomOffset = (minRange - max + min) / 2;
  16063. // if min and max options have been set, don't go beyond it
  16064. minArgs = [
  16065. min - zoomOffset,
  16066. pick(options.min, min - zoomOffset)
  16067. ];
  16068. // If space is available, stay within the data range
  16069. if (spaceAvailable) {
  16070. minArgs[2] = axis.logarithmic ?
  16071. axis.logarithmic.log2lin(axis.dataMin) :
  16072. axis.dataMin;
  16073. }
  16074. min = arrayMax(minArgs);
  16075. maxArgs = [
  16076. min + minRange,
  16077. pick(options.max, min + minRange)
  16078. ];
  16079. // If space is availabe, stay within the data range
  16080. if (spaceAvailable) {
  16081. maxArgs[2] = log ?
  16082. log.log2lin(axis.dataMax) :
  16083. axis.dataMax;
  16084. }
  16085. max = arrayMin(maxArgs);
  16086. // now if the max is adjusted, adjust the min back
  16087. if (max - min < minRange) {
  16088. minArgs[0] = max - minRange;
  16089. minArgs[1] = pick(options.min, max - minRange);
  16090. min = arrayMax(minArgs);
  16091. }
  16092. }
  16093. // Record modified extremes
  16094. axis.min = min;
  16095. axis.max = max;
  16096. };
  16097. // eslint-disable-next-line valid-jsdoc
  16098. /**
  16099. * Find the closestPointRange across all series.
  16100. *
  16101. * @private
  16102. * @function Highcharts.Axis#getClosest
  16103. */
  16104. Axis.prototype.getClosest = function () {
  16105. var ret;
  16106. if (this.categories) {
  16107. ret = 1;
  16108. }
  16109. else {
  16110. this.series.forEach(function (series) {
  16111. var seriesClosest = series.closestPointRange,
  16112. visible = series.visible ||
  16113. !series.chart.options.chart.ignoreHiddenSeries;
  16114. if (!series.noSharedTooltip &&
  16115. defined(seriesClosest) &&
  16116. visible) {
  16117. ret = defined(ret) ?
  16118. Math.min(ret, seriesClosest) :
  16119. seriesClosest;
  16120. }
  16121. });
  16122. }
  16123. return ret;
  16124. };
  16125. /**
  16126. * When a point name is given and no x, search for the name in the existing
  16127. * categories, or if categories aren't provided, search names or create a
  16128. * new category (#2522).
  16129. * @private
  16130. * @function Highcharts.Axis#nameToX
  16131. *
  16132. * @param {Highcharts.Point} point
  16133. * The point to inspect.
  16134. *
  16135. * @return {number}
  16136. * The X value that the point is given.
  16137. */
  16138. Axis.prototype.nameToX = function (point) {
  16139. var explicitCategories = isArray(this.categories),
  16140. names = explicitCategories ? this.categories : this.names,
  16141. nameX = point.options.x,
  16142. x;
  16143. point.series.requireSorting = false;
  16144. if (!defined(nameX)) {
  16145. nameX = this.options.uniqueNames ?
  16146. (explicitCategories ?
  16147. names.indexOf(point.name) :
  16148. pick(names.keys[point.name], -1)) :
  16149. point.series.autoIncrement();
  16150. }
  16151. if (nameX === -1) { // Not found in currenct categories
  16152. if (!explicitCategories) {
  16153. x = names.length;
  16154. }
  16155. }
  16156. else {
  16157. x = nameX;
  16158. }
  16159. // Write the last point's name to the names array
  16160. if (typeof x !== 'undefined') {
  16161. this.names[x] = point.name;
  16162. // Backwards mapping is much faster than array searching (#7725)
  16163. this.names.keys[point.name] = x;
  16164. }
  16165. return x;
  16166. };
  16167. /**
  16168. * When changes have been done to series data, update the axis.names.
  16169. *
  16170. * @private
  16171. * @function Highcharts.Axis#updateNames
  16172. */
  16173. Axis.prototype.updateNames = function () {
  16174. var axis = this,
  16175. names = this.names,
  16176. i = names.length;
  16177. if (i > 0) {
  16178. Object.keys(names.keys).forEach(function (key) {
  16179. delete (names.keys)[key];
  16180. });
  16181. names.length = 0;
  16182. this.minRange = this.userMinRange; // Reset
  16183. (this.series || []).forEach(function (series) {
  16184. // Reset incrementer (#5928)
  16185. series.xIncrement = null;
  16186. // When adding a series, points are not yet generated
  16187. if (!series.points || series.isDirtyData) {
  16188. // When we're updating the series with data that is longer
  16189. // than it was, and cropThreshold is passed, we need to make
  16190. // sure that the axis.max is increased _before_ running the
  16191. // premature processData. Otherwise this early iteration of
  16192. // processData will crop the points to axis.max, and the
  16193. // names array will be too short (#5857).
  16194. axis.max = Math.max(axis.max, series.xData.length - 1);
  16195. series.processData();
  16196. series.generatePoints();
  16197. }
  16198. series.data.forEach(function (point, i) {
  16199. var x;
  16200. if (point &&
  16201. point.options &&
  16202. typeof point.name !== 'undefined' // #9562
  16203. ) {
  16204. x = axis.nameToX(point);
  16205. if (typeof x !== 'undefined' && x !== point.x) {
  16206. point.x = x;
  16207. series.xData[i] = x;
  16208. }
  16209. }
  16210. });
  16211. });
  16212. }
  16213. };
  16214. /**
  16215. * Update translation information.
  16216. *
  16217. * @private
  16218. * @function Highcharts.Axis#setAxisTranslation
  16219. *
  16220. * @fires Highcharts.Axis#event:afterSetAxisTranslation
  16221. */
  16222. Axis.prototype.setAxisTranslation = function () {
  16223. var axis = this,
  16224. range = axis.max - axis.min,
  16225. pointRange = axis.axisPointRange || 0,
  16226. closestPointRange,
  16227. minPointOffset = 0,
  16228. pointRangePadding = 0,
  16229. linkedParent = axis.linkedParent,
  16230. ordinalCorrection,
  16231. hasCategories = !!axis.categories,
  16232. transA = axis.transA,
  16233. isXAxis = axis.isXAxis;
  16234. // Adjust translation for padding. Y axis with categories need to go
  16235. // through the same (#1784).
  16236. if (isXAxis || hasCategories || pointRange) {
  16237. // Get the closest points
  16238. closestPointRange = axis.getClosest();
  16239. if (linkedParent) {
  16240. minPointOffset = linkedParent.minPointOffset;
  16241. pointRangePadding = linkedParent.pointRangePadding;
  16242. }
  16243. else {
  16244. axis.series.forEach(function (series) {
  16245. var seriesPointRange = hasCategories ?
  16246. 1 :
  16247. (isXAxis ?
  16248. pick(series.options.pointRange,
  16249. closestPointRange, 0) :
  16250. (axis.axisPointRange || 0)), // #2806
  16251. pointPlacement = series.options.pointPlacement;
  16252. pointRange = Math.max(pointRange, seriesPointRange);
  16253. if (!axis.single || hasCategories) {
  16254. // TODO: series should internally set x- and y-
  16255. // pointPlacement to simplify this logic.
  16256. var isPointPlacementAxis = series.is('xrange') ? !isXAxis : isXAxis;
  16257. // minPointOffset is the value padding to the left of
  16258. // the axis in order to make room for points with a
  16259. // pointRange, typically columns. When the
  16260. // pointPlacement option is 'between' or 'on', this
  16261. // padding does not apply.
  16262. minPointOffset = Math.max(minPointOffset, isPointPlacementAxis && isString(pointPlacement) ?
  16263. 0 :
  16264. seriesPointRange / 2);
  16265. // Determine the total padding needed to the length of
  16266. // the axis to make room for the pointRange. If the
  16267. // series' pointPlacement is 'on', no padding is added.
  16268. pointRangePadding = Math.max(pointRangePadding, isPointPlacementAxis && pointPlacement === 'on' ?
  16269. 0 :
  16270. seriesPointRange);
  16271. }
  16272. });
  16273. }
  16274. // Record minPointOffset and pointRangePadding
  16275. ordinalCorrection = axis.ordinal && axis.ordinal.slope && closestPointRange ?
  16276. axis.ordinal.slope / closestPointRange :
  16277. 1; // #988, #1853
  16278. axis.minPointOffset = minPointOffset =
  16279. minPointOffset * ordinalCorrection;
  16280. axis.pointRangePadding =
  16281. pointRangePadding = pointRangePadding * ordinalCorrection;
  16282. // pointRange means the width reserved for each point, like in a
  16283. // column chart
  16284. axis.pointRange = Math.min(pointRange, axis.single && hasCategories ? 1 : range);
  16285. // closestPointRange means the closest distance between points. In
  16286. // columns it is mostly equal to pointRange, but in lines pointRange
  16287. // is 0 while closestPointRange is some other value
  16288. if (isXAxis) {
  16289. axis.closestPointRange = closestPointRange;
  16290. }
  16291. }
  16292. // Secondary values
  16293. axis.translationSlope = axis.transA = transA =
  16294. axis.staticScale ||
  16295. axis.len / ((range + pointRangePadding) || 1);
  16296. // Translation addend
  16297. axis.transB = axis.horiz ? axis.left : axis.bottom;
  16298. axis.minPixelPadding = transA * minPointOffset;
  16299. fireEvent(this, 'afterSetAxisTranslation');
  16300. };
  16301. /**
  16302. * @private
  16303. * @function Highcharts.Axis#minFromRange
  16304. *
  16305. * @return {number}
  16306. */
  16307. Axis.prototype.minFromRange = function () {
  16308. var axis = this;
  16309. return axis.max - axis.range;
  16310. };
  16311. /**
  16312. * Set the tick positions to round values and optionally extend the extremes
  16313. * to the nearest tick.
  16314. *
  16315. * @private
  16316. * @function Highcharts.Axis#setTickInterval
  16317. *
  16318. * @param {boolean} secondPass
  16319. * TO-DO: parameter description
  16320. *
  16321. * @fires Highcharts.Axis#event:foundExtremes
  16322. */
  16323. Axis.prototype.setTickInterval = function (secondPass) {
  16324. var axis = this,
  16325. chart = axis.chart,
  16326. log = axis.logarithmic,
  16327. options = axis.options,
  16328. isXAxis = axis.isXAxis,
  16329. isLinked = axis.isLinked,
  16330. maxPadding = options.maxPadding,
  16331. minPadding = options.minPadding,
  16332. length,
  16333. linkedParentExtremes,
  16334. tickIntervalOption = options.tickInterval,
  16335. minTickInterval,
  16336. tickPixelIntervalOption = options.tickPixelInterval,
  16337. categories = axis.categories,
  16338. threshold = isNumber(axis.threshold) ? axis.threshold : null,
  16339. softThreshold = axis.softThreshold,
  16340. thresholdMin,
  16341. thresholdMax,
  16342. hardMin,
  16343. hardMax;
  16344. if (!axis.dateTime && !categories && !isLinked) {
  16345. this.getTickAmount();
  16346. }
  16347. // Min or max set either by zooming/setExtremes or initial options
  16348. hardMin = pick(axis.userMin, options.min);
  16349. hardMax = pick(axis.userMax, options.max);
  16350. // Linked axis gets the extremes from the parent axis
  16351. if (isLinked) {
  16352. axis.linkedParent = chart[axis.coll][options.linkedTo];
  16353. linkedParentExtremes = axis.linkedParent.getExtremes();
  16354. axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
  16355. axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
  16356. if (options.type !== axis.linkedParent.options.type) {
  16357. // Can't link axes of different type
  16358. error(11, 1, chart);
  16359. }
  16360. // Initial min and max from the extreme data values
  16361. }
  16362. else {
  16363. // Adjust to hard threshold
  16364. if (softThreshold && defined(threshold)) {
  16365. if (axis.dataMin >= threshold) {
  16366. thresholdMin = threshold;
  16367. minPadding = 0;
  16368. }
  16369. else if (axis.dataMax <= threshold) {
  16370. thresholdMax = threshold;
  16371. maxPadding = 0;
  16372. }
  16373. }
  16374. axis.min = pick(hardMin, thresholdMin, axis.dataMin);
  16375. axis.max = pick(hardMax, thresholdMax, axis.dataMax);
  16376. }
  16377. if (log) {
  16378. if (axis.positiveValuesOnly &&
  16379. !secondPass &&
  16380. Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978
  16381. // Can't plot negative values on log axis
  16382. error(10, 1, chart);
  16383. }
  16384. // The correctFloat cures #934, float errors on full tens. But it
  16385. // was too aggressive for #4360 because of conversion back to lin,
  16386. // therefore use precision 15.
  16387. axis.min = correctFloat(log.log2lin(axis.min), 16);
  16388. axis.max = correctFloat(log.log2lin(axis.max), 16);
  16389. }
  16390. // handle zoomed range
  16391. if (axis.range && defined(axis.max)) {
  16392. // #618, #6773:
  16393. axis.userMin = axis.min = hardMin =
  16394. Math.max(axis.dataMin, axis.minFromRange());
  16395. axis.userMax = hardMax = axis.max;
  16396. axis.range = null; // don't use it when running setExtremes
  16397. }
  16398. // Hook for Highcharts Stock Scroller.
  16399. // Consider combining with beforePadding.
  16400. fireEvent(axis, 'foundExtremes');
  16401. // Hook for adjusting this.min and this.max. Used by bubble series.
  16402. if (axis.beforePadding) {
  16403. axis.beforePadding();
  16404. }
  16405. // adjust min and max for the minimum range
  16406. axis.adjustForMinRange();
  16407. // Pad the values to get clear of the chart's edges. To avoid
  16408. // tickInterval taking the padding into account, we do this after
  16409. // computing tick interval (#1337).
  16410. if (!categories &&
  16411. !axis.axisPointRange &&
  16412. !(axis.stacking && axis.stacking.usePercentage) &&
  16413. !isLinked &&
  16414. defined(axis.min) &&
  16415. defined(axis.max)) {
  16416. length = axis.max - axis.min;
  16417. if (length) {
  16418. if (!defined(hardMin) && minPadding) {
  16419. axis.min -= length * minPadding;
  16420. }
  16421. if (!defined(hardMax) && maxPadding) {
  16422. axis.max += length * maxPadding;
  16423. }
  16424. }
  16425. }
  16426. // Handle options for floor, ceiling, softMin and softMax (#6359)
  16427. if (!isNumber(axis.userMin)) {
  16428. if (isNumber(options.softMin) && options.softMin < axis.min) {
  16429. axis.min = hardMin = options.softMin; // #6894
  16430. }
  16431. if (isNumber(options.floor)) {
  16432. axis.min = Math.max(axis.min, options.floor);
  16433. }
  16434. }
  16435. if (!isNumber(axis.userMax)) {
  16436. if (isNumber(options.softMax) && options.softMax > axis.max) {
  16437. axis.max = hardMax = options.softMax; // #6894
  16438. }
  16439. if (isNumber(options.ceiling)) {
  16440. axis.max = Math.min(axis.max, options.ceiling);
  16441. }
  16442. }
  16443. // When the threshold is soft, adjust the extreme value only if the data
  16444. // extreme and the padded extreme land on either side of the threshold.
  16445. // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
  16446. // for -1 because of the default minPadding and startOnTick options.
  16447. // This is prevented by the softThreshold option.
  16448. if (softThreshold && defined(axis.dataMin)) {
  16449. threshold = threshold || 0;
  16450. if (!defined(hardMin) &&
  16451. axis.min < threshold &&
  16452. axis.dataMin >= threshold) {
  16453. axis.min = axis.options.minRange ?
  16454. Math.min(threshold, axis.max -
  16455. axis.minRange) :
  16456. threshold;
  16457. }
  16458. else if (!defined(hardMax) &&
  16459. axis.max > threshold &&
  16460. axis.dataMax <= threshold) {
  16461. axis.max = axis.options.minRange ?
  16462. Math.max(threshold, axis.min +
  16463. axis.minRange) :
  16464. threshold;
  16465. }
  16466. }
  16467. // If min is bigger than highest, or if max less than lowest value, the
  16468. // chart should not render points. (#14417)
  16469. if (isNumber(axis.min) &&
  16470. isNumber(axis.max) &&
  16471. !this.chart.polar &&
  16472. (axis.min > axis.max)) {
  16473. if (defined(axis.options.min)) {
  16474. axis.max = axis.min;
  16475. }
  16476. else if (defined(axis.options.max)) {
  16477. axis.min = axis.max;
  16478. }
  16479. }
  16480. // get tickInterval
  16481. if (axis.min === axis.max ||
  16482. typeof axis.min === 'undefined' ||
  16483. typeof axis.max === 'undefined') {
  16484. axis.tickInterval = 1;
  16485. }
  16486. else if (isLinked &&
  16487. axis.linkedParent &&
  16488. !tickIntervalOption &&
  16489. tickPixelIntervalOption ===
  16490. axis.linkedParent.options.tickPixelInterval) {
  16491. axis.tickInterval = tickIntervalOption =
  16492. axis.linkedParent.tickInterval;
  16493. }
  16494. else {
  16495. axis.tickInterval = pick(tickIntervalOption, this.tickAmount ?
  16496. ((axis.max - axis.min) /
  16497. Math.max(this.tickAmount - 1, 1)) :
  16498. void 0,
  16499. // For categoried axis, 1 is default, for linear axis use
  16500. // tickPix
  16501. categories ?
  16502. 1 :
  16503. // don't let it be more than the data range
  16504. (axis.max - axis.min) *
  16505. tickPixelIntervalOption /
  16506. Math.max(axis.len, tickPixelIntervalOption));
  16507. }
  16508. // Now we're finished detecting min and max, crop and group series data.
  16509. // This is in turn needed in order to find tick positions in ordinal
  16510. // axes.
  16511. if (isXAxis && !secondPass) {
  16512. axis.series.forEach(function (series) {
  16513. series.processData(axis.min !== (axis.old && axis.old.min) ||
  16514. axis.max !== (axis.old && axis.old.max));
  16515. });
  16516. }
  16517. // set the translation factor used in translate function
  16518. axis.setAxisTranslation();
  16519. // hook for ordinal axes and radial axes
  16520. fireEvent(this, 'initialAxisTranslation');
  16521. // In column-like charts, don't cramp in more ticks than there are
  16522. // points (#1943, #4184)
  16523. if (axis.pointRange && !tickIntervalOption) {
  16524. axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
  16525. }
  16526. // Before normalizing the tick interval, handle minimum tick interval.
  16527. // This applies only if tickInterval is not defined.
  16528. minTickInterval = pick(options.minTickInterval,
  16529. // In datetime axes, don't go below the data interval, except when
  16530. // there are scatter-like series involved (#13369).
  16531. axis.dateTime &&
  16532. !axis.series.some(function (s) { return s.noSharedTooltip; }) ?
  16533. axis.closestPointRange : 0);
  16534. if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
  16535. axis.tickInterval = minTickInterval;
  16536. }
  16537. // for linear axes, get magnitude and normalize the interval
  16538. if (!axis.dateTime && !axis.logarithmic && !tickIntervalOption) {
  16539. axis.tickInterval = normalizeTickInterval(axis.tickInterval, void 0, getMagnitude(axis.tickInterval), pick(options.allowDecimals,
  16540. // If the tick interval is greather than 0.5, avoid
  16541. // decimals, as linear axes are often used to render
  16542. // discrete values. #3363. If a tick amount is set, allow
  16543. // decimals by default, as it increases the chances for a
  16544. // good fit.
  16545. axis.tickInterval < 0.5 || this.tickAmount !== void 0), !!this.tickAmount);
  16546. }
  16547. // Prevent ticks from getting so close that we can't draw the labels
  16548. if (!this.tickAmount) {
  16549. axis.tickInterval = axis.unsquish();
  16550. }
  16551. this.setTickPositions();
  16552. };
  16553. /**
  16554. * Now we have computed the normalized tickInterval, get the tick positions.
  16555. *
  16556. * @private
  16557. * @function Highcharts.Axis#setTickPositions
  16558. *
  16559. * @fires Highcharts.Axis#event:afterSetTickPositions
  16560. */
  16561. Axis.prototype.setTickPositions = function () {
  16562. var axis = this,
  16563. options = this.options,
  16564. tickPositions,
  16565. tickPositionsOption = options.tickPositions,
  16566. minorTickIntervalOption = this.getMinorTickInterval(),
  16567. tickPositioner = options.tickPositioner,
  16568. hasVerticalPanning = this.hasVerticalPanning(),
  16569. isColorAxis = this.coll === 'colorAxis',
  16570. startOnTick = (isColorAxis || !hasVerticalPanning) && options.startOnTick,
  16571. endOnTick = (isColorAxis || !hasVerticalPanning) && options.endOnTick;
  16572. // Set the tickmarkOffset
  16573. this.tickmarkOffset = (this.categories &&
  16574. options.tickmarkPlacement === 'between' &&
  16575. this.tickInterval === 1) ? 0.5 : 0; // #3202
  16576. // get minorTickInterval
  16577. this.minorTickInterval =
  16578. minorTickIntervalOption === 'auto' &&
  16579. this.tickInterval ?
  16580. this.tickInterval / 5 :
  16581. minorTickIntervalOption;
  16582. // When there is only one point, or all points have the same value on
  16583. // this axis, then min and max are equal and tickPositions.length is 0
  16584. // or 1. In this case, add some padding in order to center the point,
  16585. // but leave it with one tick. #1337.
  16586. this.single =
  16587. this.min === this.max &&
  16588. defined(this.min) &&
  16589. !this.tickAmount &&
  16590. (
  16591. // Data is on integer (#6563)
  16592. parseInt(this.min, 10) === this.min ||
  16593. // Between integers and decimals are not allowed (#6274)
  16594. options.allowDecimals !== false);
  16595. /**
  16596. * Contains the current positions that are laid out on the axis. The
  16597. * positions are numbers in terms of axis values. In a category axis
  16598. * they are integers, in a datetime axis they are also integers, but
  16599. * designating milliseconds.
  16600. *
  16601. * This property is read only - for modifying the tick positions, use
  16602. * the `tickPositioner` callback or [axis.tickPositions(
  16603. * https://api.highcharts.com/highcharts/xAxis.tickPositions) option
  16604. * instead.
  16605. *
  16606. * @name Highcharts.Axis#tickPositions
  16607. * @type {Highcharts.AxisTickPositionsArray|undefined}
  16608. */
  16609. this.tickPositions =
  16610. // Find the tick positions. Work on a copy (#1565)
  16611. tickPositions =
  16612. (tickPositionsOption && tickPositionsOption.slice());
  16613. if (!tickPositions) {
  16614. // Too many ticks (#6405). Create a friendly warning and provide two
  16615. // ticks so at least we can show the data series.
  16616. if ((!axis.ordinal || !axis.ordinal.positions) &&
  16617. ((this.max - this.min) /
  16618. this.tickInterval >
  16619. Math.max(2 * this.len, 200))) {
  16620. tickPositions = [this.min, this.max];
  16621. error(19, false, this.chart);
  16622. }
  16623. else if (axis.dateTime) {
  16624. tickPositions = axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(this.tickInterval, options.units), this.min, this.max, options.startOfWeek, axis.ordinal && axis.ordinal.positions, this.closestPointRange, true);
  16625. }
  16626. else if (axis.logarithmic) {
  16627. tickPositions = axis.logarithmic.getLogTickPositions(this.tickInterval, this.min, this.max);
  16628. }
  16629. else {
  16630. tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
  16631. }
  16632. // Too dense ticks, keep only the first and last (#4477)
  16633. if (tickPositions.length > this.len) {
  16634. tickPositions = [tickPositions[0], tickPositions.pop()];
  16635. // Reduce doubled value (#7339)
  16636. if (tickPositions[0] === tickPositions[1]) {
  16637. tickPositions.length = 1;
  16638. }
  16639. }
  16640. this.tickPositions = tickPositions;
  16641. // Run the tick positioner callback, that allows modifying auto tick
  16642. // positions.
  16643. if (tickPositioner) {
  16644. tickPositioner = tickPositioner.apply(axis, [this.min, this.max]);
  16645. if (tickPositioner) {
  16646. this.tickPositions = tickPositions = tickPositioner;
  16647. }
  16648. }
  16649. }
  16650. // Reset min/max or remove extremes based on start/end on tick
  16651. this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
  16652. this.trimTicks(tickPositions, startOnTick, endOnTick);
  16653. if (!this.isLinked) {
  16654. // Substract half a unit (#2619, #2846, #2515, #3390),
  16655. // but not in case of multiple ticks (#6897)
  16656. if (this.single &&
  16657. tickPositions.length < 2 &&
  16658. !this.categories &&
  16659. !this.series.some(function (s) {
  16660. return (s.is('heatmap') && s.options.pointPlacement === 'between');
  16661. })) {
  16662. this.min -= 0.5;
  16663. this.max += 0.5;
  16664. }
  16665. if (!tickPositionsOption && !tickPositioner) {
  16666. this.adjustTickAmount();
  16667. }
  16668. }
  16669. fireEvent(this, 'afterSetTickPositions');
  16670. };
  16671. /**
  16672. * Handle startOnTick and endOnTick by either adapting to padding min/max or
  16673. * rounded min/max. Also handle single data points.
  16674. *
  16675. * @private
  16676. * @function Highcharts.Axis#trimTicks
  16677. *
  16678. * @param {Array<number>} tickPositions
  16679. * TO-DO: parameter description
  16680. *
  16681. * @param {boolean} [startOnTick]
  16682. * TO-DO: parameter description
  16683. *
  16684. * @param {boolean} [endOnTick]
  16685. * TO-DO: parameter description
  16686. */
  16687. Axis.prototype.trimTicks = function (tickPositions, startOnTick, endOnTick) {
  16688. var roundedMin = tickPositions[0],
  16689. roundedMax = tickPositions[tickPositions.length - 1],
  16690. minPointOffset = (!this.isOrdinal && this.minPointOffset) || 0; // (#12716)
  16691. fireEvent(this, 'trimTicks');
  16692. if (!this.isLinked) {
  16693. if (startOnTick && roundedMin !== -Infinity) { // #6502
  16694. this.min = roundedMin;
  16695. }
  16696. else {
  16697. while (this.min - minPointOffset > tickPositions[0]) {
  16698. tickPositions.shift();
  16699. }
  16700. }
  16701. if (endOnTick) {
  16702. this.max = roundedMax;
  16703. }
  16704. else {
  16705. while (this.max + minPointOffset <
  16706. tickPositions[tickPositions.length - 1]) {
  16707. tickPositions.pop();
  16708. }
  16709. }
  16710. // If no tick are left, set one tick in the middle (#3195)
  16711. if (tickPositions.length === 0 &&
  16712. defined(roundedMin) &&
  16713. !this.options.tickPositions) {
  16714. tickPositions.push((roundedMax + roundedMin) / 2);
  16715. }
  16716. }
  16717. };
  16718. /**
  16719. * Check if there are multiple axes in the same pane.
  16720. *
  16721. * @private
  16722. * @function Highcharts.Axis#alignToOthers
  16723. *
  16724. * @return {boolean|undefined}
  16725. * True if there are other axes.
  16726. */
  16727. Axis.prototype.alignToOthers = function () {
  16728. var axis = this,
  16729. others = // Whether there is another axis to pair with this one
  16730. {},
  16731. hasOther,
  16732. options = axis.options;
  16733. if (
  16734. // Only if alignTicks is true
  16735. this.chart.options.chart.alignTicks !== false &&
  16736. options.alignTicks &&
  16737. // Disabled when startOnTick or endOnTick are false (#7604)
  16738. options.startOnTick !== false &&
  16739. options.endOnTick !== false &&
  16740. // Don't try to align ticks on a log axis, they are not evenly
  16741. // spaced (#6021)
  16742. !axis.logarithmic) {
  16743. this.chart[this.coll].forEach(function (axis) {
  16744. var otherOptions = axis.options, horiz = axis.horiz, key = [
  16745. horiz ? otherOptions.left : otherOptions.top,
  16746. otherOptions.width,
  16747. otherOptions.height,
  16748. otherOptions.pane
  16749. ].join(',');
  16750. if (axis.series.length) { // #4442
  16751. if (others[key]) {
  16752. hasOther = true; // #4201
  16753. }
  16754. else {
  16755. others[key] = 1;
  16756. }
  16757. }
  16758. });
  16759. }
  16760. return hasOther;
  16761. };
  16762. /**
  16763. * Find the max ticks of either the x and y axis collection, and record it
  16764. * in `this.tickAmount`.
  16765. *
  16766. * @private
  16767. * @function Highcharts.Axis#getTickAmount
  16768. */
  16769. Axis.prototype.getTickAmount = function () {
  16770. var axis = this,
  16771. options = this.options,
  16772. tickAmount = options.tickAmount,
  16773. tickPixelInterval = options.tickPixelInterval;
  16774. if (!defined(options.tickInterval) &&
  16775. !tickAmount &&
  16776. this.len < tickPixelInterval &&
  16777. !this.isRadial &&
  16778. !axis.logarithmic &&
  16779. options.startOnTick &&
  16780. options.endOnTick) {
  16781. tickAmount = 2;
  16782. }
  16783. if (!tickAmount && this.alignToOthers()) {
  16784. // Add 1 because 4 tick intervals require 5 ticks (including first
  16785. // and last)
  16786. tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
  16787. }
  16788. // For tick amounts of 2 and 3, compute five ticks and remove the
  16789. // intermediate ones. This prevents the axis from adding ticks that are
  16790. // too far away from the data extremes.
  16791. if (tickAmount < 4) {
  16792. this.finalTickAmt = tickAmount;
  16793. tickAmount = 5;
  16794. }
  16795. this.tickAmount = tickAmount;
  16796. };
  16797. /**
  16798. * When using multiple axes, adjust the number of ticks to match the highest
  16799. * number of ticks in that group.
  16800. *
  16801. * @private
  16802. * @function Highcharts.Axis#adjustTickAmount
  16803. */
  16804. Axis.prototype.adjustTickAmount = function () {
  16805. var axis = this,
  16806. axisOptions = axis.options,
  16807. tickInterval = axis.tickInterval,
  16808. tickPositions = axis.tickPositions,
  16809. tickAmount = axis.tickAmount,
  16810. finalTickAmt = axis.finalTickAmt,
  16811. currentTickAmount = tickPositions && tickPositions.length,
  16812. threshold = pick(axis.threshold,
  16813. axis.softThreshold ? 0 : null),
  16814. len,
  16815. i;
  16816. if (axis.hasData() && isNumber(axis.min) && isNumber(axis.max)) { // #14769
  16817. if (currentTickAmount < tickAmount) {
  16818. while (tickPositions.length < tickAmount) {
  16819. // Extend evenly for both sides unless we're on the
  16820. // threshold (#3965)
  16821. if (tickPositions.length % 2 ||
  16822. axis.min === threshold) {
  16823. // to the end
  16824. tickPositions.push(correctFloat(tickPositions[tickPositions.length - 1] +
  16825. tickInterval));
  16826. }
  16827. else {
  16828. // to the start
  16829. tickPositions.unshift(correctFloat(tickPositions[0] - tickInterval));
  16830. }
  16831. }
  16832. axis.transA *= (currentTickAmount - 1) / (tickAmount - 1);
  16833. // Do not crop when ticks are not extremes (#9841)
  16834. axis.min = axisOptions.startOnTick ?
  16835. tickPositions[0] :
  16836. Math.min(axis.min, tickPositions[0]);
  16837. axis.max = axisOptions.endOnTick ?
  16838. tickPositions[tickPositions.length - 1] :
  16839. Math.max(axis.max, tickPositions[tickPositions.length - 1]);
  16840. // We have too many ticks, run second pass to try to reduce ticks
  16841. }
  16842. else if (currentTickAmount > tickAmount) {
  16843. axis.tickInterval *= 2;
  16844. axis.setTickPositions();
  16845. }
  16846. // The finalTickAmt property is set in getTickAmount
  16847. if (defined(finalTickAmt)) {
  16848. i = len = tickPositions.length;
  16849. while (i--) {
  16850. if (
  16851. // Remove every other tick
  16852. (finalTickAmt === 3 && i % 2 === 1) ||
  16853. // Remove all but first and last
  16854. (finalTickAmt <= 2 && i > 0 && i < len - 1)) {
  16855. tickPositions.splice(i, 1);
  16856. }
  16857. }
  16858. axis.finalTickAmt = void 0;
  16859. }
  16860. }
  16861. };
  16862. /**
  16863. * Set the scale based on data min and max, user set min and max or options.
  16864. *
  16865. * @private
  16866. * @function Highcharts.Axis#setScale
  16867. *
  16868. * @fires Highcharts.Axis#event:afterSetScale
  16869. */
  16870. Axis.prototype.setScale = function () {
  16871. var axis = this,
  16872. isDirtyAxisLength,
  16873. isDirtyData = false,
  16874. isXAxisDirty = false;
  16875. axis.series.forEach(function (series) {
  16876. isDirtyData = isDirtyData || series.isDirtyData || series.isDirty;
  16877. // When x axis is dirty, we need new data extremes for y as
  16878. // well:
  16879. isXAxisDirty = (isXAxisDirty ||
  16880. (series.xAxis && series.xAxis.isDirty) ||
  16881. false);
  16882. });
  16883. // set the new axisLength
  16884. axis.setAxisSize();
  16885. isDirtyAxisLength = axis.len !== (axis.old && axis.old.len);
  16886. // do we really need to go through all this?
  16887. if (isDirtyAxisLength ||
  16888. isDirtyData ||
  16889. isXAxisDirty ||
  16890. axis.isLinked ||
  16891. axis.forceRedraw ||
  16892. axis.userMin !== (axis.old && axis.old.userMin) ||
  16893. axis.userMax !== (axis.old && axis.old.userMax) ||
  16894. axis.alignToOthers()) {
  16895. if (axis.stacking) {
  16896. axis.stacking.resetStacks();
  16897. }
  16898. axis.forceRedraw = false;
  16899. // get data extremes if needed
  16900. axis.getSeriesExtremes();
  16901. // get fixed positions based on tickInterval
  16902. axis.setTickInterval();
  16903. // Mark as dirty if it is not already set to dirty and extremes have
  16904. // changed. #595.
  16905. if (!axis.isDirty) {
  16906. axis.isDirty =
  16907. isDirtyAxisLength ||
  16908. axis.min !== (axis.old && axis.old.min) ||
  16909. axis.max !== (axis.old && axis.old.max);
  16910. }
  16911. }
  16912. else if (axis.stacking) {
  16913. axis.stacking.cleanStacks();
  16914. }
  16915. // Recalculate panning state object, when the data
  16916. // has changed. It is required when vertical panning is enabled.
  16917. if (isDirtyData && axis.panningState) {
  16918. axis.panningState.isDirty = true;
  16919. }
  16920. fireEvent(this, 'afterSetScale');
  16921. };
  16922. /**
  16923. * Set the minimum and maximum of the axes after render time. If the
  16924. * `startOnTick` and `endOnTick` options are true, the minimum and maximum
  16925. * values are rounded off to the nearest tick. To prevent this, these
  16926. * options can be set to false before calling setExtremes. Also, setExtremes
  16927. * will not allow a range lower than the `minRange` option, which by default
  16928. * is the range of five points.
  16929. *
  16930. * @sample highcharts/members/axis-setextremes/
  16931. * Set extremes from a button
  16932. * @sample highcharts/members/axis-setextremes-datetime/
  16933. * Set extremes on a datetime axis
  16934. * @sample highcharts/members/axis-setextremes-off-ticks/
  16935. * Set extremes off ticks
  16936. * @sample stock/members/axis-setextremes/
  16937. * Set extremes in Highcharts Stock
  16938. * @sample maps/members/axis-setextremes/
  16939. * Set extremes in Highmaps
  16940. *
  16941. * @function Highcharts.Axis#setExtremes
  16942. *
  16943. * @param {number} [newMin]
  16944. * The new minimum value.
  16945. *
  16946. * @param {number} [newMax]
  16947. * The new maximum value.
  16948. *
  16949. * @param {boolean} [redraw=true]
  16950. * Whether to redraw the chart or wait for an explicit call to
  16951. * {@link Highcharts.Chart#redraw}
  16952. *
  16953. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  16954. * Enable or modify animations.
  16955. *
  16956. * @param {*} [eventArguments]
  16957. * Arguments to be accessed in event handler.
  16958. *
  16959. * @fires Highcharts.Axis#event:setExtremes
  16960. */
  16961. Axis.prototype.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  16962. var axis = this,
  16963. chart = axis.chart;
  16964. redraw = pick(redraw, true); // defaults to true
  16965. axis.series.forEach(function (serie) {
  16966. delete serie.kdTree;
  16967. });
  16968. // Extend the arguments with min and max
  16969. eventArguments = extend(eventArguments, {
  16970. min: newMin,
  16971. max: newMax
  16972. });
  16973. // Fire the event
  16974. fireEvent(axis, 'setExtremes', eventArguments, function () {
  16975. axis.userMin = newMin;
  16976. axis.userMax = newMax;
  16977. axis.eventArgs = eventArguments;
  16978. if (redraw) {
  16979. chart.redraw(animation);
  16980. }
  16981. });
  16982. };
  16983. /**
  16984. * Overridable method for zooming chart. Pulled out in a separate method to
  16985. * allow overriding in stock charts.
  16986. * @private
  16987. * @function Highcharts.Axis#zoom
  16988. *
  16989. * @param {number} newMin
  16990. * TO-DO: parameter description
  16991. *
  16992. * @param {number} newMax
  16993. * TO-DO: parameter description
  16994. *
  16995. * @return {boolean}
  16996. */
  16997. Axis.prototype.zoom = function (newMin, newMax) {
  16998. var axis = this,
  16999. dataMin = this.dataMin,
  17000. dataMax = this.dataMax,
  17001. options = this.options,
  17002. min = Math.min(dataMin,
  17003. pick(options.min,
  17004. dataMin)),
  17005. max = Math.max(dataMax,
  17006. pick(options.max,
  17007. dataMax)),
  17008. evt = {
  17009. newMin: newMin,
  17010. newMax: newMax
  17011. };
  17012. fireEvent(this, 'zoom', evt, function (e) {
  17013. // Use e.newMin and e.newMax - event handlers may have altered them
  17014. var newMin = e.newMin,
  17015. newMax = e.newMax;
  17016. if (newMin !== axis.min || newMax !== axis.max) { // #5790
  17017. // Prevent pinch zooming out of range. Check for defined is for
  17018. // #1946. #1734.
  17019. if (!axis.allowZoomOutside) {
  17020. // #6014, sometimes newMax will be smaller than min (or
  17021. // newMin will be larger than max).
  17022. if (defined(dataMin)) {
  17023. if (newMin < min) {
  17024. newMin = min;
  17025. }
  17026. if (newMin > max) {
  17027. newMin = max;
  17028. }
  17029. }
  17030. if (defined(dataMax)) {
  17031. if (newMax < min) {
  17032. newMax = min;
  17033. }
  17034. if (newMax > max) {
  17035. newMax = max;
  17036. }
  17037. }
  17038. }
  17039. // In full view, displaying the reset zoom button is not
  17040. // required
  17041. axis.displayBtn = (typeof newMin !== 'undefined' ||
  17042. typeof newMax !== 'undefined');
  17043. // Do it
  17044. axis.setExtremes(newMin, newMax, false, void 0, { trigger: 'zoom' });
  17045. }
  17046. e.zoomed = true;
  17047. });
  17048. return evt.zoomed;
  17049. };
  17050. /**
  17051. * Update the axis metrics.
  17052. *
  17053. * @private
  17054. * @function Highcharts.Axis#setAxisSize
  17055. */
  17056. Axis.prototype.setAxisSize = function () {
  17057. var chart = this.chart,
  17058. options = this.options,
  17059. // [top, right, bottom, left]
  17060. offsets = options.offsets || [0, 0, 0, 0],
  17061. horiz = this.horiz,
  17062. // Check for percentage based input values. Rounding fixes problems
  17063. // with column overflow and plot line filtering (#4898, #4899)
  17064. width = this.width = Math.round(relativeLength(pick(options.width,
  17065. chart.plotWidth - offsets[3] + offsets[1]),
  17066. chart.plotWidth)),
  17067. height = this.height = Math.round(relativeLength(pick(options.height,
  17068. chart.plotHeight - offsets[0] + offsets[2]),
  17069. chart.plotHeight)),
  17070. top = this.top = Math.round(relativeLength(pick(options.top,
  17071. chart.plotTop + offsets[0]),
  17072. chart.plotHeight,
  17073. chart.plotTop)),
  17074. left = this.left = Math.round(relativeLength(pick(options.left,
  17075. chart.plotLeft + offsets[3]),
  17076. chart.plotWidth,
  17077. chart.plotLeft));
  17078. // Expose basic values to use in Series object and navigator
  17079. this.bottom = chart.chartHeight - height - top;
  17080. this.right = chart.chartWidth - width - left;
  17081. // Direction agnostic properties
  17082. this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
  17083. this.pos = horiz ? left : top; // distance from SVG origin
  17084. };
  17085. /**
  17086. * Get the current extremes for the axis.
  17087. *
  17088. * @sample highcharts/members/axis-getextremes/
  17089. * Report extremes by click on a button
  17090. * @sample maps/members/axis-getextremes/
  17091. * Get extremes in Highmaps
  17092. *
  17093. * @function Highcharts.Axis#getExtremes
  17094. *
  17095. * @return {Highcharts.ExtremesObject}
  17096. * An object containing extremes information.
  17097. */
  17098. Axis.prototype.getExtremes = function () {
  17099. var axis = this;
  17100. var log = axis.logarithmic;
  17101. return {
  17102. min: log ?
  17103. correctFloat(log.lin2log(axis.min)) :
  17104. axis.min,
  17105. max: log ?
  17106. correctFloat(log.lin2log(axis.max)) :
  17107. axis.max,
  17108. dataMin: axis.dataMin,
  17109. dataMax: axis.dataMax,
  17110. userMin: axis.userMin,
  17111. userMax: axis.userMax
  17112. };
  17113. };
  17114. /**
  17115. * Get the zero plane either based on zero or on the min or max value.
  17116. * Used in bar and area plots.
  17117. *
  17118. * @function Highcharts.Axis#getThreshold
  17119. *
  17120. * @param {number} threshold
  17121. * The threshold in axis values.
  17122. *
  17123. * @return {number|undefined}
  17124. * The translated threshold position in terms of pixels, and corrected to
  17125. * stay within the axis bounds.
  17126. */
  17127. Axis.prototype.getThreshold = function (threshold) {
  17128. var axis = this,
  17129. log = axis.logarithmic,
  17130. realMin = log ? log.lin2log(axis.min) : axis.min,
  17131. realMax = log ? log.lin2log(axis.max) : axis.max;
  17132. if (threshold === null || threshold === -Infinity) {
  17133. threshold = realMin;
  17134. }
  17135. else if (threshold === Infinity) {
  17136. threshold = realMax;
  17137. }
  17138. else if (realMin > threshold) {
  17139. threshold = realMin;
  17140. }
  17141. else if (realMax < threshold) {
  17142. threshold = realMax;
  17143. }
  17144. return axis.translate(threshold, 0, 1, 0, 1);
  17145. };
  17146. /**
  17147. * Compute auto alignment for the axis label based on which side the axis is
  17148. * on and the given rotation for the label.
  17149. *
  17150. * @private
  17151. * @function Highcharts.Axis#autoLabelAlign
  17152. *
  17153. * @param {number} rotation
  17154. * The rotation in degrees as set by either the `rotation` or `autoRotation`
  17155. * options.
  17156. *
  17157. * @return {Highcharts.AlignValue}
  17158. * Can be `"center"`, `"left"` or `"right"`.
  17159. */
  17160. Axis.prototype.autoLabelAlign = function (rotation) {
  17161. var angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360,
  17162. evt = { align: 'center' };
  17163. fireEvent(this, 'autoLabelAlign', evt, function (e) {
  17164. if (angle > 15 && angle < 165) {
  17165. e.align = 'right';
  17166. }
  17167. else if (angle > 195 && angle < 345) {
  17168. e.align = 'left';
  17169. }
  17170. });
  17171. return evt.align;
  17172. };
  17173. /**
  17174. * Get the tick length and width for the axis based on axis options.
  17175. * @private
  17176. * @function Highcharts.Axis#tickSize
  17177. *
  17178. * @param {string} [prefix]
  17179. * 'tick' or 'minorTick'
  17180. *
  17181. * @return {Array<number,number>|undefined}
  17182. * An array of tickLength and tickWidth
  17183. */
  17184. Axis.prototype.tickSize = function (prefix) {
  17185. var options = this.options, tickLength = options[prefix === 'tick' ? 'tickLength' : 'minorTickLength'], tickWidth = pick(options[prefix === 'tick' ? 'tickWidth' : 'minorTickWidth'],
  17186. // Default to 1 on linear and datetime X axes
  17187. prefix === 'tick' && this.isXAxis && !this.categories ? 1 : 0), e, tickSize;
  17188. if (tickWidth && tickLength) {
  17189. // Negate the length
  17190. if (options[prefix + 'Position'] === 'inside') {
  17191. tickLength = -tickLength;
  17192. }
  17193. tickSize = [tickLength, tickWidth];
  17194. }
  17195. e = { tickSize: tickSize };
  17196. fireEvent(this, 'afterTickSize', e);
  17197. return e.tickSize;
  17198. };
  17199. /**
  17200. * Return the size of the labels.
  17201. *
  17202. * @private
  17203. * @function Highcharts.Axis#labelMetrics
  17204. *
  17205. * @return {Highcharts.FontMetricsObject}
  17206. */
  17207. Axis.prototype.labelMetrics = function () {
  17208. var index = this.tickPositions && this.tickPositions[0] || 0;
  17209. return this.chart.renderer.fontMetrics(this.options.labels.style.fontSize, this.ticks[index] && this.ticks[index].label);
  17210. };
  17211. /**
  17212. * Prevent the ticks from getting so close we can't draw the labels. On a
  17213. * horizontal axis, this is handled by rotating the labels, removing ticks
  17214. * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
  17215. *
  17216. * @private
  17217. * @function Highcharts.Axis#unsquish
  17218. *
  17219. * @return {number}
  17220. */
  17221. Axis.prototype.unsquish = function () {
  17222. var labelOptions = this.options.labels,
  17223. horiz = this.horiz,
  17224. tickInterval = this.tickInterval,
  17225. newTickInterval = tickInterval,
  17226. slotSize = this.len / (((this.categories ? 1 : 0) +
  17227. this.max -
  17228. this.min) /
  17229. tickInterval),
  17230. rotation,
  17231. rotationOption = labelOptions.rotation,
  17232. labelMetrics = this.labelMetrics(),
  17233. step,
  17234. bestScore = Number.MAX_VALUE,
  17235. autoRotation,
  17236. range = Math.max(this.max - this.min, 0),
  17237. // Return the multiple of tickInterval that is needed to avoid
  17238. // collision
  17239. getStep = function (spaceNeeded) {
  17240. var step = spaceNeeded / (slotSize || 1);
  17241. step = step > 1 ? Math.ceil(step) : 1;
  17242. // Guard for very small or negative angles (#9835)
  17243. if (step * tickInterval > range &&
  17244. spaceNeeded !== Infinity &&
  17245. slotSize !== Infinity &&
  17246. range) {
  17247. step = Math.ceil(range / tickInterval);
  17248. }
  17249. return correctFloat(step * tickInterval);
  17250. };
  17251. if (horiz) {
  17252. if (!labelOptions.staggerLines && !labelOptions.step) {
  17253. if (isNumber(rotationOption)) {
  17254. autoRotation = [rotationOption];
  17255. }
  17256. else if (slotSize < labelOptions.autoRotationLimit) {
  17257. autoRotation = labelOptions.autoRotation;
  17258. }
  17259. }
  17260. if (autoRotation) {
  17261. // Loop over the given autoRotation options, and determine
  17262. // which gives the best score. The best score is that with
  17263. // the lowest number of steps and a rotation closest
  17264. // to horizontal.
  17265. autoRotation.forEach(function (rot) {
  17266. var score;
  17267. if (rot === rotationOption ||
  17268. (rot && rot >= -90 && rot <= 90)) { // #3891
  17269. step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
  17270. score = step + Math.abs(rot / 360);
  17271. if (score < bestScore) {
  17272. bestScore = score;
  17273. rotation = rot;
  17274. newTickInterval = step;
  17275. }
  17276. }
  17277. });
  17278. }
  17279. }
  17280. else if (!labelOptions.step) { // #4411
  17281. newTickInterval = getStep(labelMetrics.h);
  17282. }
  17283. this.autoRotation = autoRotation;
  17284. this.labelRotation = pick(rotation, isNumber(rotationOption) ? rotationOption : 0);
  17285. return newTickInterval;
  17286. };
  17287. /**
  17288. * Get the general slot width for labels/categories on this axis. This may
  17289. * change between the pre-render (from Axis.getOffset) and the final tick
  17290. * rendering and placement.
  17291. *
  17292. * @private
  17293. * @function Highcharts.Axis#getSlotWidth
  17294. *
  17295. * @param {Highcharts.Tick} [tick] Optionally, calculate the slot width
  17296. * basing on tick label. It is used in highcharts-3d module, where the slots
  17297. * has different widths depending on perspective angles.
  17298. *
  17299. * @return {number}
  17300. * The pixel width allocated to each axis label.
  17301. */
  17302. Axis.prototype.getSlotWidth = function (tick) {
  17303. // #5086, #1580, #1931
  17304. var chart = this.chart,
  17305. horiz = this.horiz,
  17306. labelOptions = this.options.labels,
  17307. slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
  17308. marginLeft = chart.margin[3];
  17309. // Used by grid axis
  17310. if (tick && isNumber(tick.slotWidth)) { // #13221, can be 0
  17311. return tick.slotWidth;
  17312. }
  17313. if (horiz && labelOptions.step < 2) {
  17314. if (labelOptions.rotation) { // #4415
  17315. return 0;
  17316. }
  17317. return ((this.staggerLines || 1) * this.len) / slotCount;
  17318. }
  17319. if (!horiz) {
  17320. // #7028
  17321. var cssWidth = labelOptions.style.width;
  17322. if (cssWidth !== void 0) {
  17323. return parseInt(String(cssWidth), 10);
  17324. }
  17325. if (marginLeft) {
  17326. return marginLeft - chart.spacing[3];
  17327. }
  17328. }
  17329. // Last resort, a fraction of the available size
  17330. return chart.chartWidth * 0.33;
  17331. };
  17332. /**
  17333. * Render the axis labels and determine whether ellipsis or rotation need to
  17334. * be applied.
  17335. *
  17336. * @private
  17337. * @function Highcharts.Axis#renderUnsquish
  17338. */
  17339. Axis.prototype.renderUnsquish = function () {
  17340. var chart = this.chart,
  17341. renderer = chart.renderer,
  17342. tickPositions = this.tickPositions,
  17343. ticks = this.ticks,
  17344. labelOptions = this.options.labels,
  17345. labelStyleOptions = labelOptions.style,
  17346. horiz = this.horiz,
  17347. slotWidth = this.getSlotWidth(),
  17348. innerWidth = Math.max(1,
  17349. Math.round(slotWidth - 2 * labelOptions.padding)),
  17350. attr = {},
  17351. labelMetrics = this.labelMetrics(),
  17352. textOverflowOption = labelStyleOptions.textOverflow,
  17353. commonWidth,
  17354. commonTextOverflow,
  17355. maxLabelLength = 0,
  17356. label,
  17357. i,
  17358. pos;
  17359. // Set rotation option unless it is "auto", like in gauges
  17360. if (!isString(labelOptions.rotation)) {
  17361. // #4443
  17362. attr.rotation = labelOptions.rotation || 0;
  17363. }
  17364. // Get the longest label length
  17365. tickPositions.forEach(function (tickPosition) {
  17366. var tick = ticks[tickPosition];
  17367. // Replace label - sorting animation
  17368. if (tick.movedLabel) {
  17369. tick.replaceMovedLabel();
  17370. }
  17371. if (tick &&
  17372. tick.label &&
  17373. tick.label.textPxLength > maxLabelLength) {
  17374. maxLabelLength = tick.label.textPxLength;
  17375. }
  17376. });
  17377. this.maxLabelLength = maxLabelLength;
  17378. // Handle auto rotation on horizontal axis
  17379. if (this.autoRotation) {
  17380. // Apply rotation only if the label is too wide for the slot, and
  17381. // the label is wider than its height.
  17382. if (maxLabelLength > innerWidth &&
  17383. maxLabelLength > labelMetrics.h) {
  17384. attr.rotation = this.labelRotation;
  17385. }
  17386. else {
  17387. this.labelRotation = 0;
  17388. }
  17389. // Handle word-wrap or ellipsis on vertical axis
  17390. }
  17391. else if (slotWidth) {
  17392. // For word-wrap or ellipsis
  17393. commonWidth = innerWidth;
  17394. if (!textOverflowOption) {
  17395. commonTextOverflow = 'clip';
  17396. // On vertical axis, only allow word wrap if there is room
  17397. // for more lines.
  17398. i = tickPositions.length;
  17399. while (!horiz && i--) {
  17400. pos = tickPositions[i];
  17401. label = ticks[pos].label;
  17402. if (label) {
  17403. // Reset ellipsis in order to get the correct
  17404. // bounding box (#4070)
  17405. if (label.styles &&
  17406. label.styles.textOverflow === 'ellipsis') {
  17407. label.css({ textOverflow: 'clip' });
  17408. // Set the correct width in order to read
  17409. // the bounding box height (#4678, #5034)
  17410. }
  17411. else if (label.textPxLength > slotWidth) {
  17412. label.css({ width: slotWidth + 'px' });
  17413. }
  17414. if (label.getBBox().height > (this.len / tickPositions.length -
  17415. (labelMetrics.h - labelMetrics.f))) {
  17416. label.specificTextOverflow = 'ellipsis';
  17417. }
  17418. }
  17419. }
  17420. }
  17421. }
  17422. // Add ellipsis if the label length is significantly longer than ideal
  17423. if (attr.rotation) {
  17424. commonWidth = (maxLabelLength > chart.chartHeight * 0.5 ?
  17425. chart.chartHeight * 0.33 :
  17426. maxLabelLength);
  17427. if (!textOverflowOption) {
  17428. commonTextOverflow = 'ellipsis';
  17429. }
  17430. }
  17431. // Set the explicit or automatic label alignment
  17432. this.labelAlign = labelOptions.align ||
  17433. this.autoLabelAlign(this.labelRotation);
  17434. if (this.labelAlign) {
  17435. attr.align = this.labelAlign;
  17436. }
  17437. // Apply general and specific CSS
  17438. tickPositions.forEach(function (pos) {
  17439. var tick = ticks[pos],
  17440. label = tick && tick.label,
  17441. widthOption = labelStyleOptions.width,
  17442. css = {};
  17443. if (label) {
  17444. // This needs to go before the CSS in old IE (#4502)
  17445. label.attr(attr);
  17446. if (tick.shortenLabel) {
  17447. tick.shortenLabel();
  17448. }
  17449. else if (commonWidth &&
  17450. !widthOption &&
  17451. // Setting width in this case messes with the bounding box
  17452. // (#7975)
  17453. labelStyleOptions.whiteSpace !== 'nowrap' &&
  17454. (
  17455. // Speed optimizing, #7656
  17456. commonWidth < label.textPxLength ||
  17457. // Resetting CSS, #4928
  17458. label.element.tagName === 'SPAN')) {
  17459. css.width = commonWidth + 'px';
  17460. if (!textOverflowOption) {
  17461. css.textOverflow = (label.specificTextOverflow ||
  17462. commonTextOverflow);
  17463. }
  17464. label.css(css);
  17465. // Reset previously shortened label (#8210)
  17466. }
  17467. else if (label.styles &&
  17468. label.styles.width &&
  17469. !css.width &&
  17470. !widthOption) {
  17471. label.css({ width: null });
  17472. }
  17473. delete label.specificTextOverflow;
  17474. tick.rotation = attr.rotation;
  17475. }
  17476. }, this);
  17477. // Note: Why is this not part of getLabelPosition?
  17478. this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
  17479. };
  17480. /**
  17481. * Return true if the axis has associated data.
  17482. *
  17483. * @function Highcharts.Axis#hasData
  17484. *
  17485. * @return {boolean}
  17486. * True if the axis has associated visible series and those series have
  17487. * either valid data points or explicit `min` and `max` settings.
  17488. */
  17489. Axis.prototype.hasData = function () {
  17490. return this.series.some(function (s) {
  17491. return s.hasData();
  17492. }) ||
  17493. (this.options.showEmpty &&
  17494. defined(this.min) &&
  17495. defined(this.max));
  17496. };
  17497. /**
  17498. * Adds the title defined in axis.options.title.
  17499. *
  17500. * @function Highcharts.Axis#addTitle
  17501. *
  17502. * @param {boolean} [display]
  17503. * Whether or not to display the title.
  17504. */
  17505. Axis.prototype.addTitle = function (display) {
  17506. var axis = this,
  17507. renderer = axis.chart.renderer,
  17508. horiz = axis.horiz,
  17509. opposite = axis.opposite,
  17510. options = axis.options,
  17511. axisTitleOptions = options.title,
  17512. textAlign,
  17513. styledMode = axis.chart.styledMode;
  17514. if (!axis.axisTitle) {
  17515. textAlign = axisTitleOptions.textAlign;
  17516. if (!textAlign) {
  17517. textAlign = (horiz ? {
  17518. low: 'left',
  17519. middle: 'center',
  17520. high: 'right'
  17521. } : {
  17522. low: opposite ? 'right' : 'left',
  17523. middle: 'center',
  17524. high: opposite ? 'left' : 'right'
  17525. })[axisTitleOptions.align];
  17526. }
  17527. axis.axisTitle = renderer
  17528. .text(axisTitleOptions.text || '', 0, 0, axisTitleOptions.useHTML)
  17529. .attr({
  17530. zIndex: 7,
  17531. rotation: axisTitleOptions.rotation,
  17532. align: textAlign
  17533. })
  17534. .addClass('highcharts-axis-title');
  17535. // #7814, don't mutate style option
  17536. if (!styledMode) {
  17537. axis.axisTitle.css(merge(axisTitleOptions.style));
  17538. }
  17539. axis.axisTitle.add(axis.axisGroup);
  17540. axis.axisTitle.isNew = true;
  17541. }
  17542. // Max width defaults to the length of the axis
  17543. if (!styledMode &&
  17544. !axisTitleOptions.style.width &&
  17545. !axis.isRadial) {
  17546. axis.axisTitle.css({
  17547. width: axis.len + 'px'
  17548. });
  17549. }
  17550. // hide or show the title depending on whether showEmpty is set
  17551. axis.axisTitle[display ? 'show' : 'hide'](display);
  17552. };
  17553. /**
  17554. * Generates a tick for initial positioning.
  17555. *
  17556. * @private
  17557. * @function Highcharts.Axis#generateTick
  17558. *
  17559. * @param {number} pos
  17560. * The tick position in axis values.
  17561. *
  17562. * @param {number} [i]
  17563. * The index of the tick in {@link Axis.tickPositions}.
  17564. */
  17565. Axis.prototype.generateTick = function (pos) {
  17566. var axis = this;
  17567. var ticks = axis.ticks;
  17568. if (!ticks[pos]) {
  17569. ticks[pos] = new Tick(axis, pos);
  17570. }
  17571. else {
  17572. ticks[pos].addLabel(); // update labels depending on tick interval
  17573. }
  17574. };
  17575. /**
  17576. * Render the tick labels to a preliminary position to get their sizes
  17577. *
  17578. * @private
  17579. * @function Highcharts.Axis#getOffset
  17580. *
  17581. * @fires Highcharts.Axis#event:afterGetOffset
  17582. */
  17583. Axis.prototype.getOffset = function () {
  17584. var _this = this;
  17585. var axis = this,
  17586. chart = axis.chart,
  17587. renderer = chart.renderer,
  17588. options = axis.options,
  17589. tickPositions = axis.tickPositions,
  17590. ticks = axis.ticks,
  17591. horiz = axis.horiz,
  17592. side = axis.side,
  17593. invertedSide = chart.inverted &&
  17594. !axis.isZAxis ? [1, 0, 3, 2][side] : side,
  17595. hasData,
  17596. showAxis,
  17597. titleOffset = 0,
  17598. titleOffsetOption,
  17599. titleMargin = 0,
  17600. axisTitleOptions = options.title,
  17601. labelOptions = options.labels,
  17602. labelOffset = 0, // reset
  17603. labelOffsetPadded,
  17604. axisOffset = chart.axisOffset,
  17605. clipOffset = chart.clipOffset,
  17606. clip,
  17607. directionFactor = [-1, 1, 1, -1][side],
  17608. className = options.className,
  17609. axisParent = axis.axisParent, // Used in color axis
  17610. lineHeightCorrection;
  17611. // For reuse in Axis.render
  17612. hasData = axis.hasData();
  17613. axis.showAxis = showAxis = hasData || options.showEmpty;
  17614. // Set/reset staggerLines
  17615. axis.staggerLines = (axis.horiz && labelOptions.staggerLines) || void 0;
  17616. // Create the axisGroup and gridGroup elements on first iteration
  17617. if (!axis.axisGroup) {
  17618. var createGroup = function (name,
  17619. suffix,
  17620. zIndex) { return renderer.g(name)
  17621. .attr({ zIndex: zIndex })
  17622. .addClass("highcharts-" + _this.coll.toLowerCase() + suffix + " " +
  17623. (_this.isRadial ? "highcharts-radial-axis" + suffix + " " : '') +
  17624. (className || ''))
  17625. .add(axisParent); };
  17626. axis.gridGroup = createGroup('grid', '-grid', options.gridZIndex);
  17627. axis.axisGroup = createGroup('axis', '', options.zIndex);
  17628. axis.labelGroup = createGroup('axis-labels', '-labels', labelOptions.zIndex);
  17629. }
  17630. if (hasData || axis.isLinked) {
  17631. // Generate ticks
  17632. tickPositions.forEach(function (pos, i) {
  17633. // i is not used here, but may be used in overrides
  17634. axis.generateTick(pos, i);
  17635. });
  17636. axis.renderUnsquish();
  17637. // Left side must be align: right and right side must
  17638. // have align: left for labels
  17639. axis.reserveSpaceDefault = (side === 0 ||
  17640. side === 2 ||
  17641. { 1: 'left', 3: 'right' }[side] === axis.labelAlign);
  17642. if (pick(labelOptions.reserveSpace, axis.labelAlign === 'center' ? true : null, axis.reserveSpaceDefault)) {
  17643. tickPositions.forEach(function (pos) {
  17644. // get the highest offset
  17645. labelOffset = Math.max(ticks[pos].getLabelSize(), labelOffset);
  17646. });
  17647. }
  17648. if (axis.staggerLines) {
  17649. labelOffset *= axis.staggerLines;
  17650. }
  17651. axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
  17652. }
  17653. else { // doesn't have data
  17654. objectEach(ticks, function (tick, n) {
  17655. tick.destroy();
  17656. delete ticks[n];
  17657. });
  17658. }
  17659. if (axisTitleOptions &&
  17660. axisTitleOptions.text &&
  17661. axisTitleOptions.enabled !== false) {
  17662. axis.addTitle(showAxis);
  17663. if (showAxis && axisTitleOptions.reserveSpace !== false) {
  17664. axis.titleOffset = titleOffset =
  17665. axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
  17666. titleOffsetOption = axisTitleOptions.offset;
  17667. titleMargin = defined(titleOffsetOption) ?
  17668. 0 :
  17669. pick(axisTitleOptions.margin, horiz ? 5 : 10);
  17670. }
  17671. }
  17672. // Render the axis line
  17673. axis.renderLine();
  17674. // handle automatic or user set offset
  17675. axis.offset = directionFactor * pick(options.offset, axisOffset[side] ? axisOffset[side] + (options.margin || 0) : 0);
  17676. axis.tickRotCorr = axis.tickRotCorr || { x: 0, y: 0 }; // polar
  17677. if (side === 0) {
  17678. lineHeightCorrection = -axis.labelMetrics().h;
  17679. }
  17680. else if (side === 2) {
  17681. lineHeightCorrection = axis.tickRotCorr.y;
  17682. }
  17683. else {
  17684. lineHeightCorrection = 0;
  17685. }
  17686. // Find the padded label offset
  17687. labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
  17688. if (labelOffset) {
  17689. labelOffsetPadded -= lineHeightCorrection;
  17690. labelOffsetPadded += directionFactor * (horiz ?
  17691. pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) :
  17692. labelOptions.x);
  17693. }
  17694. axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
  17695. if (axis.getMaxLabelDimensions) {
  17696. axis.maxLabelDimensions = axis.getMaxLabelDimensions(ticks, tickPositions);
  17697. }
  17698. // Due to GridAxis.tickSize, tickSize should be calculated after ticks
  17699. // has rendered.
  17700. var tickSize = this.tickSize('tick');
  17701. axisOffset[side] = Math.max(axisOffset[side], (axis.axisTitleMargin || 0) + titleOffset +
  17702. directionFactor * axis.offset, labelOffsetPadded, // #3027
  17703. tickPositions && tickPositions.length && tickSize ?
  17704. tickSize[0] + directionFactor * axis.offset :
  17705. 0 // #4866
  17706. );
  17707. // Decide the clipping needed to keep the graph inside
  17708. // the plot area and axis lines
  17709. clip = options.offset ?
  17710. 0 :
  17711. // #4308, #4371:
  17712. Math.floor(axis.axisLine.strokeWidth() / 2) * 2;
  17713. clipOffset[invertedSide] =
  17714. Math.max(clipOffset[invertedSide], clip);
  17715. fireEvent(this, 'afterGetOffset');
  17716. };
  17717. /**
  17718. * Internal function to get the path for the axis line. Extended for polar
  17719. * charts.
  17720. *
  17721. * @function Highcharts.Axis#getLinePath
  17722. *
  17723. * @param {number} lineWidth
  17724. * The line width in pixels.
  17725. *
  17726. * @return {Highcharts.SVGPathArray}
  17727. * The SVG path definition in array form.
  17728. */
  17729. Axis.prototype.getLinePath = function (lineWidth) {
  17730. var chart = this.chart,
  17731. opposite = this.opposite,
  17732. offset = this.offset,
  17733. horiz = this.horiz,
  17734. lineLeft = this.left + (opposite ? this.width : 0) + offset,
  17735. lineTop = chart.chartHeight - this.bottom -
  17736. (opposite ? this.height : 0) + offset;
  17737. if (opposite) {
  17738. lineWidth *= -1; // crispify the other way - #1480, #1687
  17739. }
  17740. return chart.renderer
  17741. .crispLine([
  17742. [
  17743. 'M',
  17744. horiz ?
  17745. this.left :
  17746. lineLeft,
  17747. horiz ?
  17748. lineTop :
  17749. this.top
  17750. ],
  17751. [
  17752. 'L',
  17753. horiz ?
  17754. chart.chartWidth - this.right :
  17755. lineLeft,
  17756. horiz ?
  17757. lineTop :
  17758. chart.chartHeight - this.bottom
  17759. ]
  17760. ], lineWidth);
  17761. };
  17762. /**
  17763. * Render the axis line. Called internally when rendering and redrawing the
  17764. * axis.
  17765. *
  17766. * @function Highcharts.Axis#renderLine
  17767. */
  17768. Axis.prototype.renderLine = function () {
  17769. if (!this.axisLine) {
  17770. this.axisLine = this.chart.renderer.path()
  17771. .addClass('highcharts-axis-line')
  17772. .add(this.axisGroup);
  17773. if (!this.chart.styledMode) {
  17774. this.axisLine.attr({
  17775. stroke: this.options.lineColor,
  17776. 'stroke-width': this.options.lineWidth,
  17777. zIndex: 7
  17778. });
  17779. }
  17780. }
  17781. };
  17782. /**
  17783. * Position the axis title.
  17784. *
  17785. * @private
  17786. * @function Highcharts.Axis#getTitlePosition
  17787. *
  17788. * @return {Highcharts.PositionObject}
  17789. * X and Y positions for the title.
  17790. */
  17791. Axis.prototype.getTitlePosition = function () {
  17792. // compute anchor points for each of the title align options
  17793. var horiz = this.horiz,
  17794. axisLeft = this.left,
  17795. axisTop = this.top,
  17796. axisLength = this.len,
  17797. axisTitleOptions = this.options.title,
  17798. margin = horiz ? axisLeft : axisTop,
  17799. opposite = this.opposite,
  17800. offset = this.offset,
  17801. xOption = axisTitleOptions.x,
  17802. yOption = axisTitleOptions.y,
  17803. axisTitle = this.axisTitle,
  17804. fontMetrics = this.chart.renderer.fontMetrics(axisTitleOptions.style.fontSize,
  17805. axisTitle),
  17806. // The part of a multiline text that is below the baseline of the
  17807. // first line. Subtract 1 to preserve pixel-perfectness from the
  17808. // old behaviour (v5.0.12), where only one line was allowed.
  17809. textHeightOvershoot = Math.max(axisTitle.getBBox(null, 0).height - fontMetrics.h - 1, 0),
  17810. // the position in the length direction of the axis
  17811. alongAxis = {
  17812. low: margin + (horiz ? 0 : axisLength),
  17813. middle: margin + axisLength / 2,
  17814. high: margin + (horiz ? axisLength : 0)
  17815. }[axisTitleOptions.align],
  17816. // the position in the perpendicular direction of the axis
  17817. offAxis = (horiz ? axisTop + this.height : axisLeft) +
  17818. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  17819. (opposite ? -1 : 1) * // so does opposite axes
  17820. this.axisTitleMargin +
  17821. [
  17822. -textHeightOvershoot,
  17823. textHeightOvershoot,
  17824. fontMetrics.f,
  17825. -textHeightOvershoot // left
  17826. ][this.side],
  17827. titlePosition = {
  17828. x: horiz ?
  17829. alongAxis + xOption :
  17830. offAxis + (opposite ? this.width : 0) + offset + xOption,
  17831. y: horiz ?
  17832. offAxis + yOption - (opposite ? this.height : 0) + offset :
  17833. alongAxis + yOption
  17834. };
  17835. fireEvent(this, 'afterGetTitlePosition', { titlePosition: titlePosition });
  17836. return titlePosition;
  17837. };
  17838. /**
  17839. * Render a minor tick into the given position. If a minor tick already
  17840. * exists in this position, move it.
  17841. *
  17842. * @function Highcharts.Axis#renderMinorTick
  17843. *
  17844. * @param {number} pos
  17845. * The position in axis values.
  17846. */
  17847. Axis.prototype.renderMinorTick = function (pos) {
  17848. var axis = this;
  17849. var slideInTicks = axis.chart.hasRendered && axis.old;
  17850. var minorTicks = axis.minorTicks;
  17851. if (!minorTicks[pos]) {
  17852. minorTicks[pos] = new Tick(axis, pos, 'minor');
  17853. }
  17854. // Render new ticks in old position
  17855. if (slideInTicks && minorTicks[pos].isNew) {
  17856. minorTicks[pos].render(null, true);
  17857. }
  17858. minorTicks[pos].render(null, false, 1);
  17859. };
  17860. /**
  17861. * Render a major tick into the given position. If a tick already exists
  17862. * in this position, move it.
  17863. *
  17864. * @function Highcharts.Axis#renderTick
  17865. *
  17866. * @param {number} pos
  17867. * The position in axis values.
  17868. *
  17869. * @param {number} i
  17870. * The tick index.
  17871. */
  17872. Axis.prototype.renderTick = function (pos, i) {
  17873. var axis = this;
  17874. var isLinked = axis.isLinked;
  17875. var ticks = axis.ticks;
  17876. var slideInTicks = axis.chart.hasRendered && axis.old;
  17877. // Linked axes need an extra check to find out if
  17878. if (!isLinked ||
  17879. (pos >= axis.min && pos <= axis.max) ||
  17880. (axis.grid && axis.grid.isColumn)) {
  17881. if (!ticks[pos]) {
  17882. ticks[pos] = new Tick(axis, pos);
  17883. }
  17884. // NOTE this seems like overkill. Could be handled in tick.render by
  17885. // setting old position in attr, then set new position in animate.
  17886. // render new ticks in old position
  17887. if (slideInTicks && ticks[pos].isNew) {
  17888. // Start with negative opacity so that it is visible from
  17889. // halfway into the animation
  17890. ticks[pos].render(i, true, -1);
  17891. }
  17892. ticks[pos].render(i);
  17893. }
  17894. };
  17895. /**
  17896. * Render the axis.
  17897. *
  17898. * @private
  17899. * @function Highcharts.Axis#render
  17900. *
  17901. * @fires Highcharts.Axis#event:afterRender
  17902. */
  17903. Axis.prototype.render = function () {
  17904. var axis = this,
  17905. chart = axis.chart,
  17906. log = axis.logarithmic,
  17907. renderer = chart.renderer,
  17908. options = axis.options,
  17909. isLinked = axis.isLinked,
  17910. tickPositions = axis.tickPositions,
  17911. axisTitle = axis.axisTitle,
  17912. ticks = axis.ticks,
  17913. minorTicks = axis.minorTicks,
  17914. alternateBands = axis.alternateBands,
  17915. stackLabelOptions = options.stackLabels,
  17916. alternateGridColor = options.alternateGridColor,
  17917. tickmarkOffset = axis.tickmarkOffset,
  17918. axisLine = axis.axisLine,
  17919. showAxis = axis.showAxis,
  17920. animation = animObject(renderer.globalAnimation),
  17921. from,
  17922. to;
  17923. // Reset
  17924. axis.labelEdge.length = 0;
  17925. axis.overlap = false;
  17926. // Mark all elements inActive before we go over and mark the active ones
  17927. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17928. objectEach(coll, function (tick) {
  17929. tick.isActive = false;
  17930. });
  17931. });
  17932. // If the series has data draw the ticks. Else only the line and title
  17933. if (axis.hasData() || isLinked) {
  17934. // minor ticks
  17935. if (axis.minorTickInterval && !axis.categories) {
  17936. axis.getMinorTickPositions().forEach(function (pos) {
  17937. axis.renderMinorTick(pos);
  17938. });
  17939. }
  17940. // Major ticks. Pull out the first item and render it last so that
  17941. // we can get the position of the neighbour label. #808.
  17942. if (tickPositions.length) { // #1300
  17943. tickPositions.forEach(function (pos, i) {
  17944. axis.renderTick(pos, i);
  17945. });
  17946. // In a categorized axis, the tick marks are displayed
  17947. // between labels. So we need to add a tick mark and
  17948. // grid line at the left edge of the X axis.
  17949. if (tickmarkOffset && (axis.min === 0 || axis.single)) {
  17950. if (!ticks[-1]) {
  17951. ticks[-1] = new Tick(axis, -1, null, true);
  17952. }
  17953. ticks[-1].render(-1);
  17954. }
  17955. }
  17956. // alternate grid color
  17957. if (alternateGridColor) {
  17958. tickPositions.forEach(function (pos, i) {
  17959. to = typeof tickPositions[i + 1] !== 'undefined' ?
  17960. tickPositions[i + 1] + tickmarkOffset :
  17961. axis.max - tickmarkOffset;
  17962. if (i % 2 === 0 &&
  17963. pos < axis.max &&
  17964. to <= axis.max + (chart.polar ?
  17965. -tickmarkOffset :
  17966. tickmarkOffset)) { // #2248, #4660
  17967. if (!alternateBands[pos]) {
  17968. // Should be imported from PlotLineOrBand.js, but
  17969. // the dependency cycle with axis is a problem
  17970. alternateBands[pos] = new H.PlotLineOrBand(axis);
  17971. }
  17972. from = pos + tickmarkOffset; // #949
  17973. alternateBands[pos].options = {
  17974. from: log ? log.lin2log(from) : from,
  17975. to: log ? log.lin2log(to) : to,
  17976. color: alternateGridColor,
  17977. className: 'highcharts-alternate-grid'
  17978. };
  17979. alternateBands[pos].render();
  17980. alternateBands[pos].isActive = true;
  17981. }
  17982. });
  17983. }
  17984. // custom plot lines and bands
  17985. if (!axis._addedPlotLB) { // only first time
  17986. axis._addedPlotLB = true;
  17987. (options.plotLines || [])
  17988. .concat(options.plotBands || [])
  17989. .forEach(function (plotLineOptions) {
  17990. axis.addPlotBandOrLine(plotLineOptions);
  17991. });
  17992. }
  17993. } // end if hasData
  17994. // Remove inactive ticks
  17995. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17996. var i,
  17997. forDestruction = [],
  17998. delay = animation.duration,
  17999. destroyInactiveItems = function () {
  18000. i = forDestruction.length;
  18001. while (i--) {
  18002. // When resizing rapidly, the same items
  18003. // may be destroyed in different timeouts,
  18004. // or the may be reactivated
  18005. if (coll[forDestruction[i]] &&
  18006. !coll[forDestruction[i]].isActive) {
  18007. coll[forDestruction[i]].destroy();
  18008. delete coll[forDestruction[i]];
  18009. }
  18010. }
  18011. };
  18012. objectEach(coll, function (tick, pos) {
  18013. if (!tick.isActive) {
  18014. // Render to zero opacity
  18015. tick.render(pos, false, 0);
  18016. tick.isActive = false;
  18017. forDestruction.push(pos);
  18018. }
  18019. });
  18020. // When the objects are finished fading out, destroy them
  18021. syncTimeout(destroyInactiveItems, coll === alternateBands ||
  18022. !chart.hasRendered ||
  18023. !delay ?
  18024. 0 :
  18025. delay);
  18026. });
  18027. // Set the axis line path
  18028. if (axisLine) {
  18029. axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
  18030. d: this.getLinePath(axisLine.strokeWidth())
  18031. });
  18032. axisLine.isPlaced = true;
  18033. // Show or hide the line depending on options.showEmpty
  18034. axisLine[showAxis ? 'show' : 'hide'](showAxis);
  18035. }
  18036. if (axisTitle && showAxis) {
  18037. var titleXy = axis.getTitlePosition();
  18038. if (isNumber(titleXy.y)) {
  18039. axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
  18040. axisTitle.isNew = false;
  18041. }
  18042. else {
  18043. axisTitle.attr('y', -9999);
  18044. axisTitle.isNew = true;
  18045. }
  18046. }
  18047. // Stacked totals:
  18048. if (stackLabelOptions && stackLabelOptions.enabled && axis.stacking) {
  18049. axis.stacking.renderStackTotals();
  18050. }
  18051. // End stacked totals
  18052. // Record old scaling for updating/animation
  18053. axis.old = {
  18054. len: axis.len,
  18055. max: axis.max,
  18056. min: axis.min,
  18057. transA: axis.transA,
  18058. userMax: axis.userMax,
  18059. userMin: axis.userMin
  18060. };
  18061. axis.isDirty = false;
  18062. fireEvent(this, 'afterRender');
  18063. };
  18064. /**
  18065. * Redraw the axis to reflect changes in the data or axis extremes. Called
  18066. * internally from Highcharts.Chart#redraw.
  18067. *
  18068. * @private
  18069. * @function Highcharts.Axis#redraw
  18070. */
  18071. Axis.prototype.redraw = function () {
  18072. if (this.visible) {
  18073. // render the axis
  18074. this.render();
  18075. // move plot lines and bands
  18076. this.plotLinesAndBands.forEach(function (plotLine) {
  18077. plotLine.render();
  18078. });
  18079. }
  18080. // mark associated series as dirty and ready for redraw
  18081. this.series.forEach(function (series) {
  18082. series.isDirty = true;
  18083. });
  18084. };
  18085. /**
  18086. * Returns an array of axis properties, that should be untouched during
  18087. * reinitialization.
  18088. *
  18089. * @private
  18090. * @function Highcharts.Axis#getKeepProps
  18091. *
  18092. * @return {Array<string>}
  18093. */
  18094. Axis.prototype.getKeepProps = function () {
  18095. return (this.keepProps || Axis.keepProps);
  18096. };
  18097. /**
  18098. * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
  18099. * to fully remove the axis.
  18100. *
  18101. * @private
  18102. * @function Highcharts.Axis#destroy
  18103. *
  18104. * @param {boolean} [keepEvents]
  18105. * Whether to preserve events, used internally in Axis.update.
  18106. */
  18107. Axis.prototype.destroy = function (keepEvents) {
  18108. var axis = this,
  18109. plotLinesAndBands = axis.plotLinesAndBands,
  18110. plotGroup,
  18111. i;
  18112. fireEvent(this, 'destroy', { keepEvents: keepEvents });
  18113. // Remove the events
  18114. if (!keepEvents) {
  18115. removeEvent(axis);
  18116. }
  18117. // Destroy collections
  18118. [axis.ticks, axis.minorTicks, axis.alternateBands].forEach(function (coll) {
  18119. destroyObjectProperties(coll);
  18120. });
  18121. if (plotLinesAndBands) {
  18122. i = plotLinesAndBands.length;
  18123. while (i--) { // #1975
  18124. plotLinesAndBands[i].destroy();
  18125. }
  18126. }
  18127. // Destroy elements
  18128. ['axisLine', 'axisTitle', 'axisGroup',
  18129. 'gridGroup', 'labelGroup', 'cross', 'scrollbar'].forEach(function (prop) {
  18130. if (axis[prop]) {
  18131. axis[prop] = axis[prop].destroy();
  18132. }
  18133. });
  18134. // Destroy each generated group for plotlines and plotbands
  18135. for (plotGroup in axis.plotLinesAndBandsGroups) { // eslint-disable-line guard-for-in
  18136. axis.plotLinesAndBandsGroups[plotGroup] =
  18137. axis.plotLinesAndBandsGroups[plotGroup].destroy();
  18138. }
  18139. // Delete all properties and fall back to the prototype.
  18140. objectEach(axis, function (val, key) {
  18141. if (axis.getKeepProps().indexOf(key) === -1) {
  18142. delete axis[key];
  18143. }
  18144. });
  18145. };
  18146. /**
  18147. * Internal function to draw a crosshair.
  18148. *
  18149. * @function Highcharts.Axis#drawCrosshair
  18150. *
  18151. * @param {Highcharts.PointerEventObject} [e]
  18152. * The event arguments from the modified pointer event, extended with
  18153. * `chartX` and `chartY`
  18154. *
  18155. * @param {Highcharts.Point} [point]
  18156. * The Point object if the crosshair snaps to points.
  18157. *
  18158. * @fires Highcharts.Axis#event:afterDrawCrosshair
  18159. * @fires Highcharts.Axis#event:drawCrosshair
  18160. */
  18161. Axis.prototype.drawCrosshair = function (e, point) {
  18162. var path,
  18163. options = this.crosshair,
  18164. snap = pick(options && options.snap,
  18165. true),
  18166. pos,
  18167. categorized,
  18168. graphic = this.cross,
  18169. crossOptions,
  18170. chart = this.chart;
  18171. fireEvent(this, 'drawCrosshair', { e: e, point: point });
  18172. // Use last available event when updating non-snapped crosshairs without
  18173. // mouse interaction (#5287)
  18174. if (!e) {
  18175. e = this.cross && this.cross.e;
  18176. }
  18177. if (
  18178. // Disabled in options
  18179. !options ||
  18180. // Snap
  18181. ((defined(point) || !snap) === false)) {
  18182. this.hideCrosshair();
  18183. }
  18184. else {
  18185. // Get the path
  18186. if (!snap) {
  18187. pos = e &&
  18188. (this.horiz ?
  18189. e.chartX - this.pos :
  18190. this.len - e.chartY + this.pos);
  18191. }
  18192. else if (defined(point)) {
  18193. // #3834
  18194. pos = pick(this.coll !== 'colorAxis' ?
  18195. point.crosshairPos : // 3D axis extension
  18196. null, this.isXAxis ?
  18197. point.plotX :
  18198. this.len - point.plotY);
  18199. }
  18200. if (defined(pos)) {
  18201. crossOptions = {
  18202. // value, only used on radial
  18203. value: point && (this.isXAxis ?
  18204. point.x :
  18205. pick(point.stackY, point.y)),
  18206. translatedValue: pos
  18207. };
  18208. if (chart.polar) {
  18209. // Additional information required for crosshairs in
  18210. // polar chart
  18211. extend(crossOptions, {
  18212. isCrosshair: true,
  18213. chartX: e && e.chartX,
  18214. chartY: e && e.chartY,
  18215. point: point
  18216. });
  18217. }
  18218. path = this.getPlotLinePath(crossOptions) ||
  18219. null; // #3189
  18220. }
  18221. if (!defined(path)) {
  18222. this.hideCrosshair();
  18223. return;
  18224. }
  18225. categorized = this.categories && !this.isRadial;
  18226. // Draw the cross
  18227. if (!graphic) {
  18228. this.cross = graphic = chart.renderer
  18229. .path()
  18230. .addClass('highcharts-crosshair highcharts-crosshair-' +
  18231. (categorized ? 'category ' : 'thin ') +
  18232. (options.className || ''))
  18233. .attr({
  18234. zIndex: pick(options.zIndex, 2)
  18235. })
  18236. .add();
  18237. // Presentational attributes
  18238. if (!chart.styledMode) {
  18239. graphic.attr({
  18240. stroke: options.color ||
  18241. (categorized ?
  18242. Color
  18243. .parse(palette.highlightColor20)
  18244. .setOpacity(0.25)
  18245. .get() :
  18246. palette.neutralColor20),
  18247. 'stroke-width': pick(options.width, 1)
  18248. }).css({
  18249. 'pointer-events': 'none'
  18250. });
  18251. if (options.dashStyle) {
  18252. graphic.attr({
  18253. dashstyle: options.dashStyle
  18254. });
  18255. }
  18256. }
  18257. }
  18258. graphic.show().attr({
  18259. d: path
  18260. });
  18261. if (categorized && !options.width) {
  18262. graphic.attr({
  18263. 'stroke-width': this.transA
  18264. });
  18265. }
  18266. this.cross.e = e;
  18267. }
  18268. fireEvent(this, 'afterDrawCrosshair', { e: e, point: point });
  18269. };
  18270. /**
  18271. * Hide the crosshair if visible.
  18272. *
  18273. * @function Highcharts.Axis#hideCrosshair
  18274. */
  18275. Axis.prototype.hideCrosshair = function () {
  18276. if (this.cross) {
  18277. this.cross.hide();
  18278. }
  18279. fireEvent(this, 'afterHideCrosshair');
  18280. };
  18281. /**
  18282. * Check whether the chart has vertical panning ('y' or 'xy' type).
  18283. *
  18284. * @private
  18285. * @function Highcharts.Axis#hasVerticalPanning
  18286. * @return {boolean}
  18287. *
  18288. */
  18289. Axis.prototype.hasVerticalPanning = function () {
  18290. var panningOptions = this.chart.options.chart.panning;
  18291. return Boolean(panningOptions &&
  18292. panningOptions.enabled && // #14624
  18293. /y/.test(panningOptions.type));
  18294. };
  18295. /**
  18296. * Check whether the given value is a positive valid axis value.
  18297. *
  18298. * @private
  18299. * @function Highcharts.Axis#validatePositiveValue
  18300. *
  18301. * @param {unknown} value
  18302. * The axis value
  18303. *
  18304. * @return {boolean}
  18305. */
  18306. Axis.prototype.validatePositiveValue = function (value) {
  18307. return isNumber(value) && value > 0;
  18308. };
  18309. /**
  18310. * Update an axis object with a new set of options. The options are merged
  18311. * with the existing options, so only new or altered options need to be
  18312. * specified.
  18313. *
  18314. * @sample highcharts/members/axis-update/
  18315. * Axis update demo
  18316. *
  18317. * @function Highcharts.Axis#update
  18318. *
  18319. * @param {Highcharts.AxisOptions} options
  18320. * The new options that will be merged in with existing options on
  18321. * the axis.
  18322. *
  18323. * @param {boolean} [redraw=true]
  18324. * Whether to redraw the chart after the axis is altered. If doing
  18325. * more operations on the chart, it is a good idea to set redraw to
  18326. * false and call {@link Chart#redraw} after.
  18327. */
  18328. Axis.prototype.update = function (options, redraw) {
  18329. var chart = this.chart,
  18330. newEvents = ((options && options.events) || {});
  18331. options = merge(this.userOptions, options);
  18332. // Remove old events, if no new exist (#8161)
  18333. objectEach(chart.options[this.coll].events, function (fn, ev) {
  18334. if (typeof newEvents[ev] === 'undefined') {
  18335. newEvents[ev] = void 0;
  18336. }
  18337. });
  18338. this.destroy(true);
  18339. this.init(chart, extend(options, { events: newEvents }));
  18340. chart.isDirtyBox = true;
  18341. if (pick(redraw, true)) {
  18342. chart.redraw();
  18343. }
  18344. };
  18345. /**
  18346. * Remove the axis from the chart.
  18347. *
  18348. * @sample highcharts/members/chart-addaxis/
  18349. * Add and remove axes
  18350. *
  18351. * @function Highcharts.Axis#remove
  18352. *
  18353. * @param {boolean} [redraw=true]
  18354. * Whether to redraw the chart following the remove.
  18355. */
  18356. Axis.prototype.remove = function (redraw) {
  18357. var chart = this.chart,
  18358. key = this.coll, // xAxis or yAxis
  18359. axisSeries = this.series,
  18360. i = axisSeries.length;
  18361. // Remove associated series (#2687)
  18362. while (i--) {
  18363. if (axisSeries[i]) {
  18364. axisSeries[i].remove(false);
  18365. }
  18366. }
  18367. // Remove the axis
  18368. erase(chart.axes, this);
  18369. erase(chart[key], this);
  18370. chart[key].forEach(function (axis, i) {
  18371. // Re-index, #1706, #8075
  18372. axis.options.index = axis.userOptions.index = i;
  18373. });
  18374. this.destroy();
  18375. chart.isDirtyBox = true;
  18376. if (pick(redraw, true)) {
  18377. chart.redraw();
  18378. }
  18379. };
  18380. /**
  18381. * Update the axis title by options after render time.
  18382. *
  18383. * @sample highcharts/members/axis-settitle/
  18384. * Set a new Y axis title
  18385. *
  18386. * @function Highcharts.Axis#setTitle
  18387. *
  18388. * @param {Highcharts.AxisTitleOptions} titleOptions
  18389. * The additional title options.
  18390. *
  18391. * @param {boolean} [redraw=true]
  18392. * Whether to redraw the chart after setting the title.
  18393. *
  18394. * @return {void}
  18395. */
  18396. Axis.prototype.setTitle = function (titleOptions, redraw) {
  18397. this.update({ title: titleOptions }, redraw);
  18398. };
  18399. /**
  18400. * Set new axis categories and optionally redraw.
  18401. *
  18402. * @sample highcharts/members/axis-setcategories/
  18403. * Set categories by click on a button
  18404. *
  18405. * @function Highcharts.Axis#setCategories
  18406. *
  18407. * @param {Array<string>} categories
  18408. * The new categories.
  18409. *
  18410. * @param {boolean} [redraw=true]
  18411. * Whether to redraw the chart.
  18412. */
  18413. Axis.prototype.setCategories = function (categories, redraw) {
  18414. this.update({ categories: categories }, redraw);
  18415. };
  18416. /* *
  18417. *
  18418. * Static Properties
  18419. *
  18420. * */
  18421. /**
  18422. * The X axis or category axis. Normally this is the horizontal axis,
  18423. * though if the chart is inverted this is the vertical axis. In case of
  18424. * multiple axes, the xAxis node is an array of configuration objects.
  18425. *
  18426. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  18427. * access to the axis.
  18428. *
  18429. * @productdesc {highmaps}
  18430. * In Highmaps, the axis is hidden, but it is used behind the scenes to
  18431. * control features like zooming and panning. Zooming is in effect the same
  18432. * as setting the extremes of one of the exes.
  18433. *
  18434. * @type {*|Array<*>}
  18435. * @optionparent xAxis
  18436. *
  18437. * @private
  18438. */
  18439. Axis.defaultOptions = {
  18440. /**
  18441. * When using multiple axis, the ticks of two or more opposite axes
  18442. * will automatically be aligned by adding ticks to the axis or axes
  18443. * with the least ticks, as if `tickAmount` were specified.
  18444. *
  18445. * This can be prevented by setting `alignTicks` to false. If the grid
  18446. * lines look messy, it's a good idea to hide them for the secondary
  18447. * axis by setting `gridLineWidth` to 0.
  18448. *
  18449. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  18450. * then the `alignTicks ` will be disabled for the Axis.
  18451. *
  18452. * Disabled for logarithmic axes.
  18453. *
  18454. * @product highcharts highstock gantt
  18455. */
  18456. alignTicks: true,
  18457. /**
  18458. * Whether to allow decimals in this axis' ticks. When counting
  18459. * integers, like persons or hits on a web page, decimals should
  18460. * be avoided in the labels. By default, decimals are allowed on small
  18461. * scale axes.
  18462. *
  18463. * @see [minTickInterval](#xAxis.minTickInterval)
  18464. *
  18465. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-true/
  18466. * True by default
  18467. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-false/
  18468. * False
  18469. *
  18470. * @type {boolean|undefined}
  18471. * @default undefined
  18472. * @since 2.0
  18473. */
  18474. allowDecimals: void 0,
  18475. /**
  18476. * When using an alternate grid color, a band is painted across the
  18477. * plot area between every other grid line.
  18478. *
  18479. * @sample {highcharts} highcharts/yaxis/alternategridcolor/
  18480. * Alternate grid color on the Y axis
  18481. * @sample {highstock} stock/xaxis/alternategridcolor/
  18482. * Alternate grid color on the Y axis
  18483. *
  18484. * @type {Highcharts.ColorType}
  18485. * @apioption xAxis.alternateGridColor
  18486. */
  18487. /**
  18488. * An array defining breaks in the axis, the sections defined will be
  18489. * left out and all the points shifted closer to each other.
  18490. *
  18491. * @productdesc {highcharts}
  18492. * Requires that the broken-axis.js module is loaded.
  18493. *
  18494. * @sample {highcharts} highcharts/axisbreak/break-simple/
  18495. * Simple break
  18496. * @sample {highcharts|highstock} highcharts/axisbreak/break-visualized/
  18497. * Advanced with callback
  18498. * @sample {highstock} stock/demo/intraday-breaks/
  18499. * Break on nights and weekends
  18500. *
  18501. * @type {Array<*>}
  18502. * @since 4.1.0
  18503. * @product highcharts highstock gantt
  18504. * @apioption xAxis.breaks
  18505. */
  18506. /**
  18507. * A number indicating how much space should be left between the start
  18508. * and the end of the break. The break size is given in axis units,
  18509. * so for instance on a `datetime` axis, a break size of 3600000 would
  18510. * indicate the equivalent of an hour.
  18511. *
  18512. * @type {number}
  18513. * @default 0
  18514. * @since 4.1.0
  18515. * @product highcharts highstock gantt
  18516. * @apioption xAxis.breaks.breakSize
  18517. */
  18518. /**
  18519. * The point where the break starts.
  18520. *
  18521. * @type {number}
  18522. * @since 4.1.0
  18523. * @product highcharts highstock gantt
  18524. * @apioption xAxis.breaks.from
  18525. */
  18526. /**
  18527. * Defines an interval after which the break appears again. By default
  18528. * the breaks do not repeat.
  18529. *
  18530. * @type {number}
  18531. * @default 0
  18532. * @since 4.1.0
  18533. * @product highcharts highstock gantt
  18534. * @apioption xAxis.breaks.repeat
  18535. */
  18536. /**
  18537. * The point where the break ends.
  18538. *
  18539. * @type {number}
  18540. * @since 4.1.0
  18541. * @product highcharts highstock gantt
  18542. * @apioption xAxis.breaks.to
  18543. */
  18544. /**
  18545. * If categories are present for the xAxis, names are used instead of
  18546. * numbers for that axis.
  18547. *
  18548. * Since Highcharts 3.0, categories can also
  18549. * be extracted by giving each point a [name](#series.data) and setting
  18550. * axis [type](#xAxis.type) to `category`. However, if you have multiple
  18551. * series, best practice remains defining the `categories` array.
  18552. *
  18553. * Example: `categories: ['Apples', 'Bananas', 'Oranges']`
  18554. *
  18555. * @sample {highcharts} highcharts/demo/line-labels/
  18556. * With
  18557. * @sample {highcharts} highcharts/xaxis/categories/
  18558. * Without
  18559. *
  18560. * @type {Array<string>}
  18561. * @product highcharts gantt
  18562. * @apioption xAxis.categories
  18563. */
  18564. /**
  18565. * The highest allowed value for automatically computed axis extremes.
  18566. *
  18567. * @see [floor](#xAxis.floor)
  18568. *
  18569. * @sample {highcharts|highstock} highcharts/yaxis/floor-ceiling/
  18570. * Floor and ceiling
  18571. *
  18572. * @type {number}
  18573. * @since 4.0
  18574. * @product highcharts highstock gantt
  18575. * @apioption xAxis.ceiling
  18576. */
  18577. /**
  18578. * A class name that opens for styling the axis by CSS, especially in
  18579. * Highcharts styled mode. The class name is applied to group elements
  18580. * for the grid, axis elements and labels.
  18581. *
  18582. * @sample {highcharts|highstock|highmaps} highcharts/css/axis/
  18583. * Multiple axes with separate styling
  18584. *
  18585. * @type {string}
  18586. * @since 5.0.0
  18587. * @apioption xAxis.className
  18588. */
  18589. /**
  18590. * Configure a crosshair that follows either the mouse pointer or the
  18591. * hovered point.
  18592. *
  18593. * In styled mode, the crosshairs are styled in the
  18594. * `.highcharts-crosshair`, `.highcharts-crosshair-thin` or
  18595. * `.highcharts-xaxis-category` classes.
  18596. *
  18597. * @productdesc {highstock}
  18598. * In Highcharts stock, by default, the crosshair is enabled on the
  18599. * X axis and disabled on the Y axis.
  18600. *
  18601. * @sample {highcharts} highcharts/xaxis/crosshair-both/
  18602. * Crosshair on both axes
  18603. * @sample {highstock} stock/xaxis/crosshairs-xy/
  18604. * Crosshair on both axes
  18605. * @sample {highmaps} highcharts/xaxis/crosshair-both/
  18606. * Crosshair on both axes
  18607. *
  18608. * @declare Highcharts.AxisCrosshairOptions
  18609. * @type {boolean|*}
  18610. * @default false
  18611. * @since 4.1
  18612. * @apioption xAxis.crosshair
  18613. */
  18614. /**
  18615. * A class name for the crosshair, especially as a hook for styling.
  18616. *
  18617. * @type {string}
  18618. * @since 5.0.0
  18619. * @apioption xAxis.crosshair.className
  18620. */
  18621. /**
  18622. * The color of the crosshair. Defaults to `#cccccc` for numeric and
  18623. * datetime axes, and `rgba(204,214,235,0.25)` for category axes, where
  18624. * the crosshair by default highlights the whole category.
  18625. *
  18626. * @sample {highcharts|highstock|highmaps} highcharts/xaxis/crosshair-customized/
  18627. * Customized crosshairs
  18628. *
  18629. * @type {Highcharts.ColorType}
  18630. * @default #cccccc
  18631. * @since 4.1
  18632. * @apioption xAxis.crosshair.color
  18633. */
  18634. /**
  18635. * The dash style for the crosshair. See
  18636. * [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  18637. * for possible values.
  18638. *
  18639. * @sample {highcharts|highmaps} highcharts/xaxis/crosshair-dotted/
  18640. * Dotted crosshair
  18641. * @sample {highstock} stock/xaxis/crosshair-dashed/
  18642. * Dashed X axis crosshair
  18643. *
  18644. * @type {Highcharts.DashStyleValue}
  18645. * @default Solid
  18646. * @since 4.1
  18647. * @apioption xAxis.crosshair.dashStyle
  18648. */
  18649. /**
  18650. * A label on the axis next to the crosshair.
  18651. *
  18652. * In styled mode, the label is styled with the
  18653. * `.highcharts-crosshair-label` class.
  18654. *
  18655. * @sample {highstock} stock/xaxis/crosshair-label/
  18656. * Crosshair labels
  18657. * @sample {highstock} highcharts/css/crosshair-label/
  18658. * Style mode
  18659. *
  18660. * @declare Highcharts.AxisCrosshairLabelOptions
  18661. * @since 2.1
  18662. * @product highstock
  18663. * @apioption xAxis.crosshair.label
  18664. */
  18665. /**
  18666. * Alignment of the label compared to the axis. Defaults to `"left"` for
  18667. * right-side axes, `"right"` for left-side axes and `"center"` for
  18668. * horizontal axes.
  18669. *
  18670. * @type {Highcharts.AlignValue}
  18671. * @since 2.1
  18672. * @product highstock
  18673. * @apioption xAxis.crosshair.label.align
  18674. */
  18675. /**
  18676. * The background color for the label. Defaults to the related series
  18677. * color, or `#666666` if that is not available.
  18678. *
  18679. * @type {Highcharts.ColorType}
  18680. * @since 2.1
  18681. * @product highstock
  18682. * @apioption xAxis.crosshair.label.backgroundColor
  18683. */
  18684. /**
  18685. * The border color for the crosshair label
  18686. *
  18687. * @type {Highcharts.ColorType}
  18688. * @since 2.1
  18689. * @product highstock
  18690. * @apioption xAxis.crosshair.label.borderColor
  18691. */
  18692. /**
  18693. * The border corner radius of the crosshair label.
  18694. *
  18695. * @type {number}
  18696. * @default 3
  18697. * @since 2.1.10
  18698. * @product highstock
  18699. * @apioption xAxis.crosshair.label.borderRadius
  18700. */
  18701. /**
  18702. * The border width for the crosshair label.
  18703. *
  18704. * @type {number}
  18705. * @default 0
  18706. * @since 2.1
  18707. * @product highstock
  18708. * @apioption xAxis.crosshair.label.borderWidth
  18709. */
  18710. /**
  18711. * Flag to enable crosshair's label.
  18712. *
  18713. * @sample {highstock} stock/xaxis/crosshairs-xy/
  18714. * Enabled label for yAxis' crosshair
  18715. *
  18716. * @type {boolean}
  18717. * @default false
  18718. * @since 2.1
  18719. * @product highstock
  18720. * @apioption xAxis.crosshair.label.enabled
  18721. */
  18722. /**
  18723. * A format string for the crosshair label. Defaults to `{value}` for
  18724. * numeric axes and `{value:%b %d, %Y}` for datetime axes.
  18725. *
  18726. * @type {string}
  18727. * @since 2.1
  18728. * @product highstock
  18729. * @apioption xAxis.crosshair.label.format
  18730. */
  18731. /**
  18732. * Formatter function for the label text.
  18733. *
  18734. * @type {Highcharts.XAxisCrosshairLabelFormatterCallbackFunction}
  18735. * @since 2.1
  18736. * @product highstock
  18737. * @apioption xAxis.crosshair.label.formatter
  18738. */
  18739. /**
  18740. * Padding inside the crosshair label.
  18741. *
  18742. * @type {number}
  18743. * @default 8
  18744. * @since 2.1
  18745. * @product highstock
  18746. * @apioption xAxis.crosshair.label.padding
  18747. */
  18748. /**
  18749. * The shape to use for the label box.
  18750. *
  18751. * @type {string}
  18752. * @default callout
  18753. * @since 2.1
  18754. * @product highstock
  18755. * @apioption xAxis.crosshair.label.shape
  18756. */
  18757. /**
  18758. * Text styles for the crosshair label.
  18759. *
  18760. * @type {Highcharts.CSSObject}
  18761. * @default {"color": "white", "fontWeight": "normal", "fontSize": "11px", "textAlign": "center"}
  18762. * @since 2.1
  18763. * @product highstock
  18764. * @apioption xAxis.crosshair.label.style
  18765. */
  18766. /**
  18767. * Whether the crosshair should snap to the point or follow the pointer
  18768. * independent of points.
  18769. *
  18770. * @sample {highcharts|highstock} highcharts/xaxis/crosshair-snap-false/
  18771. * True by default
  18772. * @sample {highmaps} maps/demo/latlon-advanced/
  18773. * Snap is false
  18774. *
  18775. * @type {boolean}
  18776. * @default true
  18777. * @since 4.1
  18778. * @apioption xAxis.crosshair.snap
  18779. */
  18780. /**
  18781. * The pixel width of the crosshair. Defaults to 1 for numeric or
  18782. * datetime axes, and for one category width for category axes.
  18783. *
  18784. * @sample {highcharts} highcharts/xaxis/crosshair-customized/
  18785. * Customized crosshairs
  18786. * @sample {highstock} highcharts/xaxis/crosshair-customized/
  18787. * Customized crosshairs
  18788. * @sample {highmaps} highcharts/xaxis/crosshair-customized/
  18789. * Customized crosshairs
  18790. *
  18791. * @type {number}
  18792. * @default 1
  18793. * @since 4.1
  18794. * @apioption xAxis.crosshair.width
  18795. */
  18796. /**
  18797. * The Z index of the crosshair. Higher Z indices allow drawing the
  18798. * crosshair on top of the series or behind the grid lines.
  18799. *
  18800. * @type {number}
  18801. * @default 2
  18802. * @since 4.1
  18803. * @apioption xAxis.crosshair.zIndex
  18804. */
  18805. /**
  18806. * The Z index for the axis group.
  18807. */
  18808. zIndex: 2,
  18809. /**
  18810. * Whether to zoom axis. If `chart.zoomType` is set, the option allows
  18811. * to disable zooming on an individual axis.
  18812. *
  18813. * @sample {highcharts} highcharts/xaxis/zoomenabled/
  18814. * Zoom enabled is false
  18815. */
  18816. zoomEnabled: true,
  18817. /**
  18818. * For a datetime axis, the scale will automatically adjust to the
  18819. * appropriate unit. This member gives the default string
  18820. * representations used for each unit. For intermediate values,
  18821. * different units may be used, for example the `day` unit can be used
  18822. * on midnight and `hour` unit be used for intermediate values on the
  18823. * same axis.
  18824. *
  18825. * For an overview of the replacement codes, see
  18826. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  18827. *
  18828. * Defaults to:
  18829. * ```js
  18830. * {
  18831. * millisecond: '%H:%M:%S.%L',
  18832. * second: '%H:%M:%S',
  18833. * minute: '%H:%M',
  18834. * hour: '%H:%M',
  18835. * day: '%e. %b',
  18836. * week: '%e. %b',
  18837. * month: '%b \'%y',
  18838. * year: '%Y'
  18839. * }
  18840. * ```
  18841. *
  18842. * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
  18843. * Different day format on X axis
  18844. * @sample {highstock} stock/xaxis/datetimelabelformats/
  18845. * More information in x axis labels
  18846. *
  18847. * @declare Highcharts.AxisDateTimeLabelFormatsOptions
  18848. * @product highcharts highstock gantt
  18849. */
  18850. dateTimeLabelFormats: {
  18851. /**
  18852. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18853. * @type {string|*}
  18854. */
  18855. millisecond: {
  18856. main: '%H:%M:%S.%L',
  18857. range: false
  18858. },
  18859. /**
  18860. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18861. * @type {string|*}
  18862. */
  18863. second: {
  18864. main: '%H:%M:%S',
  18865. range: false
  18866. },
  18867. /**
  18868. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18869. * @type {string|*}
  18870. */
  18871. minute: {
  18872. main: '%H:%M',
  18873. range: false
  18874. },
  18875. /**
  18876. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18877. * @type {string|*}
  18878. */
  18879. hour: {
  18880. main: '%H:%M',
  18881. range: false
  18882. },
  18883. /**
  18884. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18885. * @type {string|*}
  18886. */
  18887. day: {
  18888. main: '%e. %b'
  18889. },
  18890. /**
  18891. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18892. * @type {string|*}
  18893. */
  18894. week: {
  18895. main: '%e. %b'
  18896. },
  18897. /**
  18898. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18899. * @type {string|*}
  18900. */
  18901. month: {
  18902. main: '%b \'%y'
  18903. },
  18904. /**
  18905. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18906. * @type {string|*}
  18907. */
  18908. year: {
  18909. main: '%Y'
  18910. }
  18911. },
  18912. /**
  18913. * Whether to force the axis to end on a tick. Use this option with
  18914. * the `maxPadding` option to control the axis end.
  18915. *
  18916. * @productdesc {highstock}
  18917. * In Highcharts Stock, `endOnTick` is always `false` when the navigator
  18918. * is enabled, to prevent jumpy scrolling.
  18919. *
  18920. * @sample {highcharts} highcharts/chart/reflow-true/
  18921. * True by default
  18922. * @sample {highcharts} highcharts/yaxis/endontick/
  18923. * False
  18924. * @sample {highstock} stock/demo/basic-line/
  18925. * True by default
  18926. * @sample {highstock} stock/xaxis/endontick/
  18927. * False
  18928. *
  18929. * @since 1.2.0
  18930. */
  18931. endOnTick: false,
  18932. /**
  18933. * Event handlers for the axis.
  18934. *
  18935. * @type {*}
  18936. * @apioption xAxis.events
  18937. */
  18938. /**
  18939. * An event fired after the breaks have rendered.
  18940. *
  18941. * @see [breaks](#xAxis.breaks)
  18942. *
  18943. * @sample {highcharts} highcharts/axisbreak/break-event/
  18944. * AfterBreak Event
  18945. *
  18946. * @type {Highcharts.AxisEventCallbackFunction}
  18947. * @since 4.1.0
  18948. * @product highcharts gantt
  18949. * @apioption xAxis.events.afterBreaks
  18950. */
  18951. /**
  18952. * As opposed to the `setExtremes` event, this event fires after the
  18953. * final min and max values are computed and corrected for `minRange`.
  18954. *
  18955. * Fires when the minimum and maximum is set for the axis, either by
  18956. * calling the `.setExtremes()` method or by selecting an area in the
  18957. * chart. One parameter, `event`, is passed to the function, containing
  18958. * common event information.
  18959. *
  18960. * The new user set minimum and maximum values can be found by
  18961. * `event.min` and `event.max`. These reflect the axis minimum and
  18962. * maximum in axis values. The actual data extremes are found in
  18963. * `event.dataMin` and `event.dataMax`.
  18964. *
  18965. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  18966. * @since 2.3
  18967. * @context Highcharts.Axis
  18968. * @apioption xAxis.events.afterSetExtremes
  18969. */
  18970. /**
  18971. * An event fired when a break from this axis occurs on a point.
  18972. *
  18973. * @see [breaks](#xAxis.breaks)
  18974. *
  18975. * @sample {highcharts} highcharts/axisbreak/break-visualized/
  18976. * Visualization of a Break
  18977. *
  18978. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18979. * @since 4.1.0
  18980. * @product highcharts gantt
  18981. * @context Highcharts.Axis
  18982. * @apioption xAxis.events.pointBreak
  18983. */
  18984. /**
  18985. * An event fired when a point falls inside a break from this axis.
  18986. *
  18987. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18988. * @product highcharts highstock gantt
  18989. * @context Highcharts.Axis
  18990. * @apioption xAxis.events.pointInBreak
  18991. */
  18992. /**
  18993. * Fires when the minimum and maximum is set for the axis, either by
  18994. * calling the `.setExtremes()` method or by selecting an area in the
  18995. * chart. One parameter, `event`, is passed to the function,
  18996. * containing common event information.
  18997. *
  18998. * The new user set minimum and maximum values can be found by
  18999. * `event.min` and `event.max`. These reflect the axis minimum and
  19000. * maximum in data values. When an axis is zoomed all the way out from
  19001. * the "Reset zoom" button, `event.min` and `event.max` are null, and
  19002. * the new extremes are set based on `this.dataMin` and `this.dataMax`.
  19003. *
  19004. * @sample {highstock} stock/xaxis/events-setextremes/
  19005. * Log new extremes on x axis
  19006. *
  19007. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  19008. * @since 1.2.0
  19009. * @context Highcharts.Axis
  19010. * @apioption xAxis.events.setExtremes
  19011. */
  19012. /**
  19013. * The lowest allowed value for automatically computed axis extremes.
  19014. *
  19015. * @see [ceiling](#yAxis.ceiling)
  19016. *
  19017. * @sample {highcharts} highcharts/yaxis/floor-ceiling/
  19018. * Floor and ceiling
  19019. * @sample {highstock} stock/demo/lazy-loading/
  19020. * Prevent negative stock price on Y axis
  19021. *
  19022. * @type {number}
  19023. * @since 4.0
  19024. * @product highcharts highstock gantt
  19025. * @apioption xAxis.floor
  19026. */
  19027. /**
  19028. * The dash or dot style of the grid lines. For possible values, see
  19029. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  19030. *
  19031. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  19032. * Long dashes
  19033. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  19034. * Long dashes
  19035. *
  19036. * @type {Highcharts.DashStyleValue}
  19037. * @since 1.2
  19038. */
  19039. gridLineDashStyle: 'Solid',
  19040. /**
  19041. * The Z index of the grid lines.
  19042. *
  19043. * @sample {highcharts|highstock} highcharts/xaxis/gridzindex/
  19044. * A Z index of 4 renders the grid above the graph
  19045. *
  19046. * @product highcharts highstock gantt
  19047. */
  19048. gridZIndex: 1,
  19049. /**
  19050. * An id for the axis. This can be used after render time to get
  19051. * a pointer to the axis object through `chart.get()`.
  19052. *
  19053. * @sample {highcharts} highcharts/xaxis/id/
  19054. * Get the object
  19055. * @sample {highstock} stock/xaxis/id/
  19056. * Get the object
  19057. *
  19058. * @type {string}
  19059. * @since 1.2.0
  19060. * @apioption xAxis.id
  19061. */
  19062. /**
  19063. * The axis labels show the number or category for each tick.
  19064. *
  19065. * Since v8.0.0: Labels are animated in categorized x-axis with
  19066. * updating data if `tickInterval` and `step` is set to 1.
  19067. *
  19068. * @productdesc {highmaps}
  19069. * X and Y axis labels are by default disabled in Highmaps, but the
  19070. * functionality is inherited from Highcharts and used on `colorAxis`,
  19071. * and can be enabled on X and Y axes too.
  19072. */
  19073. labels: {
  19074. /**
  19075. * What part of the string the given position is anchored to.
  19076. * If `left`, the left side of the string is at the axis position.
  19077. * Can be one of `"left"`, `"center"` or `"right"`. Defaults to
  19078. * an intelligent guess based on which side of the chart the axis
  19079. * is on and the rotation of the label.
  19080. *
  19081. * @see [reserveSpace](#xAxis.labels.reserveSpace)
  19082. *
  19083. * @sample {highcharts} highcharts/xaxis/labels-align-left/
  19084. * Left
  19085. * @sample {highcharts} highcharts/xaxis/labels-align-right/
  19086. * Right
  19087. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  19088. * Left-aligned labels on a vertical category axis
  19089. *
  19090. * @type {Highcharts.AlignValue}
  19091. * @apioption xAxis.labels.align
  19092. */
  19093. /**
  19094. * Whether to allow the axis labels to overlap.
  19095. * When false, overlapping labels are hidden.
  19096. *
  19097. * @sample {highcharts} highcharts/xaxis/labels-allowoverlap-true/
  19098. * X axis labels overlap enabled
  19099. *
  19100. * @type {boolean}
  19101. * @default false
  19102. * @apioption xAxis.labels.allowOverlap
  19103. *
  19104. */
  19105. /**
  19106. * For horizontal axes, the allowed degrees of label rotation
  19107. * to prevent overlapping labels. If there is enough space,
  19108. * labels are not rotated. As the chart gets narrower, it
  19109. * will start rotating the labels -45 degrees, then remove
  19110. * every second label and try again with rotations 0 and -45 etc.
  19111. * Set it to `undefined` to disable rotation, which will
  19112. * cause the labels to word-wrap if possible. Defaults to `[-45]``
  19113. * on bottom and top axes, `undefined` on left and right axes.
  19114. *
  19115. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-default/
  19116. * Default auto rotation of 0 or -45
  19117. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-0-90/
  19118. * Custom graded auto rotation
  19119. *
  19120. * @type {Array<number>}
  19121. * @default undefined
  19122. * @since 4.1.0
  19123. * @product highcharts highstock gantt
  19124. * @apioption xAxis.labels.autoRotation
  19125. */
  19126. autoRotation: void 0,
  19127. /**
  19128. * When each category width is more than this many pixels, we don't
  19129. * apply auto rotation. Instead, we lay out the axis label with word
  19130. * wrap. A lower limit makes sense when the label contains multiple
  19131. * short words that don't extend the available horizontal space for
  19132. * each label.
  19133. *
  19134. * @sample {highcharts} highcharts/xaxis/labels-autorotationlimit/
  19135. * Lower limit
  19136. *
  19137. * @since 4.1.5
  19138. * @product highcharts gantt
  19139. */
  19140. autoRotationLimit: 80,
  19141. /**
  19142. * Polar charts only. The label's pixel distance from the perimeter
  19143. * of the plot area.
  19144. *
  19145. * @type {number}
  19146. * @default undefined
  19147. * @product highcharts gantt
  19148. */
  19149. distance: void 0,
  19150. /**
  19151. * Enable or disable the axis labels.
  19152. *
  19153. * @sample {highcharts} highcharts/xaxis/labels-enabled/
  19154. * X axis labels disabled
  19155. * @sample {highstock} stock/xaxis/labels-enabled/
  19156. * X axis labels disabled
  19157. *
  19158. * @default {highcharts|highstock|gantt} true
  19159. * @default {highmaps} false
  19160. */
  19161. enabled: true,
  19162. /**
  19163. * A format string for the axis label. The context is available as
  19164. * format string variables. For example, you can use `{text}` to
  19165. * insert the default formatted text. The recommended way of adding
  19166. * units for the label is using `text`, for example `{text} km`.
  19167. *
  19168. * To add custom numeric or datetime formatting, use `{value}` with
  19169. * formatting, for example `{value:.1f}` or `{value:%Y-%m-%d}`.
  19170. *
  19171. * See
  19172. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  19173. * for more examples of formatting.
  19174. *
  19175. * The default value is not specified due to the dynamic
  19176. * nature of the default implementation.
  19177. *
  19178. * @sample {highcharts|highstock} highcharts/yaxis/labels-format/
  19179. * Add units to Y axis label
  19180. * @sample {highcharts} highcharts/xaxis/labels-format-linked/
  19181. * Linked category names
  19182. * @sample {highcharts} highcharts/xaxis/labels-format-custom/
  19183. * Custom number format
  19184. *
  19185. * @type {string}
  19186. * @since 3.0
  19187. * @apioption xAxis.labels.format
  19188. */
  19189. /**
  19190. * Callback JavaScript function to format the label. The value
  19191. * is given by `this.value`. Additional properties for `this` are
  19192. * `axis`, `chart`, `isFirst`, `isLast` and `text` which holds the
  19193. * value of the default formatter.
  19194. *
  19195. * Defaults to a built in function returning a formatted string
  19196. * depending on whether the axis is `category`, `datetime`,
  19197. * `numeric` or other.
  19198. *
  19199. * @sample {highcharts} highcharts/xaxis/labels-formatter-linked/
  19200. * Linked category names
  19201. * @sample {highcharts} highcharts/xaxis/labels-formatter-extended/
  19202. * Modified numeric labels
  19203. * @sample {highstock} stock/xaxis/labels-formatter/
  19204. * Added units on Y axis
  19205. *
  19206. * @type {Highcharts.AxisLabelsFormatterCallbackFunction}
  19207. * @apioption xAxis.labels.formatter
  19208. */
  19209. /**
  19210. * The number of pixels to indent the labels per level in a treegrid
  19211. * axis.
  19212. *
  19213. * @sample gantt/treegrid-axis/demo
  19214. * Indentation 10px by default.
  19215. * @sample gantt/treegrid-axis/indentation-0px
  19216. * Indentation set to 0px.
  19217. *
  19218. * @product gantt
  19219. */
  19220. indentation: 10,
  19221. /**
  19222. * Horizontal axis only. When `staggerLines` is not set,
  19223. * `maxStaggerLines` defines how many lines the axis is allowed to
  19224. * add to automatically avoid overlapping X labels. Set to `1` to
  19225. * disable overlap detection.
  19226. *
  19227. * @deprecated
  19228. * @type {number}
  19229. * @default 5
  19230. * @since 1.3.3
  19231. * @apioption xAxis.labels.maxStaggerLines
  19232. */
  19233. /**
  19234. * How to handle overflowing labels on horizontal axis. If set to
  19235. * `"allow"`, it will not be aligned at all. By default it
  19236. * `"justify"` labels inside the chart area. If there is room to
  19237. * move it, it will be aligned to the edge, else it will be removed.
  19238. *
  19239. * @since 2.2.5
  19240. * @validvalue ["allow", "justify"]
  19241. */
  19242. overflow: 'justify',
  19243. /**
  19244. * The pixel padding for axis labels, to ensure white space between
  19245. * them.
  19246. *
  19247. * @product highcharts gantt
  19248. */
  19249. padding: 5,
  19250. /**
  19251. * Whether to reserve space for the labels. By default, space is
  19252. * reserved for the labels in these cases:
  19253. *
  19254. * * On all horizontal axes.
  19255. * * On vertical axes if `label.align` is `right` on a left-side
  19256. * axis or `left` on a right-side axis.
  19257. * * On vertical axes if `label.align` is `center`.
  19258. *
  19259. * This can be turned off when for example the labels are rendered
  19260. * inside the plot area instead of outside.
  19261. *
  19262. * @see [labels.align](#xAxis.labels.align)
  19263. *
  19264. * @sample {highcharts} highcharts/xaxis/labels-reservespace/
  19265. * No reserved space, labels inside plot
  19266. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  19267. * Left-aligned labels on a vertical category axis
  19268. *
  19269. * @type {boolean}
  19270. * @since 4.1.10
  19271. * @product highcharts gantt
  19272. * @apioption xAxis.labels.reserveSpace
  19273. */
  19274. reserveSpace: void 0,
  19275. /**
  19276. * Rotation of the labels in degrees. When `undefined`, the
  19277. * `autoRotation` option takes precedence.
  19278. *
  19279. * @sample {highcharts} highcharts/xaxis/labels-rotation/
  19280. * X axis labels rotated 90°
  19281. *
  19282. * @type {number}
  19283. * @default 0
  19284. * @apioption xAxis.labels.rotation
  19285. */
  19286. rotation: void 0,
  19287. /**
  19288. * Horizontal axes only. The number of lines to spread the labels
  19289. * over to make room or tighter labels. 0 disables staggering.
  19290. *
  19291. * @sample {highcharts} highcharts/xaxis/labels-staggerlines/
  19292. * Show labels over two lines
  19293. * @sample {highstock} stock/xaxis/labels-staggerlines/
  19294. * Show labels over two lines
  19295. *
  19296. * @since 2.1
  19297. * @apioption xAxis.labels.staggerLines
  19298. */
  19299. staggerLines: 0,
  19300. /**
  19301. * To show only every _n_'th label on the axis, set the step to _n_.
  19302. * Setting the step to 2 shows every other label.
  19303. *
  19304. * By default, when 0, the step is calculated automatically to avoid
  19305. * overlap. To prevent this, set it to 1\. This usually only
  19306. * happens on a category axis, and is often a sign that you have
  19307. * chosen the wrong axis type.
  19308. *
  19309. * Read more at
  19310. * [Axis docs](https://www.highcharts.com/docs/chart-concepts/axes)
  19311. * => What axis should I use?
  19312. *
  19313. * @sample {highcharts} highcharts/xaxis/labels-step/
  19314. * Showing only every other axis label on a categorized
  19315. * x-axis
  19316. * @sample {highcharts} highcharts/xaxis/labels-step-auto/
  19317. * Auto steps on a category axis
  19318. *
  19319. * @since 2.1
  19320. */
  19321. step: 0,
  19322. /**
  19323. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  19324. * to render the labels.
  19325. */
  19326. useHTML: false,
  19327. /**
  19328. * The x position offset of all labels relative to the tick
  19329. * positions on the axis.
  19330. *
  19331. * @sample {highcharts} highcharts/xaxis/labels-x/
  19332. * Y axis labels placed on grid lines
  19333. */
  19334. x: 0,
  19335. /**
  19336. * The y position offset of all labels relative to the tick
  19337. * positions on the axis. The default makes it adapt to the font
  19338. * size of the bottom axis.
  19339. *
  19340. * @sample {highcharts} highcharts/xaxis/labels-x/
  19341. * Y axis labels placed on grid lines
  19342. *
  19343. * @type {number}
  19344. * @apioption xAxis.labels.y
  19345. */
  19346. /**
  19347. * The Z index for the axis labels.
  19348. */
  19349. zIndex: 7,
  19350. /**
  19351. * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
  19352. * wrapping of category labels. Use `textOverflow: 'none'` to
  19353. * prevent ellipsis (dots).
  19354. *
  19355. * In styled mode, the labels are styled with the
  19356. * `.highcharts-axis-labels` class.
  19357. *
  19358. * @sample {highcharts} highcharts/xaxis/labels-style/
  19359. * Red X axis labels
  19360. *
  19361. * @type {Highcharts.CSSObject}
  19362. */
  19363. style: {
  19364. /** @internal */
  19365. color: palette.neutralColor60,
  19366. /** @internal */
  19367. cursor: 'default',
  19368. /** @internal */
  19369. fontSize: '11px'
  19370. }
  19371. },
  19372. /**
  19373. * The left position as the horizontal axis. If it's a number, it is
  19374. * interpreted as pixel position relative to the chart.
  19375. *
  19376. * Since Highcharts v5.0.13: If it's a percentage string, it is
  19377. * interpreted as percentages of the plot width, offset from plot area
  19378. * left.
  19379. *
  19380. * @type {number|string}
  19381. * @product highcharts highstock
  19382. * @apioption xAxis.left
  19383. */
  19384. /**
  19385. * The top position as the vertical axis. If it's a number, it is
  19386. * interpreted as pixel position relative to the chart.
  19387. *
  19388. * Since Highcharts 2: If it's a percentage string, it is interpreted
  19389. * as percentages of the plot height, offset from plot area top.
  19390. *
  19391. * @type {number|string}
  19392. * @product highcharts highstock
  19393. * @apioption xAxis.top
  19394. */
  19395. /**
  19396. * Index of another axis that this axis is linked to. When an axis is
  19397. * linked to a master axis, it will take the same extremes as
  19398. * the master, but as assigned by min or max or by setExtremes.
  19399. * It can be used to show additional info, or to ease reading the
  19400. * chart by duplicating the scales.
  19401. *
  19402. * @sample {highcharts} highcharts/xaxis/linkedto/
  19403. * Different string formats of the same date
  19404. * @sample {highcharts} highcharts/yaxis/linkedto/
  19405. * Y values on both sides
  19406. *
  19407. * @type {number}
  19408. * @since 2.0.2
  19409. * @product highcharts highstock gantt
  19410. * @apioption xAxis.linkedTo
  19411. */
  19412. /**
  19413. * The maximum value of the axis. If `null`, the max value is
  19414. * automatically calculated.
  19415. *
  19416. * If the [endOnTick](#yAxis.endOnTick) option is true, the `max` value
  19417. * might be rounded up.
  19418. *
  19419. * If a [tickAmount](#yAxis.tickAmount) is set, the axis may be extended
  19420. * beyond the set max in order to reach the given number of ticks. The
  19421. * same may happen in a chart with multiple axes, determined by [chart.
  19422. * alignTicks](#chart), where a `tickAmount` is applied internally.
  19423. *
  19424. * @sample {highcharts} highcharts/yaxis/max-200/
  19425. * Y axis max of 200
  19426. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  19427. * Y axis max on logarithmic axis
  19428. * @sample {highstock} stock/xaxis/min-max/
  19429. * Fixed min and max on X axis
  19430. * @sample {highmaps} maps/axis/min-max/
  19431. * Pre-zoomed to a specific area
  19432. *
  19433. * @type {number|null}
  19434. * @apioption xAxis.max
  19435. */
  19436. /**
  19437. * Padding of the max value relative to the length of the axis. A
  19438. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19439. * when you don't want the highest data value to appear on the edge
  19440. * of the plot area. When the axis' `max` option is set or a max extreme
  19441. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  19442. *
  19443. * @sample {highcharts} highcharts/yaxis/maxpadding/
  19444. * Max padding of 0.25 on y axis
  19445. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19446. * Greater min- and maxPadding
  19447. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  19448. * Add some padding
  19449. *
  19450. * @default {highcharts} 0.01
  19451. * @default {highstock|highmaps} 0
  19452. * @since 1.2.0
  19453. */
  19454. maxPadding: 0.01,
  19455. /**
  19456. * Deprecated. Use `minRange` instead.
  19457. *
  19458. * @deprecated
  19459. * @type {number}
  19460. * @product highcharts highstock
  19461. * @apioption xAxis.maxZoom
  19462. */
  19463. /**
  19464. * The minimum value of the axis. If `null` the min value is
  19465. * automatically calculated.
  19466. *
  19467. * If the [startOnTick](#yAxis.startOnTick) option is true (default),
  19468. * the `min` value might be rounded down.
  19469. *
  19470. * The automatically calculated minimum value is also affected by
  19471. * [floor](#yAxis.floor), [softMin](#yAxis.softMin),
  19472. * [minPadding](#yAxis.minPadding), [minRange](#yAxis.minRange)
  19473. * as well as [series.threshold](#plotOptions.series.threshold)
  19474. * and [series.softThreshold](#plotOptions.series.softThreshold).
  19475. *
  19476. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  19477. * -50 with startOnTick to false
  19478. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  19479. * -50 with startOnTick true by default
  19480. * @sample {highstock} stock/xaxis/min-max/
  19481. * Set min and max on X axis
  19482. * @sample {highmaps} maps/axis/min-max/
  19483. * Pre-zoomed to a specific area
  19484. *
  19485. * @type {number|null}
  19486. * @apioption xAxis.min
  19487. */
  19488. /**
  19489. * The dash or dot style of the minor grid lines. For possible values,
  19490. * see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  19491. *
  19492. * @sample {highcharts} highcharts/yaxis/minorgridlinedashstyle/
  19493. * Long dashes on minor grid lines
  19494. * @sample {highstock} stock/xaxis/minorgridlinedashstyle/
  19495. * Long dashes on minor grid lines
  19496. *
  19497. * @type {Highcharts.DashStyleValue}
  19498. * @since 1.2
  19499. */
  19500. minorGridLineDashStyle: 'Solid',
  19501. /**
  19502. * Specific tick interval in axis units for the minor ticks. On a linear
  19503. * axis, if `"auto"`, the minor tick interval is calculated as a fifth
  19504. * of the tickInterval. If `null` or `undefined`, minor ticks are not
  19505. * shown.
  19506. *
  19507. * On logarithmic axes, the unit is the power of the value. For example,
  19508. * setting the minorTickInterval to 1 puts one tick on each of 0.1, 1,
  19509. * 10, 100 etc. Setting the minorTickInterval to 0.1 produces 9 ticks
  19510. * between 1 and 10, 10 and 100 etc.
  19511. *
  19512. * If user settings dictate minor ticks to become too dense, they don't
  19513. * make sense, and will be ignored to prevent performance problems.
  19514. *
  19515. * @sample {highcharts} highcharts/yaxis/minortickinterval-null/
  19516. * Null by default
  19517. * @sample {highcharts} highcharts/yaxis/minortickinterval-5/
  19518. * 5 units
  19519. * @sample {highcharts} highcharts/yaxis/minortickinterval-log-auto/
  19520. * "auto"
  19521. * @sample {highcharts} highcharts/yaxis/minortickinterval-log/
  19522. * 0.1
  19523. * @sample {highstock} stock/demo/basic-line/
  19524. * Null by default
  19525. * @sample {highstock} stock/xaxis/minortickinterval-auto/
  19526. * "auto"
  19527. *
  19528. * @type {number|string|null}
  19529. * @apioption xAxis.minorTickInterval
  19530. */
  19531. /**
  19532. * The pixel length of the minor tick marks.
  19533. *
  19534. * @sample {highcharts} highcharts/yaxis/minorticklength/
  19535. * 10px on Y axis
  19536. * @sample {highstock} stock/xaxis/minorticks/
  19537. * 10px on Y axis
  19538. */
  19539. minorTickLength: 2,
  19540. /**
  19541. * The position of the minor tick marks relative to the axis line.
  19542. * Can be one of `inside` and `outside`.
  19543. *
  19544. * @sample {highcharts} highcharts/yaxis/minortickposition-outside/
  19545. * Outside by default
  19546. * @sample {highcharts} highcharts/yaxis/minortickposition-inside/
  19547. * Inside
  19548. * @sample {highstock} stock/xaxis/minorticks/
  19549. * Inside
  19550. *
  19551. * @validvalue ["inside", "outside"]
  19552. */
  19553. minorTickPosition: 'outside',
  19554. /**
  19555. * Enable or disable minor ticks. Unless
  19556. * [minorTickInterval](#xAxis.minorTickInterval) is set, the tick
  19557. * interval is calculated as a fifth of the `tickInterval`.
  19558. *
  19559. * On a logarithmic axis, minor ticks are laid out based on a best
  19560. * guess, attempting to enter approximately 5 minor ticks between
  19561. * each major tick.
  19562. *
  19563. * Prior to v6.0.0, ticks were unabled in auto layout by setting
  19564. * `minorTickInterval` to `"auto"`.
  19565. *
  19566. * @productdesc {highcharts}
  19567. * On axes using [categories](#xAxis.categories), minor ticks are not
  19568. * supported.
  19569. *
  19570. * @sample {highcharts} highcharts/yaxis/minorticks-true/
  19571. * Enabled on linear Y axis
  19572. *
  19573. * @type {boolean}
  19574. * @default false
  19575. * @since 6.0.0
  19576. * @apioption xAxis.minorTicks
  19577. */
  19578. /**
  19579. * The pixel width of the minor tick mark.
  19580. *
  19581. * @sample {highcharts} highcharts/yaxis/minortickwidth/
  19582. * 3px width
  19583. * @sample {highstock} stock/xaxis/minorticks/
  19584. * 1px width
  19585. *
  19586. * @type {number}
  19587. * @default 0
  19588. * @apioption xAxis.minorTickWidth
  19589. */
  19590. /**
  19591. * Padding of the min value relative to the length of the axis. A
  19592. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19593. * when you don't want the lowest data value to appear on the edge
  19594. * of the plot area. When the axis' `min` option is set or a min extreme
  19595. * is set using `axis.setExtremes()`, the minPadding will be ignored.
  19596. *
  19597. * @sample {highcharts} highcharts/yaxis/minpadding/
  19598. * Min padding of 0.2
  19599. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19600. * Greater min- and maxPadding
  19601. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  19602. * Add some padding
  19603. *
  19604. * @default {highcharts} 0.01
  19605. * @default {highstock|highmaps} 0
  19606. * @since 1.2.0
  19607. * @product highcharts highstock gantt
  19608. */
  19609. minPadding: 0.01,
  19610. /**
  19611. * The minimum range to display on this axis. The entire axis will not
  19612. * be allowed to span over a smaller interval than this. For example,
  19613. * for a datetime axis the main unit is milliseconds. If minRange is
  19614. * set to 3600000, you can't zoom in more than to one hour.
  19615. *
  19616. * The default minRange for the x axis is five times the smallest
  19617. * interval between any of the data points.
  19618. *
  19619. * On a logarithmic axis, the unit for the minimum range is the power.
  19620. * So a minRange of 1 means that the axis can be zoomed to 10-100,
  19621. * 100-1000, 1000-10000 etc.
  19622. *
  19623. * **Note**: The `minPadding`, `maxPadding`, `startOnTick` and
  19624. * `endOnTick` settings also affect how the extremes of the axis
  19625. * are computed.
  19626. *
  19627. * @sample {highcharts} highcharts/xaxis/minrange/
  19628. * Minimum range of 5
  19629. * @sample {highstock} stock/xaxis/minrange/
  19630. * Max zoom of 6 months overrides user selections
  19631. * @sample {highmaps} maps/axis/minrange/
  19632. * Minimum range of 1000
  19633. *
  19634. * @type {number}
  19635. * @apioption xAxis.minRange
  19636. */
  19637. /**
  19638. * The minimum tick interval allowed in axis values. For example on
  19639. * zooming in on an axis with daily data, this can be used to prevent
  19640. * the axis from showing hours. Defaults to the closest distance between
  19641. * two points on the axis.
  19642. *
  19643. * @type {number}
  19644. * @since 2.3.0
  19645. * @apioption xAxis.minTickInterval
  19646. */
  19647. /**
  19648. * The distance in pixels from the plot area to the axis line.
  19649. * A positive offset moves the axis with it's line, labels and ticks
  19650. * away from the plot area. This is typically used when two or more
  19651. * axes are displayed on the same side of the plot. With multiple
  19652. * axes the offset is dynamically adjusted to avoid collision, this
  19653. * can be overridden by setting offset explicitly.
  19654. *
  19655. * @sample {highcharts} highcharts/yaxis/offset/
  19656. * Y axis offset of 70
  19657. * @sample {highcharts} highcharts/yaxis/offset-centered/
  19658. * Axes positioned in the center of the plot
  19659. * @sample {highstock} stock/xaxis/offset/
  19660. * Y axis offset by 70 px
  19661. *
  19662. */
  19663. offset: void 0,
  19664. /**
  19665. * Whether to display the axis on the opposite side of the normal. The
  19666. * normal is on the left side for vertical axes and bottom for
  19667. * horizontal, so the opposite sides will be right and top respectively.
  19668. * This is typically used with dual or multiple axes.
  19669. *
  19670. * @sample {highcharts} highcharts/yaxis/opposite/
  19671. * Secondary Y axis opposite
  19672. * @sample {highstock} stock/xaxis/opposite/
  19673. * Y axis on left side
  19674. *
  19675. * @default {highcharts|highstock|highmaps} false
  19676. * @default {gantt} true
  19677. */
  19678. opposite: false,
  19679. /**
  19680. * In an ordinal axis, the points are equally spaced in the chart
  19681. * regardless of the actual time or x distance between them. This means
  19682. * that missing data periods (e.g. nights or weekends for a stock chart)
  19683. * will not take up space in the chart.
  19684. * Having `ordinal: false` will show any gaps created by the `gapSize`
  19685. * setting proportionate to their duration.
  19686. *
  19687. * In stock charts the X axis is ordinal by default, unless
  19688. * the boost module is used and at least one of the series' data length
  19689. * exceeds the [boostThreshold](#series.line.boostThreshold).
  19690. *
  19691. * @sample {highstock} stock/xaxis/ordinal-true/
  19692. * True by default
  19693. * @sample {highstock} stock/xaxis/ordinal-false/
  19694. * False
  19695. *
  19696. * @type {boolean}
  19697. * @default true
  19698. * @since 1.1
  19699. * @product highstock
  19700. * @apioption xAxis.ordinal
  19701. */
  19702. /**
  19703. * Additional range on the right side of the xAxis. Works similar to
  19704. * `xAxis.maxPadding`, but value is set in milliseconds. Can be set for
  19705. * both main `xAxis` and the navigator's `xAxis`.
  19706. *
  19707. * @sample {highstock} stock/xaxis/overscroll/
  19708. * One minute overscroll with live data
  19709. *
  19710. * @type {number}
  19711. * @default 0
  19712. * @since 6.0.0
  19713. * @product highstock
  19714. * @apioption xAxis.overscroll
  19715. */
  19716. /**
  19717. * Refers to the index in the [panes](#panes) array. Used for circular
  19718. * gauges and polar charts. When the option is not set then first pane
  19719. * will be used.
  19720. *
  19721. * @sample highcharts/demo/gauge-vu-meter
  19722. * Two gauges with different center
  19723. *
  19724. * @type {number}
  19725. * @product highcharts
  19726. * @apioption xAxis.pane
  19727. */
  19728. /**
  19729. * The zoomed range to display when only defining one or none of `min`
  19730. * or `max`. For example, to show the latest month, a range of one month
  19731. * can be set.
  19732. *
  19733. * @sample {highstock} stock/xaxis/range/
  19734. * Setting a zoomed range when the rangeSelector is disabled
  19735. *
  19736. * @type {number}
  19737. * @product highstock
  19738. * @apioption xAxis.range
  19739. */
  19740. /**
  19741. * Whether to reverse the axis so that the highest number is closest
  19742. * to the origin. If the chart is inverted, the x axis is reversed by
  19743. * default.
  19744. *
  19745. * @sample {highcharts} highcharts/yaxis/reversed/
  19746. * Reversed Y axis
  19747. * @sample {highstock} stock/xaxis/reversed/
  19748. * Reversed Y axis
  19749. *
  19750. * @type {boolean}
  19751. * @default undefined
  19752. * @apioption xAxis.reversed
  19753. */
  19754. reversed: void 0,
  19755. /**
  19756. * This option determines how stacks should be ordered within a group.
  19757. * For example reversed xAxis also reverses stacks, so first series
  19758. * comes last in a group. To keep order like for non-reversed xAxis
  19759. * enable this option.
  19760. *
  19761. * @sample {highcharts} highcharts/xaxis/reversedstacks/
  19762. * Reversed stacks comparison
  19763. * @sample {highstock} highcharts/xaxis/reversedstacks/
  19764. * Reversed stacks comparison
  19765. *
  19766. * @since 6.1.1
  19767. * @product highcharts highstock
  19768. */
  19769. reversedStacks: false,
  19770. /**
  19771. * An optional scrollbar to display on the X axis in response to
  19772. * limiting the minimum and maximum of the axis values.
  19773. *
  19774. * In styled mode, all the presentational options for the scrollbar are
  19775. * replaced by the classes `.highcharts-scrollbar-thumb`,
  19776. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  19777. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  19778. *
  19779. * @sample {highstock} stock/yaxis/heatmap-scrollbars/
  19780. * Heatmap with both scrollbars
  19781. *
  19782. * @extends scrollbar
  19783. * @since 4.2.6
  19784. * @product highstock
  19785. * @apioption xAxis.scrollbar
  19786. */
  19787. /**
  19788. * Whether to show the axis line and title when the axis has no data.
  19789. *
  19790. * @sample {highcharts} highcharts/yaxis/showempty/
  19791. * When clicking the legend to hide series, one axis preserves
  19792. * line and title, the other doesn't
  19793. * @sample {highstock} highcharts/yaxis/showempty/
  19794. * When clicking the legend to hide series, one axis preserves
  19795. * line and title, the other doesn't
  19796. *
  19797. * @since 1.1
  19798. */
  19799. showEmpty: true,
  19800. /**
  19801. * Whether to show the first tick label.
  19802. *
  19803. * @sample {highcharts} highcharts/xaxis/showfirstlabel-false/
  19804. * Set to false on X axis
  19805. * @sample {highstock} stock/xaxis/showfirstlabel/
  19806. * Labels below plot lines on Y axis
  19807. */
  19808. showFirstLabel: true,
  19809. /**
  19810. * Whether to show the last tick label. Defaults to `true` on cartesian
  19811. * charts, and `false` on polar charts.
  19812. *
  19813. * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
  19814. * Set to true on X axis
  19815. * @sample {highstock} stock/xaxis/showfirstlabel/
  19816. * Labels below plot lines on Y axis
  19817. *
  19818. * @product highcharts highstock gantt
  19819. */
  19820. showLastLabel: true,
  19821. /**
  19822. * A soft maximum for the axis. If the series data maximum is less than
  19823. * this, the axis will stay at this maximum, but if the series data
  19824. * maximum is higher, the axis will flex to show all data.
  19825. *
  19826. * @sample highcharts/yaxis/softmin-softmax/
  19827. * Soft min and max
  19828. *
  19829. * @type {number}
  19830. * @since 5.0.1
  19831. * @product highcharts highstock gantt
  19832. * @apioption xAxis.softMax
  19833. */
  19834. /**
  19835. * A soft minimum for the axis. If the series data minimum is greater
  19836. * than this, the axis will stay at this minimum, but if the series
  19837. * data minimum is lower, the axis will flex to show all data.
  19838. *
  19839. * @sample highcharts/yaxis/softmin-softmax/
  19840. * Soft min and max
  19841. *
  19842. * @type {number}
  19843. * @since 5.0.1
  19844. * @product highcharts highstock gantt
  19845. * @apioption xAxis.softMin
  19846. */
  19847. /**
  19848. * For datetime axes, this decides where to put the tick between weeks.
  19849. * 0 = Sunday, 1 = Monday.
  19850. *
  19851. * @sample {highcharts} highcharts/xaxis/startofweek-monday/
  19852. * Monday by default
  19853. * @sample {highcharts} highcharts/xaxis/startofweek-sunday/
  19854. * Sunday
  19855. * @sample {highstock} stock/xaxis/startofweek-1
  19856. * Monday by default
  19857. * @sample {highstock} stock/xaxis/startofweek-0
  19858. * Sunday
  19859. *
  19860. * @product highcharts highstock gantt
  19861. */
  19862. startOfWeek: 1,
  19863. /**
  19864. * Whether to force the axis to start on a tick. Use this option with
  19865. * the `minPadding` option to control the axis start.
  19866. *
  19867. * @productdesc {highstock}
  19868. * In Highcharts Stock, `startOnTick` is always `false` when
  19869. * the navigator is enabled, to prevent jumpy scrolling.
  19870. *
  19871. * @sample {highcharts} highcharts/xaxis/startontick-false/
  19872. * False by default
  19873. * @sample {highcharts} highcharts/xaxis/startontick-true/
  19874. * True
  19875. *
  19876. * @since 1.2.0
  19877. */
  19878. startOnTick: false,
  19879. /**
  19880. * The amount of ticks to draw on the axis. This opens up for aligning
  19881. * the ticks of multiple charts or panes within a chart. This option
  19882. * overrides the `tickPixelInterval` option.
  19883. *
  19884. * This option only has an effect on linear axes. Datetime, logarithmic
  19885. * or category axes are not affected.
  19886. *
  19887. * @sample {highcharts} highcharts/yaxis/tickamount/
  19888. * 8 ticks on Y axis
  19889. * @sample {highstock} highcharts/yaxis/tickamount/
  19890. * 8 ticks on Y axis
  19891. *
  19892. * @type {number}
  19893. * @since 4.1.0
  19894. * @product highcharts highstock gantt
  19895. * @apioption xAxis.tickAmount
  19896. */
  19897. /**
  19898. * The interval of the tick marks in axis units. When `undefined`, the
  19899. * tick interval is computed to approximately follow the
  19900. * [tickPixelInterval](#xAxis.tickPixelInterval) on linear and datetime
  19901. * axes. On categorized axes, a `undefined` tickInterval will default to
  19902. * 1, one category. Note that datetime axes are based on milliseconds,
  19903. * so for example an interval of one day is expressed as
  19904. * `24 * 3600 * 1000`.
  19905. *
  19906. * On logarithmic axes, the tickInterval is based on powers, so a
  19907. * tickInterval of 1 means one tick on each of 0.1, 1, 10, 100 etc. A
  19908. * tickInterval of 2 means a tick of 0.1, 10, 1000 etc. A tickInterval
  19909. * of 0.2 puts a tick on 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20,
  19910. * 40 etc.
  19911. *
  19912. *
  19913. * If the tickInterval is too dense for labels to be drawn, Highcharts
  19914. * may remove ticks.
  19915. *
  19916. * If the chart has multiple axes, the [alignTicks](#chart.alignTicks)
  19917. * option may interfere with the `tickInterval` setting.
  19918. *
  19919. * @see [tickPixelInterval](#xAxis.tickPixelInterval)
  19920. * @see [tickPositions](#xAxis.tickPositions)
  19921. * @see [tickPositioner](#xAxis.tickPositioner)
  19922. *
  19923. * @sample {highcharts} highcharts/xaxis/tickinterval-5/
  19924. * Tick interval of 5 on a linear axis
  19925. * @sample {highstock} stock/xaxis/tickinterval/
  19926. * Tick interval of 0.01 on Y axis
  19927. *
  19928. * @type {number}
  19929. * @apioption xAxis.tickInterval
  19930. */
  19931. /**
  19932. * The pixel length of the main tick marks.
  19933. *
  19934. * @sample {highcharts} highcharts/xaxis/ticklength/
  19935. * 20 px tick length on the X axis
  19936. * @sample {highstock} stock/xaxis/ticks/
  19937. * Formatted ticks on X axis
  19938. */
  19939. tickLength: 10,
  19940. /**
  19941. * If tickInterval is `null` this option sets the approximate pixel
  19942. * interval of the tick marks. Not applicable to categorized axis.
  19943. *
  19944. * The tick interval is also influenced by the [minTickInterval](
  19945. * #xAxis.minTickInterval) option, that, by default prevents ticks from
  19946. * being denser than the data points.
  19947. *
  19948. * @see [tickInterval](#xAxis.tickInterval)
  19949. * @see [tickPositioner](#xAxis.tickPositioner)
  19950. * @see [tickPositions](#xAxis.tickPositions)
  19951. *
  19952. * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
  19953. * 50 px on X axis
  19954. * @sample {highstock} stock/xaxis/tickpixelinterval/
  19955. * 200 px on X axis
  19956. */
  19957. tickPixelInterval: 100,
  19958. /**
  19959. * For categorized axes only. If `on` the tick mark is placed in the
  19960. * center of the category, if `between` the tick mark is placed between
  19961. * categories. The default is `between` if the `tickInterval` is 1, else
  19962. * `on`.
  19963. *
  19964. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
  19965. * "between" by default
  19966. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
  19967. * "on"
  19968. *
  19969. * @product highcharts gantt
  19970. * @validvalue ["on", "between"]
  19971. */
  19972. tickmarkPlacement: 'between',
  19973. /**
  19974. * The position of the major tick marks relative to the axis line.
  19975. * Can be one of `inside` and `outside`.
  19976. *
  19977. * @sample {highcharts} highcharts/xaxis/tickposition-outside/
  19978. * "outside" by default
  19979. * @sample {highcharts} highcharts/xaxis/tickposition-inside/
  19980. * "inside"
  19981. * @sample {highstock} stock/xaxis/ticks/
  19982. * Formatted ticks on X axis
  19983. *
  19984. * @validvalue ["inside", "outside"]
  19985. */
  19986. tickPosition: 'outside',
  19987. /**
  19988. * A callback function returning array defining where the ticks are
  19989. * laid out on the axis. This overrides the default behaviour of
  19990. * [tickPixelInterval](#xAxis.tickPixelInterval) and [tickInterval](
  19991. * #xAxis.tickInterval). The automatic tick positions are accessible
  19992. * through `this.tickPositions` and can be modified by the callback.
  19993. *
  19994. * @see [tickPositions](#xAxis.tickPositions)
  19995. *
  19996. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  19997. * Demo of tickPositions and tickPositioner
  19998. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  19999. * Demo of tickPositions and tickPositioner
  20000. *
  20001. * @type {Highcharts.AxisTickPositionerCallbackFunction}
  20002. * @apioption xAxis.tickPositioner
  20003. */
  20004. /**
  20005. * An array defining where the ticks are laid out on the axis. This
  20006. * overrides the default behaviour of [tickPixelInterval](
  20007. * #xAxis.tickPixelInterval) and [tickInterval](#xAxis.tickInterval).
  20008. *
  20009. * @see [tickPositioner](#xAxis.tickPositioner)
  20010. *
  20011. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  20012. * Demo of tickPositions and tickPositioner
  20013. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  20014. * Demo of tickPositions and tickPositioner
  20015. *
  20016. * @type {Array<number>}
  20017. * @apioption xAxis.tickPositions
  20018. */
  20019. /**
  20020. * The pixel width of the major tick marks. Defaults to 0 on category
  20021. * axes, otherwise 1.
  20022. *
  20023. * In styled mode, the stroke width is given in the `.highcharts-tick`
  20024. * class, but in order for the element to be generated on category axes,
  20025. * the option must be explicitly set to 1.
  20026. *
  20027. * @sample {highcharts} highcharts/xaxis/tickwidth/
  20028. * 10 px width
  20029. * @sample {highcharts} highcharts/css/axis-grid/
  20030. * Styled mode
  20031. * @sample {highstock} stock/xaxis/ticks/
  20032. * Formatted ticks on X axis
  20033. * @sample {highstock} highcharts/css/axis-grid/
  20034. * Styled mode
  20035. *
  20036. * @type {undefined|number}
  20037. * @default {highstock} 1
  20038. * @default {highmaps} 0
  20039. * @apioption xAxis.tickWidth
  20040. */
  20041. /**
  20042. * The axis title, showing next to the axis line.
  20043. *
  20044. * @productdesc {highmaps}
  20045. * In Highmaps, the axis is hidden by default, but adding an axis title
  20046. * is still possible. X axis and Y axis titles will appear at the bottom
  20047. * and left by default.
  20048. */
  20049. title: {
  20050. /**
  20051. * Alignment of the title relative to the axis values. Possible
  20052. * values are "low", "middle" or "high".
  20053. *
  20054. * @sample {highcharts} highcharts/xaxis/title-align-low/
  20055. * "low"
  20056. * @sample {highcharts} highcharts/xaxis/title-align-center/
  20057. * "middle" by default
  20058. * @sample {highcharts} highcharts/xaxis/title-align-high/
  20059. * "high"
  20060. * @sample {highcharts} highcharts/yaxis/title-offset/
  20061. * Place the Y axis title on top of the axis
  20062. * @sample {highstock} stock/xaxis/title-align/
  20063. * Aligned to "high" value
  20064. *
  20065. * @type {Highcharts.AxisTitleAlignValue}
  20066. */
  20067. align: 'middle',
  20068. /**
  20069. * Deprecated. Set the `text` to `undefined` to disable the title.
  20070. *
  20071. * @deprecated
  20072. * @type {boolean}
  20073. * @product highcharts
  20074. * @apioption xAxis.title.enabled
  20075. */
  20076. /**
  20077. * The pixel distance between the axis labels or line and the title.
  20078. * Defaults to 0 for horizontal axes, 10 for vertical
  20079. *
  20080. * @sample {highcharts} highcharts/xaxis/title-margin/
  20081. * Y axis title margin of 60
  20082. *
  20083. * @type {number}
  20084. * @apioption xAxis.title.margin
  20085. */
  20086. /**
  20087. * The distance of the axis title from the axis line. By default,
  20088. * this distance is computed from the offset width of the labels,
  20089. * the labels' distance from the axis and the title's margin.
  20090. * However when the offset option is set, it overrides all this.
  20091. *
  20092. * @sample {highcharts} highcharts/yaxis/title-offset/
  20093. * Place the axis title on top of the axis
  20094. * @sample {highstock} highcharts/yaxis/title-offset/
  20095. * Place the axis title on top of the Y axis
  20096. *
  20097. * @type {number}
  20098. * @since 2.2.0
  20099. * @apioption xAxis.title.offset
  20100. */
  20101. /**
  20102. * Whether to reserve space for the title when laying out the axis.
  20103. *
  20104. * @type {boolean}
  20105. * @default true
  20106. * @since 5.0.11
  20107. * @product highcharts highstock gantt
  20108. * @apioption xAxis.title.reserveSpace
  20109. */
  20110. /**
  20111. * The rotation of the text in degrees. 0 is horizontal, 270 is
  20112. * vertical reading from bottom to top.
  20113. *
  20114. * @sample {highcharts} highcharts/yaxis/title-offset/
  20115. * Horizontal
  20116. */
  20117. rotation: 0,
  20118. /**
  20119. * The actual text of the axis title. It can contain basic HTML tags
  20120. * like `b`, `i` and `span` with style.
  20121. *
  20122. * @sample {highcharts} highcharts/xaxis/title-text/
  20123. * Custom HTML
  20124. * @sample {highstock} stock/xaxis/title-text/
  20125. * Titles for both axes
  20126. *
  20127. * @type {string|null}
  20128. * @apioption xAxis.title.text
  20129. */
  20130. /**
  20131. * Alignment of the text, can be `"left"`, `"right"` or `"center"`.
  20132. * Default alignment depends on the
  20133. * [title.align](xAxis.title.align):
  20134. *
  20135. * Horizontal axes:
  20136. * - for `align` = `"low"`, `textAlign` is set to `left`
  20137. * - for `align` = `"middle"`, `textAlign` is set to `center`
  20138. * - for `align` = `"high"`, `textAlign` is set to `right`
  20139. *
  20140. * Vertical axes:
  20141. * - for `align` = `"low"` and `opposite` = `true`, `textAlign` is
  20142. * set to `right`
  20143. * - for `align` = `"low"` and `opposite` = `false`, `textAlign` is
  20144. * set to `left`
  20145. * - for `align` = `"middle"`, `textAlign` is set to `center`
  20146. * - for `align` = `"high"` and `opposite` = `true` `textAlign` is
  20147. * set to `left`
  20148. * - for `align` = `"high"` and `opposite` = `false` `textAlign` is
  20149. * set to `right`
  20150. *
  20151. * @type {Highcharts.AlignValue}
  20152. * @apioption xAxis.title.textAlign
  20153. */
  20154. /**
  20155. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20156. * to render the axis title.
  20157. *
  20158. * @product highcharts highstock gantt
  20159. */
  20160. useHTML: false,
  20161. /**
  20162. * Horizontal pixel offset of the title position.
  20163. *
  20164. * @since 4.1.6
  20165. * @product highcharts highstock gantt
  20166. */
  20167. x: 0,
  20168. /**
  20169. * Vertical pixel offset of the title position.
  20170. *
  20171. * @product highcharts highstock gantt
  20172. */
  20173. y: 0,
  20174. /**
  20175. * CSS styles for the title. If the title text is longer than the
  20176. * axis length, it will wrap to multiple lines by default. This can
  20177. * be customized by setting `textOverflow: 'ellipsis'`, by
  20178. * setting a specific `width` or by setting `whiteSpace: 'nowrap'`.
  20179. *
  20180. * In styled mode, the stroke width is given in the
  20181. * `.highcharts-axis-title` class.
  20182. *
  20183. * @sample {highcharts} highcharts/xaxis/title-style/
  20184. * Red
  20185. * @sample {highcharts} highcharts/css/axis/
  20186. * Styled mode
  20187. *
  20188. * @type {Highcharts.CSSObject}
  20189. */
  20190. style: {
  20191. /** @internal */
  20192. color: palette.neutralColor60
  20193. }
  20194. },
  20195. /**
  20196. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
  20197. * or `category`. In a datetime axis, the numbers are given in
  20198. * milliseconds, and tick marks are placed on appropriate values like
  20199. * full hours or days. In a category axis, the
  20200. * [point names](#series.line.data.name) of the chart's series are used
  20201. * for categories, if not a [categories](#xAxis.categories) array is
  20202. * defined.
  20203. *
  20204. * @sample {highcharts} highcharts/xaxis/type-linear/
  20205. * Linear
  20206. * @sample {highcharts} highcharts/yaxis/type-log/
  20207. * Logarithmic
  20208. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  20209. * Logarithmic with minor grid lines
  20210. * @sample {highcharts} highcharts/xaxis/type-log-both/
  20211. * Logarithmic on two axes
  20212. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  20213. * Logarithmic with extension to emulate negative values
  20214. *
  20215. * @type {Highcharts.AxisTypeValue}
  20216. * @product highcharts gantt
  20217. */
  20218. type: 'linear',
  20219. /**
  20220. * If there are multiple axes on the same side of the chart, the pixel
  20221. * margin between the axes. Defaults to 0 on vertical axes, 15 on
  20222. * horizontal axes.
  20223. *
  20224. * @type {number}
  20225. * @since 7.0.3
  20226. * @apioption xAxis.margin
  20227. */
  20228. /**
  20229. * Applies only when the axis `type` is `category`. When `uniqueNames`
  20230. * is true, points are placed on the X axis according to their names.
  20231. * If the same point name is repeated in the same or another series,
  20232. * the point is placed on the same X position as other points of the
  20233. * same name. When `uniqueNames` is false, the points are laid out in
  20234. * increasing X positions regardless of their names, and the X axis
  20235. * category will take the name of the last point in each position.
  20236. *
  20237. * @sample {highcharts} highcharts/xaxis/uniquenames-true/
  20238. * True by default
  20239. * @sample {highcharts} highcharts/xaxis/uniquenames-false/
  20240. * False
  20241. *
  20242. * @since 4.2.7
  20243. * @product highcharts gantt
  20244. */
  20245. uniqueNames: true,
  20246. /**
  20247. * Datetime axis only. An array determining what time intervals the
  20248. * ticks are allowed to fall on. Each array item is an array where the
  20249. * first value is the time unit and the second value another array of
  20250. * allowed multiples.
  20251. *
  20252. * Defaults to:
  20253. * ```js
  20254. * units: [[
  20255. * 'millisecond', // unit name
  20256. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  20257. * ], [
  20258. * 'second',
  20259. * [1, 2, 5, 10, 15, 30]
  20260. * ], [
  20261. * 'minute',
  20262. * [1, 2, 5, 10, 15, 30]
  20263. * ], [
  20264. * 'hour',
  20265. * [1, 2, 3, 4, 6, 8, 12]
  20266. * ], [
  20267. * 'day',
  20268. * [1, 2]
  20269. * ], [
  20270. * 'week',
  20271. * [1, 2]
  20272. * ], [
  20273. * 'month',
  20274. * [1, 2, 3, 4, 6]
  20275. * ], [
  20276. * 'year',
  20277. * null
  20278. * ]]
  20279. * ```
  20280. *
  20281. * @type {Array<Array<string,(Array<number>|null)>>}
  20282. * @product highcharts highstock gantt
  20283. * @apioption xAxis.units
  20284. */
  20285. /**
  20286. * Whether axis, including axis title, line, ticks and labels, should
  20287. * be visible.
  20288. *
  20289. * @since 4.1.9
  20290. * @product highcharts highstock gantt
  20291. */
  20292. visible: true,
  20293. /**
  20294. * Color of the minor, secondary grid lines.
  20295. *
  20296. * In styled mode, the stroke width is given in the
  20297. * `.highcharts-minor-grid-line` class.
  20298. *
  20299. * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
  20300. * Bright grey lines from Y axis
  20301. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20302. * Styled mode
  20303. * @sample {highstock} stock/xaxis/minorgridlinecolor/
  20304. * Bright grey lines from Y axis
  20305. *
  20306. * @type {Highcharts.ColorType}
  20307. * @default #f2f2f2
  20308. */
  20309. minorGridLineColor: palette.neutralColor5,
  20310. /**
  20311. * Width of the minor, secondary grid lines.
  20312. *
  20313. * In styled mode, the stroke width is given in the
  20314. * `.highcharts-grid-line` class.
  20315. *
  20316. * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
  20317. * 2px lines from Y axis
  20318. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20319. * Styled mode
  20320. * @sample {highstock} stock/xaxis/minorgridlinewidth/
  20321. * 2px lines from Y axis
  20322. */
  20323. minorGridLineWidth: 1,
  20324. /**
  20325. * Color for the minor tick marks.
  20326. *
  20327. * @sample {highcharts} highcharts/yaxis/minortickcolor/
  20328. * Black tick marks on Y axis
  20329. * @sample {highstock} stock/xaxis/minorticks/
  20330. * Black tick marks on Y axis
  20331. *
  20332. * @type {Highcharts.ColorType}
  20333. * @default #999999
  20334. */
  20335. minorTickColor: palette.neutralColor40,
  20336. /**
  20337. * The color of the line marking the axis itself.
  20338. *
  20339. * In styled mode, the line stroke is given in the
  20340. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  20341. *
  20342. * @productdesc {highmaps}
  20343. * In Highmaps, the axis line is hidden by default, because the axis is
  20344. * not visible by default.
  20345. *
  20346. * @sample {highcharts} highcharts/yaxis/linecolor/
  20347. * A red line on Y axis
  20348. * @sample {highcharts|highstock} highcharts/css/axis/
  20349. * Axes in styled mode
  20350. * @sample {highstock} stock/xaxis/linecolor/
  20351. * A red line on X axis
  20352. *
  20353. * @type {Highcharts.ColorType}
  20354. * @default #ccd6eb
  20355. */
  20356. lineColor: palette.highlightColor20,
  20357. /**
  20358. * The width of the line marking the axis itself.
  20359. *
  20360. * In styled mode, the stroke width is given in the
  20361. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  20362. *
  20363. * @sample {highcharts} highcharts/yaxis/linecolor/
  20364. * A 1px line on Y axis
  20365. * @sample {highcharts|highstock} highcharts/css/axis/
  20366. * Axes in styled mode
  20367. * @sample {highstock} stock/xaxis/linewidth/
  20368. * A 2px line on X axis
  20369. *
  20370. * @default {highcharts|highstock} 1
  20371. * @default {highmaps} 0
  20372. */
  20373. lineWidth: 1,
  20374. /**
  20375. * Color of the grid lines extending the ticks across the plot area.
  20376. *
  20377. * In styled mode, the stroke is given in the `.highcharts-grid-line`
  20378. * class.
  20379. *
  20380. * @productdesc {highmaps}
  20381. * In Highmaps, the grid lines are hidden by default.
  20382. *
  20383. * @sample {highcharts} highcharts/yaxis/gridlinecolor/
  20384. * Green lines
  20385. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20386. * Styled mode
  20387. * @sample {highstock} stock/xaxis/gridlinecolor/
  20388. * Green lines
  20389. *
  20390. * @type {Highcharts.ColorType}
  20391. * @default #e6e6e6
  20392. */
  20393. gridLineColor: palette.neutralColor10,
  20394. /**
  20395. * The width of the grid lines extending the ticks across the plot area.
  20396. * Defaults to 1 on the Y axis and 0 on the X axis, except for 3d
  20397. * charts.
  20398. *
  20399. * In styled mode, the stroke width is given in the
  20400. * `.highcharts-grid-line` class.
  20401. *
  20402. * @sample {highcharts} highcharts/yaxis/gridlinewidth/
  20403. * 2px lines
  20404. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20405. * Styled mode
  20406. * @sample {highstock} stock/xaxis/gridlinewidth/
  20407. * 2px lines
  20408. *
  20409. * @type {number}
  20410. * @apioption xAxis.gridLineWidth
  20411. */
  20412. gridLineWidth: void 0,
  20413. /**
  20414. * The height as the vertical axis. If it's a number, it is
  20415. * interpreted as pixels.
  20416. *
  20417. * Since Highcharts 2: If it's a percentage string, it is interpreted
  20418. * as percentages of the total plot height.
  20419. *
  20420. * @type {number|string}
  20421. * @product highcharts highstock
  20422. * @apioption xAxis.height
  20423. */
  20424. /**
  20425. * The width as the horizontal axis. If it's a number, it is interpreted
  20426. * as pixels.
  20427. *
  20428. * Since Highcharts v5.0.13: If it's a percentage string, it is
  20429. * interpreted as percentages of the total plot width.
  20430. *
  20431. * @type {number|string}
  20432. * @product highcharts highstock
  20433. * @apioption xAxis.width
  20434. */
  20435. /**
  20436. * Color for the main tick marks.
  20437. *
  20438. * In styled mode, the stroke is given in the `.highcharts-tick`
  20439. * class.
  20440. *
  20441. * @sample {highcharts} highcharts/xaxis/tickcolor/
  20442. * Red ticks on X axis
  20443. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20444. * Styled mode
  20445. * @sample {highstock} stock/xaxis/ticks/
  20446. * Formatted ticks on X axis
  20447. *
  20448. * @type {Highcharts.ColorType}
  20449. * @default #ccd6eb
  20450. */
  20451. tickColor: palette.highlightColor20
  20452. // tickWidth: 1
  20453. };
  20454. /**
  20455. * The Y axis or value axis. Normally this is the vertical axis,
  20456. * though if the chart is inverted this is the horizontal axis.
  20457. * In case of multiple axes, the yAxis node is an array of
  20458. * configuration objects.
  20459. *
  20460. * See [the Axis object](/class-reference/Highcharts.Axis) for programmatic
  20461. * access to the axis.
  20462. *
  20463. * @type {*|Array<*>}
  20464. * @extends xAxis
  20465. * @excluding currentDateIndicator,ordinal,overscroll
  20466. * @optionparent yAxis
  20467. *
  20468. * @private
  20469. */
  20470. Axis.defaultYAxisOptions = {
  20471. /**
  20472. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`,
  20473. * `category` or `treegrid`. Defaults to `treegrid` for Gantt charts,
  20474. * `linear` for other chart types.
  20475. *
  20476. * In a datetime axis, the numbers are given in milliseconds, and tick
  20477. * marks are placed on appropriate values, like full hours or days. In a
  20478. * category or treegrid axis, the [point names](#series.line.data.name)
  20479. * of the chart's series are used for categories, if a
  20480. * [categories](#xAxis.categories) array is not defined.
  20481. *
  20482. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  20483. * Logarithmic with minor grid lines
  20484. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  20485. * Logarithmic with extension to emulate negative values
  20486. * @sample {gantt} gantt/treegrid-axis/demo
  20487. * Treegrid axis
  20488. *
  20489. * @type {Highcharts.AxisTypeValue}
  20490. * @default {highcharts} linear
  20491. * @default {gantt} treegrid
  20492. * @product highcharts gantt
  20493. * @apioption yAxis.type
  20494. */
  20495. /**
  20496. * The height of the Y axis. If it's a number, it is interpreted as
  20497. * pixels.
  20498. *
  20499. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  20500. * percentages of the total plot height.
  20501. *
  20502. * @see [yAxis.top](#yAxis.top)
  20503. *
  20504. * @sample {highstock} stock/demo/candlestick-and-volume/
  20505. * Percentage height panes
  20506. *
  20507. * @type {number|string}
  20508. * @product highcharts highstock
  20509. * @apioption yAxis.height
  20510. */
  20511. /**
  20512. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  20513. * to represent the maximum value of the Y axis.
  20514. *
  20515. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  20516. * Min and max colors
  20517. *
  20518. * @type {Highcharts.ColorType}
  20519. * @default #003399
  20520. * @since 4.0
  20521. * @product highcharts
  20522. * @apioption yAxis.maxColor
  20523. */
  20524. /**
  20525. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  20526. * to represent the minimum value of the Y axis.
  20527. *
  20528. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  20529. * Min and max color
  20530. *
  20531. * @type {Highcharts.ColorType}
  20532. * @default #e6ebf5
  20533. * @since 4.0
  20534. * @product highcharts
  20535. * @apioption yAxis.minColor
  20536. */
  20537. /**
  20538. * Whether to reverse the axis so that the highest number is closest
  20539. * to the origin.
  20540. *
  20541. * @sample {highcharts} highcharts/yaxis/reversed/
  20542. * Reversed Y axis
  20543. * @sample {highstock} stock/xaxis/reversed/
  20544. * Reversed Y axis
  20545. *
  20546. * @type {boolean}
  20547. * @default {highcharts} false
  20548. * @default {highstock} false
  20549. * @default {highmaps} true
  20550. * @default {gantt} true
  20551. * @apioption yAxis.reversed
  20552. */
  20553. /**
  20554. * If `true`, the first series in a stack will be drawn on top in a
  20555. * positive, non-reversed Y axis. If `false`, the first series is in
  20556. * the base of the stack.
  20557. *
  20558. * @sample {highcharts} highcharts/yaxis/reversedstacks-false/
  20559. * Non-reversed stacks
  20560. * @sample {highstock} highcharts/yaxis/reversedstacks-false/
  20561. * Non-reversed stacks
  20562. *
  20563. * @type {boolean}
  20564. * @default true
  20565. * @since 3.0.10
  20566. * @product highcharts highstock
  20567. * @apioption yAxis.reversedStacks
  20568. */
  20569. reversedStacks: true,
  20570. /**
  20571. * Solid gauge series only. Color stops for the solid gauge. Use this
  20572. * in cases where a linear gradient between a `minColor` and `maxColor`
  20573. * is not sufficient. The stops is an array of tuples, where the first
  20574. * item is a float between 0 and 1 assigning the relative position in
  20575. * the gradient, and the second item is the color.
  20576. *
  20577. * For solid gauges, the Y axis also inherits the concept of
  20578. * [data classes](https://api.highcharts.com/highmaps#colorAxis.dataClasses)
  20579. * from the Highmaps color axis.
  20580. *
  20581. * @see [minColor](#yAxis.minColor)
  20582. * @see [maxColor](#yAxis.maxColor)
  20583. *
  20584. * @sample {highcharts} highcharts/demo/gauge-solid/
  20585. * True by default
  20586. *
  20587. * @type {Array<Array<number,Highcharts.ColorType>>}
  20588. * @since 4.0
  20589. * @product highcharts
  20590. * @apioption yAxis.stops
  20591. */
  20592. /**
  20593. * The pixel width of the major tick marks.
  20594. *
  20595. * @sample {highcharts} highcharts/xaxis/tickwidth/ 10 px width
  20596. * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
  20597. *
  20598. * @type {number}
  20599. * @default 0
  20600. * @product highcharts highstock gantt
  20601. * @apioption yAxis.tickWidth
  20602. */
  20603. /**
  20604. * Whether to force the axis to end on a tick. Use this option with
  20605. * the `maxPadding` option to control the axis end.
  20606. *
  20607. * This option is always disabled, when panning type is
  20608. * either `y` or `xy`.
  20609. *
  20610. * @see [type](#chart.panning.type)
  20611. *
  20612. *
  20613. * @sample {highcharts} highcharts/chart/reflow-true/
  20614. * True by default
  20615. * @sample {highcharts} highcharts/yaxis/endontick/
  20616. * False
  20617. * @sample {highstock} stock/demo/basic-line/
  20618. * True by default
  20619. * @sample {highstock} stock/xaxis/endontick/
  20620. * False for Y axis
  20621. *
  20622. * @since 1.2.0
  20623. */
  20624. endOnTick: true,
  20625. /**
  20626. * Padding of the max value relative to the length of the axis. A
  20627. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  20628. * when you don't want the highest data value to appear on the edge
  20629. * of the plot area. When the axis' `max` option is set or a max extreme
  20630. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  20631. *
  20632. * Also the `softThreshold` option takes precedence over `maxPadding`,
  20633. * so if the data is tangent to the threshold, `maxPadding` may not
  20634. * apply unless `softThreshold` is set to false.
  20635. *
  20636. * @sample {highcharts} highcharts/yaxis/maxpadding-02/
  20637. * Max padding of 0.2
  20638. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  20639. * Greater min- and maxPadding
  20640. *
  20641. * @since 1.2.0
  20642. * @product highcharts highstock gantt
  20643. */
  20644. maxPadding: 0.05,
  20645. /**
  20646. * Padding of the min value relative to the length of the axis. A
  20647. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  20648. * when you don't want the lowest data value to appear on the edge
  20649. * of the plot area. When the axis' `min` option is set or a max extreme
  20650. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  20651. *
  20652. * Also the `softThreshold` option takes precedence over `minPadding`,
  20653. * so if the data is tangent to the threshold, `minPadding` may not
  20654. * apply unless `softThreshold` is set to false.
  20655. *
  20656. * @sample {highcharts} highcharts/yaxis/minpadding/
  20657. * Min padding of 0.2
  20658. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  20659. * Greater min- and maxPadding
  20660. *
  20661. * @since 1.2.0
  20662. * @product highcharts highstock gantt
  20663. */
  20664. minPadding: 0.05,
  20665. /**
  20666. * @productdesc {highstock}
  20667. * In Highcharts Stock 1.x, the Y axis was placed
  20668. * on the left side by default.
  20669. *
  20670. * @sample {highcharts} highcharts/yaxis/opposite/
  20671. * Secondary Y axis opposite
  20672. * @sample {highstock} stock/xaxis/opposite/
  20673. * Y axis on left side
  20674. *
  20675. * @type {boolean}
  20676. * @default {highstock} true
  20677. * @default {highcharts} false
  20678. * @product highstock highcharts gantt
  20679. * @apioption yAxis.opposite
  20680. */
  20681. /**
  20682. * @see [tickInterval](#xAxis.tickInterval)
  20683. * @see [tickPositioner](#xAxis.tickPositioner)
  20684. * @see [tickPositions](#xAxis.tickPositions)
  20685. */
  20686. tickPixelInterval: 72,
  20687. showLastLabel: true,
  20688. /**
  20689. * @extends xAxis.labels
  20690. */
  20691. labels: {
  20692. /**
  20693. * Angular gauges and solid gauges only.
  20694. * The label's pixel distance from the perimeter of the plot area.
  20695. *
  20696. * Since v7.1.2: If it's a percentage string, it is interpreted the
  20697. * same as [series.radius](#plotOptions.gauge.radius), so label can be
  20698. * aligned under the gauge's shape.
  20699. *
  20700. * @sample {highcharts} highcharts/yaxis/labels-distance/
  20701. * Labels centered under the arc
  20702. *
  20703. * @type {number|string}
  20704. * @default -25
  20705. * @product highcharts
  20706. * @apioption yAxis.labels.distance
  20707. */
  20708. /**
  20709. * The y position offset of all labels relative to the tick
  20710. * positions on the axis. For polar and radial axis consider the use
  20711. * of the [distance](#yAxis.labels.distance) option.
  20712. *
  20713. * @sample {highcharts} highcharts/xaxis/labels-x/
  20714. * Y axis labels placed on grid lines
  20715. *
  20716. * @type {number}
  20717. * @default {highcharts} 3
  20718. * @default {highstock} -2
  20719. * @default {highmaps} 3
  20720. * @apioption yAxis.labels.y
  20721. */
  20722. /**
  20723. * What part of the string the given position is anchored to. Can
  20724. * be one of `"left"`, `"center"` or `"right"`. The exact position
  20725. * also depends on the `labels.x` setting.
  20726. *
  20727. * Angular gauges and solid gauges defaults to `"center"`.
  20728. * Solid gauges with two labels have additional option `"auto"`
  20729. * for automatic horizontal and vertical alignment.
  20730. *
  20731. * @see [yAxis.labels.distance](#yAxis.labels.distance)
  20732. *
  20733. * @sample {highcharts} highcharts/yaxis/labels-align-left/
  20734. * Left
  20735. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  20736. * Solid gauge labels auto aligned
  20737. *
  20738. * @type {Highcharts.AlignValue}
  20739. * @default {highcharts|highmaps} right
  20740. * @default {highstock} left
  20741. * @apioption yAxis.labels.align
  20742. */
  20743. /**
  20744. * The x position offset of all labels relative to the tick
  20745. * positions on the axis. Defaults to -15 for left axis, 15 for
  20746. * right axis.
  20747. *
  20748. * @sample {highcharts} highcharts/xaxis/labels-x/
  20749. * Y axis labels placed on grid lines
  20750. */
  20751. x: -8
  20752. },
  20753. /**
  20754. * @productdesc {highmaps}
  20755. * In Highmaps, the axis line is hidden by default, because the axis is
  20756. * not visible by default.
  20757. *
  20758. * @type {Highcharts.ColorType}
  20759. * @apioption yAxis.lineColor
  20760. */
  20761. /**
  20762. * @sample {highcharts} highcharts/yaxis/max-200/
  20763. * Y axis max of 200
  20764. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  20765. * Y axis max on logarithmic axis
  20766. * @sample {highstock} stock/yaxis/min-max/
  20767. * Fixed min and max on Y axis
  20768. * @sample {highmaps} maps/axis/min-max/
  20769. * Pre-zoomed to a specific area
  20770. *
  20771. * @apioption yAxis.max
  20772. */
  20773. /**
  20774. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  20775. * -50 with startOnTick to false
  20776. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  20777. * -50 with startOnTick true by default
  20778. * @sample {highstock} stock/yaxis/min-max/
  20779. * Fixed min and max on Y axis
  20780. * @sample {highmaps} maps/axis/min-max/
  20781. * Pre-zoomed to a specific area
  20782. *
  20783. * @apioption yAxis.min
  20784. */
  20785. /**
  20786. * An optional scrollbar to display on the Y axis in response to
  20787. * limiting the minimum an maximum of the axis values.
  20788. *
  20789. * In styled mode, all the presentational options for the scrollbar
  20790. * are replaced by the classes `.highcharts-scrollbar-thumb`,
  20791. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  20792. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  20793. *
  20794. * @sample {highstock} stock/yaxis/scrollbar/
  20795. * Scrollbar on the Y axis
  20796. *
  20797. * @extends scrollbar
  20798. * @since 4.2.6
  20799. * @product highstock
  20800. * @excluding height
  20801. * @apioption yAxis.scrollbar
  20802. */
  20803. /**
  20804. * Enable the scrollbar on the Y axis.
  20805. *
  20806. * @sample {highstock} stock/yaxis/scrollbar/
  20807. * Enabled on Y axis
  20808. *
  20809. * @type {boolean}
  20810. * @default false
  20811. * @since 4.2.6
  20812. * @product highstock
  20813. * @apioption yAxis.scrollbar.enabled
  20814. */
  20815. /**
  20816. * Pixel margin between the scrollbar and the axis elements.
  20817. *
  20818. * @type {number}
  20819. * @default 10
  20820. * @since 4.2.6
  20821. * @product highstock
  20822. * @apioption yAxis.scrollbar.margin
  20823. */
  20824. /**
  20825. * Whether to show the scrollbar when it is fully zoomed out at max
  20826. * range. Setting it to `false` on the Y axis makes the scrollbar stay
  20827. * hidden until the user zooms in, like common in browsers.
  20828. *
  20829. * @type {boolean}
  20830. * @default true
  20831. * @since 4.2.6
  20832. * @product highstock
  20833. * @apioption yAxis.scrollbar.showFull
  20834. */
  20835. /**
  20836. * The width of a vertical scrollbar or height of a horizontal
  20837. * scrollbar. Defaults to 20 on touch devices.
  20838. *
  20839. * @type {number}
  20840. * @default 14
  20841. * @since 4.2.6
  20842. * @product highstock
  20843. * @apioption yAxis.scrollbar.size
  20844. */
  20845. /**
  20846. * Z index of the scrollbar elements.
  20847. *
  20848. * @type {number}
  20849. * @default 3
  20850. * @since 4.2.6
  20851. * @product highstock
  20852. * @apioption yAxis.scrollbar.zIndex
  20853. */
  20854. /**
  20855. * A soft maximum for the axis. If the series data maximum is less
  20856. * than this, the axis will stay at this maximum, but if the series
  20857. * data maximum is higher, the axis will flex to show all data.
  20858. *
  20859. * **Note**: The [series.softThreshold](
  20860. * #plotOptions.series.softThreshold) option takes precedence over this
  20861. * option.
  20862. *
  20863. * @sample highcharts/yaxis/softmin-softmax/
  20864. * Soft min and max
  20865. *
  20866. * @type {number}
  20867. * @since 5.0.1
  20868. * @product highcharts highstock gantt
  20869. * @apioption yAxis.softMax
  20870. */
  20871. /**
  20872. * A soft minimum for the axis. If the series data minimum is greater
  20873. * than this, the axis will stay at this minimum, but if the series
  20874. * data minimum is lower, the axis will flex to show all data.
  20875. *
  20876. * **Note**: The [series.softThreshold](
  20877. * #plotOptions.series.softThreshold) option takes precedence over this
  20878. * option.
  20879. *
  20880. * @sample highcharts/yaxis/softmin-softmax/
  20881. * Soft min and max
  20882. *
  20883. * @type {number}
  20884. * @since 5.0.1
  20885. * @product highcharts highstock gantt
  20886. * @apioption yAxis.softMin
  20887. */
  20888. /**
  20889. * Defines the horizontal alignment of the stack total label. Can be one
  20890. * of `"left"`, `"center"` or `"right"`. The default value is calculated
  20891. * at runtime and depends on orientation and whether the stack is
  20892. * positive or negative.
  20893. *
  20894. * @sample {highcharts} highcharts/yaxis/stacklabels-align-left/
  20895. * Aligned to the left
  20896. * @sample {highcharts} highcharts/yaxis/stacklabels-align-center/
  20897. * Aligned in center
  20898. * @sample {highcharts} highcharts/yaxis/stacklabels-align-right/
  20899. * Aligned to the right
  20900. *
  20901. * @type {Highcharts.AlignValue}
  20902. * @since 2.1.5
  20903. * @product highcharts
  20904. * @apioption yAxis.stackLabels.align
  20905. */
  20906. /**
  20907. * A format string for the data label. Available variables are the same
  20908. * as for `formatter`.
  20909. *
  20910. * @type {string}
  20911. * @default {total}
  20912. * @since 3.0.2
  20913. * @product highcharts highstock
  20914. * @apioption yAxis.stackLabels.format
  20915. */
  20916. /**
  20917. * Rotation of the labels in degrees.
  20918. *
  20919. * @sample {highcharts} highcharts/yaxis/stacklabels-rotation/
  20920. * Labels rotated 45°
  20921. *
  20922. * @type {number}
  20923. * @default 0
  20924. * @since 2.1.5
  20925. * @product highcharts
  20926. * @apioption yAxis.stackLabels.rotation
  20927. */
  20928. /**
  20929. * The text alignment for the label. While `align` determines where the
  20930. * texts anchor point is placed with regards to the stack, `textAlign`
  20931. * determines how the text is aligned against its anchor point. Possible
  20932. * values are `"left"`, `"center"` and `"right"`. The default value is
  20933. * calculated at runtime and depends on orientation and whether the
  20934. * stack is positive or negative.
  20935. *
  20936. * @sample {highcharts} highcharts/yaxis/stacklabels-textalign-left/
  20937. * Label in center position but text-aligned left
  20938. *
  20939. * @type {Highcharts.AlignValue}
  20940. * @since 2.1.5
  20941. * @product highcharts
  20942. * @apioption yAxis.stackLabels.textAlign
  20943. */
  20944. /**
  20945. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20946. * to render the labels.
  20947. *
  20948. * @type {boolean}
  20949. * @default false
  20950. * @since 3.0
  20951. * @product highcharts highstock
  20952. * @apioption yAxis.stackLabels.useHTML
  20953. */
  20954. /**
  20955. * Defines the vertical alignment of the stack total label. Can be one
  20956. * of `"top"`, `"middle"` or `"bottom"`. The default value is calculated
  20957. * at runtime and depends on orientation and whether the stack is
  20958. * positive or negative.
  20959. *
  20960. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-top/
  20961. * Vertically aligned top
  20962. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-middle/
  20963. * Vertically aligned middle
  20964. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-bottom/
  20965. * Vertically aligned bottom
  20966. *
  20967. * @type {Highcharts.VerticalAlignValue}
  20968. * @since 2.1.5
  20969. * @product highcharts
  20970. * @apioption yAxis.stackLabels.verticalAlign
  20971. */
  20972. /**
  20973. * The x position offset of the label relative to the left of the
  20974. * stacked bar. The default value is calculated at runtime and depends
  20975. * on orientation and whether the stack is positive or negative.
  20976. *
  20977. * @sample {highcharts} highcharts/yaxis/stacklabels-x/
  20978. * Stack total labels with x offset
  20979. *
  20980. * @type {number}
  20981. * @since 2.1.5
  20982. * @product highcharts
  20983. * @apioption yAxis.stackLabels.x
  20984. */
  20985. /**
  20986. * The y position offset of the label relative to the tick position
  20987. * on the axis. The default value is calculated at runtime and depends
  20988. * on orientation and whether the stack is positive or negative.
  20989. *
  20990. * @sample {highcharts} highcharts/yaxis/stacklabels-y/
  20991. * Stack total labels with y offset
  20992. *
  20993. * @type {number}
  20994. * @since 2.1.5
  20995. * @product highcharts
  20996. * @apioption yAxis.stackLabels.y
  20997. */
  20998. /**
  20999. * Whether to force the axis to start on a tick. Use this option with
  21000. * the `maxPadding` option to control the axis start.
  21001. *
  21002. * This option is always disabled, when panning type is
  21003. * either `y` or `xy`.
  21004. *
  21005. * @see [type](#chart.panning.type)
  21006. *
  21007. * @sample {highcharts} highcharts/xaxis/startontick-false/
  21008. * False by default
  21009. * @sample {highcharts} highcharts/xaxis/startontick-true/
  21010. * True
  21011. * @sample {highstock} stock/xaxis/endontick/
  21012. * False for Y axis
  21013. *
  21014. * @since 1.2.0
  21015. * @product highcharts highstock gantt
  21016. */
  21017. startOnTick: true,
  21018. title: {
  21019. /**
  21020. * The pixel distance between the axis labels and the title.
  21021. * Positive values are outside the axis line, negative are inside.
  21022. *
  21023. * @sample {highcharts} highcharts/xaxis/title-margin/
  21024. * Y axis title margin of 60
  21025. *
  21026. * @type {number}
  21027. * @default 40
  21028. * @apioption yAxis.title.margin
  21029. */
  21030. /**
  21031. * The rotation of the text in degrees. 0 is horizontal, 270 is
  21032. * vertical reading from bottom to top.
  21033. *
  21034. * @sample {highcharts} highcharts/yaxis/title-offset/
  21035. * Horizontal
  21036. */
  21037. rotation: 270,
  21038. /**
  21039. * The actual text of the axis title. Horizontal texts can contain
  21040. * HTML, but rotated texts are painted using vector techniques and
  21041. * must be clean text. The Y axis title is disabled by setting the
  21042. * `text` option to `undefined`.
  21043. *
  21044. * @sample {highcharts} highcharts/xaxis/title-text/
  21045. * Custom HTML
  21046. *
  21047. * @type {string|null}
  21048. * @default {highcharts} Values
  21049. * @default {highstock} undefined
  21050. * @product highcharts highstock gantt
  21051. */
  21052. text: 'Values'
  21053. },
  21054. /**
  21055. * The top position of the Y axis. If it's a number, it is interpreted
  21056. * as pixel position relative to the chart.
  21057. *
  21058. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  21059. * percentages of the plot height, offset from plot area top.
  21060. *
  21061. * @see [yAxis.height](#yAxis.height)
  21062. *
  21063. * @sample {highstock} stock/demo/candlestick-and-volume/
  21064. * Percentage height panes
  21065. *
  21066. * @type {number|string}
  21067. * @product highcharts highstock
  21068. * @apioption yAxis.top
  21069. */
  21070. /**
  21071. * The stack labels show the total value for each bar in a stacked
  21072. * column or bar chart. The label will be placed on top of positive
  21073. * columns and below negative columns. In case of an inverted column
  21074. * chart or a bar chart the label is placed to the right of positive
  21075. * bars and to the left of negative bars.
  21076. *
  21077. * @product highcharts
  21078. */
  21079. stackLabels: {
  21080. /**
  21081. * Enable or disable the initial animation when a series is
  21082. * displayed for the `stackLabels`. The animation can also be set as
  21083. * a configuration object. Please note that this option only
  21084. * applies to the initial animation.
  21085. * For other animations, see [chart.animation](#chart.animation)
  21086. * and the animation parameter under the API methods.
  21087. * The following properties are supported:
  21088. *
  21089. * - `defer`: The animation delay time in milliseconds.
  21090. *
  21091. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  21092. * Animation defer settings
  21093. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  21094. * @since 8.2.0
  21095. * @apioption yAxis.stackLabels.animation
  21096. */
  21097. animation: {},
  21098. /**
  21099. * The animation delay time in milliseconds.
  21100. * Set to `0` renders stackLabel immediately.
  21101. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  21102. *
  21103. * @type {number}
  21104. * @since 8.2.0
  21105. * @apioption yAxis.stackLabels.animation.defer
  21106. */
  21107. /**
  21108. * Allow the stack labels to overlap.
  21109. *
  21110. * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
  21111. * Default false
  21112. *
  21113. * @since 5.0.13
  21114. * @product highcharts
  21115. */
  21116. allowOverlap: false,
  21117. /**
  21118. * The background color or gradient for the stack label.
  21119. *
  21120. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21121. * Stack labels box options
  21122. * @type {Highcharts.ColorType}
  21123. * @since 8.1.0
  21124. * @apioption yAxis.stackLabels.backgroundColor
  21125. */
  21126. /**
  21127. * The border color for the stack label. Defaults to `undefined`.
  21128. *
  21129. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21130. * Stack labels box options
  21131. * @type {Highcharts.ColorType}
  21132. * @since 8.1.0
  21133. * @apioption yAxis.stackLabels.borderColor
  21134. */
  21135. /**
  21136. * The border radius in pixels for the stack label.
  21137. *
  21138. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21139. * Stack labels box options
  21140. * @type {number}
  21141. * @default 0
  21142. * @since 8.1.0
  21143. * @apioption yAxis.stackLabels.borderRadius
  21144. */
  21145. /**
  21146. * The border width in pixels for the stack label.
  21147. *
  21148. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21149. * Stack labels box options
  21150. * @type {number}
  21151. * @default 0
  21152. * @since 8.1.0
  21153. * @apioption yAxis.stackLabels.borderWidth
  21154. */
  21155. /**
  21156. * Enable or disable the stack total labels.
  21157. *
  21158. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
  21159. * Enabled stack total labels
  21160. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled-waterfall/
  21161. * Enabled stack labels in waterfall chart
  21162. *
  21163. * @since 2.1.5
  21164. * @product highcharts
  21165. */
  21166. enabled: false,
  21167. /**
  21168. * Whether to hide stack labels that are outside the plot area.
  21169. * By default, the stack label is moved
  21170. * inside the plot area according to the
  21171. * [overflow](/highcharts/#yAxis/stackLabels/overflow)
  21172. * option.
  21173. *
  21174. * @type {boolean}
  21175. * @since 7.1.3
  21176. */
  21177. crop: true,
  21178. /**
  21179. * How to handle stack total labels that flow outside the plot area.
  21180. * The default is set to `"justify"`,
  21181. * which aligns them inside the plot area.
  21182. * For columns and bars, this means it will be moved inside the bar.
  21183. * To display stack labels outside the plot area,
  21184. * set `crop` to `false` and `overflow` to `"allow"`.
  21185. *
  21186. * @sample highcharts/yaxis/stacklabels-overflow/
  21187. * Stack labels flows outside the plot area.
  21188. *
  21189. * @type {Highcharts.DataLabelsOverflowValue}
  21190. * @since 7.1.3
  21191. */
  21192. overflow: 'justify',
  21193. /* eslint-disable valid-jsdoc */
  21194. /**
  21195. * Callback JavaScript function to format the label. The value is
  21196. * given by `this.total`.
  21197. *
  21198. * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
  21199. * Added units to stack total value
  21200. *
  21201. * @type {Highcharts.FormatterCallbackFunction<Highcharts.StackItemObject>}
  21202. * @since 2.1.5
  21203. * @product highcharts
  21204. */
  21205. formatter: function () {
  21206. var numberFormatter = this.axis.chart.numberFormatter;
  21207. /* eslint-enable valid-jsdoc */
  21208. return numberFormatter(this.total, -1);
  21209. },
  21210. /**
  21211. * CSS styles for the label.
  21212. *
  21213. * In styled mode, the styles are set in the
  21214. * `.highcharts-stack-label` class.
  21215. *
  21216. * @sample {highcharts} highcharts/yaxis/stacklabels-style/
  21217. * Red stack total labels
  21218. *
  21219. * @type {Highcharts.CSSObject}
  21220. * @since 2.1.5
  21221. * @product highcharts
  21222. */
  21223. style: {
  21224. /** @internal */
  21225. color: palette.neutralColor100,
  21226. /** @internal */
  21227. fontSize: '11px',
  21228. /** @internal */
  21229. fontWeight: 'bold',
  21230. /** @internal */
  21231. textOutline: '1px contrast'
  21232. }
  21233. },
  21234. gridLineWidth: 1,
  21235. lineWidth: 0
  21236. // tickWidth: 0
  21237. };
  21238. /**
  21239. * The Z axis or depth axis for 3D plots.
  21240. *
  21241. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  21242. * access to the axis.
  21243. *
  21244. * @sample {highcharts} highcharts/3d/scatter-zaxis-categories/
  21245. * Z-Axis with Categories
  21246. * @sample {highcharts} highcharts/3d/scatter-zaxis-grid/
  21247. * Z-Axis with styling
  21248. *
  21249. * @type {*|Array<*>}
  21250. * @extends xAxis
  21251. * @since 5.0.0
  21252. * @product highcharts
  21253. * @excluding breaks, crosshair, height, left, lineColor, lineWidth,
  21254. * nameToX, showEmpty, top, width
  21255. * @apioption zAxis
  21256. *
  21257. * @private
  21258. */
  21259. // This variable extends the defaultOptions for left axes.
  21260. Axis.defaultLeftAxisOptions = {
  21261. labels: {
  21262. x: -15
  21263. },
  21264. title: {
  21265. rotation: 270
  21266. }
  21267. };
  21268. // This variable extends the defaultOptions for right axes.
  21269. Axis.defaultRightAxisOptions = {
  21270. labels: {
  21271. x: 15
  21272. },
  21273. title: {
  21274. rotation: 90
  21275. }
  21276. };
  21277. // This variable extends the defaultOptions for bottom axes.
  21278. Axis.defaultBottomAxisOptions = {
  21279. labels: {
  21280. autoRotation: [-45],
  21281. x: 0
  21282. // overflow: undefined,
  21283. // staggerLines: null
  21284. },
  21285. margin: 15,
  21286. title: {
  21287. rotation: 0
  21288. }
  21289. };
  21290. // This variable extends the defaultOptions for top axes.
  21291. Axis.defaultTopAxisOptions = {
  21292. labels: {
  21293. autoRotation: [-45],
  21294. x: 0
  21295. // overflow: undefined
  21296. // staggerLines: null
  21297. },
  21298. margin: 15,
  21299. title: {
  21300. rotation: 0
  21301. }
  21302. };
  21303. // Properties to survive after destroy, needed for Axis.update (#4317,
  21304. // #5773, #5881).
  21305. Axis.keepProps = ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'];
  21306. return Axis;
  21307. }());
  21308. H.Axis = Axis;
  21309. return H.Axis;
  21310. });
  21311. _registerModule(_modules, 'Core/Axis/DateTimeAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21312. /* *
  21313. *
  21314. * (c) 2010-2021 Torstein Honsi
  21315. *
  21316. * License: www.highcharts.com/license
  21317. *
  21318. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21319. *
  21320. * */
  21321. var addEvent = U.addEvent,
  21322. getMagnitude = U.getMagnitude,
  21323. normalizeTickInterval = U.normalizeTickInterval,
  21324. timeUnits = U.timeUnits;
  21325. /* eslint-disable valid-jsdoc */
  21326. var DateTimeAxisAdditions = /** @class */ (function () {
  21327. /* *
  21328. *
  21329. * Constructors
  21330. *
  21331. * */
  21332. function DateTimeAxisAdditions(axis) {
  21333. this.axis = axis;
  21334. }
  21335. /* *
  21336. *
  21337. * Functions
  21338. *
  21339. * */
  21340. /**
  21341. * Get a normalized tick interval for dates. Returns a configuration object
  21342. * with unit range (interval), count and name. Used to prepare data for
  21343. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21344. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21345. * logic was extracted in order to prevent it for running over again for
  21346. * each segment having the same interval. #662, #697.
  21347. * @private
  21348. */
  21349. /**
  21350. * Get a normalized tick interval for dates. Returns a configuration object
  21351. * with unit range (interval), count and name. Used to prepare data for
  21352. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21353. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21354. * logic was extracted in order to prevent it for running over again for
  21355. * each segment having the same interval. #662, #697.
  21356. * @private
  21357. */
  21358. DateTimeAxisAdditions.prototype.normalizeTimeTickInterval = function (tickInterval, unitsOption) {
  21359. var units = unitsOption || [[
  21360. 'millisecond',
  21361. [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  21362. ],
  21363. [
  21364. 'second',
  21365. [1, 2, 5, 10, 15, 30]
  21366. ],
  21367. [
  21368. 'minute',
  21369. [1, 2, 5, 10, 15, 30]
  21370. ],
  21371. [
  21372. 'hour',
  21373. [1, 2, 3, 4, 6, 8, 12]
  21374. ],
  21375. [
  21376. 'day',
  21377. [1, 2]
  21378. ],
  21379. [
  21380. 'week',
  21381. [1, 2]
  21382. ],
  21383. [
  21384. 'month',
  21385. [1, 2, 3, 4, 6]
  21386. ],
  21387. [
  21388. 'year',
  21389. null
  21390. ]],
  21391. unit = units[units.length - 1], // default unit is years
  21392. interval = timeUnits[unit[0]],
  21393. multiples = unit[1],
  21394. count,
  21395. i;
  21396. // loop through the units to find the one that best fits the
  21397. // tickInterval
  21398. for (i = 0; i < units.length; i++) {
  21399. unit = units[i];
  21400. interval = timeUnits[unit[0]];
  21401. multiples = unit[1];
  21402. if (units[i + 1]) {
  21403. // lessThan is in the middle between the highest multiple and
  21404. // the next unit.
  21405. var lessThan = (interval *
  21406. multiples[multiples.length - 1] +
  21407. timeUnits[units[i + 1][0]]) / 2;
  21408. // break and keep the current unit
  21409. if (tickInterval <= lessThan) {
  21410. break;
  21411. }
  21412. }
  21413. }
  21414. // prevent 2.5 years intervals, though 25, 250 etc. are allowed
  21415. if (interval === timeUnits.year && tickInterval < 5 * interval) {
  21416. multiples = [1, 2, 5];
  21417. }
  21418. // get the count
  21419. count = normalizeTickInterval(tickInterval / interval, multiples, unit[0] === 'year' ? // #1913, #2360
  21420. Math.max(getMagnitude(tickInterval / interval), 1) :
  21421. 1);
  21422. return {
  21423. unitRange: interval,
  21424. count: count,
  21425. unitName: unit[0]
  21426. };
  21427. };
  21428. return DateTimeAxisAdditions;
  21429. }());
  21430. /**
  21431. * Date and time support for axes.
  21432. *
  21433. * @private
  21434. * @class
  21435. */
  21436. var DateTimeAxis = /** @class */ (function () {
  21437. function DateTimeAxis() {
  21438. }
  21439. /* *
  21440. *
  21441. * Static Functions
  21442. *
  21443. * */
  21444. /**
  21445. * Extends axis class with date and time support.
  21446. * @private
  21447. */
  21448. DateTimeAxis.compose = function (AxisClass) {
  21449. AxisClass.keepProps.push('dateTime');
  21450. var axisProto = AxisClass.prototype;
  21451. /**
  21452. * Set the tick positions to a time unit that makes sense, for example
  21453. * on the first of each month or on every Monday. Return an array with
  21454. * the time positions. Used in datetime axes as well as for grouping
  21455. * data on a datetime axis.
  21456. *
  21457. * @private
  21458. * @function Highcharts.Axis#getTimeTicks
  21459. *
  21460. * @param {Highcharts.TimeNormalizeObject} normalizedInterval
  21461. * The interval in axis values (ms) and thecount.
  21462. *
  21463. * @param {number} min
  21464. * The minimum in axis values.
  21465. *
  21466. * @param {number} max
  21467. * The maximum in axis values.
  21468. *
  21469. * @param {number} startOfWeek
  21470. *
  21471. * @return {Highcharts.AxisTickPositionsArray}
  21472. */
  21473. axisProto.getTimeTicks = function () {
  21474. return this.chart.time.getTimeTicks.apply(this.chart.time, arguments);
  21475. };
  21476. /* eslint-disable no-invalid-this */
  21477. addEvent(AxisClass, 'init', function (e) {
  21478. var axis = this;
  21479. var options = e.userOptions;
  21480. if (options.type !== 'datetime') {
  21481. axis.dateTime = void 0;
  21482. return;
  21483. }
  21484. if (!axis.dateTime) {
  21485. axis.dateTime = new DateTimeAxisAdditions(axis);
  21486. }
  21487. });
  21488. /* eslint-enable no-invalid-this */
  21489. };
  21490. /* *
  21491. *
  21492. * Static Properties
  21493. *
  21494. * */
  21495. DateTimeAxis.AdditionsClass = DateTimeAxisAdditions;
  21496. return DateTimeAxis;
  21497. }());
  21498. DateTimeAxis.compose(Axis);
  21499. return DateTimeAxis;
  21500. });
  21501. _registerModule(_modules, 'Core/Axis/LogarithmicAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21502. /* *
  21503. *
  21504. * (c) 2010-2021 Torstein Honsi
  21505. *
  21506. * License: www.highcharts.com/license
  21507. *
  21508. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21509. *
  21510. * */
  21511. var addEvent = U.addEvent,
  21512. getMagnitude = U.getMagnitude,
  21513. normalizeTickInterval = U.normalizeTickInterval,
  21514. pick = U.pick;
  21515. /* eslint-disable valid-jsdoc */
  21516. /**
  21517. * Provides logarithmic support for axes.
  21518. *
  21519. * @private
  21520. * @class
  21521. */
  21522. var LogarithmicAxisAdditions = /** @class */ (function () {
  21523. /* *
  21524. *
  21525. * Constructors
  21526. *
  21527. * */
  21528. function LogarithmicAxisAdditions(axis) {
  21529. this.axis = axis;
  21530. }
  21531. /* *
  21532. *
  21533. * Functions
  21534. *
  21535. * */
  21536. /**
  21537. * Set the tick positions of a logarithmic axis.
  21538. */
  21539. LogarithmicAxisAdditions.prototype.getLogTickPositions = function (interval, min, max, minor) {
  21540. var log = this;
  21541. var axis = log.axis;
  21542. var axisLength = axis.len;
  21543. var options = axis.options;
  21544. // Since we use this method for both major and minor ticks,
  21545. // use a local variable and return the result
  21546. var positions = [];
  21547. // Reset
  21548. if (!minor) {
  21549. log.minorAutoInterval = void 0;
  21550. }
  21551. // First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
  21552. if (interval >= 0.5) {
  21553. interval = Math.round(interval);
  21554. positions = axis.getLinearTickPositions(interval, min, max);
  21555. // Second case: We need intermediary ticks. For example
  21556. // 1, 2, 4, 6, 8, 10, 20, 40 etc.
  21557. }
  21558. else if (interval >= 0.08) {
  21559. var roundedMin = Math.floor(min),
  21560. intermediate = void 0,
  21561. i = void 0,
  21562. j = void 0,
  21563. len = void 0,
  21564. pos = void 0,
  21565. lastPos = void 0,
  21566. break2 = void 0;
  21567. if (interval > 0.3) {
  21568. intermediate = [1, 2, 4];
  21569. // 0.2 equals five minor ticks per 1, 10, 100 etc
  21570. }
  21571. else if (interval > 0.15) {
  21572. intermediate = [1, 2, 4, 6, 8];
  21573. }
  21574. else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
  21575. intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  21576. }
  21577. for (i = roundedMin; i < max + 1 && !break2; i++) {
  21578. len = intermediate.length;
  21579. for (j = 0; j < len && !break2; j++) {
  21580. pos = log.log2lin(log.lin2log(i) * intermediate[j]);
  21581. // #1670, lastPos is #3113
  21582. if (pos > min &&
  21583. (!minor || lastPos <= max) &&
  21584. typeof lastPos !== 'undefined') {
  21585. positions.push(lastPos);
  21586. }
  21587. if (lastPos > max) {
  21588. break2 = true;
  21589. }
  21590. lastPos = pos;
  21591. }
  21592. }
  21593. // Third case: We are so deep in between whole logarithmic values that
  21594. // we might as well handle the tick positions like a linear axis. For
  21595. // example 1.01, 1.02, 1.03, 1.04.
  21596. }
  21597. else {
  21598. var realMin = log.lin2log(min),
  21599. realMax = log.lin2log(max),
  21600. tickIntervalOption = minor ?
  21601. axis.getMinorTickInterval() :
  21602. options.tickInterval,
  21603. filteredTickIntervalOption = tickIntervalOption === 'auto' ?
  21604. null :
  21605. tickIntervalOption,
  21606. tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
  21607. totalPixelLength = minor ?
  21608. axisLength / axis.tickPositions.length :
  21609. axisLength;
  21610. interval = pick(filteredTickIntervalOption, log.minorAutoInterval, (realMax - realMin) *
  21611. tickPixelIntervalOption / (totalPixelLength || 1));
  21612. interval = normalizeTickInterval(interval, void 0, getMagnitude(interval));
  21613. positions = axis.getLinearTickPositions(interval, realMin, realMax).map(log.log2lin);
  21614. if (!minor) {
  21615. log.minorAutoInterval = interval / 5;
  21616. }
  21617. }
  21618. // Set the axis-level tickInterval variable
  21619. if (!minor) {
  21620. axis.tickInterval = interval;
  21621. }
  21622. return positions;
  21623. };
  21624. LogarithmicAxisAdditions.prototype.lin2log = function (num) {
  21625. return Math.pow(10, num);
  21626. };
  21627. LogarithmicAxisAdditions.prototype.log2lin = function (num) {
  21628. return Math.log(num) / Math.LN10;
  21629. };
  21630. return LogarithmicAxisAdditions;
  21631. }());
  21632. var LogarithmicAxis = /** @class */ (function () {
  21633. function LogarithmicAxis() {
  21634. }
  21635. /**
  21636. * Provides logarithmic support for axes.
  21637. *
  21638. * @private
  21639. */
  21640. LogarithmicAxis.compose = function (AxisClass) {
  21641. AxisClass.keepProps.push('logarithmic');
  21642. /* eslint-disable no-invalid-this */
  21643. addEvent(AxisClass, 'init', function (e) {
  21644. var axis = this;
  21645. var options = e.userOptions;
  21646. var logarithmic = axis.logarithmic;
  21647. if (options.type !== 'logarithmic') {
  21648. axis.logarithmic = void 0;
  21649. }
  21650. else {
  21651. if (!logarithmic) {
  21652. logarithmic = axis.logarithmic = new LogarithmicAxisAdditions(axis);
  21653. }
  21654. }
  21655. });
  21656. addEvent(AxisClass, 'afterInit', function () {
  21657. var axis = this;
  21658. var log = axis.logarithmic;
  21659. // extend logarithmic axis
  21660. if (log) {
  21661. axis.lin2val = function (num) {
  21662. return log.lin2log(num);
  21663. };
  21664. axis.val2lin = function (num) {
  21665. return log.log2lin(num);
  21666. };
  21667. }
  21668. });
  21669. };
  21670. return LogarithmicAxis;
  21671. }());
  21672. LogarithmicAxis.compose(Axis); // @todo move to factory functions
  21673. return LogarithmicAxis;
  21674. });
  21675. _registerModule(_modules, 'Core/Axis/PlotLineOrBand.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (Axis, H, palette, U) {
  21676. /* *
  21677. *
  21678. * (c) 2010-2021 Torstein Honsi
  21679. *
  21680. * License: www.highcharts.com/license
  21681. *
  21682. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21683. *
  21684. * */
  21685. /**
  21686. * Options for plot bands on axes.
  21687. *
  21688. * @typedef {Highcharts.XAxisPlotBandsOptions|Highcharts.YAxisPlotBandsOptions|Highcharts.ZAxisPlotBandsOptions} Highcharts.AxisPlotBandsOptions
  21689. */
  21690. /**
  21691. * Options for plot band labels on axes.
  21692. *
  21693. * @typedef {Highcharts.XAxisPlotBandsLabelOptions|Highcharts.YAxisPlotBandsLabelOptions|Highcharts.ZAxisPlotBandsLabelOptions} Highcharts.AxisPlotBandsLabelOptions
  21694. */
  21695. /**
  21696. * Options for plot lines on axes.
  21697. *
  21698. * @typedef {Highcharts.XAxisPlotLinesOptions|Highcharts.YAxisPlotLinesOptions|Highcharts.ZAxisPlotLinesOptions} Highcharts.AxisPlotLinesOptions
  21699. */
  21700. /**
  21701. * Options for plot line labels on axes.
  21702. *
  21703. * @typedef {Highcharts.XAxisPlotLinesLabelOptions|Highcharts.YAxisPlotLinesLabelOptions|Highcharts.ZAxisPlotLinesLabelOptions} Highcharts.AxisPlotLinesLabelOptions
  21704. */
  21705. var arrayMax = U.arrayMax,
  21706. arrayMin = U.arrayMin,
  21707. defined = U.defined,
  21708. destroyObjectProperties = U.destroyObjectProperties,
  21709. erase = U.erase,
  21710. extend = U.extend,
  21711. fireEvent = U.fireEvent,
  21712. isNumber = U.isNumber,
  21713. merge = U.merge,
  21714. objectEach = U.objectEach,
  21715. pick = U.pick;
  21716. /* eslint-disable no-invalid-this, valid-jsdoc */
  21717. /**
  21718. * The object wrapper for plot lines and plot bands
  21719. *
  21720. * @class
  21721. * @name Highcharts.PlotLineOrBand
  21722. *
  21723. * @param {Highcharts.Axis} axis
  21724. *
  21725. * @param {Highcharts.AxisPlotLinesOptions|Highcharts.AxisPlotBandsOptions} [options]
  21726. */
  21727. var PlotLineOrBand = /** @class */ (function () {
  21728. function PlotLineOrBand(axis, options) {
  21729. this.axis = axis;
  21730. if (options) {
  21731. this.options = options;
  21732. this.id = options.id;
  21733. }
  21734. }
  21735. /**
  21736. * Render the plot line or plot band. If it is already existing,
  21737. * move it.
  21738. *
  21739. * @private
  21740. * @function Highcharts.PlotLineOrBand#render
  21741. * @return {Highcharts.PlotLineOrBand|undefined}
  21742. */
  21743. PlotLineOrBand.prototype.render = function () {
  21744. fireEvent(this, 'render');
  21745. var plotLine = this,
  21746. axis = plotLine.axis,
  21747. horiz = axis.horiz,
  21748. log = axis.logarithmic,
  21749. options = plotLine.options,
  21750. optionsLabel = options.label,
  21751. label = plotLine.label,
  21752. to = options.to,
  21753. from = options.from,
  21754. value = options.value,
  21755. isBand = defined(from) && defined(to),
  21756. isLine = defined(value),
  21757. svgElem = plotLine.svgElem,
  21758. isNew = !svgElem,
  21759. path = [],
  21760. color = options.color,
  21761. zIndex = pick(options.zIndex, 0),
  21762. events = options.events,
  21763. attribs = {
  21764. 'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') +
  21765. (options.className || '')
  21766. },
  21767. groupAttribs = {},
  21768. renderer = axis.chart.renderer,
  21769. groupName = isBand ? 'bands' : 'lines',
  21770. group;
  21771. // logarithmic conversion
  21772. if (log) {
  21773. from = log.log2lin(from);
  21774. to = log.log2lin(to);
  21775. value = log.log2lin(value);
  21776. }
  21777. // Set the presentational attributes
  21778. if (!axis.chart.styledMode) {
  21779. if (isLine) {
  21780. attribs.stroke = color || palette.neutralColor40;
  21781. attribs['stroke-width'] = pick(options.width, 1);
  21782. if (options.dashStyle) {
  21783. attribs.dashstyle =
  21784. options.dashStyle;
  21785. }
  21786. }
  21787. else if (isBand) { // plot band
  21788. attribs.fill = color || palette.highlightColor10;
  21789. if (options.borderWidth) {
  21790. attribs.stroke = options.borderColor;
  21791. attribs['stroke-width'] = options.borderWidth;
  21792. }
  21793. }
  21794. }
  21795. // Grouping and zIndex
  21796. groupAttribs.zIndex = zIndex;
  21797. groupName += '-' + zIndex;
  21798. group = axis.plotLinesAndBandsGroups[groupName];
  21799. if (!group) {
  21800. axis.plotLinesAndBandsGroups[groupName] = group =
  21801. renderer.g('plot-' + groupName)
  21802. .attr(groupAttribs).add();
  21803. }
  21804. // Create the path
  21805. if (isNew) {
  21806. /**
  21807. * SVG element of the plot line or band.
  21808. *
  21809. * @name Highcharts.PlotLineOrBand#svgElement
  21810. * @type {Highcharts.SVGElement}
  21811. */
  21812. plotLine.svgElem = svgElem = renderer
  21813. .path()
  21814. .attr(attribs)
  21815. .add(group);
  21816. }
  21817. // Set the path or return
  21818. if (isLine) {
  21819. path = axis.getPlotLinePath({
  21820. value: value,
  21821. lineWidth: svgElem.strokeWidth(),
  21822. acrossPanes: options.acrossPanes
  21823. });
  21824. }
  21825. else if (isBand) { // plot band
  21826. path = axis.getPlotBandPath(from, to, options);
  21827. }
  21828. else {
  21829. return;
  21830. }
  21831. // common for lines and bands
  21832. // Add events only if they were not added before.
  21833. if (!plotLine.eventsAdded && events) {
  21834. objectEach(events, function (event, eventType) {
  21835. svgElem.on(eventType, function (e) {
  21836. events[eventType].apply(plotLine, [e]);
  21837. });
  21838. });
  21839. plotLine.eventsAdded = true;
  21840. }
  21841. if ((isNew || !svgElem.d) && path && path.length) {
  21842. svgElem.attr({ d: path });
  21843. }
  21844. else if (svgElem) {
  21845. if (path) {
  21846. svgElem.show(true);
  21847. svgElem.animate({ d: path });
  21848. }
  21849. else if (svgElem.d) {
  21850. svgElem.hide();
  21851. if (label) {
  21852. plotLine.label = label = label.destroy();
  21853. }
  21854. }
  21855. }
  21856. // the plot band/line label
  21857. if (optionsLabel &&
  21858. (defined(optionsLabel.text) || defined(optionsLabel.formatter)) &&
  21859. path &&
  21860. path.length &&
  21861. axis.width > 0 &&
  21862. axis.height > 0 &&
  21863. !path.isFlat) {
  21864. // apply defaults
  21865. optionsLabel = merge({
  21866. align: horiz && isBand && 'center',
  21867. x: horiz ? !isBand && 4 : 10,
  21868. verticalAlign: !horiz && isBand && 'middle',
  21869. y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
  21870. rotation: horiz && !isBand && 90
  21871. }, optionsLabel);
  21872. this.renderLabel(optionsLabel, path, isBand, zIndex);
  21873. }
  21874. else if (label) { // move out of sight
  21875. label.hide();
  21876. }
  21877. // chainable
  21878. return plotLine;
  21879. };
  21880. /**
  21881. * Render and align label for plot line or band.
  21882. *
  21883. * @private
  21884. * @function Highcharts.PlotLineOrBand#renderLabel
  21885. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  21886. * @param {Highcharts.SVGPathArray} path
  21887. * @param {boolean} [isBand]
  21888. * @param {number} [zIndex]
  21889. * @return {void}
  21890. */
  21891. PlotLineOrBand.prototype.renderLabel = function (optionsLabel, path, isBand, zIndex) {
  21892. var plotLine = this,
  21893. label = plotLine.label,
  21894. renderer = plotLine.axis.chart.renderer,
  21895. attribs,
  21896. xBounds,
  21897. yBounds,
  21898. x,
  21899. y,
  21900. labelText;
  21901. // add the SVG element
  21902. if (!label) {
  21903. attribs = {
  21904. align: optionsLabel.textAlign || optionsLabel.align,
  21905. rotation: optionsLabel.rotation,
  21906. 'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') +
  21907. '-label ' + (optionsLabel.className || '')
  21908. };
  21909. attribs.zIndex = zIndex;
  21910. labelText = this.getLabelText(optionsLabel);
  21911. /**
  21912. * SVG element of the label.
  21913. *
  21914. * @name Highcharts.PlotLineOrBand#label
  21915. * @type {Highcharts.SVGElement}
  21916. */
  21917. plotLine.label = label = renderer
  21918. .text(labelText, 0, 0, optionsLabel.useHTML)
  21919. .attr(attribs)
  21920. .add();
  21921. if (!this.axis.chart.styledMode) {
  21922. label.css(optionsLabel.style);
  21923. }
  21924. }
  21925. // get the bounding box and align the label
  21926. // #3000 changed to better handle choice between plotband or plotline
  21927. xBounds = path.xBounds ||
  21928. [path[0][1], path[1][1], (isBand ? path[2][1] : path[0][1])];
  21929. yBounds = path.yBounds ||
  21930. [path[0][2], path[1][2], (isBand ? path[2][2] : path[0][2])];
  21931. x = arrayMin(xBounds);
  21932. y = arrayMin(yBounds);
  21933. label.align(optionsLabel, false, {
  21934. x: x,
  21935. y: y,
  21936. width: arrayMax(xBounds) - x,
  21937. height: arrayMax(yBounds) - y
  21938. });
  21939. label.show(true);
  21940. };
  21941. /**
  21942. * Get label's text content.
  21943. *
  21944. * @private
  21945. * @function Highcharts.PlotLineOrBand#getLabelText
  21946. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  21947. * @return {string}
  21948. */
  21949. PlotLineOrBand.prototype.getLabelText = function (optionsLabel) {
  21950. return defined(optionsLabel.formatter) ?
  21951. optionsLabel.formatter
  21952. .call(this) :
  21953. optionsLabel.text;
  21954. };
  21955. /**
  21956. * Remove the plot line or band.
  21957. *
  21958. * @function Highcharts.PlotLineOrBand#destroy
  21959. * @return {void}
  21960. */
  21961. PlotLineOrBand.prototype.destroy = function () {
  21962. // remove it from the lookup
  21963. erase(this.axis.plotLinesAndBands, this);
  21964. delete this.axis;
  21965. destroyObjectProperties(this);
  21966. };
  21967. return PlotLineOrBand;
  21968. }());
  21969. /* eslint-enable no-invalid-this, valid-jsdoc */
  21970. // Object with members for extending the Axis prototype
  21971. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  21972. /**
  21973. * An array of colored bands stretching across the plot area marking an
  21974. * interval on the axis.
  21975. *
  21976. * In styled mode, the plot bands are styled by the `.highcharts-plot-band`
  21977. * class in addition to the `className` option.
  21978. *
  21979. * @productdesc {highcharts}
  21980. * In a gauge, a plot band on the Y axis (value axis) will stretch along the
  21981. * perimeter of the gauge.
  21982. *
  21983. * @type {Array<*>}
  21984. * @product highcharts highstock gantt
  21985. * @apioption xAxis.plotBands
  21986. */
  21987. /**
  21988. * Flag to decide if plotBand should be rendered across all panes.
  21989. *
  21990. * @since 7.1.2
  21991. * @product highstock
  21992. * @type {boolean}
  21993. * @default true
  21994. * @apioption xAxis.plotBands.acrossPanes
  21995. */
  21996. /**
  21997. * Border color for the plot band. Also requires `borderWidth` to be set.
  21998. *
  21999. * @type {Highcharts.ColorString}
  22000. * @apioption xAxis.plotBands.borderColor
  22001. */
  22002. /**
  22003. * Border width for the plot band. Also requires `borderColor` to be set.
  22004. *
  22005. * @type {number}
  22006. * @default 0
  22007. * @apioption xAxis.plotBands.borderWidth
  22008. */
  22009. /**
  22010. * A custom class name, in addition to the default `highcharts-plot-band`,
  22011. * to apply to each individual band.
  22012. *
  22013. * @type {string}
  22014. * @since 5.0.0
  22015. * @apioption xAxis.plotBands.className
  22016. */
  22017. /**
  22018. * The color of the plot band.
  22019. *
  22020. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22021. * Color band
  22022. * @sample {highstock} stock/xaxis/plotbands/
  22023. * Plot band on Y axis
  22024. *
  22025. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  22026. * @default ${palette.highlightColor10}
  22027. * @apioption xAxis.plotBands.color
  22028. */
  22029. /**
  22030. * An object defining mouse events for the plot band. Supported properties
  22031. * are `click`, `mouseover`, `mouseout`, `mousemove`.
  22032. *
  22033. * @sample {highcharts} highcharts/xaxis/plotbands-events/
  22034. * Mouse events demonstrated
  22035. *
  22036. * @since 1.2
  22037. * @apioption xAxis.plotBands.events
  22038. */
  22039. /**
  22040. * Click event on a plot band.
  22041. *
  22042. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22043. * @apioption xAxis.plotBands.events.click
  22044. */
  22045. /**
  22046. * Mouse move event on a plot band.
  22047. *
  22048. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22049. * @apioption xAxis.plotBands.events.mousemove
  22050. */
  22051. /**
  22052. * Mouse out event on the corner of a plot band.
  22053. *
  22054. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22055. * @apioption xAxis.plotBands.events.mouseout
  22056. */
  22057. /**
  22058. * Mouse over event on a plot band.
  22059. *
  22060. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22061. * @apioption xAxis.plotBands.events.mouseover
  22062. */
  22063. /**
  22064. * The start position of the plot band in axis units.
  22065. *
  22066. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22067. * Datetime axis
  22068. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22069. * Categorized axis
  22070. * @sample {highstock} stock/xaxis/plotbands/
  22071. * Plot band on Y axis
  22072. *
  22073. * @type {number}
  22074. * @apioption xAxis.plotBands.from
  22075. */
  22076. /**
  22077. * An id used for identifying the plot band in Axis.removePlotBand.
  22078. *
  22079. * @sample {highcharts} highcharts/xaxis/plotbands-id/
  22080. * Remove plot band by id
  22081. * @sample {highstock} highcharts/xaxis/plotbands-id/
  22082. * Remove plot band by id
  22083. *
  22084. * @type {string}
  22085. * @apioption xAxis.plotBands.id
  22086. */
  22087. /**
  22088. * The end position of the plot band in axis units.
  22089. *
  22090. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22091. * Datetime axis
  22092. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22093. * Categorized axis
  22094. * @sample {highstock} stock/xaxis/plotbands/
  22095. * Plot band on Y axis
  22096. *
  22097. * @type {number}
  22098. * @apioption xAxis.plotBands.to
  22099. */
  22100. /**
  22101. * The z index of the plot band within the chart, relative to other
  22102. * elements. Using the same z index as another element may give
  22103. * unpredictable results, as the last rendered element will be on top.
  22104. * Values from 0 to 20 make sense.
  22105. *
  22106. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22107. * Behind plot lines by default
  22108. * @sample {highcharts} highcharts/xaxis/plotbands-zindex/
  22109. * Above plot lines
  22110. * @sample {highcharts} highcharts/xaxis/plotbands-zindex-above-series/
  22111. * Above plot lines and series
  22112. *
  22113. * @type {number}
  22114. * @since 1.2
  22115. * @apioption xAxis.plotBands.zIndex
  22116. */
  22117. /**
  22118. * Text labels for the plot bands
  22119. *
  22120. * @product highcharts highstock gantt
  22121. * @apioption xAxis.plotBands.label
  22122. */
  22123. /**
  22124. * Horizontal alignment of the label. Can be one of "left", "center" or
  22125. * "right".
  22126. *
  22127. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22128. * Aligned to the right
  22129. * @sample {highstock} stock/xaxis/plotbands-label/
  22130. * Plot band with labels
  22131. *
  22132. * @type {Highcharts.AlignValue}
  22133. * @default center
  22134. * @since 2.1
  22135. * @apioption xAxis.plotBands.label.align
  22136. */
  22137. /**
  22138. * Rotation of the text label in degrees .
  22139. *
  22140. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22141. * Vertical text
  22142. *
  22143. * @type {number}
  22144. * @default 0
  22145. * @since 2.1
  22146. * @apioption xAxis.plotBands.label.rotation
  22147. */
  22148. /**
  22149. * CSS styles for the text label.
  22150. *
  22151. * In styled mode, the labels are styled by the
  22152. * `.highcharts-plot-band-label` class.
  22153. *
  22154. * @sample {highcharts} highcharts/xaxis/plotbands-label-style/
  22155. * Blue and bold label
  22156. *
  22157. * @type {Highcharts.CSSObject}
  22158. * @since 2.1
  22159. * @apioption xAxis.plotBands.label.style
  22160. */
  22161. /**
  22162. * The string text itself. A subset of HTML is supported.
  22163. *
  22164. * @type {string}
  22165. * @since 2.1
  22166. * @apioption xAxis.plotBands.label.text
  22167. */
  22168. /**
  22169. * The text alignment for the label. While `align` determines where the
  22170. * texts anchor point is placed within the plot band, `textAlign` determines
  22171. * how the text is aligned against its anchor point. Possible values are
  22172. * "left", "center" and "right". Defaults to the same as the `align` option.
  22173. *
  22174. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22175. * Vertical text in center position but text-aligned left
  22176. *
  22177. * @type {Highcharts.AlignValue}
  22178. * @since 2.1
  22179. * @apioption xAxis.plotBands.label.textAlign
  22180. */
  22181. /**
  22182. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22183. * to render the labels.
  22184. *
  22185. * @type {boolean}
  22186. * @default false
  22187. * @since 3.0.3
  22188. * @apioption xAxis.plotBands.label.useHTML
  22189. */
  22190. /**
  22191. * Vertical alignment of the label relative to the plot band. Can be one of
  22192. * "top", "middle" or "bottom".
  22193. *
  22194. * @sample {highcharts} highcharts/xaxis/plotbands-label-verticalalign/
  22195. * Vertically centered label
  22196. * @sample {highstock} stock/xaxis/plotbands-label/
  22197. * Plot band with labels
  22198. *
  22199. * @type {Highcharts.VerticalAlignValue}
  22200. * @default top
  22201. * @since 2.1
  22202. * @apioption xAxis.plotBands.label.verticalAlign
  22203. */
  22204. /**
  22205. * Horizontal position relative the alignment. Default varies by
  22206. * orientation.
  22207. *
  22208. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22209. * Aligned 10px from the right edge
  22210. * @sample {highstock} stock/xaxis/plotbands-label/
  22211. * Plot band with labels
  22212. *
  22213. * @type {number}
  22214. * @since 2.1
  22215. * @apioption xAxis.plotBands.label.x
  22216. */
  22217. /**
  22218. * Vertical position of the text baseline relative to the alignment. Default
  22219. * varies by orientation.
  22220. *
  22221. * @sample {highcharts} highcharts/xaxis/plotbands-label-y/
  22222. * Label on x axis
  22223. * @sample {highstock} stock/xaxis/plotbands-label/
  22224. * Plot band with labels
  22225. *
  22226. * @type {number}
  22227. * @since 2.1
  22228. * @apioption xAxis.plotBands.label.y
  22229. */
  22230. /**
  22231. * An array of lines stretching across the plot area, marking a specific
  22232. * value on one of the axes.
  22233. *
  22234. * In styled mode, the plot lines are styled by the
  22235. * `.highcharts-plot-line` class in addition to the `className` option.
  22236. *
  22237. * @type {Array<*>}
  22238. * @product highcharts highstock gantt
  22239. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22240. * Basic plot line
  22241. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  22242. * Solid gauge plot line
  22243. * @apioption xAxis.plotLines
  22244. */
  22245. /**
  22246. * Flag to decide if plotLine should be rendered across all panes.
  22247. *
  22248. * @sample {highstock} stock/xaxis/plotlines-acrosspanes/
  22249. * Plot lines on different panes
  22250. *
  22251. * @since 7.1.2
  22252. * @product highstock
  22253. * @type {boolean}
  22254. * @default true
  22255. * @apioption xAxis.plotLines.acrossPanes
  22256. */
  22257. /**
  22258. * A custom class name, in addition to the default `highcharts-plot-line`,
  22259. * to apply to each individual line.
  22260. *
  22261. * @type {string}
  22262. * @since 5.0.0
  22263. * @apioption xAxis.plotLines.className
  22264. */
  22265. /**
  22266. * The color of the line.
  22267. *
  22268. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22269. * A red line from X axis
  22270. * @sample {highstock} stock/xaxis/plotlines/
  22271. * Plot line on Y axis
  22272. *
  22273. * @type {Highcharts.ColorString}
  22274. * @default ${palette.neutralColor40}
  22275. * @apioption xAxis.plotLines.color
  22276. */
  22277. /**
  22278. * The dashing or dot style for the plot line. For possible values see
  22279. * [this overview](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  22280. *
  22281. * @sample {highcharts} highcharts/xaxis/plotlines-dashstyle/
  22282. * Dash and dot pattern
  22283. * @sample {highstock} stock/xaxis/plotlines/
  22284. * Plot line on Y axis
  22285. *
  22286. * @type {Highcharts.DashStyleValue}
  22287. * @default Solid
  22288. * @since 1.2
  22289. * @apioption xAxis.plotLines.dashStyle
  22290. */
  22291. /**
  22292. * An object defining mouse events for the plot line. Supported
  22293. * properties are `click`, `mouseover`, `mouseout`, `mousemove`.
  22294. *
  22295. * @sample {highcharts} highcharts/xaxis/plotlines-events/
  22296. * Mouse events demonstrated
  22297. *
  22298. * @since 1.2
  22299. * @apioption xAxis.plotLines.events
  22300. */
  22301. /**
  22302. * Click event on a plot band.
  22303. *
  22304. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22305. * @apioption xAxis.plotLines.events.click
  22306. */
  22307. /**
  22308. * Mouse move event on a plot band.
  22309. *
  22310. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22311. * @apioption xAxis.plotLines.events.mousemove
  22312. */
  22313. /**
  22314. * Mouse out event on the corner of a plot band.
  22315. *
  22316. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22317. * @apioption xAxis.plotLines.events.mouseout
  22318. */
  22319. /**
  22320. * Mouse over event on a plot band.
  22321. *
  22322. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22323. * @apioption xAxis.plotLines.events.mouseover
  22324. */
  22325. /**
  22326. * An id used for identifying the plot line in Axis.removePlotLine.
  22327. *
  22328. * @sample {highcharts} highcharts/xaxis/plotlines-id/
  22329. * Remove plot line by id
  22330. *
  22331. * @type {string}
  22332. * @apioption xAxis.plotLines.id
  22333. */
  22334. /**
  22335. * The position of the line in axis units.
  22336. *
  22337. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22338. * Between two categories on X axis
  22339. * @sample {highstock} stock/xaxis/plotlines/
  22340. * Plot line on Y axis
  22341. *
  22342. * @type {number}
  22343. * @apioption xAxis.plotLines.value
  22344. */
  22345. /**
  22346. * The width or thickness of the plot line.
  22347. *
  22348. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22349. * 2px wide line from X axis
  22350. * @sample {highstock} stock/xaxis/plotlines/
  22351. * Plot line on Y axis
  22352. *
  22353. * @type {number}
  22354. * @default 2
  22355. * @apioption xAxis.plotLines.width
  22356. */
  22357. /**
  22358. * The z index of the plot line within the chart.
  22359. *
  22360. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-behind/
  22361. * Behind plot lines by default
  22362. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above/
  22363. * Above plot lines
  22364. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above-all/
  22365. * Above plot lines and series
  22366. *
  22367. * @type {number}
  22368. * @since 1.2
  22369. * @apioption xAxis.plotLines.zIndex
  22370. */
  22371. /**
  22372. * Text labels for the plot bands
  22373. *
  22374. * @apioption xAxis.plotLines.label
  22375. */
  22376. /**
  22377. * Horizontal alignment of the label. Can be one of "left", "center" or
  22378. * "right".
  22379. *
  22380. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22381. * Aligned to the right
  22382. * @sample {highstock} stock/xaxis/plotlines/
  22383. * Plot line on Y axis
  22384. *
  22385. * @type {Highcharts.AlignValue}
  22386. * @default left
  22387. * @since 2.1
  22388. * @apioption xAxis.plotLines.label.align
  22389. */
  22390. /**
  22391. * Callback JavaScript function to format the label. Useful properties like
  22392. * the value of plot line or the range of plot band (`from` & `to`
  22393. * properties) can be found in `this.options` object.
  22394. *
  22395. * @sample {highcharts} highcharts/xaxis/plotlines-plotbands-label-formatter
  22396. * Label formatters for plot line and plot band.
  22397. * @type {Highcharts.FormatterCallbackFunction<Highcharts.PlotLineOrBand>}
  22398. * @apioption xAxis.plotLines.label.formatter
  22399. */
  22400. /**
  22401. * Rotation of the text label in degrees. Defaults to 0 for horizontal plot
  22402. * lines and 90 for vertical lines.
  22403. *
  22404. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22405. * Slanted text
  22406. *
  22407. * @type {number}
  22408. * @since 2.1
  22409. * @apioption xAxis.plotLines.label.rotation
  22410. */
  22411. /**
  22412. * CSS styles for the text label.
  22413. *
  22414. * In styled mode, the labels are styled by the
  22415. * `.highcharts-plot-line-label` class.
  22416. *
  22417. * @sample {highcharts} highcharts/xaxis/plotlines-label-style/
  22418. * Blue and bold label
  22419. *
  22420. * @type {Highcharts.CSSObject}
  22421. * @since 2.1
  22422. * @apioption xAxis.plotLines.label.style
  22423. */
  22424. /**
  22425. * The text itself. A subset of HTML is supported.
  22426. *
  22427. * @type {string}
  22428. * @since 2.1
  22429. * @apioption xAxis.plotLines.label.text
  22430. */
  22431. /**
  22432. * The text alignment for the label. While `align` determines where the
  22433. * texts anchor point is placed within the plot band, `textAlign` determines
  22434. * how the text is aligned against its anchor point. Possible values are
  22435. * "left", "center" and "right". Defaults to the same as the `align` option.
  22436. *
  22437. * @sample {highcharts} highcharts/xaxis/plotlines-label-textalign/
  22438. * Text label in bottom position
  22439. *
  22440. * @type {Highcharts.AlignValue}
  22441. * @since 2.1
  22442. * @apioption xAxis.plotLines.label.textAlign
  22443. */
  22444. /**
  22445. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22446. * to render the labels.
  22447. *
  22448. * @type {boolean}
  22449. * @default false
  22450. * @since 3.0.3
  22451. * @apioption xAxis.plotLines.label.useHTML
  22452. */
  22453. /**
  22454. * Vertical alignment of the label relative to the plot line. Can be
  22455. * one of "top", "middle" or "bottom".
  22456. *
  22457. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22458. * Vertically centered label
  22459. *
  22460. * @type {Highcharts.VerticalAlignValue}
  22461. * @default {highcharts} top
  22462. * @default {highstock} top
  22463. * @since 2.1
  22464. * @apioption xAxis.plotLines.label.verticalAlign
  22465. */
  22466. /**
  22467. * Horizontal position relative the alignment. Default varies by
  22468. * orientation.
  22469. *
  22470. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22471. * Aligned 10px from the right edge
  22472. * @sample {highstock} stock/xaxis/plotlines/
  22473. * Plot line on Y axis
  22474. *
  22475. * @type {number}
  22476. * @since 2.1
  22477. * @apioption xAxis.plotLines.label.x
  22478. */
  22479. /**
  22480. * Vertical position of the text baseline relative to the alignment. Default
  22481. * varies by orientation.
  22482. *
  22483. * @sample {highcharts} highcharts/xaxis/plotlines-label-y/
  22484. * Label below the plot line
  22485. * @sample {highstock} stock/xaxis/plotlines/
  22486. * Plot line on Y axis
  22487. *
  22488. * @type {number}
  22489. * @since 2.1
  22490. * @apioption xAxis.plotLines.label.y
  22491. */
  22492. /**
  22493. *
  22494. * @type {Array<*>}
  22495. * @extends xAxis.plotBands
  22496. * @apioption yAxis.plotBands
  22497. */
  22498. /**
  22499. * In a gauge chart, this option determines the inner radius of the
  22500. * plot band that stretches along the perimeter. It can be given as
  22501. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22502. * By default, the inner radius is controlled by the [thickness](
  22503. * #yAxis.plotBands.thickness) option.
  22504. *
  22505. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22506. * Gauge plot band
  22507. *
  22508. * @type {number|string}
  22509. * @since 2.3
  22510. * @product highcharts
  22511. * @apioption yAxis.plotBands.innerRadius
  22512. */
  22513. /**
  22514. * In a gauge chart, this option determines the outer radius of the
  22515. * plot band that stretches along the perimeter. It can be given as
  22516. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22517. *
  22518. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22519. * Gauge plot band
  22520. *
  22521. * @type {number|string}
  22522. * @default 100%
  22523. * @since 2.3
  22524. * @product highcharts
  22525. * @apioption yAxis.plotBands.outerRadius
  22526. */
  22527. /**
  22528. * In a gauge chart, this option sets the width of the plot band
  22529. * stretching along the perimeter. It can be given as a percentage
  22530. * string, like `"10%"`, or as a pixel number, like `10`. The default
  22531. * value 10 is the same as the default [tickLength](#yAxis.tickLength),
  22532. * thus making the plot band act as a background for the tick markers.
  22533. *
  22534. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22535. * Gauge plot band
  22536. *
  22537. * @type {number|string}
  22538. * @default 10
  22539. * @since 2.3
  22540. * @product highcharts
  22541. * @apioption yAxis.plotBands.thickness
  22542. */
  22543. /**
  22544. * @type {Array<*>}
  22545. * @extends xAxis.plotLines
  22546. * @apioption yAxis.plotLines
  22547. */
  22548. /* eslint-disable no-invalid-this, valid-jsdoc */
  22549. /**
  22550. * Internal function to create the SVG path definition for a plot band.
  22551. *
  22552. * @function Highcharts.Axis#getPlotBandPath
  22553. *
  22554. * @param {number} from
  22555. * The axis value to start from.
  22556. *
  22557. * @param {number} to
  22558. * The axis value to end on.
  22559. *
  22560. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  22561. * The plotBand or plotLine configuration object.
  22562. *
  22563. * @return {Highcharts.SVGPathArray}
  22564. * The SVG path definition in array form.
  22565. */
  22566. getPlotBandPath: function (from, to, options) {
  22567. if (options === void 0) { options = this.options; }
  22568. var toPath = this.getPlotLinePath({
  22569. value: to,
  22570. force: true,
  22571. acrossPanes: options.acrossPanes
  22572. }),
  22573. path = this.getPlotLinePath({
  22574. value: from,
  22575. force: true,
  22576. acrossPanes: options.acrossPanes
  22577. }),
  22578. result = [],
  22579. i,
  22580. // #4964 check if chart is inverted or plotband is on yAxis
  22581. horiz = this.horiz,
  22582. plus = 1,
  22583. isFlat,
  22584. outside = !isNumber(this.min) ||
  22585. !isNumber(this.max) ||
  22586. (from < this.min && to < this.min) ||
  22587. (from > this.max && to > this.max);
  22588. if (path && toPath) {
  22589. // Flat paths don't need labels (#3836)
  22590. if (outside) {
  22591. isFlat = path.toString() === toPath.toString();
  22592. plus = 0;
  22593. }
  22594. // Go over each subpath - for panes in Highcharts Stock
  22595. for (i = 0; i < path.length; i += 2) {
  22596. var pathStart = path[i],
  22597. pathEnd = path[i + 1],
  22598. toPathStart = toPath[i],
  22599. toPathEnd = toPath[i + 1];
  22600. // Type checking all affected path segments. Consider something
  22601. // smarter.
  22602. if ((pathStart[0] === 'M' || pathStart[0] === 'L') &&
  22603. (pathEnd[0] === 'M' || pathEnd[0] === 'L') &&
  22604. (toPathStart[0] === 'M' || toPathStart[0] === 'L') &&
  22605. (toPathEnd[0] === 'M' || toPathEnd[0] === 'L')) {
  22606. // Add 1 pixel when coordinates are the same
  22607. if (horiz && toPathStart[1] === pathStart[1]) {
  22608. toPathStart[1] += plus;
  22609. toPathEnd[1] += plus;
  22610. }
  22611. else if (!horiz && toPathStart[2] === pathStart[2]) {
  22612. toPathStart[2] += plus;
  22613. toPathEnd[2] += plus;
  22614. }
  22615. result.push(['M', pathStart[1], pathStart[2]], ['L', pathEnd[1], pathEnd[2]], ['L', toPathEnd[1], toPathEnd[2]], ['L', toPathStart[1], toPathStart[2]], ['Z']);
  22616. }
  22617. result.isFlat = isFlat;
  22618. }
  22619. }
  22620. else { // outside the axis area
  22621. path = null;
  22622. }
  22623. return result;
  22624. },
  22625. /**
  22626. * Add a plot band after render time.
  22627. *
  22628. * @sample highcharts/members/axis-addplotband/
  22629. * Toggle the plot band from a button
  22630. *
  22631. * @function Highcharts.Axis#addPlotBand
  22632. *
  22633. * @param {Highcharts.AxisPlotBandsOptions} options
  22634. * A configuration object for the plot band, as defined in
  22635. * [xAxis.plotBands](https://api.highcharts.com/highcharts/xAxis.plotBands).
  22636. *
  22637. * @return {Highcharts.PlotLineOrBand|undefined}
  22638. * The added plot band.
  22639. */
  22640. addPlotBand: function (options) {
  22641. return this.addPlotBandOrLine(options, 'plotBands');
  22642. },
  22643. /**
  22644. * Add a plot line after render time.
  22645. *
  22646. * @sample highcharts/members/axis-addplotline/
  22647. * Toggle the plot line from a button
  22648. *
  22649. * @function Highcharts.Axis#addPlotLine
  22650. *
  22651. * @param {Highcharts.AxisPlotLinesOptions} options
  22652. * A configuration object for the plot line, as defined in
  22653. * [xAxis.plotLines](https://api.highcharts.com/highcharts/xAxis.plotLines).
  22654. *
  22655. * @return {Highcharts.PlotLineOrBand|undefined}
  22656. * The added plot line.
  22657. */
  22658. addPlotLine: function (options) {
  22659. return this.addPlotBandOrLine(options, 'plotLines');
  22660. },
  22661. /**
  22662. * Add a plot band or plot line after render time. Called from addPlotBand
  22663. * and addPlotLine internally.
  22664. *
  22665. * @private
  22666. * @function Highcharts.Axis#addPlotBandOrLine
  22667. *
  22668. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  22669. * The plotBand or plotLine configuration object.
  22670. *
  22671. * @param {"plotBands"|"plotLines"} [coll]
  22672. *
  22673. * @return {Highcharts.PlotLineOrBand|undefined}
  22674. */
  22675. addPlotBandOrLine: function (options, coll) {
  22676. var _this = this;
  22677. var obj = new H.PlotLineOrBand(this,
  22678. options),
  22679. userOptions = this.userOptions;
  22680. if (this.visible) {
  22681. obj = obj.render();
  22682. }
  22683. if (obj) { // #2189
  22684. if (!this._addedPlotLB) {
  22685. this._addedPlotLB = true;
  22686. (userOptions.plotLines || [])
  22687. .concat(userOptions.plotBands || [])
  22688. .forEach(function (plotLineOptions) {
  22689. _this.addPlotBandOrLine(plotLineOptions);
  22690. });
  22691. }
  22692. // Add it to the user options for exporting and Axis.update
  22693. if (coll) {
  22694. // Workaround Microsoft/TypeScript issue #32693
  22695. var updatedOptions = (userOptions[coll] || []);
  22696. updatedOptions.push(options);
  22697. userOptions[coll] = updatedOptions;
  22698. }
  22699. this.plotLinesAndBands.push(obj);
  22700. }
  22701. return obj;
  22702. },
  22703. /**
  22704. * Remove a plot band or plot line from the chart by id. Called internally
  22705. * from `removePlotBand` and `removePlotLine`.
  22706. *
  22707. * @private
  22708. * @function Highcharts.Axis#removePlotBandOrLine
  22709. * @param {string} id
  22710. * @return {void}
  22711. */
  22712. removePlotBandOrLine: function (id) {
  22713. var plotLinesAndBands = this.plotLinesAndBands,
  22714. options = this.options,
  22715. userOptions = this.userOptions,
  22716. i = plotLinesAndBands.length;
  22717. while (i--) {
  22718. if (plotLinesAndBands[i].id === id) {
  22719. plotLinesAndBands[i].destroy();
  22720. }
  22721. }
  22722. ([
  22723. options.plotLines || [],
  22724. userOptions.plotLines || [],
  22725. options.plotBands || [],
  22726. userOptions.plotBands || []
  22727. ]).forEach(function (arr) {
  22728. i = arr.length;
  22729. while (i--) {
  22730. if ((arr[i] || {}).id === id) {
  22731. erase(arr, arr[i]);
  22732. }
  22733. }
  22734. });
  22735. },
  22736. /**
  22737. * Remove a plot band by its id.
  22738. *
  22739. * @sample highcharts/members/axis-removeplotband/
  22740. * Remove plot band by id
  22741. * @sample highcharts/members/axis-addplotband/
  22742. * Toggle the plot band from a button
  22743. *
  22744. * @function Highcharts.Axis#removePlotBand
  22745. *
  22746. * @param {string} id
  22747. * The plot band's `id` as given in the original configuration
  22748. * object or in the `addPlotBand` option.
  22749. *
  22750. * @return {void}
  22751. */
  22752. removePlotBand: function (id) {
  22753. this.removePlotBandOrLine(id);
  22754. },
  22755. /**
  22756. * Remove a plot line by its id.
  22757. *
  22758. * @sample highcharts/xaxis/plotlines-id/
  22759. * Remove plot line by id
  22760. * @sample highcharts/members/axis-addplotline/
  22761. * Toggle the plot line from a button
  22762. *
  22763. * @function Highcharts.Axis#removePlotLine
  22764. *
  22765. * @param {string} id
  22766. * The plot line's `id` as given in the original configuration
  22767. * object or in the `addPlotLine` option.
  22768. */
  22769. removePlotLine: function (id) {
  22770. this.removePlotBandOrLine(id);
  22771. }
  22772. });
  22773. H.PlotLineOrBand = PlotLineOrBand;
  22774. return H.PlotLineOrBand;
  22775. });
  22776. _registerModule(_modules, 'Core/Tooltip.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (F, H, palette, U) {
  22777. /* *
  22778. *
  22779. * (c) 2010-2021 Torstein Honsi
  22780. *
  22781. * License: www.highcharts.com/license
  22782. *
  22783. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  22784. *
  22785. * */
  22786. var format = F.format;
  22787. var doc = H.doc;
  22788. var clamp = U.clamp,
  22789. css = U.css,
  22790. defined = U.defined,
  22791. discardElement = U.discardElement,
  22792. extend = U.extend,
  22793. fireEvent = U.fireEvent,
  22794. isArray = U.isArray,
  22795. isNumber = U.isNumber,
  22796. isString = U.isString,
  22797. merge = U.merge,
  22798. pick = U.pick,
  22799. splat = U.splat,
  22800. syncTimeout = U.syncTimeout,
  22801. timeUnits = U.timeUnits;
  22802. /**
  22803. * Callback function to format the text of the tooltip from scratch.
  22804. *
  22805. * In case of single or shared tooltips, a string should be be returned. In case
  22806. * of splitted tooltips, it should return an array where the first item is the
  22807. * header, and subsequent items are mapped to the points. Return `false` to
  22808. * disable tooltip for a specific point on series.
  22809. *
  22810. * @callback Highcharts.TooltipFormatterCallbackFunction
  22811. *
  22812. * @param {Highcharts.TooltipFormatterContextObject} this
  22813. * Context to format
  22814. *
  22815. * @param {Highcharts.Tooltip} tooltip
  22816. * The tooltip instance
  22817. *
  22818. * @return {false|string|Array<(string|null|undefined)>|null|undefined}
  22819. * Formatted text or false
  22820. */
  22821. /**
  22822. * @interface Highcharts.TooltipFormatterContextObject
  22823. */ /**
  22824. * @name Highcharts.TooltipFormatterContextObject#color
  22825. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  22826. */ /**
  22827. * @name Highcharts.TooltipFormatterContextObject#colorIndex
  22828. * @type {number|undefined}
  22829. */ /**
  22830. * @name Highcharts.TooltipFormatterContextObject#key
  22831. * @type {number}
  22832. */ /**
  22833. * @name Highcharts.TooltipFormatterContextObject#percentage
  22834. * @type {number|undefined}
  22835. */ /**
  22836. * @name Highcharts.TooltipFormatterContextObject#point
  22837. * @type {Highcharts.Point}
  22838. */ /**
  22839. * @name Highcharts.TooltipFormatterContextObject#points
  22840. * @type {Array<Highcharts.TooltipFormatterContextObject>|undefined}
  22841. */ /**
  22842. * @name Highcharts.TooltipFormatterContextObject#series
  22843. * @type {Highcharts.Series}
  22844. */ /**
  22845. * @name Highcharts.TooltipFormatterContextObject#total
  22846. * @type {number|undefined}
  22847. */ /**
  22848. * @name Highcharts.TooltipFormatterContextObject#x
  22849. * @type {number}
  22850. */ /**
  22851. * @name Highcharts.TooltipFormatterContextObject#y
  22852. * @type {number}
  22853. */
  22854. /**
  22855. * A callback function to place the tooltip in a specific position.
  22856. *
  22857. * @callback Highcharts.TooltipPositionerCallbackFunction
  22858. *
  22859. * @param {Highcharts.Tooltip} this
  22860. * Tooltip context of the callback.
  22861. *
  22862. * @param {number} labelWidth
  22863. * Width of the tooltip.
  22864. *
  22865. * @param {number} labelHeight
  22866. * Height of the tooltip.
  22867. *
  22868. * @param {Highcharts.TooltipPositionerPointObject} point
  22869. * Point information for positioning a tooltip.
  22870. *
  22871. * @return {Highcharts.PositionObject}
  22872. * New position for the tooltip.
  22873. */
  22874. /**
  22875. * Point information for positioning a tooltip.
  22876. *
  22877. * @interface Highcharts.TooltipPositionerPointObject
  22878. * @extends Highcharts.Point
  22879. */ /**
  22880. * If `tooltip.split` option is enabled and positioner is called for each of the
  22881. * boxes separately, this property indicates the call on the xAxis header, which
  22882. * is not a point itself.
  22883. * @name Highcharts.TooltipPositionerPointObject#isHeader
  22884. * @type {boolean}
  22885. */ /**
  22886. * The reference point relative to the plot area. Add chart.plotLeft to get the
  22887. * full coordinates.
  22888. * @name Highcharts.TooltipPositionerPointObject#plotX
  22889. * @type {number}
  22890. */ /**
  22891. * The reference point relative to the plot area. Add chart.plotTop to get the
  22892. * full coordinates.
  22893. * @name Highcharts.TooltipPositionerPointObject#plotY
  22894. * @type {number}
  22895. */
  22896. /**
  22897. * @typedef {"callout"|"circle"|"square"} Highcharts.TooltipShapeValue
  22898. */
  22899. ''; // separates doclets above from variables below
  22900. /* eslint-disable no-invalid-this, valid-jsdoc */
  22901. /**
  22902. * Tooltip of a chart.
  22903. *
  22904. * @class
  22905. * @name Highcharts.Tooltip
  22906. *
  22907. * @param {Highcharts.Chart} chart
  22908. * The chart instance.
  22909. *
  22910. * @param {Highcharts.TooltipOptions} options
  22911. * Tooltip options.
  22912. */
  22913. var Tooltip = /** @class */ (function () {
  22914. /* *
  22915. *
  22916. * Constructors
  22917. *
  22918. * */
  22919. function Tooltip(chart, options) {
  22920. this.container = void 0;
  22921. this.crosshairs = [];
  22922. this.distance = 0;
  22923. this.isHidden = true;
  22924. this.isSticky = false;
  22925. this.now = {};
  22926. this.options = {};
  22927. this.outside = false;
  22928. this.chart = chart;
  22929. this.init(chart, options);
  22930. }
  22931. /* *
  22932. *
  22933. * Functions
  22934. *
  22935. * */
  22936. /**
  22937. * In styled mode, apply the default filter for the tooltip drop-shadow. It
  22938. * needs to have an id specific to the chart, otherwise there will be issues
  22939. * when one tooltip adopts the filter of a different chart, specifically one
  22940. * where the container is hidden.
  22941. *
  22942. * @private
  22943. * @function Highcharts.Tooltip#applyFilter
  22944. */
  22945. Tooltip.prototype.applyFilter = function () {
  22946. var chart = this.chart;
  22947. chart.renderer.definition({
  22948. tagName: 'filter',
  22949. attributes: {
  22950. id: 'drop-shadow-' + chart.index,
  22951. opacity: 0.5
  22952. },
  22953. children: [{
  22954. tagName: 'feGaussianBlur',
  22955. attributes: {
  22956. 'in': 'SourceAlpha',
  22957. stdDeviation: 1
  22958. }
  22959. }, {
  22960. tagName: 'feOffset',
  22961. attributes: {
  22962. dx: 1,
  22963. dy: 1
  22964. }
  22965. }, {
  22966. tagName: 'feComponentTransfer',
  22967. children: [{
  22968. tagName: 'feFuncA',
  22969. attributes: {
  22970. type: 'linear',
  22971. slope: 0.3
  22972. }
  22973. }]
  22974. }, {
  22975. tagName: 'feMerge',
  22976. children: [{
  22977. tagName: 'feMergeNode'
  22978. }, {
  22979. tagName: 'feMergeNode',
  22980. attributes: {
  22981. 'in': 'SourceGraphic'
  22982. }
  22983. }]
  22984. }]
  22985. });
  22986. chart.renderer.definition({
  22987. tagName: 'style',
  22988. textContent: '.highcharts-tooltip-' + chart.index + '{' +
  22989. 'filter:url(#drop-shadow-' + chart.index + ')' +
  22990. '}'
  22991. });
  22992. };
  22993. /**
  22994. * Build the body (lines) of the tooltip by iterating over the items and
  22995. * returning one entry for each item, abstracting this functionality allows
  22996. * to easily overwrite and extend it.
  22997. *
  22998. * @private
  22999. * @function Highcharts.Tooltip#bodyFormatter
  23000. * @param {Array<(Highcharts.Point|Highcharts.Series)>} items
  23001. * @return {Array<string>}
  23002. */
  23003. Tooltip.prototype.bodyFormatter = function (items) {
  23004. return items.map(function (item) {
  23005. var tooltipOptions = item.series.tooltipOptions;
  23006. return (tooltipOptions[(item.point.formatPrefix || 'point') + 'Formatter'] ||
  23007. item.point.tooltipFormatter).call(item.point, tooltipOptions[(item.point.formatPrefix || 'point') + 'Format'] || '');
  23008. });
  23009. };
  23010. /**
  23011. * Destroy the single tooltips in a split tooltip.
  23012. * If the tooltip is active then it is not destroyed, unless forced to.
  23013. *
  23014. * @private
  23015. * @function Highcharts.Tooltip#cleanSplit
  23016. *
  23017. * @param {boolean} [force]
  23018. * Force destroy all tooltips.
  23019. */
  23020. Tooltip.prototype.cleanSplit = function (force) {
  23021. this.chart.series.forEach(function (series) {
  23022. var tt = series && series.tt;
  23023. if (tt) {
  23024. if (!tt.isActive || force) {
  23025. series.tt = tt.destroy();
  23026. }
  23027. else {
  23028. tt.isActive = false;
  23029. }
  23030. }
  23031. });
  23032. };
  23033. /**
  23034. * In case no user defined formatter is given, this will be used. Note that
  23035. * the context here is an object holding point, series, x, y etc.
  23036. *
  23037. * @function Highcharts.Tooltip#defaultFormatter
  23038. *
  23039. * @param {Highcharts.Tooltip} tooltip
  23040. *
  23041. * @return {Array<string>}
  23042. */
  23043. Tooltip.prototype.defaultFormatter = function (tooltip) {
  23044. var items = this.points || splat(this),
  23045. s;
  23046. // Build the header
  23047. s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
  23048. // build the values
  23049. s = s.concat(tooltip.bodyFormatter(items));
  23050. // footer
  23051. s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
  23052. return s;
  23053. };
  23054. /**
  23055. * Removes and destroys the tooltip and its elements.
  23056. *
  23057. * @function Highcharts.Tooltip#destroy
  23058. */
  23059. Tooltip.prototype.destroy = function () {
  23060. // Destroy and clear local variables
  23061. if (this.label) {
  23062. this.label = this.label.destroy();
  23063. }
  23064. if (this.split && this.tt) {
  23065. this.cleanSplit(this.chart, true);
  23066. this.tt = this.tt.destroy();
  23067. }
  23068. if (this.renderer) {
  23069. this.renderer = this.renderer.destroy();
  23070. discardElement(this.container);
  23071. }
  23072. U.clearTimeout(this.hideTimer);
  23073. U.clearTimeout(this.tooltipTimeout);
  23074. };
  23075. /**
  23076. * Extendable method to get the anchor position of the tooltip
  23077. * from a point or set of points
  23078. *
  23079. * @private
  23080. * @function Highcharts.Tooltip#getAnchor
  23081. *
  23082. * @param {Highcharts.Point|Array<Highcharts.Point>} points
  23083. *
  23084. * @param {Highcharts.PointerEventObject} [mouseEvent]
  23085. *
  23086. * @return {Array<number>}
  23087. */
  23088. Tooltip.prototype.getAnchor = function (points, mouseEvent) {
  23089. var ret,
  23090. chart = this.chart,
  23091. pointer = chart.pointer,
  23092. inverted = chart.inverted,
  23093. plotTop = chart.plotTop,
  23094. plotLeft = chart.plotLeft,
  23095. plotX = 0,
  23096. plotY = 0,
  23097. yAxis,
  23098. xAxis;
  23099. points = splat(points);
  23100. // When tooltip follows mouse, relate the position to the mouse
  23101. if (this.followPointer && mouseEvent) {
  23102. if (typeof mouseEvent.chartX === 'undefined') {
  23103. mouseEvent = pointer.normalize(mouseEvent);
  23104. }
  23105. ret = [
  23106. mouseEvent.chartX - plotLeft,
  23107. mouseEvent.chartY - plotTop
  23108. ];
  23109. // Some series types use a specificly calculated tooltip position for
  23110. // each point
  23111. }
  23112. else if (points[0].tooltipPos) {
  23113. ret = points[0].tooltipPos;
  23114. // Calculate the average position and adjust for axis positions
  23115. }
  23116. else {
  23117. points.forEach(function (point) {
  23118. yAxis = point.series.yAxis;
  23119. xAxis = point.series.xAxis;
  23120. plotX += point.plotX || 0;
  23121. plotY += (point.plotLow ?
  23122. (point.plotLow + (point.plotHigh || 0)) / 2 :
  23123. (point.plotY || 0));
  23124. // Adjust position for positioned axes (top/left settings)
  23125. if (xAxis && yAxis) {
  23126. if (!inverted) { // #1151
  23127. plotX += xAxis.pos - plotLeft;
  23128. plotY += yAxis.pos - plotTop;
  23129. }
  23130. else { // #14771
  23131. plotX += plotTop + chart.plotHeight - xAxis.len - xAxis.pos;
  23132. plotY += plotLeft + chart.plotWidth - yAxis.len - yAxis.pos;
  23133. }
  23134. }
  23135. });
  23136. plotX /= points.length;
  23137. plotY /= points.length;
  23138. // Use the average position for multiple points
  23139. ret = [
  23140. inverted ? chart.plotWidth - plotY : plotX,
  23141. inverted ? chart.plotHeight - plotX : plotY
  23142. ];
  23143. // When shared, place the tooltip next to the mouse (#424)
  23144. if (this.shared && points.length > 1 && mouseEvent) {
  23145. if (inverted) {
  23146. ret[0] = mouseEvent.chartX - plotLeft;
  23147. }
  23148. else {
  23149. ret[1] = mouseEvent.chartY - plotTop;
  23150. }
  23151. }
  23152. }
  23153. return ret.map(Math.round);
  23154. };
  23155. /**
  23156. * Get the optimal date format for a point, based on a range.
  23157. *
  23158. * @private
  23159. * @function Highcharts.Tooltip#getDateFormat
  23160. *
  23161. * @param {number} range
  23162. * The time range
  23163. *
  23164. * @param {number} date
  23165. * The date of the point in question
  23166. *
  23167. * @param {number} startOfWeek
  23168. * An integer representing the first day of the week, where 0 is
  23169. * Sunday.
  23170. *
  23171. * @param {Highcharts.Dictionary<string>} dateTimeLabelFormats
  23172. * A map of time units to formats.
  23173. *
  23174. * @return {string}
  23175. * The optimal date format for a point.
  23176. */
  23177. Tooltip.prototype.getDateFormat = function (range, date, startOfWeek, dateTimeLabelFormats) {
  23178. 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 = {
  23179. millisecond: 15,
  23180. second: 12,
  23181. minute: 9,
  23182. hour: 6,
  23183. day: 3
  23184. }, lastN = 'millisecond'; // for sub-millisecond data, #4223
  23185. for (n in timeUnits) { // eslint-disable-line guard-for-in
  23186. // If the range is exactly one week and we're looking at a
  23187. // Sunday/Monday, go for the week format
  23188. if (range === timeUnits.week &&
  23189. +time.dateFormat('%w', date) === startOfWeek &&
  23190. dateStr.substr(6) === blank.substr(6)) {
  23191. n = 'week';
  23192. break;
  23193. }
  23194. // The first format that is too great for the range
  23195. if (timeUnits[n] > range) {
  23196. n = lastN;
  23197. break;
  23198. }
  23199. // If the point is placed every day at 23:59, we need to show
  23200. // the minutes as well. #2637.
  23201. if (strpos[n] &&
  23202. dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
  23203. break;
  23204. }
  23205. // Weeks are outside the hierarchy, only apply them on
  23206. // Mondays/Sundays like in the first condition
  23207. if (n !== 'week') {
  23208. lastN = n;
  23209. }
  23210. }
  23211. if (n) {
  23212. format = time.resolveDTLFormat(dateTimeLabelFormats[n]).main;
  23213. }
  23214. return format;
  23215. };
  23216. /**
  23217. * Creates the Tooltip label element if it does not exist, then returns it.
  23218. *
  23219. * @function Highcharts.Tooltip#getLabel
  23220. * @return {Highcharts.SVGElement}
  23221. */
  23222. Tooltip.prototype.getLabel = function () {
  23223. var tooltip = this,
  23224. renderer = this.chart.renderer,
  23225. styledMode = this.chart.styledMode,
  23226. options = this.options,
  23227. className = ('tooltip' + (defined(options.className) ?
  23228. ' ' + options.className :
  23229. '')),
  23230. pointerEvents = ((options.style && options.style.pointerEvents) ||
  23231. (!this.followPointer && options.stickOnContact ? 'auto' : 'none')),
  23232. container,
  23233. onMouseEnter = function () {
  23234. tooltip.inContact = true;
  23235. }, onMouseLeave = function () {
  23236. var series = tooltip.chart.hoverSeries;
  23237. tooltip.inContact = false;
  23238. if (series &&
  23239. series.onMouseOut) {
  23240. series.onMouseOut();
  23241. }
  23242. };
  23243. if (!this.label) {
  23244. if (this.outside) {
  23245. var chartStyle = this.chart.options.chart.style;
  23246. /**
  23247. * Reference to the tooltip's container, when
  23248. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23249. * it's undefined.
  23250. *
  23251. * @name Highcharts.Tooltip#container
  23252. * @type {Highcharts.HTMLDOMElement|undefined}
  23253. */
  23254. this.container = container = H.doc.createElement('div');
  23255. container.className = 'highcharts-tooltip-container';
  23256. css(container, {
  23257. position: 'absolute',
  23258. top: '1px',
  23259. pointerEvents: pointerEvents,
  23260. zIndex: Math.max((this.options.style && this.options.style.zIndex || 0), (chartStyle && chartStyle.zIndex || 0) + 3)
  23261. });
  23262. H.doc.body.appendChild(container);
  23263. /**
  23264. * Reference to the tooltip's renderer, when
  23265. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23266. * it's undefined.
  23267. *
  23268. * @name Highcharts.Tooltip#renderer
  23269. * @type {Highcharts.SVGRenderer|undefined}
  23270. */
  23271. this.renderer = renderer = new H.Renderer(container, 0, 0, chartStyle, void 0, void 0, renderer.styledMode);
  23272. }
  23273. // Create the label
  23274. if (this.split) {
  23275. this.label = renderer.g(className);
  23276. }
  23277. else {
  23278. this.label = renderer
  23279. .label('', 0, 0, options.shape || 'callout', null, null, options.useHTML, null, className)
  23280. .attr({
  23281. padding: options.padding,
  23282. r: options.borderRadius
  23283. });
  23284. if (!styledMode) {
  23285. this.label
  23286. .attr({
  23287. fill: options.backgroundColor,
  23288. 'stroke-width': options.borderWidth
  23289. })
  23290. // #2301, #2657
  23291. .css(options.style)
  23292. .css({ pointerEvents: pointerEvents })
  23293. .shadow(options.shadow);
  23294. }
  23295. }
  23296. if (styledMode) {
  23297. // Apply the drop-shadow filter
  23298. this.applyFilter();
  23299. this.label.addClass('highcharts-tooltip-' + this.chart.index);
  23300. }
  23301. // Split tooltip use updateTooltipContainer to position the tooltip
  23302. // container.
  23303. if (tooltip.outside && !tooltip.split) {
  23304. var label_1 = this.label;
  23305. var xSetter_1 = label_1.xSetter,
  23306. ySetter_1 = label_1.ySetter;
  23307. label_1.xSetter = function (value) {
  23308. xSetter_1.call(label_1, tooltip.distance);
  23309. container.style.left = value + 'px';
  23310. };
  23311. label_1.ySetter = function (value) {
  23312. ySetter_1.call(label_1, tooltip.distance);
  23313. container.style.top = value + 'px';
  23314. };
  23315. }
  23316. this.label
  23317. .on('mouseenter', onMouseEnter)
  23318. .on('mouseleave', onMouseLeave)
  23319. .attr({ zIndex: 8 })
  23320. .add();
  23321. }
  23322. return this.label;
  23323. };
  23324. /**
  23325. * Place the tooltip in a chart without spilling over
  23326. * and not covering the point it self.
  23327. *
  23328. * @private
  23329. * @function Highcharts.Tooltip#getPosition
  23330. *
  23331. * @param {number} boxWidth
  23332. *
  23333. * @param {number} boxHeight
  23334. *
  23335. * @param {Highcharts.Point} point
  23336. *
  23337. * @return {Highcharts.PositionObject}
  23338. */
  23339. Tooltip.prototype.getPosition = function (boxWidth, boxHeight, point) {
  23340. var chart = this.chart,
  23341. distance = this.distance,
  23342. ret = {},
  23343. // Don't use h if chart isn't inverted (#7242) ???
  23344. h = (chart.inverted && point.h) || 0, // #4117 ???
  23345. swapped,
  23346. outside = this.outside,
  23347. outerWidth = outside ?
  23348. // substract distance to prevent scrollbars
  23349. doc.documentElement.clientWidth - 2 * distance :
  23350. chart.chartWidth,
  23351. outerHeight = outside ?
  23352. Math.max(doc.body.scrollHeight,
  23353. doc.documentElement.scrollHeight,
  23354. doc.body.offsetHeight,
  23355. doc.documentElement.offsetHeight,
  23356. doc.documentElement.clientHeight) :
  23357. chart.chartHeight,
  23358. chartPosition = chart.pointer.getChartPosition(),
  23359. scaleX = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23360. val * chartPosition.scaleX); },
  23361. scaleY = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23362. val * chartPosition.scaleY); },
  23363. // Build parameter arrays for firstDimension()/secondDimension()
  23364. buildDimensionArray = function (dim) {
  23365. var isX = dim === 'x';
  23366. return [
  23367. dim,
  23368. isX ? outerWidth : outerHeight,
  23369. isX ? boxWidth : boxHeight
  23370. ].concat(outside ? [
  23371. // If we are using tooltip.outside, we need to scale the
  23372. // position to match scaling of the container in case there
  23373. // is a transform/zoom on the container. #11329
  23374. isX ? scaleX(boxWidth) : scaleY(boxHeight),
  23375. isX ? chartPosition.left - distance +
  23376. scaleX(point.plotX + chart.plotLeft) :
  23377. chartPosition.top - distance +
  23378. scaleY(point.plotY + chart.plotTop),
  23379. 0,
  23380. isX ? outerWidth : outerHeight
  23381. ] : [
  23382. // Not outside, no scaling is needed
  23383. isX ? boxWidth : boxHeight,
  23384. isX ? point.plotX + chart.plotLeft :
  23385. point.plotY + chart.plotTop,
  23386. isX ? chart.plotLeft : chart.plotTop,
  23387. isX ? chart.plotLeft + chart.plotWidth :
  23388. chart.plotTop + chart.plotHeight
  23389. ]);
  23390. }, first = buildDimensionArray('y'), second = buildDimensionArray('x'),
  23391. // The far side is right or bottom
  23392. preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
  23393. /*
  23394. * Handle the preferred dimension. When the preferred dimension is
  23395. * tooltip on top or bottom of the point, it will look for space
  23396. * there.
  23397. *
  23398. * @private
  23399. */
  23400. firstDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23401. point, min, max) {
  23402. var scaledDist = outside ?
  23403. (dim === 'y' ? scaleY(distance) : scaleX(distance)) :
  23404. distance,
  23405. scaleDiff = (innerSize - scaledInnerSize) / 2,
  23406. roomLeft = scaledInnerSize < point - distance,
  23407. roomRight = point + distance + scaledInnerSize < outerSize,
  23408. alignedLeft = point - scaledDist - innerSize + scaleDiff,
  23409. alignedRight = point + scaledDist - scaleDiff;
  23410. if (preferFarSide && roomRight) {
  23411. ret[dim] = alignedRight;
  23412. }
  23413. else if (!preferFarSide && roomLeft) {
  23414. ret[dim] = alignedLeft;
  23415. }
  23416. else if (roomLeft) {
  23417. ret[dim] = Math.min(max - scaledInnerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
  23418. }
  23419. else if (roomRight) {
  23420. ret[dim] = Math.max(min, alignedRight + h + innerSize > outerSize ?
  23421. alignedRight :
  23422. alignedRight + h);
  23423. }
  23424. else {
  23425. return false;
  23426. }
  23427. },
  23428. /*
  23429. * Handle the secondary dimension. If the preferred dimension is
  23430. * tooltip on top or bottom of the point, the second dimension is to
  23431. * align the tooltip above the point, trying to align center but
  23432. * allowing left or right align within the chart box.
  23433. *
  23434. * @private
  23435. */
  23436. secondDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23437. point) {
  23438. var retVal;
  23439. // Too close to the edge, return false and swap dimensions
  23440. if (point < distance || point > outerSize - distance) {
  23441. retVal = false;
  23442. // Align left/top
  23443. }
  23444. else if (point < innerSize / 2) {
  23445. ret[dim] = 1;
  23446. // Align right/bottom
  23447. }
  23448. else if (point > outerSize - scaledInnerSize / 2) {
  23449. ret[dim] = outerSize - scaledInnerSize - 2;
  23450. // Align center
  23451. }
  23452. else {
  23453. ret[dim] = point - innerSize / 2;
  23454. }
  23455. return retVal;
  23456. },
  23457. /*
  23458. * Swap the dimensions
  23459. */
  23460. swap = function (count) {
  23461. var temp = first;
  23462. first = second;
  23463. second = temp;
  23464. swapped = count;
  23465. }, run = function () {
  23466. if (firstDimension.apply(0, first) !== false) {
  23467. if (secondDimension.apply(0, second) === false &&
  23468. !swapped) {
  23469. swap(true);
  23470. run();
  23471. }
  23472. }
  23473. else if (!swapped) {
  23474. swap(true);
  23475. run();
  23476. }
  23477. else {
  23478. ret.x = ret.y = 0;
  23479. }
  23480. };
  23481. // Under these conditions, prefer the tooltip on the side of the point
  23482. if (chart.inverted || this.len > 1) {
  23483. swap();
  23484. }
  23485. run();
  23486. return ret;
  23487. };
  23488. /**
  23489. * Get the best X date format based on the closest point range on the axis.
  23490. *
  23491. * @private
  23492. * @function Highcharts.Tooltip#getXDateFormat
  23493. *
  23494. * @param {Highcharts.Point} point
  23495. *
  23496. * @param {Highcharts.TooltipOptions} options
  23497. *
  23498. * @param {Highcharts.Axis} xAxis
  23499. *
  23500. * @return {string}
  23501. */
  23502. Tooltip.prototype.getXDateFormat = function (point, options, xAxis) {
  23503. var xDateFormat,
  23504. dateTimeLabelFormats = options.dateTimeLabelFormats,
  23505. closestPointRange = xAxis && xAxis.closestPointRange;
  23506. if (closestPointRange) {
  23507. xDateFormat = this.getDateFormat(closestPointRange, point.x, xAxis.options.startOfWeek, dateTimeLabelFormats);
  23508. }
  23509. else {
  23510. xDateFormat = dateTimeLabelFormats.day;
  23511. }
  23512. return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
  23513. };
  23514. /**
  23515. * Hides the tooltip with a fade out animation.
  23516. *
  23517. * @function Highcharts.Tooltip#hide
  23518. *
  23519. * @param {number} [delay]
  23520. * The fade out in milliseconds. If no value is provided the value
  23521. * of the tooltip.hideDelay option is used. A value of 0 disables
  23522. * the fade out animation.
  23523. */
  23524. Tooltip.prototype.hide = function (delay) {
  23525. var tooltip = this;
  23526. // disallow duplicate timers (#1728, #1766)
  23527. U.clearTimeout(this.hideTimer);
  23528. delay = pick(delay, this.options.hideDelay, 500);
  23529. if (!this.isHidden) {
  23530. this.hideTimer = syncTimeout(function () {
  23531. // If there is a delay, do fadeOut with the default duration. If
  23532. // the hideDelay is 0, we assume no animation is wanted, so we
  23533. // pass 0 duration. #12994.
  23534. tooltip.getLabel().fadeOut(delay ? void 0 : delay);
  23535. tooltip.isHidden = true;
  23536. }, delay);
  23537. }
  23538. };
  23539. /**
  23540. * @private
  23541. * @function Highcharts.Tooltip#init
  23542. *
  23543. * @param {Highcharts.Chart} chart
  23544. * The chart instance.
  23545. *
  23546. * @param {Highcharts.TooltipOptions} options
  23547. * Tooltip options.
  23548. */
  23549. Tooltip.prototype.init = function (chart, options) {
  23550. /**
  23551. * Chart of the tooltip.
  23552. *
  23553. * @readonly
  23554. * @name Highcharts.Tooltip#chart
  23555. * @type {Highcharts.Chart}
  23556. */
  23557. this.chart = chart;
  23558. /**
  23559. * Used tooltip options.
  23560. *
  23561. * @readonly
  23562. * @name Highcharts.Tooltip#options
  23563. * @type {Highcharts.TooltipOptions}
  23564. */
  23565. this.options = options;
  23566. /**
  23567. * List of crosshairs.
  23568. *
  23569. * @private
  23570. * @readonly
  23571. * @name Highcharts.Tooltip#crosshairs
  23572. * @type {Array<null>}
  23573. */
  23574. this.crosshairs = [];
  23575. /**
  23576. * Current values of x and y when animating.
  23577. *
  23578. * @private
  23579. * @readonly
  23580. * @name Highcharts.Tooltip#now
  23581. * @type {Highcharts.PositionObject}
  23582. */
  23583. this.now = { x: 0, y: 0 };
  23584. /**
  23585. * Tooltips are initially hidden.
  23586. *
  23587. * @private
  23588. * @readonly
  23589. * @name Highcharts.Tooltip#isHidden
  23590. * @type {boolean}
  23591. */
  23592. this.isHidden = true;
  23593. /**
  23594. * True, if the tooltip is split into one label per series, with the
  23595. * header close to the axis.
  23596. *
  23597. * @readonly
  23598. * @name Highcharts.Tooltip#split
  23599. * @type {boolean|undefined}
  23600. */
  23601. this.split = options.split && !chart.inverted && !chart.polar;
  23602. /**
  23603. * When the tooltip is shared, the entire plot area will capture mouse
  23604. * movement or touch events.
  23605. *
  23606. * @readonly
  23607. * @name Highcharts.Tooltip#shared
  23608. * @type {boolean|undefined}
  23609. */
  23610. this.shared = options.shared || this.split;
  23611. /**
  23612. * Whether to allow the tooltip to render outside the chart's SVG
  23613. * element box. By default (false), the tooltip is rendered within the
  23614. * chart's SVG element, which results in the tooltip being aligned
  23615. * inside the chart area.
  23616. *
  23617. * @readonly
  23618. * @name Highcharts.Tooltip#outside
  23619. * @type {boolean}
  23620. *
  23621. * @todo
  23622. * Split tooltip does not support outside in the first iteration. Should
  23623. * not be too complicated to implement.
  23624. */
  23625. this.outside = pick(options.outside, Boolean(chart.scrollablePixelsX || chart.scrollablePixelsY));
  23626. };
  23627. /**
  23628. * Returns true, if the pointer is in contact with the tooltip tracker.
  23629. */
  23630. Tooltip.prototype.isStickyOnContact = function () {
  23631. return !!(!this.followPointer &&
  23632. this.options.stickOnContact &&
  23633. this.inContact);
  23634. };
  23635. /**
  23636. * Moves the tooltip with a soft animation to a new position.
  23637. *
  23638. * @private
  23639. * @function Highcharts.Tooltip#move
  23640. *
  23641. * @param {number} x
  23642. *
  23643. * @param {number} y
  23644. *
  23645. * @param {number} anchorX
  23646. *
  23647. * @param {number} anchorY
  23648. */
  23649. Tooltip.prototype.move = function (x, y, anchorX, anchorY) {
  23650. var tooltip = this,
  23651. now = tooltip.now,
  23652. animate = tooltip.options.animation !== false &&
  23653. !tooltip.isHidden &&
  23654. // When we get close to the target position, abort animation and
  23655. // land on the right place (#3056)
  23656. (Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
  23657. skipAnchor = tooltip.followPointer || tooltip.len > 1;
  23658. // Get intermediate values for animation
  23659. extend(now, {
  23660. x: animate ? (2 * now.x + x) / 3 : x,
  23661. y: animate ? (now.y + y) / 2 : y,
  23662. anchorX: skipAnchor ?
  23663. void 0 :
  23664. animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
  23665. anchorY: skipAnchor ?
  23666. void 0 :
  23667. animate ? (now.anchorY + anchorY) / 2 : anchorY
  23668. });
  23669. // Move to the intermediate value
  23670. tooltip.getLabel().attr(now);
  23671. tooltip.drawTracker();
  23672. // Run on next tick of the mouse tracker
  23673. if (animate) {
  23674. // Never allow two timeouts
  23675. U.clearTimeout(this.tooltipTimeout);
  23676. // Set the fixed interval ticking for the smooth tooltip
  23677. this.tooltipTimeout = setTimeout(function () {
  23678. // The interval function may still be running during destroy,
  23679. // so check that the chart is really there before calling.
  23680. if (tooltip) {
  23681. tooltip.move(x, y, anchorX, anchorY);
  23682. }
  23683. }, 32);
  23684. }
  23685. };
  23686. /**
  23687. * Refresh the tooltip's text and position.
  23688. *
  23689. * @function Highcharts.Tooltip#refresh
  23690. *
  23691. * @param {Highcharts.Point|Array<Highcharts.Point>} pointOrPoints
  23692. * Either a point or an array of points.
  23693. *
  23694. * @param {Highcharts.PointerEventObject} [mouseEvent]
  23695. * Mouse event, that is responsible for the refresh and should be
  23696. * used for the tooltip update.
  23697. */
  23698. Tooltip.prototype.refresh = function (pointOrPoints, mouseEvent) {
  23699. var tooltip = this,
  23700. chart = this.chart,
  23701. options = tooltip.options,
  23702. x,
  23703. y,
  23704. points = splat(pointOrPoints),
  23705. point = points[0],
  23706. anchor,
  23707. textConfig = {},
  23708. text,
  23709. pointConfig = [],
  23710. formatter = options.formatter || tooltip.defaultFormatter,
  23711. shared = tooltip.shared,
  23712. styledMode = chart.styledMode;
  23713. if (!options.enabled) {
  23714. return;
  23715. }
  23716. U.clearTimeout(this.hideTimer);
  23717. // get the reference point coordinates (pie charts use tooltipPos)
  23718. tooltip.followPointer = !tooltip.split && point.series.tooltipOptions.followPointer;
  23719. anchor = tooltip.getAnchor(pointOrPoints, mouseEvent);
  23720. x = anchor[0];
  23721. y = anchor[1];
  23722. // shared tooltip, array is sent over
  23723. if (shared &&
  23724. !(!isArray(pointOrPoints) &&
  23725. pointOrPoints.series &&
  23726. pointOrPoints.series.noSharedTooltip)) {
  23727. chart.pointer.applyInactiveState(points);
  23728. // Now set hover state for the choosen ones:
  23729. points.forEach(function (item) {
  23730. item.setState('hover');
  23731. pointConfig.push(item.getLabelConfig());
  23732. });
  23733. textConfig = {
  23734. x: point.category,
  23735. y: point.y
  23736. };
  23737. textConfig.points = pointConfig;
  23738. // single point tooltip
  23739. }
  23740. else {
  23741. textConfig = point.getLabelConfig();
  23742. }
  23743. this.len = pointConfig.length; // #6128
  23744. text = formatter.call(textConfig, tooltip);
  23745. // register the current series
  23746. var currentSeries = point.series;
  23747. this.distance = pick(currentSeries.tooltipOptions.distance, 16);
  23748. // update the inner HTML
  23749. if (text === false) {
  23750. this.hide();
  23751. }
  23752. else {
  23753. // update text
  23754. if (tooltip.split) {
  23755. this.renderSplit(text, points);
  23756. }
  23757. else {
  23758. var checkX = x;
  23759. var checkY = y;
  23760. if (mouseEvent && chart.pointer.isDirectTouch) {
  23761. checkX = mouseEvent.chartX - chart.plotLeft;
  23762. checkY = mouseEvent.chartY - chart.plotTop;
  23763. }
  23764. // #11493, #13095
  23765. if (chart.polar ||
  23766. currentSeries.options.clip === false ||
  23767. currentSeries.shouldShowTooltip(checkX, checkY)) {
  23768. var label = tooltip.getLabel();
  23769. // Prevent the tooltip from flowing over the chart box
  23770. // (#6659)
  23771. if (!options.style.width || styledMode) {
  23772. label.css({
  23773. width: this.chart.spacingBox.width + 'px'
  23774. });
  23775. }
  23776. label.attr({
  23777. text: text && text.join ?
  23778. text.join('') :
  23779. text
  23780. });
  23781. // Set the stroke color of the box to reflect the point
  23782. label.removeClass(/highcharts-color-[\d]+/g)
  23783. .addClass('highcharts-color-' +
  23784. pick(point.colorIndex, currentSeries.colorIndex));
  23785. if (!styledMode) {
  23786. label.attr({
  23787. stroke: (options.borderColor ||
  23788. point.color ||
  23789. currentSeries.color ||
  23790. palette.neutralColor60)
  23791. });
  23792. }
  23793. tooltip.updatePosition({
  23794. plotX: x,
  23795. plotY: y,
  23796. negative: point.negative,
  23797. ttBelow: point.ttBelow,
  23798. h: anchor[2] || 0
  23799. });
  23800. }
  23801. else {
  23802. tooltip.hide();
  23803. return;
  23804. }
  23805. }
  23806. // show it
  23807. if (tooltip.isHidden && tooltip.label) {
  23808. tooltip.label.attr({
  23809. opacity: 1
  23810. }).show();
  23811. }
  23812. tooltip.isHidden = false;
  23813. }
  23814. fireEvent(this, 'refresh');
  23815. };
  23816. /**
  23817. * Render the split tooltip. Loops over each point's text and adds
  23818. * a label next to the point, then uses the distribute function to
  23819. * find best non-overlapping positions.
  23820. *
  23821. * @private
  23822. * @function Highcharts.Tooltip#renderSplit
  23823. *
  23824. * @param {string|Array<(boolean|string)>} labels
  23825. *
  23826. * @param {Array<Highcharts.Point>} points
  23827. */
  23828. Tooltip.prototype.renderSplit = function (labels, points) {
  23829. var tooltip = this;
  23830. var chart = tooltip.chart,
  23831. _a = tooltip.chart,
  23832. chartWidth = _a.chartWidth,
  23833. chartHeight = _a.chartHeight,
  23834. plotHeight = _a.plotHeight,
  23835. plotLeft = _a.plotLeft,
  23836. plotTop = _a.plotTop,
  23837. pointer = _a.pointer,
  23838. _b = _a.scrollablePixelsY,
  23839. scrollablePixelsY = _b === void 0 ? 0 : _b,
  23840. scrollablePixelsX = _a.scrollablePixelsX,
  23841. _c = _a.scrollingContainer,
  23842. _d = _c === void 0 ? { scrollLeft: 0,
  23843. scrollTop: 0 } : _c,
  23844. scrollLeft = _d.scrollLeft,
  23845. scrollTop = _d.scrollTop,
  23846. styledMode = _a.styledMode,
  23847. distance = tooltip.distance,
  23848. options = tooltip.options,
  23849. positioner = tooltip.options.positioner;
  23850. // The area which the tooltip should be limited to. Limit to scrollable
  23851. // plot area if enabled, otherwise limit to the chart container.
  23852. // If outside is true it should be the whole viewport
  23853. var bounds = tooltip.outside && typeof scrollablePixelsX !== 'number' ?
  23854. doc.documentElement.getBoundingClientRect() : {
  23855. left: scrollLeft,
  23856. right: scrollLeft + chartWidth,
  23857. top: scrollTop,
  23858. bottom: scrollTop + chartHeight
  23859. };
  23860. var tooltipLabel = tooltip.getLabel();
  23861. var ren = this.renderer || chart.renderer;
  23862. var headerTop = Boolean(chart.xAxis[0] && chart.xAxis[0].opposite);
  23863. var _e = pointer.getChartPosition(),
  23864. chartLeft = _e.left,
  23865. chartTop = _e.top;
  23866. var distributionBoxTop = plotTop + scrollTop;
  23867. var headerHeight = 0;
  23868. var adjustedPlotHeight = plotHeight - scrollablePixelsY;
  23869. /**
  23870. * Calculates the anchor position for the partial tooltip
  23871. *
  23872. * @private
  23873. * @param {Highcharts.Point} point The point related to the tooltip
  23874. * @return {object} Returns an object with anchorX and anchorY
  23875. */
  23876. function getAnchor(point) {
  23877. var isHeader = point.isHeader,
  23878. _a = point.plotX,
  23879. plotX = _a === void 0 ? 0 : _a,
  23880. _b = point.plotY,
  23881. plotY = _b === void 0 ? 0 : _b,
  23882. series = point.series;
  23883. var anchorX;
  23884. var anchorY;
  23885. if (isHeader) {
  23886. // Set anchorX to plotX
  23887. anchorX = plotLeft + plotX;
  23888. // Set anchorY to center of visible plot area.
  23889. anchorY = plotTop + plotHeight / 2;
  23890. }
  23891. else {
  23892. var xAxis = series.xAxis,
  23893. yAxis = series.yAxis;
  23894. // Set anchorX to plotX. Limit to within xAxis.
  23895. anchorX = xAxis.pos + clamp(plotX, -distance, xAxis.len + distance);
  23896. // Set anchorY, limit to the scrollable plot area
  23897. if (series.shouldShowTooltip(0, yAxis.pos - plotTop + plotY, {
  23898. ignoreX: true
  23899. })) {
  23900. anchorY = yAxis.pos + plotY;
  23901. }
  23902. }
  23903. // Limit values to plot area
  23904. anchorX = clamp(anchorX, bounds.left - distance, bounds.right + distance);
  23905. return { anchorX: anchorX, anchorY: anchorY };
  23906. }
  23907. /**
  23908. * Calculates the position of the partial tooltip
  23909. *
  23910. * @private
  23911. * @param {number} anchorX The partial tooltip anchor x position
  23912. * @param {number} anchorY The partial tooltip anchor y position
  23913. * @param {boolean} isHeader Whether the partial tooltip is a header
  23914. * @param {number} boxWidth Width of the partial tooltip
  23915. * @return {Highcharts.PositionObject} Returns the partial tooltip x and
  23916. * y position
  23917. */
  23918. function defaultPositioner(anchorX, anchorY, isHeader, boxWidth, alignedLeft) {
  23919. if (alignedLeft === void 0) { alignedLeft = true; }
  23920. var y;
  23921. var x;
  23922. if (isHeader) {
  23923. y = headerTop ? 0 : adjustedPlotHeight;
  23924. x = clamp(anchorX - (boxWidth / 2), bounds.left, bounds.right - boxWidth - (tooltip.outside ? chartLeft : 0));
  23925. }
  23926. else {
  23927. y = anchorY - distributionBoxTop;
  23928. x = alignedLeft ?
  23929. anchorX - boxWidth - distance :
  23930. anchorX + distance;
  23931. x = clamp(x, alignedLeft ? x : bounds.left, bounds.right);
  23932. }
  23933. // NOTE: y is relative to distributionBoxTop
  23934. return { x: x, y: y };
  23935. }
  23936. /**
  23937. * Updates the attributes and styling of the partial tooltip. Creates a
  23938. * new partial tooltip if it does not exists.
  23939. *
  23940. * @private
  23941. * @param {Highcharts.SVGElement|undefined} partialTooltip
  23942. * The partial tooltip to update
  23943. * @param {Highcharts.Point} point
  23944. * The point related to the partial tooltip
  23945. * @param {boolean|string} str The text for the partial tooltip
  23946. * @return {Highcharts.SVGElement} Returns the updated partial tooltip
  23947. */
  23948. function updatePartialTooltip(partialTooltip, point, str) {
  23949. var tt = partialTooltip;
  23950. var isHeader = point.isHeader,
  23951. series = point.series;
  23952. var colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none');
  23953. if (!tt) {
  23954. var attribs = {
  23955. padding: options.padding,
  23956. r: options.borderRadius
  23957. };
  23958. if (!styledMode) {
  23959. attribs.fill = options.backgroundColor;
  23960. attribs['stroke-width'] = options.borderWidth;
  23961. }
  23962. tt = ren
  23963. .label('', 0, 0, (options[isHeader ? 'headerShape' : 'shape']) ||
  23964. 'callout', void 0, void 0, options.useHTML)
  23965. .addClass((isHeader ? 'highcharts-tooltip-header ' : '') +
  23966. 'highcharts-tooltip-box ' +
  23967. colorClass)
  23968. .attr(attribs)
  23969. .add(tooltipLabel);
  23970. }
  23971. tt.isActive = true;
  23972. tt.attr({
  23973. text: str
  23974. });
  23975. if (!styledMode) {
  23976. tt.css(options.style)
  23977. .shadow(options.shadow)
  23978. .attr({
  23979. stroke: (options.borderColor ||
  23980. point.color ||
  23981. series.color ||
  23982. palette.neutralColor80)
  23983. });
  23984. }
  23985. return tt;
  23986. }
  23987. // Graceful degradation for legacy formatters
  23988. if (isString(labels)) {
  23989. labels = [false, labels];
  23990. }
  23991. // Create the individual labels for header and points, ignore footer
  23992. var boxes = labels.slice(0,
  23993. points.length + 1).reduce(function (boxes,
  23994. str,
  23995. i) {
  23996. if (str !== false && str !== '') {
  23997. var point = (points[i - 1] ||
  23998. {
  23999. // Item 0 is the header. Instead of this, we could also
  24000. // use the crosshair label
  24001. isHeader: true,
  24002. plotX: points[0].plotX,
  24003. plotY: plotHeight,
  24004. series: {}
  24005. });
  24006. var isHeader = point.isHeader;
  24007. // Store the tooltip label referance on the series
  24008. var owner = isHeader ? tooltip : point.series;
  24009. var tt = owner.tt = updatePartialTooltip(owner.tt,
  24010. point,
  24011. str.toString());
  24012. // Get X position now, so we can move all to the other side in
  24013. // case of overflow
  24014. var bBox = tt.getBBox();
  24015. var boxWidth = bBox.width + tt.strokeWidth();
  24016. if (isHeader) {
  24017. headerHeight = bBox.height;
  24018. adjustedPlotHeight += headerHeight;
  24019. if (headerTop) {
  24020. distributionBoxTop -= headerHeight;
  24021. }
  24022. }
  24023. var _a = getAnchor(point),
  24024. anchorX = _a.anchorX,
  24025. anchorY = _a.anchorY;
  24026. if (typeof anchorY === 'number') {
  24027. var size = bBox.height + 1;
  24028. var boxPosition = (positioner ?
  24029. positioner.call(tooltip,
  24030. boxWidth,
  24031. size,
  24032. point) :
  24033. defaultPositioner(anchorX,
  24034. anchorY,
  24035. isHeader,
  24036. boxWidth));
  24037. boxes.push({
  24038. // 0-align to the top, 1-align to the bottom
  24039. align: positioner ? 0 : void 0,
  24040. anchorX: anchorX,
  24041. anchorY: anchorY,
  24042. boxWidth: boxWidth,
  24043. point: point,
  24044. rank: pick(boxPosition.rank, isHeader ? 1 : 0),
  24045. size: size,
  24046. target: boxPosition.y,
  24047. tt: tt,
  24048. x: boxPosition.x
  24049. });
  24050. }
  24051. else {
  24052. // Hide tooltips which anchorY is outside the visible plot
  24053. // area
  24054. tt.isActive = false;
  24055. }
  24056. }
  24057. return boxes;
  24058. }, []);
  24059. // Realign the tooltips towards the right if there is not enough
  24060. // space to the left and there is space to to the right
  24061. if (!positioner && boxes.some(function (box) {
  24062. // Always realign if the beginning of a label is outside bounds
  24063. var outside = tooltip.outside;
  24064. var boxStart = (outside ? chartLeft : 0) + box.anchorX;
  24065. if (boxStart < bounds.left && boxStart + box.boxWidth < bounds.right) {
  24066. return true;
  24067. }
  24068. // Otherwise, check if there is more space available to the right
  24069. return boxStart < (chartLeft - bounds.left) + box.boxWidth &&
  24070. bounds.right - boxStart > boxStart;
  24071. })) {
  24072. boxes = boxes.map(function (box) {
  24073. var _a = defaultPositioner(box.anchorX,
  24074. box.anchorY,
  24075. box.point.isHeader,
  24076. box.boxWidth,
  24077. false),
  24078. x = _a.x,
  24079. y = _a.y;
  24080. return extend(box, {
  24081. target: y,
  24082. x: x
  24083. });
  24084. });
  24085. }
  24086. // Clean previous run (for missing points)
  24087. tooltip.cleanSplit();
  24088. // Distribute and put in place
  24089. H.distribute(boxes, adjustedPlotHeight);
  24090. var boxExtremes = {
  24091. left: chartLeft,
  24092. right: chartLeft
  24093. };
  24094. // Get the extremes from series tooltips
  24095. boxes.forEach(function (box) {
  24096. var x = box.x,
  24097. boxWidth = box.boxWidth,
  24098. isHeader = box.isHeader;
  24099. if (!isHeader) {
  24100. if (tooltip.outside && chartLeft + x < boxExtremes.left) {
  24101. boxExtremes.left = chartLeft + x;
  24102. }
  24103. if (!isHeader && tooltip.outside && boxExtremes.left + boxWidth > boxExtremes.right) {
  24104. boxExtremes.right = chartLeft + x;
  24105. }
  24106. }
  24107. });
  24108. boxes.forEach(function (box) {
  24109. var x = box.x,
  24110. anchorX = box.anchorX,
  24111. anchorY = box.anchorY,
  24112. pos = box.pos,
  24113. isHeader = box.point.isHeader;
  24114. var attributes = {
  24115. visibility: typeof pos === 'undefined' ? 'hidden' : 'inherit',
  24116. x: x,
  24117. /* NOTE: y should equal pos to be consistent with !split
  24118. * tooltip,
  24119. but is currently relative to plotTop. Is left as is
  24120. * to avoid breaking change. Remove distributionBoxTop to make
  24121. * it consistent.
  24122. */
  24123. y: pos + distributionBoxTop,
  24124. anchorX: anchorX,
  24125. anchorY: anchorY
  24126. };
  24127. // Handle left-aligned tooltips overflowing the chart area
  24128. if (tooltip.outside && x < anchorX) {
  24129. var offset = chartLeft - boxExtremes.left;
  24130. // Skip this if there is no overflow
  24131. if (offset > 0) {
  24132. if (!isHeader) {
  24133. attributes.x = x + offset;
  24134. attributes.anchorX = anchorX + offset;
  24135. }
  24136. if (isHeader) {
  24137. attributes.x = (boxExtremes.right - boxExtremes.left) / 2;
  24138. attributes.anchorX = anchorX + offset;
  24139. }
  24140. }
  24141. }
  24142. // Put the label in place
  24143. box.tt.attr(attributes);
  24144. });
  24145. /* If we have a seperate tooltip container, then update the necessary
  24146. * container properties.
  24147. * Test that tooltip has its own container and renderer before executing
  24148. * the operation.
  24149. */
  24150. var container = tooltip.container,
  24151. outside = tooltip.outside,
  24152. renderer = tooltip.renderer;
  24153. if (outside && container && renderer) {
  24154. // Set container size to fit the bounds
  24155. var _f = tooltipLabel.getBBox(),
  24156. width = _f.width,
  24157. height = _f.height,
  24158. x = _f.x,
  24159. y = _f.y;
  24160. renderer.setSize(width + x, height + y, false);
  24161. // Position the tooltip container to the chart container
  24162. container.style.left = boxExtremes.left + 'px';
  24163. container.style.top = chartTop + 'px';
  24164. }
  24165. };
  24166. /**
  24167. * If the `stickOnContact` option is active, this will add a tracker shape.
  24168. *
  24169. * @private
  24170. * @function Highcharts.Tooltip#drawTracker
  24171. */
  24172. Tooltip.prototype.drawTracker = function () {
  24173. var tooltip = this;
  24174. if (tooltip.followPointer ||
  24175. !tooltip.options.stickOnContact) {
  24176. if (tooltip.tracker) {
  24177. tooltip.tracker.destroy();
  24178. }
  24179. return;
  24180. }
  24181. var chart = tooltip.chart;
  24182. var label = tooltip.label;
  24183. var point = chart.hoverPoint;
  24184. if (!label || !point) {
  24185. return;
  24186. }
  24187. var box = {
  24188. x: 0,
  24189. y: 0,
  24190. width: 0,
  24191. height: 0
  24192. };
  24193. // Combine anchor and tooltip
  24194. var anchorPos = this.getAnchor(point);
  24195. var labelBBox = label.getBBox();
  24196. anchorPos[0] += chart.plotLeft - label.translateX;
  24197. anchorPos[1] += chart.plotTop - label.translateY;
  24198. // When the mouse pointer is between the anchor point and the label,
  24199. // the label should stick.
  24200. box.x = Math.min(0, anchorPos[0]);
  24201. box.y = Math.min(0, anchorPos[1]);
  24202. box.width = (anchorPos[0] < 0 ?
  24203. Math.max(Math.abs(anchorPos[0]), (labelBBox.width - anchorPos[0])) :
  24204. Math.max(Math.abs(anchorPos[0]), labelBBox.width));
  24205. box.height = (anchorPos[1] < 0 ?
  24206. Math.max(Math.abs(anchorPos[1]), (labelBBox.height - Math.abs(anchorPos[1]))) :
  24207. Math.max(Math.abs(anchorPos[1]), labelBBox.height));
  24208. if (tooltip.tracker) {
  24209. tooltip.tracker.attr(box);
  24210. }
  24211. else {
  24212. tooltip.tracker = label.renderer
  24213. .rect(box)
  24214. .addClass('highcharts-tracker')
  24215. .add(label);
  24216. if (!chart.styledMode) {
  24217. tooltip.tracker.attr({
  24218. fill: 'rgba(0,0,0,0)'
  24219. });
  24220. }
  24221. }
  24222. };
  24223. /**
  24224. * @private
  24225. */
  24226. Tooltip.prototype.styledModeFormat = function (formatString) {
  24227. return formatString
  24228. .replace('style="font-size: 10px"', 'class="highcharts-header"')
  24229. .replace(/style="color:{(point|series)\.color}"/g, 'class="highcharts-color-{$1.colorIndex}"');
  24230. };
  24231. /**
  24232. * Format the footer/header of the tooltip
  24233. * #3397: abstraction to enable formatting of footer and header
  24234. *
  24235. * @private
  24236. * @function Highcharts.Tooltip#tooltipFooterHeaderFormatter
  24237. * @param {Highcharts.PointLabelObject} labelConfig
  24238. * @param {boolean} [isFooter]
  24239. * @return {string}
  24240. */
  24241. Tooltip.prototype.tooltipFooterHeaderFormatter = function (labelConfig, isFooter) {
  24242. var footOrHead = isFooter ? 'footer' : 'header',
  24243. series = labelConfig.series,
  24244. tooltipOptions = series.tooltipOptions,
  24245. xDateFormat = tooltipOptions.xDateFormat,
  24246. xAxis = series.xAxis,
  24247. isDateTime = (xAxis &&
  24248. xAxis.options.type === 'datetime' &&
  24249. isNumber(labelConfig.key)),
  24250. formatString = tooltipOptions[footOrHead + 'Format'],
  24251. e = {
  24252. isFooter: isFooter,
  24253. labelConfig: labelConfig
  24254. };
  24255. fireEvent(this, 'headerFormatter', e, function (e) {
  24256. // Guess the best date format based on the closest point distance
  24257. // (#568, #3418)
  24258. if (isDateTime && !xDateFormat) {
  24259. xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
  24260. }
  24261. // Insert the footer date format if any
  24262. if (isDateTime && xDateFormat) {
  24263. ((labelConfig.point && labelConfig.point.tooltipDateKeys) ||
  24264. ['key']).forEach(function (key) {
  24265. formatString = formatString.replace('{point.' + key + '}', '{point.' + key + ':' + xDateFormat + '}');
  24266. });
  24267. }
  24268. // Replace default header style with class name
  24269. if (series.chart.styledMode) {
  24270. formatString = this.styledModeFormat(formatString);
  24271. }
  24272. e.text = format(formatString, {
  24273. point: labelConfig,
  24274. series: series
  24275. }, this.chart);
  24276. });
  24277. return e.text;
  24278. };
  24279. /**
  24280. * Updates the tooltip with the provided tooltip options.
  24281. *
  24282. * @function Highcharts.Tooltip#update
  24283. *
  24284. * @param {Highcharts.TooltipOptions} options
  24285. * The tooltip options to update.
  24286. */
  24287. Tooltip.prototype.update = function (options) {
  24288. this.destroy();
  24289. // Update user options (#6218)
  24290. merge(true, this.chart.options.tooltip.userOptions, options);
  24291. this.init(this.chart, merge(true, this.options, options));
  24292. };
  24293. /**
  24294. * Find the new position and perform the move
  24295. *
  24296. * @private
  24297. * @function Highcharts.Tooltip#updatePosition
  24298. *
  24299. * @param {Highcharts.Point} point
  24300. */
  24301. Tooltip.prototype.updatePosition = function (point) {
  24302. var chart = this.chart,
  24303. pointer = chart.pointer,
  24304. label = this.getLabel(),
  24305. pos,
  24306. anchorX = point.plotX + chart.plotLeft,
  24307. anchorY = point.plotY + chart.plotTop,
  24308. pad;
  24309. // Needed for outside: true (#11688)
  24310. var chartPosition = pointer.getChartPosition();
  24311. pos = (this.options.positioner || this.getPosition).call(this, label.width, label.height, point);
  24312. // Set the renderer size dynamically to prevent document size to change
  24313. if (this.outside) {
  24314. pad = (this.options.borderWidth || 0) + 2 * this.distance;
  24315. this.renderer.setSize(label.width + pad, label.height + pad, false);
  24316. // Anchor and tooltip container need scaling if chart container has
  24317. // scale transform/css zoom. #11329.
  24318. if (chartPosition.scaleX !== 1 || chartPosition.scaleY !== 1) {
  24319. css(this.container, {
  24320. transform: "scale(" + chartPosition.scaleX + ", " + chartPosition.scaleY + ")"
  24321. });
  24322. anchorX *= chartPosition.scaleX;
  24323. anchorY *= chartPosition.scaleY;
  24324. }
  24325. anchorX += chartPosition.left - pos.x;
  24326. anchorY += chartPosition.top - pos.y;
  24327. }
  24328. // do the move
  24329. this.move(Math.round(pos.x), Math.round(pos.y || 0), // can be undefined (#3977)
  24330. anchorX, anchorY);
  24331. };
  24332. return Tooltip;
  24333. }());
  24334. H.Tooltip = Tooltip;
  24335. return H.Tooltip;
  24336. });
  24337. _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) {
  24338. /* *
  24339. *
  24340. * (c) 2010-2021 Torstein Honsi
  24341. *
  24342. * License: www.highcharts.com/license
  24343. *
  24344. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  24345. *
  24346. * */
  24347. var color = Color.parse;
  24348. var charts = H.charts,
  24349. noop = H.noop;
  24350. var addEvent = U.addEvent,
  24351. attr = U.attr,
  24352. css = U.css,
  24353. defined = U.defined,
  24354. extend = U.extend,
  24355. find = U.find,
  24356. fireEvent = U.fireEvent,
  24357. isNumber = U.isNumber,
  24358. isObject = U.isObject,
  24359. objectEach = U.objectEach,
  24360. offset = U.offset,
  24361. pick = U.pick,
  24362. splat = U.splat;
  24363. /**
  24364. * One position in relation to an axis.
  24365. *
  24366. * @interface Highcharts.PointerAxisCoordinateObject
  24367. */ /**
  24368. * Related axis.
  24369. *
  24370. * @name Highcharts.PointerAxisCoordinateObject#axis
  24371. * @type {Highcharts.Axis}
  24372. */ /**
  24373. * Axis value.
  24374. *
  24375. * @name Highcharts.PointerAxisCoordinateObject#value
  24376. * @type {number}
  24377. */
  24378. /**
  24379. * Positions in terms of axis values.
  24380. *
  24381. * @interface Highcharts.PointerAxisCoordinatesObject
  24382. */ /**
  24383. * Positions on the x-axis.
  24384. * @name Highcharts.PointerAxisCoordinatesObject#xAxis
  24385. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  24386. */ /**
  24387. * Positions on the y-axis.
  24388. * @name Highcharts.PointerAxisCoordinatesObject#yAxis
  24389. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  24390. */
  24391. /**
  24392. * Pointer coordinates.
  24393. *
  24394. * @interface Highcharts.PointerCoordinatesObject
  24395. */ /**
  24396. * @name Highcharts.PointerCoordinatesObject#chartX
  24397. * @type {number}
  24398. */ /**
  24399. * @name Highcharts.PointerCoordinatesObject#chartY
  24400. * @type {number}
  24401. */
  24402. /**
  24403. * A native browser mouse or touch event, extended with position information
  24404. * relative to the {@link Chart.container}.
  24405. *
  24406. * @interface Highcharts.PointerEventObject
  24407. * @extends global.PointerEvent
  24408. */ /**
  24409. * The X coordinate of the pointer interaction relative to the chart.
  24410. *
  24411. * @name Highcharts.PointerEventObject#chartX
  24412. * @type {number}
  24413. */ /**
  24414. * The Y coordinate of the pointer interaction relative to the chart.
  24415. *
  24416. * @name Highcharts.PointerEventObject#chartY
  24417. * @type {number}
  24418. */
  24419. /**
  24420. * Axis-specific data of a selection.
  24421. *
  24422. * @interface Highcharts.SelectDataObject
  24423. */ /**
  24424. * @name Highcharts.SelectDataObject#axis
  24425. * @type {Highcharts.Axis}
  24426. */ /**
  24427. * @name Highcharts.SelectDataObject#max
  24428. * @type {number}
  24429. */ /**
  24430. * @name Highcharts.SelectDataObject#min
  24431. * @type {number}
  24432. */
  24433. /**
  24434. * Object for select events.
  24435. *
  24436. * @interface Highcharts.SelectEventObject
  24437. */ /**
  24438. * @name Highcharts.SelectEventObject#originalEvent
  24439. * @type {global.Event}
  24440. */ /**
  24441. * @name Highcharts.SelectEventObject#xAxis
  24442. * @type {Array<Highcharts.SelectDataObject>}
  24443. */ /**
  24444. * @name Highcharts.SelectEventObject#yAxis
  24445. * @type {Array<Highcharts.SelectDataObject>}
  24446. */
  24447. /**
  24448. * Chart position and scale.
  24449. *
  24450. * @interface Highcharts.ChartPositionObject
  24451. */ /**
  24452. * @name Highcharts.ChartPositionObject#left
  24453. * @type {number}
  24454. */ /**
  24455. * @name Highcharts.ChartPositionObject#scaleX
  24456. * @type {number}
  24457. */ /**
  24458. * @name Highcharts.ChartPositionObject#scaleY
  24459. * @type {number}
  24460. */ /**
  24461. * @name Highcharts.ChartPositionObject#top
  24462. * @type {number}
  24463. */
  24464. ''; // detach doclets above
  24465. /* eslint-disable no-invalid-this, valid-jsdoc */
  24466. /**
  24467. * The mouse and touch tracker object. Each {@link Chart} item has one
  24468. * assosiated Pointer item that can be accessed from the {@link Chart.pointer}
  24469. * property.
  24470. *
  24471. * @class
  24472. * @name Highcharts.Pointer
  24473. *
  24474. * @param {Highcharts.Chart} chart
  24475. * The chart instance.
  24476. *
  24477. * @param {Highcharts.Options} options
  24478. * The root options object. The pointer uses options from the chart and
  24479. * tooltip structures.
  24480. */
  24481. var Pointer = /** @class */ (function () {
  24482. /* *
  24483. *
  24484. * Constructors
  24485. *
  24486. * */
  24487. function Pointer(chart, options) {
  24488. this.lastValidTouch = {};
  24489. this.pinchDown = [];
  24490. this.runChartClick = false;
  24491. this.eventsToUnbind = [];
  24492. this.chart = chart;
  24493. this.hasDragged = false;
  24494. this.options = options;
  24495. this.init(chart, options);
  24496. }
  24497. /* *
  24498. *
  24499. * Functions
  24500. *
  24501. * */
  24502. /**
  24503. * Set inactive state to all series that are not currently hovered,
  24504. * or, if `inactiveOtherPoints` is set to true, set inactive state to
  24505. * all points within that series.
  24506. *
  24507. * @private
  24508. * @function Highcharts.Pointer#applyInactiveState
  24509. * @param {Array<Highcharts.Point>} points
  24510. * Currently hovered points
  24511. */
  24512. Pointer.prototype.applyInactiveState = function (points) {
  24513. var activeSeries = [],
  24514. series;
  24515. // Get all active series from the hovered points
  24516. (points || []).forEach(function (item) {
  24517. series = item.series;
  24518. // Include itself
  24519. activeSeries.push(series);
  24520. // Include parent series
  24521. if (series.linkedParent) {
  24522. activeSeries.push(series.linkedParent);
  24523. }
  24524. // Include all child series
  24525. if (series.linkedSeries) {
  24526. activeSeries = activeSeries.concat(series.linkedSeries);
  24527. }
  24528. // Include navigator series
  24529. if (series.navigatorSeries) {
  24530. activeSeries.push(series.navigatorSeries);
  24531. }
  24532. });
  24533. // Now loop over all series, filtering out active series
  24534. this.chart.series.forEach(function (inactiveSeries) {
  24535. if (activeSeries.indexOf(inactiveSeries) === -1) {
  24536. // Inactive series
  24537. inactiveSeries.setState('inactive', true);
  24538. }
  24539. else if (inactiveSeries.options.inactiveOtherPoints) {
  24540. // Active series, but other points should be inactivated
  24541. inactiveSeries.setAllPointsToState('inactive');
  24542. }
  24543. });
  24544. };
  24545. /**
  24546. * Destroys the Pointer object and disconnects DOM events.
  24547. *
  24548. * @function Highcharts.Pointer#destroy
  24549. */
  24550. Pointer.prototype.destroy = function () {
  24551. var pointer = this;
  24552. this.eventsToUnbind.forEach(function (unbind) { return unbind(); });
  24553. this.eventsToUnbind = [];
  24554. if (!H.chartCount) {
  24555. if (H.unbindDocumentMouseUp) {
  24556. H.unbindDocumentMouseUp = H.unbindDocumentMouseUp();
  24557. }
  24558. if (H.unbindDocumentTouchEnd) {
  24559. H.unbindDocumentTouchEnd = H.unbindDocumentTouchEnd();
  24560. }
  24561. }
  24562. // memory and CPU leak
  24563. clearInterval(pointer.tooltipTimeout);
  24564. objectEach(pointer, function (_val, prop) {
  24565. pointer[prop] = void 0;
  24566. });
  24567. };
  24568. /**
  24569. * Perform a drag operation in response to a mousemove event while the mouse
  24570. * is down.
  24571. *
  24572. * @private
  24573. * @function Highcharts.Pointer#drag
  24574. */
  24575. Pointer.prototype.drag = function (e) {
  24576. var chart = this.chart,
  24577. chartOptions = chart.options.chart,
  24578. chartX = e.chartX,
  24579. chartY = e.chartY,
  24580. zoomHor = this.zoomHor,
  24581. zoomVert = this.zoomVert,
  24582. plotLeft = chart.plotLeft,
  24583. plotTop = chart.plotTop,
  24584. plotWidth = chart.plotWidth,
  24585. plotHeight = chart.plotHeight,
  24586. clickedInside,
  24587. size,
  24588. selectionMarker = this.selectionMarker,
  24589. mouseDownX = (this.mouseDownX || 0),
  24590. mouseDownY = (this.mouseDownY || 0),
  24591. panningEnabled = isObject(chartOptions.panning) ?
  24592. chartOptions.panning && chartOptions.panning.enabled :
  24593. chartOptions.panning,
  24594. panKey = (chartOptions.panKey && e[chartOptions.panKey + 'Key']);
  24595. // If the device supports both touch and mouse (like IE11), and we are
  24596. // touch-dragging inside the plot area, don't handle the mouse event.
  24597. // #4339.
  24598. if (selectionMarker && selectionMarker.touch) {
  24599. return;
  24600. }
  24601. // If the mouse is outside the plot area, adjust to cooordinates
  24602. // inside to prevent the selection marker from going outside
  24603. if (chartX < plotLeft) {
  24604. chartX = plotLeft;
  24605. }
  24606. else if (chartX > plotLeft + plotWidth) {
  24607. chartX = plotLeft + plotWidth;
  24608. }
  24609. if (chartY < plotTop) {
  24610. chartY = plotTop;
  24611. }
  24612. else if (chartY > plotTop + plotHeight) {
  24613. chartY = plotTop + plotHeight;
  24614. }
  24615. // determine if the mouse has moved more than 10px
  24616. this.hasDragged = Math.sqrt(Math.pow(mouseDownX - chartX, 2) +
  24617. Math.pow(mouseDownY - chartY, 2));
  24618. if (this.hasDragged > 10) {
  24619. clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop, {
  24620. visiblePlotOnly: true
  24621. });
  24622. // make a selection
  24623. if (chart.hasCartesianSeries &&
  24624. (this.zoomX || this.zoomY) &&
  24625. clickedInside &&
  24626. !panKey) {
  24627. if (!selectionMarker) {
  24628. this.selectionMarker = selectionMarker =
  24629. chart.renderer.rect(plotLeft, plotTop, zoomHor ? 1 : plotWidth, zoomVert ? 1 : plotHeight, 0)
  24630. .attr({
  24631. 'class': 'highcharts-selection-marker',
  24632. zIndex: 7
  24633. })
  24634. .add();
  24635. if (!chart.styledMode) {
  24636. selectionMarker.attr({
  24637. fill: (chartOptions.selectionMarkerFill ||
  24638. color(palette.highlightColor80)
  24639. .setOpacity(0.25).get())
  24640. });
  24641. }
  24642. }
  24643. }
  24644. // adjust the width of the selection marker
  24645. if (selectionMarker && zoomHor) {
  24646. size = chartX - mouseDownX;
  24647. selectionMarker.attr({
  24648. width: Math.abs(size),
  24649. x: (size > 0 ? 0 : size) + mouseDownX
  24650. });
  24651. }
  24652. // adjust the height of the selection marker
  24653. if (selectionMarker && zoomVert) {
  24654. size = chartY - mouseDownY;
  24655. selectionMarker.attr({
  24656. height: Math.abs(size),
  24657. y: (size > 0 ? 0 : size) + mouseDownY
  24658. });
  24659. }
  24660. // panning
  24661. if (clickedInside &&
  24662. !selectionMarker &&
  24663. panningEnabled) {
  24664. chart.pan(e, chartOptions.panning);
  24665. }
  24666. }
  24667. };
  24668. /**
  24669. * Start a drag operation.
  24670. *
  24671. * @private
  24672. * @function Highcharts.Pointer#dragStart
  24673. */
  24674. Pointer.prototype.dragStart = function (e) {
  24675. var chart = this.chart;
  24676. // Record the start position
  24677. chart.mouseIsDown = e.type;
  24678. chart.cancelClick = false;
  24679. chart.mouseDownX = this.mouseDownX = e.chartX;
  24680. chart.mouseDownY = this.mouseDownY = e.chartY;
  24681. };
  24682. /**
  24683. * On mouse up or touch end across the entire document, drop the selection.
  24684. *
  24685. * @private
  24686. * @function Highcharts.Pointer#drop
  24687. *
  24688. * @param {global.Event} e
  24689. */
  24690. Pointer.prototype.drop = function (e) {
  24691. var pointer = this,
  24692. chart = this.chart,
  24693. hasPinched = this.hasPinched;
  24694. if (this.selectionMarker) {
  24695. var selectionData_1 = {
  24696. originalEvent: e,
  24697. xAxis: [],
  24698. yAxis: []
  24699. },
  24700. selectionBox = this.selectionMarker,
  24701. selectionLeft_1 = selectionBox.attr ?
  24702. selectionBox.attr('x') :
  24703. selectionBox.x,
  24704. selectionTop_1 = selectionBox.attr ?
  24705. selectionBox.attr('y') :
  24706. selectionBox.y,
  24707. selectionWidth_1 = selectionBox.attr ?
  24708. selectionBox.attr('width') :
  24709. selectionBox.width,
  24710. selectionHeight_1 = selectionBox.attr ?
  24711. selectionBox.attr('height') :
  24712. selectionBox.height,
  24713. runZoom_1;
  24714. // a selection has been made
  24715. if (this.hasDragged || hasPinched) {
  24716. // record each axis' min and max
  24717. chart.axes.forEach(function (axis) {
  24718. if (axis.zoomEnabled &&
  24719. defined(axis.min) &&
  24720. (hasPinched ||
  24721. pointer[{
  24722. xAxis: 'zoomX',
  24723. yAxis: 'zoomY'
  24724. }[axis.coll]]) &&
  24725. isNumber(selectionLeft_1) &&
  24726. isNumber(selectionTop_1)) { // #859, #3569
  24727. var horiz = axis.horiz,
  24728. minPixelPadding = e.type === 'touchend' ?
  24729. axis.minPixelPadding :
  24730. 0, // #1207, #3075
  24731. selectionMin = axis.toValue((horiz ? selectionLeft_1 : selectionTop_1) +
  24732. minPixelPadding),
  24733. selectionMax = axis.toValue((horiz ?
  24734. selectionLeft_1 + selectionWidth_1 :
  24735. selectionTop_1 + selectionHeight_1) - minPixelPadding);
  24736. selectionData_1[axis.coll].push({
  24737. axis: axis,
  24738. // Min/max for reversed axes
  24739. min: Math.min(selectionMin, selectionMax),
  24740. max: Math.max(selectionMin, selectionMax)
  24741. });
  24742. runZoom_1 = true;
  24743. }
  24744. });
  24745. if (runZoom_1) {
  24746. fireEvent(chart, 'selection', selectionData_1, function (args) {
  24747. chart.zoom(extend(args, hasPinched ?
  24748. { animation: false } :
  24749. null));
  24750. });
  24751. }
  24752. }
  24753. if (isNumber(chart.index)) {
  24754. this.selectionMarker = this.selectionMarker.destroy();
  24755. }
  24756. // Reset scaling preview
  24757. if (hasPinched) {
  24758. this.scaleGroups();
  24759. }
  24760. }
  24761. // Reset all. Check isNumber because it may be destroyed on mouse up
  24762. // (#877)
  24763. if (chart && isNumber(chart.index)) {
  24764. css(chart.container, { cursor: chart._cursor });
  24765. chart.cancelClick = this.hasDragged > 10; // #370
  24766. chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
  24767. this.pinchDown = [];
  24768. }
  24769. };
  24770. /**
  24771. * Finds the closest point to a set of coordinates, using the k-d-tree
  24772. * algorithm.
  24773. *
  24774. * @function Highcharts.Pointer#findNearestKDPoint
  24775. *
  24776. * @param {Array<Highcharts.Series>} series
  24777. * All the series to search in.
  24778. *
  24779. * @param {boolean|undefined} shared
  24780. * Whether it is a shared tooltip or not.
  24781. *
  24782. * @param {Highcharts.PointerEventObject} e
  24783. * The pointer event object, containing chart coordinates of the
  24784. * pointer.
  24785. *
  24786. * @return {Highcharts.Point|undefined}
  24787. * The point closest to given coordinates.
  24788. */
  24789. Pointer.prototype.findNearestKDPoint = function (series, shared, e) {
  24790. var chart = this.chart;
  24791. var hoverPoint = chart.hoverPoint;
  24792. var tooltip = chart.tooltip;
  24793. if (hoverPoint &&
  24794. tooltip &&
  24795. tooltip.isStickyOnContact()) {
  24796. return hoverPoint;
  24797. }
  24798. var closest;
  24799. /** @private */
  24800. function sort(p1, p2) {
  24801. var isCloserX = p1.distX - p2.distX,
  24802. isCloser = p1.dist - p2.dist,
  24803. isAbove = (p2.series.group && p2.series.group.zIndex) -
  24804. (p1.series.group && p1.series.group.zIndex),
  24805. result;
  24806. // We have two points which are not in the same place on xAxis
  24807. // and shared tooltip:
  24808. if (isCloserX !== 0 && shared) { // #5721
  24809. result = isCloserX;
  24810. // Points are not exactly in the same place on x/yAxis:
  24811. }
  24812. else if (isCloser !== 0) {
  24813. result = isCloser;
  24814. // The same xAxis and yAxis position, sort by z-index:
  24815. }
  24816. else if (isAbove !== 0) {
  24817. result = isAbove;
  24818. // The same zIndex, sort by array index:
  24819. }
  24820. else {
  24821. result =
  24822. p1.series.index > p2.series.index ?
  24823. -1 :
  24824. 1;
  24825. }
  24826. return result;
  24827. }
  24828. series.forEach(function (s) {
  24829. var noSharedTooltip = s.noSharedTooltip && shared,
  24830. compareX = (!noSharedTooltip &&
  24831. s.options.findNearestPointBy.indexOf('y') < 0),
  24832. point = s.searchPoint(e,
  24833. compareX);
  24834. if ( // Check that we actually found a point on the series.
  24835. isObject(point, true) && point.series &&
  24836. // Use the new point if it is closer.
  24837. (!isObject(closest, true) ||
  24838. (sort(closest, point) > 0))) {
  24839. closest = point;
  24840. }
  24841. });
  24842. return closest;
  24843. };
  24844. /**
  24845. * @private
  24846. * @function Highcharts.Pointer#getChartCoordinatesFromPoint
  24847. * @param {Highcharts.Point} point
  24848. * @param {boolean} [inverted]
  24849. * @return {Highcharts.PointerCoordinatesObject|undefined}
  24850. */
  24851. Pointer.prototype.getChartCoordinatesFromPoint = function (point, inverted) {
  24852. var series = point.series,
  24853. xAxis = series.xAxis,
  24854. yAxis = series.yAxis,
  24855. shapeArgs = point.shapeArgs;
  24856. if (xAxis && yAxis) {
  24857. var x = pick(point.clientX,
  24858. point.plotX);
  24859. var y = point.plotY || 0;
  24860. if (point.isNode &&
  24861. shapeArgs &&
  24862. isNumber(shapeArgs.x) &&
  24863. isNumber(shapeArgs.y)) {
  24864. x = shapeArgs.x;
  24865. y = shapeArgs.y;
  24866. }
  24867. return inverted ? {
  24868. chartX: yAxis.len + yAxis.pos - y,
  24869. chartY: xAxis.len + xAxis.pos - x
  24870. } : {
  24871. chartX: x + xAxis.pos,
  24872. chartY: y + yAxis.pos
  24873. };
  24874. }
  24875. if (shapeArgs && shapeArgs.x && shapeArgs.y) {
  24876. // E.g. pies do not have axes
  24877. return {
  24878. chartX: shapeArgs.x,
  24879. chartY: shapeArgs.y
  24880. };
  24881. }
  24882. };
  24883. /**
  24884. * Return the cached chartPosition if it is available on the Pointer,
  24885. * otherwise find it. Running offset is quite expensive, so it should be
  24886. * avoided when we know the chart hasn't moved.
  24887. *
  24888. * @function Highcharts.Pointer#getChartPosition
  24889. *
  24890. * @return {Highcharts.ChartPositionObject}
  24891. * The offset of the chart container within the page
  24892. */
  24893. Pointer.prototype.getChartPosition = function () {
  24894. if (this.chartPosition) {
  24895. return this.chartPosition;
  24896. }
  24897. var container = this.chart.container;
  24898. var pos = offset(container);
  24899. this.chartPosition = {
  24900. left: pos.left,
  24901. top: pos.top,
  24902. scaleX: 1,
  24903. scaleY: 1
  24904. };
  24905. var offsetWidth = container.offsetWidth;
  24906. var offsetHeight = container.offsetHeight;
  24907. // #13342 - tooltip was not visible in Chrome, when chart
  24908. // updates height.
  24909. if (offsetWidth > 2 && // #13342
  24910. offsetHeight > 2 // #13342
  24911. ) {
  24912. this.chartPosition.scaleX = pos.width / offsetWidth;
  24913. this.chartPosition.scaleY = pos.height / offsetHeight;
  24914. }
  24915. return this.chartPosition;
  24916. };
  24917. /**
  24918. * Get the click position in terms of axis values.
  24919. *
  24920. * @function Highcharts.Pointer#getCoordinates
  24921. *
  24922. * @param {Highcharts.PointerEventObject} e
  24923. * Pointer event, extended with `chartX` and `chartY` properties.
  24924. *
  24925. * @return {Highcharts.PointerAxisCoordinatesObject}
  24926. */
  24927. Pointer.prototype.getCoordinates = function (e) {
  24928. var coordinates = {
  24929. xAxis: [],
  24930. yAxis: []
  24931. };
  24932. this.chart.axes.forEach(function (axis) {
  24933. coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
  24934. axis: axis,
  24935. value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
  24936. });
  24937. });
  24938. return coordinates;
  24939. };
  24940. /**
  24941. * Calculates what is the current hovered point/points and series.
  24942. *
  24943. * @private
  24944. * @function Highcharts.Pointer#getHoverData
  24945. *
  24946. * @param {Highcharts.Point|undefined} existingHoverPoint
  24947. * The point currrently beeing hovered.
  24948. *
  24949. * @param {Highcharts.Series|undefined} existingHoverSeries
  24950. * The series currently beeing hovered.
  24951. *
  24952. * @param {Array<Highcharts.Series>} series
  24953. * All the series in the chart.
  24954. *
  24955. * @param {boolean} isDirectTouch
  24956. * Is the pointer directly hovering the point.
  24957. *
  24958. * @param {boolean|undefined} shared
  24959. * Whether it is a shared tooltip or not.
  24960. *
  24961. * @param {Highcharts.PointerEventObject} [e]
  24962. * The triggering event, containing chart coordinates of the pointer.
  24963. *
  24964. * @return {object}
  24965. * Object containing resulting hover data: hoverPoint, hoverSeries,
  24966. * and hoverPoints.
  24967. */
  24968. Pointer.prototype.getHoverData = function (existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
  24969. var hoverPoint,
  24970. hoverPoints = [],
  24971. hoverSeries = existingHoverSeries,
  24972. useExisting = !!(isDirectTouch && existingHoverPoint),
  24973. notSticky = hoverSeries && !hoverSeries.stickyTracking,
  24974. // Which series to look in for the hover point
  24975. searchSeries,
  24976. // Parameters needed for beforeGetHoverData event.
  24977. eventArgs = {
  24978. chartX: e ? e.chartX : void 0,
  24979. chartY: e ? e.chartY : void 0,
  24980. shared: shared
  24981. },
  24982. filter = function (s) {
  24983. return (s.visible &&
  24984. !(!shared && s.directTouch) && // #3821
  24985. pick(s.options.enableMouseTracking,
  24986. true));
  24987. };
  24988. // Find chart.hoverPane and update filter method in polar.
  24989. fireEvent(this, 'beforeGetHoverData', eventArgs);
  24990. searchSeries = notSticky ?
  24991. // Only search on hovered series if it has stickyTracking false
  24992. [hoverSeries] :
  24993. // Filter what series to look in.
  24994. series.filter(function (s) {
  24995. return eventArgs.filter ? eventArgs.filter(s) : filter(s) &&
  24996. s.stickyTracking;
  24997. });
  24998. // Use existing hovered point or find the one closest to coordinates.
  24999. hoverPoint = useExisting || !e ?
  25000. existingHoverPoint :
  25001. this.findNearestKDPoint(searchSeries, shared, e);
  25002. // Assign hover series
  25003. hoverSeries = hoverPoint && hoverPoint.series;
  25004. // If we have a hoverPoint, assign hoverPoints.
  25005. if (hoverPoint) {
  25006. // When tooltip is shared, it displays more than one point
  25007. if (shared && !hoverSeries.noSharedTooltip) {
  25008. searchSeries = series.filter(function (s) {
  25009. return eventArgs.filter ?
  25010. eventArgs.filter(s) : filter(s) && !s.noSharedTooltip;
  25011. });
  25012. // Get all points with the same x value as the hoverPoint
  25013. searchSeries.forEach(function (s) {
  25014. var point = find(s.points,
  25015. function (p) {
  25016. return p.x === hoverPoint.x && !p.isNull;
  25017. });
  25018. if (isObject(point)) {
  25019. /*
  25020. * Boost returns a minimal point. Convert it to a usable
  25021. * point for tooltip and states.
  25022. */
  25023. if (s.chart.isBoosting) {
  25024. point = s.getPoint(point);
  25025. }
  25026. hoverPoints.push(point);
  25027. }
  25028. });
  25029. }
  25030. else {
  25031. hoverPoints.push(hoverPoint);
  25032. }
  25033. }
  25034. // Check whether the hoverPoint is inside pane we are hovering over.
  25035. eventArgs = { hoverPoint: hoverPoint };
  25036. fireEvent(this, 'afterGetHoverData', eventArgs);
  25037. return {
  25038. hoverPoint: eventArgs.hoverPoint,
  25039. hoverSeries: hoverSeries,
  25040. hoverPoints: hoverPoints
  25041. };
  25042. };
  25043. /**
  25044. * @private
  25045. * @function Highcharts.Pointer#getPointFromEvent
  25046. *
  25047. * @param {global.Event} e
  25048. *
  25049. * @return {Highcharts.Point|undefined}
  25050. */
  25051. Pointer.prototype.getPointFromEvent = function (e) {
  25052. var target = e.target,
  25053. point;
  25054. while (target && !point) {
  25055. point = target.point;
  25056. target = target.parentNode;
  25057. }
  25058. return point;
  25059. };
  25060. /**
  25061. * @private
  25062. * @function Highcharts.Pointer#onTrackerMouseOut
  25063. */
  25064. Pointer.prototype.onTrackerMouseOut = function (e) {
  25065. var chart = this.chart;
  25066. var relatedTarget = e.relatedTarget || e.toElement;
  25067. var series = chart.hoverSeries;
  25068. this.isDirectTouch = false;
  25069. if (series &&
  25070. relatedTarget &&
  25071. !series.stickyTracking &&
  25072. !this.inClass(relatedTarget, 'highcharts-tooltip') &&
  25073. (!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465, #5553
  25074. !this.inClass(relatedTarget, 'highcharts-tracker'))) {
  25075. series.onMouseOut();
  25076. }
  25077. };
  25078. /**
  25079. * Utility to detect whether an element has, or has a parent with, a
  25080. * specificclass name. Used on detection of tracker objects and on deciding
  25081. * whether hovering the tooltip should cause the active series to mouse out.
  25082. *
  25083. * @function Highcharts.Pointer#inClass
  25084. *
  25085. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  25086. * The element to investigate.
  25087. *
  25088. * @param {string} className
  25089. * The class name to look for.
  25090. *
  25091. * @return {boolean|undefined}
  25092. * True if either the element or one of its parents has the given
  25093. * class name.
  25094. */
  25095. Pointer.prototype.inClass = function (element, className) {
  25096. var elemClassName;
  25097. while (element) {
  25098. elemClassName = attr(element, 'class');
  25099. if (elemClassName) {
  25100. if (elemClassName.indexOf(className) !== -1) {
  25101. return true;
  25102. }
  25103. if (elemClassName.indexOf('highcharts-container') !== -1) {
  25104. return false;
  25105. }
  25106. }
  25107. element = element.parentNode;
  25108. }
  25109. };
  25110. /**
  25111. * Initialize the Pointer.
  25112. *
  25113. * @private
  25114. * @function Highcharts.Pointer#init
  25115. *
  25116. * @param {Highcharts.Chart} chart
  25117. * The Chart instance.
  25118. *
  25119. * @param {Highcharts.Options} options
  25120. * The root options object. The pointer uses options from the chart
  25121. * and tooltip structures.
  25122. *
  25123. * @return {void}
  25124. */
  25125. Pointer.prototype.init = function (chart, options) {
  25126. // Store references
  25127. this.options = options;
  25128. this.chart = chart;
  25129. // Do we need to handle click on a touch device?
  25130. this.runChartClick = Boolean(options.chart.events && options.chart.events.click);
  25131. this.pinchDown = [];
  25132. this.lastValidTouch = {};
  25133. if (Tooltip) {
  25134. /**
  25135. * Tooltip object for points of series.
  25136. *
  25137. * @name Highcharts.Chart#tooltip
  25138. * @type {Highcharts.Tooltip}
  25139. */
  25140. chart.tooltip = new Tooltip(chart, options.tooltip);
  25141. this.followTouchMove = pick(options.tooltip.followTouchMove, true);
  25142. }
  25143. this.setDOMEvents();
  25144. };
  25145. /**
  25146. * Takes a browser event object and extends it with custom Highcharts
  25147. * properties `chartX` and `chartY` in order to work on the internal
  25148. * coordinate system.
  25149. *
  25150. * @function Highcharts.Pointer#normalize
  25151. *
  25152. * @param {global.MouseEvent|global.PointerEvent|global.TouchEvent} e
  25153. * Event object in standard browsers.
  25154. *
  25155. * @param {Highcharts.OffsetObject} [chartPosition]
  25156. * Additional chart offset.
  25157. *
  25158. * @return {Highcharts.PointerEventObject}
  25159. * A browser event with extended properties `chartX` and `chartY`.
  25160. */
  25161. Pointer.prototype.normalize = function (e, chartPosition) {
  25162. var touches = e.touches;
  25163. // iOS (#2757)
  25164. var ePos = (touches ?
  25165. touches.length ?
  25166. touches.item(0) :
  25167. (pick(// #13534
  25168. touches.changedTouches,
  25169. e.changedTouches))[0] :
  25170. e);
  25171. // Get mouse position
  25172. if (!chartPosition) {
  25173. chartPosition = this.getChartPosition();
  25174. }
  25175. var chartX = ePos.pageX - chartPosition.left,
  25176. chartY = ePos.pageY - chartPosition.top;
  25177. // #11329 - when there is scaling on a parent element, we need to take
  25178. // this into account
  25179. chartX /= chartPosition.scaleX;
  25180. chartY /= chartPosition.scaleY;
  25181. return extend(e, {
  25182. chartX: Math.round(chartX),
  25183. chartY: Math.round(chartY)
  25184. });
  25185. };
  25186. /**
  25187. * @private
  25188. * @function Highcharts.Pointer#onContainerClick
  25189. */
  25190. Pointer.prototype.onContainerClick = function (e) {
  25191. var chart = this.chart;
  25192. var hoverPoint = chart.hoverPoint;
  25193. var pEvt = this.normalize(e);
  25194. var plotLeft = chart.plotLeft;
  25195. var plotTop = chart.plotTop;
  25196. if (!chart.cancelClick) {
  25197. // On tracker click, fire the series and point events. #783, #1583
  25198. if (hoverPoint &&
  25199. this.inClass(pEvt.target, 'highcharts-tracker')) {
  25200. // the series click event
  25201. fireEvent(hoverPoint.series, 'click', extend(pEvt, {
  25202. point: hoverPoint
  25203. }));
  25204. // the point click event
  25205. if (chart.hoverPoint) { // it may be destroyed (#1844)
  25206. hoverPoint.firePointEvent('click', pEvt);
  25207. }
  25208. // When clicking outside a tracker, fire a chart event
  25209. }
  25210. else {
  25211. extend(pEvt, this.getCoordinates(pEvt));
  25212. // fire a click event in the chart
  25213. if (chart.isInsidePlot(pEvt.chartX - plotLeft, pEvt.chartY - plotTop, {
  25214. visiblePlotOnly: true
  25215. })) {
  25216. fireEvent(chart, 'click', pEvt);
  25217. }
  25218. }
  25219. }
  25220. };
  25221. /**
  25222. * @private
  25223. * @function Highcharts.Pointer#onContainerMouseDown
  25224. *
  25225. * @param {global.MouseEvent} e
  25226. */
  25227. Pointer.prototype.onContainerMouseDown = function (e) {
  25228. var isPrimaryButton = ((e.buttons || e.button) & 1) === 1;
  25229. // Normalize before the 'if' for the legacy IE (#7850)
  25230. e = this.normalize(e);
  25231. // #11635, Firefox does not reliable fire move event after click scroll
  25232. if (H.isFirefox &&
  25233. e.button !== 0) {
  25234. this.onContainerMouseMove(e);
  25235. }
  25236. // #11635, limiting to primary button (incl. IE 8 support)
  25237. if (typeof e.button === 'undefined' ||
  25238. isPrimaryButton) {
  25239. this.zoomOption(e);
  25240. // #295, #13737 solve conflict between container drag and chart zoom
  25241. if (isPrimaryButton &&
  25242. e.preventDefault) {
  25243. e.preventDefault();
  25244. }
  25245. this.dragStart(e);
  25246. }
  25247. };
  25248. /**
  25249. * When mouse leaves the container, hide the tooltip.
  25250. *
  25251. * @private
  25252. * @function Highcharts.Pointer#onContainerMouseLeave
  25253. *
  25254. * @param {global.MouseEvent} e
  25255. *
  25256. * @return {void}
  25257. */
  25258. Pointer.prototype.onContainerMouseLeave = function (e) {
  25259. var chart = charts[pick(H.hoverChartIndex, -1)];
  25260. var tooltip = this.chart.tooltip;
  25261. e = this.normalize(e);
  25262. // #4886, MS Touch end fires mouseleave but with no related target
  25263. if (chart &&
  25264. (e.relatedTarget || e.toElement)) {
  25265. chart.pointer.reset();
  25266. // Also reset the chart position, used in #149 fix
  25267. chart.pointer.chartPosition = void 0;
  25268. }
  25269. if ( // #11635, Firefox wheel scroll does not fire out events consistently
  25270. tooltip &&
  25271. !tooltip.isHidden) {
  25272. this.reset();
  25273. }
  25274. };
  25275. /**
  25276. * When mouse enters the container, delete pointer's chartPosition.
  25277. *
  25278. * @private
  25279. * @function Highcharts.Pointer#onContainerMouseEnter
  25280. *
  25281. * @param {global.MouseEvent} e
  25282. *
  25283. * @return {void}
  25284. */
  25285. Pointer.prototype.onContainerMouseEnter = function (e) {
  25286. delete this.chartPosition;
  25287. };
  25288. /**
  25289. * The mousemove, touchmove and touchstart event handler
  25290. *
  25291. * @private
  25292. * @function Highcharts.Pointer#onContainerMouseMove
  25293. *
  25294. * @param {global.MouseEvent} e
  25295. *
  25296. * @return {void}
  25297. */
  25298. Pointer.prototype.onContainerMouseMove = function (e) {
  25299. var chart = this.chart;
  25300. var pEvt = this.normalize(e);
  25301. this.setHoverChartIndex();
  25302. // In IE8 we apparently need this returnValue set to false in order to
  25303. // avoid text being selected. But in Chrome, e.returnValue is prevented,
  25304. // plus we don't need to run e.preventDefault to prevent selected text
  25305. // in modern browsers. So we set it conditionally. Remove it when IE8 is
  25306. // no longer needed. #2251, #3224.
  25307. if (!pEvt.preventDefault) {
  25308. pEvt.returnValue = false;
  25309. }
  25310. if (chart.mouseIsDown === 'mousedown' || this.touchSelect(pEvt)) {
  25311. this.drag(pEvt);
  25312. }
  25313. // Show the tooltip and run mouse over events (#977)
  25314. if (!chart.openMenu &&
  25315. (this.inClass(pEvt.target, 'highcharts-tracker') ||
  25316. chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25317. visiblePlotOnly: true
  25318. }))) {
  25319. this.runPointActions(pEvt);
  25320. }
  25321. };
  25322. /**
  25323. * @private
  25324. * @function Highcharts.Pointer#onDocumentTouchEnd
  25325. *
  25326. * @param {Highcharts.PointerEventObject} e
  25327. *
  25328. * @return {void}
  25329. */
  25330. Pointer.prototype.onDocumentTouchEnd = function (e) {
  25331. if (charts[H.hoverChartIndex]) {
  25332. charts[H.hoverChartIndex].pointer.drop(e);
  25333. }
  25334. };
  25335. /**
  25336. * @private
  25337. * @function Highcharts.Pointer#onContainerTouchMove
  25338. *
  25339. * @param {Highcharts.PointerEventObject} e
  25340. *
  25341. * @return {void}
  25342. */
  25343. Pointer.prototype.onContainerTouchMove = function (e) {
  25344. if (this.touchSelect(e)) {
  25345. this.onContainerMouseMove(e);
  25346. }
  25347. else {
  25348. this.touch(e);
  25349. }
  25350. };
  25351. /**
  25352. * @private
  25353. * @function Highcharts.Pointer#onContainerTouchStart
  25354. *
  25355. * @param {Highcharts.PointerEventObject} e
  25356. *
  25357. * @return {void}
  25358. */
  25359. Pointer.prototype.onContainerTouchStart = function (e) {
  25360. if (this.touchSelect(e)) {
  25361. this.onContainerMouseDown(e);
  25362. }
  25363. else {
  25364. this.zoomOption(e);
  25365. this.touch(e, true);
  25366. }
  25367. };
  25368. /**
  25369. * Special handler for mouse move that will hide the tooltip when the mouse
  25370. * leaves the plotarea. Issue #149 workaround. The mouseleave event does not
  25371. * always fire.
  25372. *
  25373. * @private
  25374. * @function Highcharts.Pointer#onDocumentMouseMove
  25375. *
  25376. * @param {global.MouseEvent} e
  25377. *
  25378. * @return {void}
  25379. */
  25380. Pointer.prototype.onDocumentMouseMove = function (e) {
  25381. var chart = this.chart;
  25382. var chartPosition = this.chartPosition;
  25383. var pEvt = this.normalize(e,
  25384. chartPosition);
  25385. var tooltip = chart.tooltip;
  25386. // If we're outside, hide the tooltip
  25387. if (chartPosition &&
  25388. (!tooltip ||
  25389. !tooltip.isStickyOnContact()) &&
  25390. !chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25391. visiblePlotOnly: true
  25392. }) &&
  25393. !this.inClass(pEvt.target, 'highcharts-tracker')) {
  25394. this.reset();
  25395. }
  25396. };
  25397. /**
  25398. * @private
  25399. * @function Highcharts.Pointer#onDocumentMouseUp
  25400. *
  25401. * @param {global.MouseEvent} e
  25402. *
  25403. * @return {void}
  25404. */
  25405. Pointer.prototype.onDocumentMouseUp = function (e) {
  25406. var chart = charts[pick(H.hoverChartIndex, -1)];
  25407. if (chart) {
  25408. chart.pointer.drop(e);
  25409. }
  25410. };
  25411. /**
  25412. * Handle touch events with two touches
  25413. *
  25414. * @private
  25415. * @function Highcharts.Pointer#pinch
  25416. *
  25417. * @param {Highcharts.PointerEventObject} e
  25418. *
  25419. * @return {void}
  25420. */
  25421. Pointer.prototype.pinch = function (e) {
  25422. var self = this,
  25423. chart = self.chart,
  25424. pinchDown = self.pinchDown,
  25425. touches = (e.touches || []),
  25426. touchesLength = touches.length,
  25427. lastValidTouch = self.lastValidTouch,
  25428. hasZoom = self.hasZoom,
  25429. selectionMarker = self.selectionMarker,
  25430. transform = {},
  25431. fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
  25432. chart.runTrackerClick) ||
  25433. self.runChartClick),
  25434. clip = {};
  25435. // Don't initiate panning until the user has pinched. This prevents us
  25436. // from blocking page scrolling as users scroll down a long page
  25437. // (#4210).
  25438. if (touchesLength > 1) {
  25439. self.initiated = true;
  25440. }
  25441. // On touch devices, only proceed to trigger click if a handler is
  25442. // defined
  25443. if (hasZoom && self.initiated && !fireClickEvent && e.cancelable !== false) {
  25444. e.preventDefault();
  25445. }
  25446. // Normalize each touch
  25447. [].map.call(touches, function (e) {
  25448. return self.normalize(e);
  25449. });
  25450. // Register the touch start position
  25451. if (e.type === 'touchstart') {
  25452. [].forEach.call(touches, function (e, i) {
  25453. pinchDown[i] = { chartX: e.chartX, chartY: e.chartY };
  25454. });
  25455. lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] &&
  25456. pinchDown[1].chartX];
  25457. lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] &&
  25458. pinchDown[1].chartY];
  25459. // Identify the data bounds in pixels
  25460. chart.axes.forEach(function (axis) {
  25461. if (axis.zoomEnabled) {
  25462. var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
  25463. minPixelPadding = axis.minPixelPadding,
  25464. min = axis.toPixels(Math.min(pick(axis.options.min,
  25465. axis.dataMin),
  25466. axis.dataMin)),
  25467. max = axis.toPixels(Math.max(pick(axis.options.max,
  25468. axis.dataMax),
  25469. axis.dataMax)),
  25470. absMin = Math.min(min,
  25471. max),
  25472. absMax = Math.max(min,
  25473. max);
  25474. // Store the bounds for use in the touchmove handler
  25475. bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
  25476. bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
  25477. }
  25478. });
  25479. self.res = true; // reset on next move
  25480. // Optionally move the tooltip on touchmove
  25481. }
  25482. else if (self.followTouchMove && touchesLength === 1) {
  25483. this.runPointActions(self.normalize(e));
  25484. // Event type is touchmove, handle panning and pinching
  25485. }
  25486. else if (pinchDown.length) { // can be 0 when releasing, if touchend
  25487. // fires first
  25488. // Set the marker
  25489. if (!selectionMarker) {
  25490. // @todo It's a mock object, so maybe we need a separate
  25491. // interface
  25492. self.selectionMarker = selectionMarker = extend({
  25493. destroy: noop,
  25494. touch: true
  25495. }, chart.plotBox);
  25496. }
  25497. self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25498. self.hasPinched = hasZoom;
  25499. // Scale and translate the groups to provide visual feedback during
  25500. // pinching
  25501. self.scaleGroups(transform, clip);
  25502. if (self.res) {
  25503. self.res = false;
  25504. this.reset(false, 0);
  25505. }
  25506. }
  25507. };
  25508. /**
  25509. * Run translation operations
  25510. *
  25511. * @private
  25512. * @function Highcharts.Pointer#pinchTranslate
  25513. *
  25514. * @param {Array<*>} pinchDown
  25515. *
  25516. * @param {Array<Highcharts.PointerEventObject>} touches
  25517. *
  25518. * @param {*} transform
  25519. *
  25520. * @param {*} selectionMarker
  25521. *
  25522. * @param {*} clip
  25523. *
  25524. * @param {*} lastValidTouch
  25525. *
  25526. * @return {void}
  25527. */
  25528. Pointer.prototype.pinchTranslate = function (pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  25529. if (this.zoomHor) {
  25530. this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25531. }
  25532. if (this.zoomVert) {
  25533. this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25534. }
  25535. };
  25536. /**
  25537. * Run translation operations for each direction (horizontal and vertical)
  25538. * independently.
  25539. *
  25540. * @private
  25541. * @function Highcharts.Pointer#pinchTranslateDirection
  25542. *
  25543. * @param {boolean} horiz
  25544. *
  25545. * @param {Array<*>} pinchDown
  25546. *
  25547. * @param {Array<Highcharts.PointerEventObject>} touches
  25548. *
  25549. * @param {*} transform
  25550. *
  25551. * @param {*} selectionMarker
  25552. *
  25553. * @param {*} clip
  25554. *
  25555. * @param {*} lastValidTouch
  25556. *
  25557. * @param {number|undefined} [forcedScale=1]
  25558. *
  25559. * @return {void}
  25560. */
  25561. Pointer.prototype.pinchTranslateDirection = function (horiz, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, forcedScale) {
  25562. 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')], selectionWH, selectionXY, clipXY, scale = forcedScale || 1, inverted = chart.inverted, bounds = chart.bounds[horiz ? 'h' : 'v'], singleTouch = pinchDown.length === 1, touch0Start = pinchDown[0][sChartXY], touch0Now = touches[0][sChartXY], touch1Start = !singleTouch && pinchDown[1][sChartXY], touch1Now = !singleTouch && touches[1][sChartXY], outOfBounds, transformScale, scaleKey, setScale = function () {
  25563. // Don't zoom if fingers are too close on this axis
  25564. if (typeof touch1Now === 'number' &&
  25565. Math.abs(touch0Start - touch1Start) > 20) {
  25566. scale = forcedScale ||
  25567. Math.abs(touch0Now - touch1Now) /
  25568. Math.abs(touch0Start - touch1Start);
  25569. }
  25570. clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
  25571. selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
  25572. };
  25573. // Set the scale, first pass
  25574. setScale();
  25575. // The clip position (x or y) is altered if out of bounds, the selection
  25576. // position is not
  25577. selectionXY = clipXY;
  25578. // Out of bounds
  25579. if (selectionXY < bounds.min) {
  25580. selectionXY = bounds.min;
  25581. outOfBounds = true;
  25582. }
  25583. else if (selectionXY + selectionWH > bounds.max) {
  25584. selectionXY = bounds.max - selectionWH;
  25585. outOfBounds = true;
  25586. }
  25587. // Is the chart dragged off its bounds, determined by dataMin and
  25588. // dataMax?
  25589. if (outOfBounds) {
  25590. // Modify the touchNow position in order to create an elastic drag
  25591. // movement. This indicates to the user that the chart is responsive
  25592. // but can't be dragged further.
  25593. touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
  25594. if (typeof touch1Now === 'number') {
  25595. touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
  25596. }
  25597. // Set the scale, second pass to adapt to the modified touchNow
  25598. // positions
  25599. setScale();
  25600. }
  25601. else {
  25602. lastValidTouch[xy] = [touch0Now, touch1Now];
  25603. }
  25604. // Set geometry for clipping, selection and transformation
  25605. if (!inverted) {
  25606. clip[xy] = clipXY - plotLeftTop;
  25607. clip[wh] = selectionWH;
  25608. }
  25609. scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
  25610. transformScale = inverted ? 1 / scale : scale;
  25611. selectionMarker[wh] = selectionWH;
  25612. selectionMarker[xy] = selectionXY;
  25613. transform[scaleKey] = scale;
  25614. transform['translate' + XY] = (transformScale * plotLeftTop) +
  25615. (touch0Now - (transformScale * touch0Start));
  25616. };
  25617. /**
  25618. * Reset the tracking by hiding the tooltip, the hover series state and the
  25619. * hover point
  25620. *
  25621. * @function Highcharts.Pointer#reset
  25622. *
  25623. * @param {boolean} [allowMove]
  25624. * Instead of destroying the tooltip altogether, allow moving it if
  25625. * possible.
  25626. *
  25627. * @param {number} [delay]
  25628. *
  25629. * @return {void}
  25630. */
  25631. Pointer.prototype.reset = function (allowMove, delay) {
  25632. var pointer = this,
  25633. chart = pointer.chart,
  25634. hoverSeries = chart.hoverSeries,
  25635. hoverPoint = chart.hoverPoint,
  25636. hoverPoints = chart.hoverPoints,
  25637. tooltip = chart.tooltip,
  25638. tooltipPoints = tooltip && tooltip.shared ?
  25639. hoverPoints :
  25640. hoverPoint;
  25641. // Check if the points have moved outside the plot area (#1003, #4736,
  25642. // #5101)
  25643. if (allowMove && tooltipPoints) {
  25644. splat(tooltipPoints).forEach(function (point) {
  25645. if (point.series.isCartesian &&
  25646. typeof point.plotX === 'undefined') {
  25647. allowMove = false;
  25648. }
  25649. });
  25650. }
  25651. // Just move the tooltip, #349
  25652. if (allowMove) {
  25653. if (tooltip && tooltipPoints && splat(tooltipPoints).length) {
  25654. tooltip.refresh(tooltipPoints);
  25655. if (tooltip.shared && hoverPoints) { // #8284
  25656. hoverPoints.forEach(function (point) {
  25657. point.setState(point.state, true);
  25658. if (point.series.isCartesian) {
  25659. if (point.series.xAxis.crosshair) {
  25660. point.series.xAxis
  25661. .drawCrosshair(null, point);
  25662. }
  25663. if (point.series.yAxis.crosshair) {
  25664. point.series.yAxis
  25665. .drawCrosshair(null, point);
  25666. }
  25667. }
  25668. });
  25669. }
  25670. else if (hoverPoint) { // #2500
  25671. hoverPoint.setState(hoverPoint.state, true);
  25672. chart.axes.forEach(function (axis) {
  25673. if (axis.crosshair &&
  25674. hoverPoint.series[axis.coll] === axis) {
  25675. axis.drawCrosshair(null, hoverPoint);
  25676. }
  25677. });
  25678. }
  25679. }
  25680. // Full reset
  25681. }
  25682. else {
  25683. if (hoverPoint) {
  25684. hoverPoint.onMouseOut();
  25685. }
  25686. if (hoverPoints) {
  25687. hoverPoints.forEach(function (point) {
  25688. point.setState();
  25689. });
  25690. }
  25691. if (hoverSeries) {
  25692. hoverSeries.onMouseOut();
  25693. }
  25694. if (tooltip) {
  25695. tooltip.hide(delay);
  25696. }
  25697. if (pointer.unDocMouseMove) {
  25698. pointer.unDocMouseMove = pointer.unDocMouseMove();
  25699. }
  25700. // Remove crosshairs
  25701. chart.axes.forEach(function (axis) {
  25702. axis.hideCrosshair();
  25703. });
  25704. pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
  25705. }
  25706. };
  25707. /**
  25708. * With line type charts with a single tracker, get the point closest to the
  25709. * mouse. Run Point.onMouseOver and display tooltip for the point or points.
  25710. *
  25711. * @private
  25712. * @function Highcharts.Pointer#runPointActions
  25713. *
  25714. * @fires Highcharts.Point#event:mouseOut
  25715. * @fires Highcharts.Point#event:mouseOver
  25716. */
  25717. Pointer.prototype.runPointActions = function (e, p) {
  25718. var pointer = this,
  25719. chart = pointer.chart,
  25720. series = chart.series,
  25721. tooltip = (chart.tooltip && chart.tooltip.options.enabled ?
  25722. chart.tooltip :
  25723. void 0),
  25724. shared = (tooltip ?
  25725. tooltip.shared :
  25726. false),
  25727. hoverPoint = p || chart.hoverPoint,
  25728. hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
  25729. // onMouseOver or already hovering a series with directTouch
  25730. isDirectTouch = (!e || e.type !== 'touchmove') && (!!p || ((hoverSeries && hoverSeries.directTouch) &&
  25731. pointer.isDirectTouch)),
  25732. hoverData = this.getHoverData(hoverPoint,
  25733. hoverSeries,
  25734. series,
  25735. isDirectTouch,
  25736. shared,
  25737. e),
  25738. useSharedTooltip,
  25739. followPointer,
  25740. points;
  25741. // Update variables from hoverData.
  25742. hoverPoint = hoverData.hoverPoint;
  25743. points = hoverData.hoverPoints;
  25744. hoverSeries = hoverData.hoverSeries;
  25745. followPointer = hoverSeries &&
  25746. hoverSeries.tooltipOptions.followPointer &&
  25747. !hoverSeries.tooltipOptions.split;
  25748. useSharedTooltip = (shared &&
  25749. hoverSeries &&
  25750. !hoverSeries.noSharedTooltip);
  25751. // Refresh tooltip for kdpoint if new hover point or tooltip was hidden
  25752. // #3926, #4200
  25753. if (hoverPoint &&
  25754. // !(hoverSeries && hoverSeries.directTouch) &&
  25755. (hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))) {
  25756. (chart.hoverPoints || []).forEach(function (p) {
  25757. if (points.indexOf(p) === -1) {
  25758. p.setState();
  25759. }
  25760. });
  25761. // Set normal state to previous series
  25762. if (chart.hoverSeries !== hoverSeries) {
  25763. hoverSeries.onMouseOver();
  25764. }
  25765. pointer.applyInactiveState(points);
  25766. // Do mouseover on all points (#3919, #3985, #4410, #5622)
  25767. (points || []).forEach(function (p) {
  25768. p.setState('hover');
  25769. });
  25770. // If tracking is on series in stead of on each point,
  25771. // fire mouseOver on hover point. // #4448
  25772. if (chart.hoverPoint) {
  25773. chart.hoverPoint.firePointEvent('mouseOut');
  25774. }
  25775. // Hover point may have been destroyed in the event handlers (#7127)
  25776. if (!hoverPoint.series) {
  25777. return;
  25778. }
  25779. /**
  25780. * Contains all hovered points.
  25781. *
  25782. * @name Highcharts.Chart#hoverPoints
  25783. * @type {Array<Highcharts.Point>|null}
  25784. */
  25785. chart.hoverPoints = points;
  25786. /**
  25787. * Contains the original hovered point.
  25788. *
  25789. * @name Highcharts.Chart#hoverPoint
  25790. * @type {Highcharts.Point|null}
  25791. */
  25792. chart.hoverPoint = hoverPoint;
  25793. /**
  25794. * Hover state should not be lost when axis is updated (#12569)
  25795. * Axis.update runs pointer.reset which uses chart.hoverPoint.state
  25796. * to apply state which does not exist in hoverPoint yet.
  25797. * The mouseOver event should be triggered when hoverPoint
  25798. * is correct.
  25799. */
  25800. hoverPoint.firePointEvent('mouseOver');
  25801. // Draw tooltip if necessary
  25802. if (tooltip) {
  25803. tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
  25804. }
  25805. // Update positions (regardless of kdpoint or hoverPoint)
  25806. }
  25807. else if (followPointer && tooltip && !tooltip.isHidden) {
  25808. var anchor = tooltip.getAnchor([{}],
  25809. e);
  25810. if (chart.isInsidePlot(anchor[0], anchor[1], {
  25811. visiblePlotOnly: true
  25812. })) {
  25813. tooltip.updatePosition({ plotX: anchor[0], plotY: anchor[1] });
  25814. }
  25815. }
  25816. // Start the event listener to pick up the tooltip and crosshairs
  25817. if (!pointer.unDocMouseMove) {
  25818. pointer.unDocMouseMove = addEvent(chart.container.ownerDocument, 'mousemove', function (e) {
  25819. var chart = charts[H.hoverChartIndex];
  25820. if (chart) {
  25821. chart.pointer.onDocumentMouseMove(e);
  25822. }
  25823. });
  25824. pointer.eventsToUnbind.push(pointer.unDocMouseMove);
  25825. }
  25826. // Issues related to crosshair #4927, #5269 #5066, #5658
  25827. chart.axes.forEach(function drawAxisCrosshair(axis) {
  25828. var snap = pick((axis.crosshair || {}).snap,
  25829. true);
  25830. var point;
  25831. if (snap) {
  25832. point = chart.hoverPoint; // #13002
  25833. if (!point || point.series[axis.coll] !== axis) {
  25834. point = find(points, function (p) {
  25835. return p.series[axis.coll] === axis;
  25836. });
  25837. }
  25838. }
  25839. // Axis has snapping crosshairs, and one of the hover points belongs
  25840. // to axis. Always call drawCrosshair when it is not snap.
  25841. if (point || !snap) {
  25842. axis.drawCrosshair(e, point);
  25843. // Axis has snapping crosshairs, but no hover point belongs to axis
  25844. }
  25845. else {
  25846. axis.hideCrosshair();
  25847. }
  25848. });
  25849. };
  25850. /**
  25851. * Scale series groups to a certain scale and translation.
  25852. *
  25853. * @private
  25854. * @function Highcharts.Pointer#scaleGroups
  25855. */
  25856. Pointer.prototype.scaleGroups = function (attribs, clip) {
  25857. var chart = this.chart,
  25858. seriesAttribs;
  25859. // Scale each series
  25860. chart.series.forEach(function (series) {
  25861. seriesAttribs = attribs || series.getPlotBox(); // #1701
  25862. if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
  25863. series.group.attr(seriesAttribs);
  25864. if (series.markerGroup) {
  25865. series.markerGroup.attr(seriesAttribs);
  25866. series.markerGroup.clip(clip ? chart.clipRect : null);
  25867. }
  25868. if (series.dataLabelsGroup) {
  25869. series.dataLabelsGroup.attr(seriesAttribs);
  25870. }
  25871. }
  25872. });
  25873. // Clip
  25874. chart.clipRect.attr(clip || chart.clipBox);
  25875. };
  25876. /**
  25877. * Set the JS DOM events on the container and document. This method should
  25878. * contain a one-to-one assignment between methods and their handlers. Any
  25879. * advanced logic should be moved to the handler reflecting the event's
  25880. * name.
  25881. *
  25882. * @private
  25883. * @function Highcharts.Pointer#setDOMEvents
  25884. */
  25885. Pointer.prototype.setDOMEvents = function () {
  25886. var _this = this;
  25887. var container = this.chart.container,
  25888. ownerDoc = container.ownerDocument;
  25889. container.onmousedown = this.onContainerMouseDown.bind(this);
  25890. container.onmousemove = this.onContainerMouseMove.bind(this);
  25891. container.onclick = this.onContainerClick.bind(this);
  25892. this.eventsToUnbind.push(addEvent(container, 'mouseenter', this.onContainerMouseEnter.bind(this)));
  25893. this.eventsToUnbind.push(addEvent(container, 'mouseleave', this.onContainerMouseLeave.bind(this)));
  25894. if (!H.unbindDocumentMouseUp) {
  25895. H.unbindDocumentMouseUp = addEvent(ownerDoc, 'mouseup', this.onDocumentMouseUp.bind(this));
  25896. }
  25897. // In case we are dealing with overflow, reset the chart position when
  25898. // scrolling parent elements
  25899. var parent = this.chart.renderTo.parentElement;
  25900. while (parent && parent.tagName !== 'BODY') {
  25901. this.eventsToUnbind.push(addEvent(parent, 'scroll', function () {
  25902. delete _this.chartPosition;
  25903. }));
  25904. parent = parent.parentElement;
  25905. }
  25906. if (H.hasTouch) {
  25907. this.eventsToUnbind.push(addEvent(container, 'touchstart', this.onContainerTouchStart.bind(this), { passive: false }));
  25908. this.eventsToUnbind.push(addEvent(container, 'touchmove', this.onContainerTouchMove.bind(this), { passive: false }));
  25909. if (!H.unbindDocumentTouchEnd) {
  25910. H.unbindDocumentTouchEnd = addEvent(ownerDoc, 'touchend', this.onDocumentTouchEnd.bind(this), { passive: false });
  25911. }
  25912. }
  25913. };
  25914. /**
  25915. * Sets the index of the hovered chart and leaves the previous hovered
  25916. * chart, to reset states like tooltip.
  25917. *
  25918. * @private
  25919. * @function Highcharts.Pointer#setHoverChartIndex
  25920. */
  25921. Pointer.prototype.setHoverChartIndex = function () {
  25922. var chart = this.chart;
  25923. var hoverChart = H.charts[pick(H.hoverChartIndex, -1)];
  25924. if (hoverChart &&
  25925. hoverChart !== chart) {
  25926. hoverChart.pointer.onContainerMouseLeave({ relatedTarget: true });
  25927. }
  25928. if (!hoverChart ||
  25929. !hoverChart.mouseIsDown) {
  25930. H.hoverChartIndex = chart.index;
  25931. }
  25932. };
  25933. /**
  25934. * General touch handler shared by touchstart and touchmove.
  25935. *
  25936. * @private
  25937. * @function Highcharts.Pointer#touch
  25938. */
  25939. Pointer.prototype.touch = function (e, start) {
  25940. var chart = this.chart,
  25941. hasMoved,
  25942. pinchDown,
  25943. isInside;
  25944. this.setHoverChartIndex();
  25945. if (e.touches.length === 1) {
  25946. e = this.normalize(e);
  25947. isInside = chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop, {
  25948. visiblePlotOnly: true
  25949. });
  25950. if (isInside && !chart.openMenu) {
  25951. // Run mouse events and display tooltip etc
  25952. if (start) {
  25953. this.runPointActions(e);
  25954. }
  25955. // Android fires touchmove events after the touchstart even if
  25956. // the finger hasn't moved, or moved only a pixel or two. In iOS
  25957. // however, the touchmove doesn't fire unless the finger moves
  25958. // more than ~4px. So we emulate this behaviour in Android by
  25959. // checking how much it moved, and cancelling on small
  25960. // distances. #3450.
  25961. if (e.type === 'touchmove') {
  25962. pinchDown = this.pinchDown;
  25963. hasMoved = pinchDown[0] ? Math.sqrt(// #5266
  25964. Math.pow(pinchDown[0].chartX - e.chartX, 2) +
  25965. Math.pow(pinchDown[0].chartY - e.chartY, 2)) >= 4 : false;
  25966. }
  25967. if (pick(hasMoved, true)) {
  25968. this.pinch(e);
  25969. }
  25970. }
  25971. else if (start) {
  25972. // Hide the tooltip on touching outside the plot area (#1203)
  25973. this.reset();
  25974. }
  25975. }
  25976. else if (e.touches.length === 2) {
  25977. this.pinch(e);
  25978. }
  25979. };
  25980. /**
  25981. * Returns true if the chart is set up for zooming by single touch and the
  25982. * event is capable
  25983. * @param {PointEvent} e
  25984. * Event object
  25985. */
  25986. Pointer.prototype.touchSelect = function (e) {
  25987. return Boolean(this.chart.options.chart.zoomBySingleTouch &&
  25988. e.touches &&
  25989. e.touches.length === 1);
  25990. };
  25991. /**
  25992. * Resolve the zoomType option, this is reset on all touch start and mouse
  25993. * down events.
  25994. *
  25995. * @private
  25996. * @function Highcharts.Pointer#zoomOption
  25997. *
  25998. * @param {global.Event} e
  25999. * Event object.
  26000. *
  26001. * @param {void}
  26002. */
  26003. Pointer.prototype.zoomOption = function (e) {
  26004. var chart = this.chart,
  26005. options = chart.options.chart,
  26006. zoomType = options.zoomType || '',
  26007. inverted = chart.inverted,
  26008. zoomX,
  26009. zoomY;
  26010. // Look for the pinchType option
  26011. if (/touch/.test(e.type)) {
  26012. zoomType = pick(options.pinchType, zoomType);
  26013. }
  26014. this.zoomX = zoomX = /x/.test(zoomType);
  26015. this.zoomY = zoomY = /y/.test(zoomType);
  26016. this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
  26017. this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
  26018. this.hasZoom = zoomX || zoomY;
  26019. };
  26020. return Pointer;
  26021. }());
  26022. H.Pointer = Pointer;
  26023. return Pointer;
  26024. });
  26025. _registerModule(_modules, 'Core/MSPointer.js', [_modules['Core/Globals.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (H, Pointer, U) {
  26026. /* *
  26027. *
  26028. * (c) 2010-2021 Torstein Honsi
  26029. *
  26030. * License: www.highcharts.com/license
  26031. *
  26032. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26033. *
  26034. * */
  26035. var __extends = (this && this.__extends) || (function () {
  26036. var extendStatics = function (d,
  26037. b) {
  26038. extendStatics = Object.setPrototypeOf ||
  26039. ({ __proto__: [] } instanceof Array && function (d,
  26040. b) { d.__proto__ = b; }) ||
  26041. function (d,
  26042. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  26043. return extendStatics(d, b);
  26044. };
  26045. return function (d, b) {
  26046. extendStatics(d, b);
  26047. function __() { this.constructor = d; }
  26048. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26049. };
  26050. })();
  26051. var charts = H.charts,
  26052. doc = H.doc,
  26053. noop = H.noop,
  26054. win = H.win;
  26055. var addEvent = U.addEvent,
  26056. css = U.css,
  26057. objectEach = U.objectEach,
  26058. removeEvent = U.removeEvent;
  26059. /* globals MSPointerEvent, PointerEvent */
  26060. // The touches object keeps track of the points being touched at all times
  26061. var touches = {};
  26062. var hasPointerEvent = !!win.PointerEvent;
  26063. /* eslint-disable valid-jsdoc */
  26064. /** @private */
  26065. function getWebkitTouches() {
  26066. var fake = [];
  26067. fake.item = function (i) {
  26068. return this[i];
  26069. };
  26070. objectEach(touches, function (touch) {
  26071. fake.push({
  26072. pageX: touch.pageX,
  26073. pageY: touch.pageY,
  26074. target: touch.target
  26075. });
  26076. });
  26077. return fake;
  26078. }
  26079. /** @private */
  26080. function translateMSPointer(e, method, wktype, func) {
  26081. var p;
  26082. if ((e.pointerType === 'touch' ||
  26083. e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
  26084. func(e);
  26085. p = charts[H.hoverChartIndex].pointer;
  26086. p[method]({
  26087. type: wktype,
  26088. target: e.currentTarget,
  26089. preventDefault: noop,
  26090. touches: getWebkitTouches()
  26091. });
  26092. }
  26093. }
  26094. /** @private */
  26095. var MSPointer = /** @class */ (function (_super) {
  26096. __extends(MSPointer, _super);
  26097. function MSPointer() {
  26098. return _super !== null && _super.apply(this, arguments) || this;
  26099. }
  26100. /* *
  26101. *
  26102. * Functions
  26103. *
  26104. * */
  26105. /**
  26106. * Add or remove the MS Pointer specific events
  26107. *
  26108. * @private
  26109. * @function Highcharts.Pointer#batchMSEvents
  26110. *
  26111. * @param {Function} fn
  26112. *
  26113. * @return {void}
  26114. */
  26115. MSPointer.prototype.batchMSEvents = function (fn) {
  26116. fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
  26117. fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
  26118. fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
  26119. };
  26120. // Destroy MS events also
  26121. MSPointer.prototype.destroy = function () {
  26122. this.batchMSEvents(removeEvent);
  26123. _super.prototype.destroy.call(this);
  26124. };
  26125. // Disable default IE actions for pinch and such on chart element
  26126. MSPointer.prototype.init = function (chart, options) {
  26127. _super.prototype.init.call(this, chart, options);
  26128. if (this.hasZoom) { // #4014
  26129. css(chart.container, {
  26130. '-ms-touch-action': 'none',
  26131. 'touch-action': 'none'
  26132. });
  26133. }
  26134. };
  26135. /**
  26136. * @private
  26137. * @function Highcharts.Pointer#onContainerPointerDown
  26138. *
  26139. * @param {Highcharts.PointerEventObject} e
  26140. *
  26141. * @return {void}
  26142. */
  26143. MSPointer.prototype.onContainerPointerDown = function (e) {
  26144. translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function (e) {
  26145. touches[e.pointerId] = {
  26146. pageX: e.pageX,
  26147. pageY: e.pageY,
  26148. target: e.currentTarget
  26149. };
  26150. });
  26151. };
  26152. /**
  26153. * @private
  26154. * @function Highcharts.Pointer#onContainerPointerMove
  26155. *
  26156. * @param {Highcharts.PointerEventObject} e
  26157. *
  26158. * @return {void}
  26159. */
  26160. MSPointer.prototype.onContainerPointerMove = function (e) {
  26161. translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function (e) {
  26162. touches[e.pointerId] = ({ pageX: e.pageX, pageY: e.pageY });
  26163. if (!touches[e.pointerId].target) {
  26164. touches[e.pointerId].target = e.currentTarget;
  26165. }
  26166. });
  26167. };
  26168. /**
  26169. * @private
  26170. * @function Highcharts.Pointer#onDocumentPointerUp
  26171. *
  26172. * @param {Highcharts.PointerEventObject} e
  26173. *
  26174. * @return {void}
  26175. */
  26176. MSPointer.prototype.onDocumentPointerUp = function (e) {
  26177. translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function (e) {
  26178. delete touches[e.pointerId];
  26179. });
  26180. };
  26181. // Add IE specific touch events to chart
  26182. MSPointer.prototype.setDOMEvents = function () {
  26183. _super.prototype.setDOMEvents.call(this);
  26184. if (this.hasZoom || this.followTouchMove) {
  26185. this.batchMSEvents(addEvent);
  26186. }
  26187. };
  26188. return MSPointer;
  26189. }(Pointer));
  26190. return MSPointer;
  26191. });
  26192. _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/Options.js'], _modules['Core/Utilities.js']], function (AST, A, F, H, O, U) {
  26193. /* *
  26194. *
  26195. * (c) 2010-2021 Torstein Honsi
  26196. *
  26197. * License: www.highcharts.com/license
  26198. *
  26199. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26200. *
  26201. * */
  26202. var animObject = A.animObject;
  26203. var format = F.format;
  26204. var defaultOptions = O.defaultOptions;
  26205. var addEvent = U.addEvent,
  26206. defined = U.defined,
  26207. erase = U.erase,
  26208. extend = U.extend,
  26209. fireEvent = U.fireEvent,
  26210. getNestedProperty = U.getNestedProperty,
  26211. isArray = U.isArray,
  26212. isFunction = U.isFunction,
  26213. isNumber = U.isNumber,
  26214. isObject = U.isObject,
  26215. merge = U.merge,
  26216. objectEach = U.objectEach,
  26217. pick = U.pick,
  26218. syncTimeout = U.syncTimeout,
  26219. removeEvent = U.removeEvent,
  26220. uniqueKey = U.uniqueKey;
  26221. /**
  26222. * Function callback when a series point is clicked. Return false to cancel the
  26223. * action.
  26224. *
  26225. * @callback Highcharts.PointClickCallbackFunction
  26226. *
  26227. * @param {Highcharts.Point} this
  26228. * The point where the event occured.
  26229. *
  26230. * @param {Highcharts.PointClickEventObject} event
  26231. * Event arguments.
  26232. */
  26233. /**
  26234. * Common information for a click event on a series point.
  26235. *
  26236. * @interface Highcharts.PointClickEventObject
  26237. * @extends Highcharts.PointerEventObject
  26238. */ /**
  26239. * Clicked point.
  26240. * @name Highcharts.PointClickEventObject#point
  26241. * @type {Highcharts.Point}
  26242. */
  26243. /**
  26244. * Configuration hash for the data label and tooltip formatters.
  26245. *
  26246. * @interface Highcharts.PointLabelObject
  26247. */ /**
  26248. * The point's current color.
  26249. * @name Highcharts.PointLabelObject#color
  26250. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  26251. */ /**
  26252. * The point's current color index, used in styled mode instead of `color`. The
  26253. * color index is inserted in class names used for styling.
  26254. * @name Highcharts.PointLabelObject#colorIndex
  26255. * @type {number}
  26256. */ /**
  26257. * The name of the related point.
  26258. * @name Highcharts.PointLabelObject#key
  26259. * @type {string|undefined}
  26260. */ /**
  26261. * The percentage for related points in a stacked series or pies.
  26262. * @name Highcharts.PointLabelObject#percentage
  26263. * @type {number}
  26264. */ /**
  26265. * The related point. The point name, if defined, is available through
  26266. * `this.point.name`.
  26267. * @name Highcharts.PointLabelObject#point
  26268. * @type {Highcharts.Point}
  26269. */ /**
  26270. * The related series. The series name is available through `this.series.name`.
  26271. * @name Highcharts.PointLabelObject#series
  26272. * @type {Highcharts.Series}
  26273. */ /**
  26274. * The total of values in either a stack for stacked series, or a pie in a pie
  26275. * series.
  26276. * @name Highcharts.PointLabelObject#total
  26277. * @type {number|undefined}
  26278. */ /**
  26279. * For categorized axes this property holds the category name for the point. For
  26280. * other axes it holds the X value.
  26281. * @name Highcharts.PointLabelObject#x
  26282. * @type {number|string|undefined}
  26283. */ /**
  26284. * The y value of the point.
  26285. * @name Highcharts.PointLabelObject#y
  26286. * @type {number|undefined}
  26287. */
  26288. /**
  26289. * Gets fired when the mouse leaves the area close to the point.
  26290. *
  26291. * @callback Highcharts.PointMouseOutCallbackFunction
  26292. *
  26293. * @param {Highcharts.Point} this
  26294. * Point where the event occured.
  26295. *
  26296. * @param {global.PointerEvent} event
  26297. * Event that occured.
  26298. */
  26299. /**
  26300. * Gets fired when the mouse enters the area close to the point.
  26301. *
  26302. * @callback Highcharts.PointMouseOverCallbackFunction
  26303. *
  26304. * @param {Highcharts.Point} this
  26305. * Point where the event occured.
  26306. *
  26307. * @param {global.Event} event
  26308. * Event that occured.
  26309. */
  26310. /**
  26311. * The generic point options for all series.
  26312. *
  26313. * In TypeScript you have to extend `PointOptionsObject` with an additional
  26314. * declaration to allow custom data options:
  26315. *
  26316. * ```
  26317. * declare interface PointOptionsObject {
  26318. * customProperty: string;
  26319. * }
  26320. * ```
  26321. *
  26322. * @interface Highcharts.PointOptionsObject
  26323. */
  26324. /**
  26325. * Possible option types for a data point. Use `null` to indicate a gap.
  26326. *
  26327. * @typedef {number|string|Highcharts.PointOptionsObject|Array<(number|string|null)>|null} Highcharts.PointOptionsType
  26328. */
  26329. /**
  26330. * Gets fired when the point is removed using the `.remove()` method.
  26331. *
  26332. * @callback Highcharts.PointRemoveCallbackFunction
  26333. *
  26334. * @param {Highcharts.Point} this
  26335. * Point where the event occured.
  26336. *
  26337. * @param {global.Event} event
  26338. * Event that occured.
  26339. */
  26340. /**
  26341. * Possible key values for the point state options.
  26342. *
  26343. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.PointStateValue
  26344. */
  26345. /**
  26346. * Gets fired when the point is updated programmatically through the `.update()`
  26347. * method.
  26348. *
  26349. * @callback Highcharts.PointUpdateCallbackFunction
  26350. *
  26351. * @param {Highcharts.Point} this
  26352. * Point where the event occured.
  26353. *
  26354. * @param {Highcharts.PointUpdateEventObject} event
  26355. * Event that occured.
  26356. */
  26357. /**
  26358. * Information about the update event.
  26359. *
  26360. * @interface Highcharts.PointUpdateEventObject
  26361. * @extends global.Event
  26362. */ /**
  26363. * Options data of the update event.
  26364. * @name Highcharts.PointUpdateEventObject#options
  26365. * @type {Highcharts.PointOptionsType}
  26366. */
  26367. /**
  26368. * @interface Highcharts.PointEventsOptionsObject
  26369. */ /**
  26370. * Fires when the point is selected either programmatically or following a click
  26371. * on the point. One parameter, `event`, is passed to the function. Returning
  26372. * `false` cancels the operation.
  26373. * @name Highcharts.PointEventsOptionsObject#select
  26374. * @type {Highcharts.PointSelectCallbackFunction|undefined}
  26375. */ /**
  26376. * Fires when the point is unselected either programmatically or following a
  26377. * click on the point. One parameter, `event`, is passed to the function.
  26378. * Returning `false` cancels the operation.
  26379. * @name Highcharts.PointEventsOptionsObject#unselect
  26380. * @type {Highcharts.PointUnselectCallbackFunction|undefined}
  26381. */
  26382. /**
  26383. * Information about the select/unselect event.
  26384. *
  26385. * @interface Highcharts.PointInteractionEventObject
  26386. * @extends global.Event
  26387. */ /**
  26388. * @name Highcharts.PointInteractionEventObject#accumulate
  26389. * @type {boolean}
  26390. */
  26391. /**
  26392. * Gets fired when the point is selected either programmatically or following a
  26393. * click on the point.
  26394. *
  26395. * @callback Highcharts.PointSelectCallbackFunction
  26396. *
  26397. * @param {Highcharts.Point} this
  26398. * Point where the event occured.
  26399. *
  26400. * @param {Highcharts.PointInteractionEventObject} event
  26401. * Event that occured.
  26402. */
  26403. /**
  26404. * Fires when the point is unselected either programmatically or following a
  26405. * click on the point.
  26406. *
  26407. * @callback Highcharts.PointUnselectCallbackFunction
  26408. *
  26409. * @param {Highcharts.Point} this
  26410. * Point where the event occured.
  26411. *
  26412. * @param {Highcharts.PointInteractionEventObject} event
  26413. * Event that occured.
  26414. */
  26415. ''; // detach doclet above
  26416. /* eslint-disable no-invalid-this, valid-jsdoc */
  26417. /**
  26418. * The Point object. The point objects are generated from the `series.data`
  26419. * configuration objects or raw numbers. They can be accessed from the
  26420. * `Series.points` array. Other ways to instantiate points are through {@link
  26421. * Highcharts.Series#addPoint} or {@link Highcharts.Series#setData}.
  26422. *
  26423. * @class
  26424. * @name Highcharts.Point
  26425. */
  26426. var Point = /** @class */ (function () {
  26427. function Point() {
  26428. /* *
  26429. *
  26430. * Properties
  26431. *
  26432. * */
  26433. /**
  26434. * For categorized axes this property holds the category name for the
  26435. * point. For other axes it holds the X value.
  26436. *
  26437. * @name Highcharts.Point#category
  26438. * @type {string}
  26439. */
  26440. this.category = void 0;
  26441. /**
  26442. * The point's current color index, used in styled mode instead of
  26443. * `color`. The color index is inserted in class names used for styling.
  26444. *
  26445. * @name Highcharts.Point#colorIndex
  26446. * @type {number}
  26447. */
  26448. this.colorIndex = void 0;
  26449. this.formatPrefix = 'point';
  26450. this.id = void 0;
  26451. this.isNull = false;
  26452. /**
  26453. * The name of the point. The name can be given as the first position of the
  26454. * point configuration array, or as a `name` property in the configuration:
  26455. *
  26456. * @example
  26457. * // Array config
  26458. * data: [
  26459. * ['John', 1],
  26460. * ['Jane', 2]
  26461. * ]
  26462. *
  26463. * // Object config
  26464. * data: [{
  26465. * name: 'John',
  26466. * y: 1
  26467. * }, {
  26468. * name: 'Jane',
  26469. * y: 2
  26470. * }]
  26471. *
  26472. * @name Highcharts.Point#name
  26473. * @type {string}
  26474. */
  26475. this.name = void 0;
  26476. /**
  26477. * The point's options as applied in the initial configuration, or
  26478. * extended through `Point.update`.
  26479. *
  26480. * In TypeScript you have to extend `PointOptionsObject` via an
  26481. * additional interface to allow custom data options:
  26482. *
  26483. * ```
  26484. * declare interface PointOptionsObject {
  26485. * customProperty: string;
  26486. * }
  26487. * ```
  26488. *
  26489. * @name Highcharts.Point#options
  26490. * @type {Highcharts.PointOptionsObject}
  26491. */
  26492. this.options = void 0;
  26493. /**
  26494. * The percentage for points in a stacked series or pies.
  26495. *
  26496. * @name Highcharts.Point#percentage
  26497. * @type {number|undefined}
  26498. */
  26499. this.percentage = void 0;
  26500. this.selected = false;
  26501. /**
  26502. * The series object associated with the point.
  26503. *
  26504. * @name Highcharts.Point#series
  26505. * @type {Highcharts.Series}
  26506. */
  26507. this.series = void 0;
  26508. /**
  26509. * The total of values in either a stack for stacked series, or a pie in a
  26510. * pie series.
  26511. *
  26512. * @name Highcharts.Point#total
  26513. * @type {number|undefined}
  26514. */
  26515. this.total = void 0;
  26516. /**
  26517. * For certain series types, like pie charts, where individual points can
  26518. * be shown or hidden.
  26519. *
  26520. * @name Highcharts.Point#visible
  26521. * @type {boolean}
  26522. * @default true
  26523. */
  26524. this.visible = true;
  26525. this.x = void 0;
  26526. }
  26527. /* *
  26528. *
  26529. * Functions
  26530. *
  26531. * */
  26532. /**
  26533. * Animate SVG elements associated with the point.
  26534. *
  26535. * @private
  26536. * @function Highcharts.Point#animateBeforeDestroy
  26537. */
  26538. Point.prototype.animateBeforeDestroy = function () {
  26539. var point = this,
  26540. animateParams = { x: point.startXPos,
  26541. opacity: 0 },
  26542. isDataLabel,
  26543. graphicalProps = point.getGraphicalProps();
  26544. graphicalProps.singular.forEach(function (prop) {
  26545. isDataLabel = prop === 'dataLabel';
  26546. point[prop] = point[prop].animate(isDataLabel ? {
  26547. x: point[prop].startXPos,
  26548. y: point[prop].startYPos,
  26549. opacity: 0
  26550. } : animateParams);
  26551. });
  26552. graphicalProps.plural.forEach(function (plural) {
  26553. point[plural].forEach(function (item) {
  26554. if (item.element) {
  26555. item.animate(extend({ x: point.startXPos }, (item.startYPos ? {
  26556. x: item.startXPos,
  26557. y: item.startYPos
  26558. } : {})));
  26559. }
  26560. });
  26561. });
  26562. };
  26563. /**
  26564. * Apply the options containing the x and y data and possible some extra
  26565. * properties. Called on point init or from point.update.
  26566. *
  26567. * @private
  26568. * @function Highcharts.Point#applyOptions
  26569. *
  26570. * @param {Highcharts.PointOptionsType} options
  26571. * The point options as defined in series.data.
  26572. *
  26573. * @param {number} [x]
  26574. * Optionally, the x value.
  26575. *
  26576. * @return {Highcharts.Point}
  26577. * The Point instance.
  26578. */
  26579. Point.prototype.applyOptions = function (options, x) {
  26580. var point = this,
  26581. series = point.series,
  26582. pointValKey = series.options.pointValKey || series.pointValKey;
  26583. options = Point.prototype.optionsToObject.call(this, options);
  26584. // copy options directly to point
  26585. extend(point, options);
  26586. point.options = point.options ? extend(point.options, options) : options;
  26587. // Since options are copied into the Point instance, some accidental
  26588. // options must be shielded (#5681)
  26589. if (options.group) {
  26590. delete point.group;
  26591. }
  26592. if (options.dataLabels) {
  26593. delete point.dataLabels;
  26594. }
  26595. /**
  26596. * The y value of the point.
  26597. * @name Highcharts.Point#y
  26598. * @type {number|undefined}
  26599. */
  26600. // For higher dimension series types. For instance, for ranges, point.y
  26601. // is mapped to point.low.
  26602. if (pointValKey) {
  26603. point.y = Point.prototype.getNestedProperty.call(point, pointValKey);
  26604. }
  26605. point.isNull = pick(point.isValid && !point.isValid(), point.x === null || !isNumber(point.y)); // #3571, check for NaN
  26606. point.formatPrefix = point.isNull ? 'null' : 'point'; // #9233, #10874
  26607. // The point is initially selected by options (#5777)
  26608. if (point.selected) {
  26609. point.state = 'select';
  26610. }
  26611. /**
  26612. * The x value of the point.
  26613. * @name Highcharts.Point#x
  26614. * @type {number}
  26615. */
  26616. // If no x is set by now, get auto incremented value. All points must
  26617. // have an x value, however the y value can be null to create a gap in
  26618. // the series
  26619. if ('name' in point &&
  26620. typeof x === 'undefined' &&
  26621. series.xAxis &&
  26622. series.xAxis.hasNames) {
  26623. point.x = series.xAxis.nameToX(point);
  26624. }
  26625. if (typeof point.x === 'undefined' && series) {
  26626. if (typeof x === 'undefined') {
  26627. point.x = series.autoIncrement(point);
  26628. }
  26629. else {
  26630. point.x = x;
  26631. }
  26632. }
  26633. return point;
  26634. };
  26635. /**
  26636. * Destroy a point to clear memory. Its reference still stays in
  26637. * `series.data`.
  26638. *
  26639. * @private
  26640. * @function Highcharts.Point#destroy
  26641. */
  26642. Point.prototype.destroy = function () {
  26643. var point = this,
  26644. series = point.series,
  26645. chart = series.chart,
  26646. dataSorting = series.options.dataSorting,
  26647. hoverPoints = chart.hoverPoints,
  26648. globalAnimation = point.series.chart.renderer.globalAnimation,
  26649. animation = animObject(globalAnimation),
  26650. prop;
  26651. /**
  26652. * Allow to call after animation.
  26653. * @private
  26654. */
  26655. function destroyPoint() {
  26656. // Remove all events and elements
  26657. if (point.graphic || point.dataLabel || point.dataLabels) {
  26658. removeEvent(point);
  26659. point.destroyElements();
  26660. }
  26661. for (prop in point) { // eslint-disable-line guard-for-in
  26662. point[prop] = null;
  26663. }
  26664. }
  26665. if (point.legendItem) { // pies have legend items
  26666. chart.legend.destroyItem(point);
  26667. }
  26668. if (hoverPoints) {
  26669. point.setState();
  26670. erase(hoverPoints, point);
  26671. if (!hoverPoints.length) {
  26672. chart.hoverPoints = null;
  26673. }
  26674. }
  26675. if (point === chart.hoverPoint) {
  26676. point.onMouseOut();
  26677. }
  26678. // Remove properties after animation
  26679. if (!dataSorting || !dataSorting.enabled) {
  26680. destroyPoint();
  26681. }
  26682. else {
  26683. this.animateBeforeDestroy();
  26684. syncTimeout(destroyPoint, animation.duration);
  26685. }
  26686. chart.pointCount--;
  26687. };
  26688. /**
  26689. * Destroy SVG elements associated with the point.
  26690. *
  26691. * @private
  26692. * @function Highcharts.Point#destroyElements
  26693. * @param {Highcharts.Dictionary<number>} [kinds]
  26694. */
  26695. Point.prototype.destroyElements = function (kinds) {
  26696. var point = this,
  26697. props = point.getGraphicalProps(kinds);
  26698. props.singular.forEach(function (prop) {
  26699. point[prop] = point[prop].destroy();
  26700. });
  26701. props.plural.forEach(function (plural) {
  26702. point[plural].forEach(function (item) {
  26703. if (item.element) {
  26704. item.destroy();
  26705. }
  26706. });
  26707. delete point[plural];
  26708. });
  26709. };
  26710. /**
  26711. * Fire an event on the Point object.
  26712. *
  26713. * @private
  26714. * @function Highcharts.Point#firePointEvent
  26715. *
  26716. * @param {string} eventType
  26717. * Type of the event.
  26718. *
  26719. * @param {Highcharts.Dictionary<any>|Event} [eventArgs]
  26720. * Additional event arguments.
  26721. *
  26722. * @param {Highcharts.EventCallbackFunction<Highcharts.Point>|Function} [defaultFunction]
  26723. * Default event handler.
  26724. *
  26725. * @fires Highcharts.Point#event:*
  26726. */
  26727. Point.prototype.firePointEvent = function (eventType, eventArgs, defaultFunction) {
  26728. var point = this,
  26729. series = this.series,
  26730. seriesOptions = series.options;
  26731. // load event handlers on demand to save time on mouseover/out
  26732. if (seriesOptions.point.events[eventType] ||
  26733. (point.options &&
  26734. point.options.events &&
  26735. point.options.events[eventType])) {
  26736. point.importEvents();
  26737. }
  26738. // add default handler if in selection mode
  26739. if (eventType === 'click' && seriesOptions.allowPointSelect) {
  26740. defaultFunction = function (event) {
  26741. // Control key is for Windows, meta (= Cmd key) for Mac, Shift
  26742. // for Opera.
  26743. if (point.select) { // #2911
  26744. point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
  26745. }
  26746. };
  26747. }
  26748. fireEvent(point, eventType, eventArgs, defaultFunction);
  26749. };
  26750. /**
  26751. * Get the CSS class names for individual points. Used internally where the
  26752. * returned value is set on every point.
  26753. *
  26754. * @function Highcharts.Point#getClassName
  26755. *
  26756. * @return {string}
  26757. * The class names.
  26758. */
  26759. Point.prototype.getClassName = function () {
  26760. var point = this;
  26761. return 'highcharts-point' +
  26762. (point.selected ? ' highcharts-point-select' : '') +
  26763. (point.negative ? ' highcharts-negative' : '') +
  26764. (point.isNull ? ' highcharts-null-point' : '') +
  26765. (typeof point.colorIndex !== 'undefined' ?
  26766. ' highcharts-color-' + point.colorIndex : '') +
  26767. (point.options.className ? ' ' + point.options.className : '') +
  26768. (point.zone && point.zone.className ? ' ' +
  26769. point.zone.className.replace('highcharts-negative', '') : '');
  26770. };
  26771. /**
  26772. * Get props of all existing graphical point elements.
  26773. *
  26774. * @private
  26775. * @function Highcharts.Point#getGraphicalProps
  26776. * @param {Highcharts.Dictionary<number>} [kinds]
  26777. * @return {Highcharts.PointGraphicalProps}
  26778. */
  26779. Point.prototype.getGraphicalProps = function (kinds) {
  26780. var point = this,
  26781. props = [],
  26782. prop,
  26783. i,
  26784. graphicalProps = { singular: [],
  26785. plural: [] };
  26786. kinds = kinds || { graphic: 1, dataLabel: 1 };
  26787. if (kinds.graphic) {
  26788. props.push('graphic', 'upperGraphic', 'shadowGroup');
  26789. }
  26790. if (kinds.dataLabel) {
  26791. props.push('dataLabel', 'dataLabelUpper', 'connector');
  26792. }
  26793. i = props.length;
  26794. while (i--) {
  26795. prop = props[i];
  26796. if (point[prop]) {
  26797. graphicalProps.singular.push(prop);
  26798. }
  26799. }
  26800. ['dataLabel', 'connector'].forEach(function (prop) {
  26801. var plural = prop + 's';
  26802. if (kinds[prop] && point[plural]) {
  26803. graphicalProps.plural.push(plural);
  26804. }
  26805. });
  26806. return graphicalProps;
  26807. };
  26808. /**
  26809. * Return the configuration hash needed for the data label and tooltip
  26810. * formatters.
  26811. *
  26812. * @function Highcharts.Point#getLabelConfig
  26813. *
  26814. * @return {Highcharts.PointLabelObject}
  26815. * Abstract object used in formatters and formats.
  26816. */
  26817. Point.prototype.getLabelConfig = function () {
  26818. return {
  26819. x: this.category,
  26820. y: this.y,
  26821. color: this.color,
  26822. colorIndex: this.colorIndex,
  26823. key: this.name || this.category,
  26824. series: this.series,
  26825. point: this,
  26826. percentage: this.percentage,
  26827. total: this.total || this.stackTotal
  26828. };
  26829. };
  26830. /**
  26831. * Returns the value of the point property for a given value.
  26832. * @private
  26833. */
  26834. Point.prototype.getNestedProperty = function (key) {
  26835. if (!key) {
  26836. return;
  26837. }
  26838. if (key.indexOf('custom.') === 0) {
  26839. return getNestedProperty(key, this.options);
  26840. }
  26841. return this[key];
  26842. };
  26843. /**
  26844. * In a series with `zones`, return the zone that the point belongs to.
  26845. *
  26846. * @function Highcharts.Point#getZone
  26847. *
  26848. * @return {Highcharts.SeriesZonesOptionsObject}
  26849. * The zone item.
  26850. */
  26851. Point.prototype.getZone = function () {
  26852. var series = this.series,
  26853. zones = series.zones,
  26854. zoneAxis = series.zoneAxis || 'y',
  26855. i = 0,
  26856. zone;
  26857. zone = zones[i];
  26858. while (this[zoneAxis] >= zone.value) {
  26859. zone = zones[++i];
  26860. }
  26861. // For resetting or reusing the point (#8100)
  26862. if (!this.nonZonedColor) {
  26863. this.nonZonedColor = this.color;
  26864. }
  26865. if (zone && zone.color && !this.options.color) {
  26866. this.color = zone.color;
  26867. }
  26868. else {
  26869. this.color = this.nonZonedColor;
  26870. }
  26871. return zone;
  26872. };
  26873. /**
  26874. * Utility to check if point has new shape type. Used in column series and
  26875. * all others that are based on column series.
  26876. *
  26877. * @return boolean|undefined
  26878. */
  26879. Point.prototype.hasNewShapeType = function () {
  26880. var point = this;
  26881. var oldShapeType = point.graphic &&
  26882. (point.graphic.symbolName || point.graphic.element.nodeName);
  26883. return oldShapeType !== this.shapeType;
  26884. };
  26885. /**
  26886. * Initialize the point. Called internally based on the `series.data`
  26887. * option.
  26888. *
  26889. * @function Highcharts.Point#init
  26890. *
  26891. * @param {Highcharts.Series} series
  26892. * The series object containing this point.
  26893. *
  26894. * @param {Highcharts.PointOptionsType} options
  26895. * The data in either number, array or object format.
  26896. *
  26897. * @param {number} [x]
  26898. * Optionally, the X value of the point.
  26899. *
  26900. * @return {Highcharts.Point}
  26901. * The Point instance.
  26902. *
  26903. * @fires Highcharts.Point#event:afterInit
  26904. */
  26905. Point.prototype.init = function (series, options, x) {
  26906. this.series = series;
  26907. this.applyOptions(options, x);
  26908. // Add a unique ID to the point if none is assigned
  26909. this.id = defined(this.id) ? this.id : uniqueKey();
  26910. this.resolveColor();
  26911. series.chart.pointCount++;
  26912. fireEvent(this, 'afterInit');
  26913. return this;
  26914. };
  26915. /**
  26916. * Transform number or array configs into objects. Also called for object
  26917. * configs. Used internally to unify the different configuration formats for
  26918. * points. For example, a simple number `10` in a line series will be
  26919. * transformed to `{ y: 10 }`, and an array config like `[1, 10]` in a
  26920. * scatter series will be transformed to `{ x: 1, y: 10 }`.
  26921. *
  26922. * @function Highcharts.Point#optionsToObject
  26923. *
  26924. * @param {Highcharts.PointOptionsType} options
  26925. * The input option.
  26926. *
  26927. * @return {Highcharts.Dictionary<*>}
  26928. * Transformed options.
  26929. */
  26930. Point.prototype.optionsToObject = function (options) {
  26931. var ret = {},
  26932. series = this.series,
  26933. keys = series.options.keys,
  26934. pointArrayMap = keys || series.pointArrayMap || ['y'],
  26935. valueCount = pointArrayMap.length,
  26936. firstItemType,
  26937. i = 0,
  26938. j = 0;
  26939. if (isNumber(options) || options === null) {
  26940. ret[pointArrayMap[0]] = options;
  26941. }
  26942. else if (isArray(options)) {
  26943. // with leading x value
  26944. if (!keys && options.length > valueCount) {
  26945. firstItemType = typeof options[0];
  26946. if (firstItemType === 'string') {
  26947. ret.name = options[0];
  26948. }
  26949. else if (firstItemType === 'number') {
  26950. ret.x = options[0];
  26951. }
  26952. i++;
  26953. }
  26954. while (j < valueCount) {
  26955. // Skip undefined positions for keys
  26956. if (!keys || typeof options[i] !== 'undefined') {
  26957. if (pointArrayMap[j].indexOf('.') > 0) {
  26958. // Handle nested keys, e.g. ['color.pattern.image']
  26959. // Avoid function call unless necessary.
  26960. Point.prototype.setNestedProperty(ret, options[i], pointArrayMap[j]);
  26961. }
  26962. else {
  26963. ret[pointArrayMap[j]] = options[i];
  26964. }
  26965. }
  26966. i++;
  26967. j++;
  26968. }
  26969. }
  26970. else if (typeof options === 'object') {
  26971. ret = options;
  26972. // This is the fastest way to detect if there are individual point
  26973. // dataLabels that need to be considered in drawDataLabels. These
  26974. // can only occur in object configs.
  26975. if (options.dataLabels) {
  26976. series._hasPointLabels = true;
  26977. }
  26978. // Same approach as above for markers
  26979. if (options.marker) {
  26980. series._hasPointMarkers = true;
  26981. }
  26982. }
  26983. return ret;
  26984. };
  26985. /**
  26986. * @private
  26987. * @function Highcharts.Point#resolveColor
  26988. * @return {void}
  26989. */
  26990. Point.prototype.resolveColor = function () {
  26991. var series = this.series,
  26992. colors,
  26993. optionsChart = series.chart.options.chart,
  26994. colorCount = optionsChart.colorCount,
  26995. styledMode = series.chart.styledMode,
  26996. colorIndex,
  26997. color;
  26998. // remove points nonZonedColor for later recalculation
  26999. delete this.nonZonedColor;
  27000. if (series.options.colorByPoint) {
  27001. if (!styledMode) {
  27002. colors = series.options.colors || series.chart.options.colors;
  27003. color = colors[series.colorCounter];
  27004. colorCount = colors.length;
  27005. }
  27006. colorIndex = series.colorCounter;
  27007. series.colorCounter++;
  27008. // loop back to zero
  27009. if (series.colorCounter === colorCount) {
  27010. series.colorCounter = 0;
  27011. }
  27012. }
  27013. else {
  27014. if (!styledMode) {
  27015. color = series.color;
  27016. }
  27017. colorIndex = series.colorIndex;
  27018. }
  27019. this.colorIndex = pick(this.options.colorIndex, colorIndex);
  27020. /**
  27021. * The point's current color.
  27022. *
  27023. * @name Highcharts.Point#color
  27024. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  27025. */
  27026. this.color = pick(this.options.color, color);
  27027. };
  27028. /**
  27029. * Set a value in an object, on the property defined by key. The key
  27030. * supports nested properties using dot notation. The function modifies the
  27031. * input object and does not make a copy.
  27032. *
  27033. * @function Highcharts.Point#setNestedProperty<T>
  27034. *
  27035. * @param {T} object
  27036. * The object to set the value on.
  27037. *
  27038. * @param {*} value
  27039. * The value to set.
  27040. *
  27041. * @param {string} key
  27042. * Key to the property to set.
  27043. *
  27044. * @return {T}
  27045. * The modified object.
  27046. */
  27047. Point.prototype.setNestedProperty = function (object, value, key) {
  27048. var nestedKeys = key.split('.');
  27049. nestedKeys.reduce(function (result, key, i, arr) {
  27050. var isLastKey = arr.length - 1 === i;
  27051. result[key] = (isLastKey ?
  27052. value :
  27053. isObject(result[key], true) ?
  27054. result[key] :
  27055. {});
  27056. return result[key];
  27057. }, object);
  27058. return object;
  27059. };
  27060. /**
  27061. * Extendable method for formatting each point's tooltip line.
  27062. *
  27063. * @function Highcharts.Point#tooltipFormatter
  27064. *
  27065. * @param {string} pointFormat
  27066. * The point format.
  27067. *
  27068. * @return {string}
  27069. * A string to be concatenated in to the common tooltip text.
  27070. */
  27071. Point.prototype.tooltipFormatter = function (pointFormat) {
  27072. // Insert options for valueDecimals, valuePrefix, and valueSuffix
  27073. var series = this.series, seriesTooltipOptions = series.tooltipOptions, valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''), valuePrefix = seriesTooltipOptions.valuePrefix || '', valueSuffix = seriesTooltipOptions.valueSuffix || '';
  27074. // Replace default point style with class name
  27075. if (series.chart.styledMode) {
  27076. pointFormat =
  27077. series.chart.tooltip.styledModeFormat(pointFormat);
  27078. }
  27079. // Loop over the point array map and replace unformatted values with
  27080. // sprintf formatting markup
  27081. (series.pointArrayMap || ['y']).forEach(function (key) {
  27082. key = '{point.' + key; // without the closing bracket
  27083. if (valuePrefix || valueSuffix) {
  27084. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), valuePrefix + key + '}' + valueSuffix);
  27085. }
  27086. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), key + ':,.' + valueDecimals + 'f}');
  27087. });
  27088. return format(pointFormat, {
  27089. point: this,
  27090. series: this.series
  27091. }, series.chart);
  27092. };
  27093. /**
  27094. * Update point with new options (typically x/y data) and optionally redraw
  27095. * the series.
  27096. *
  27097. * @sample highcharts/members/point-update-column/
  27098. * Update column value
  27099. * @sample highcharts/members/point-update-pie/
  27100. * Update pie slice
  27101. * @sample maps/members/point-update/
  27102. * Update map area value in Highmaps
  27103. *
  27104. * @function Highcharts.Point#update
  27105. *
  27106. * @param {Highcharts.PointOptionsType} options
  27107. * The point options. Point options are handled as described under
  27108. * the `series.type.data` item for each series type. For example
  27109. * for a line series, if options is a single number, the point will
  27110. * be given that number as the marin y value. If it is an array, it
  27111. * will be interpreted as x and y values respectively. If it is an
  27112. * object, advanced options are applied.
  27113. *
  27114. * @param {boolean} [redraw=true]
  27115. * Whether to redraw the chart after the point is updated. If doing
  27116. * more operations on the chart, it is best practice to set
  27117. * `redraw` to false and call `chart.redraw()` after.
  27118. *
  27119. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  27120. * Whether to apply animation, and optionally animation
  27121. * configuration.
  27122. *
  27123. * @fires Highcharts.Point#event:update
  27124. */
  27125. Point.prototype.update = function (options, redraw, animation, runEvent) {
  27126. var point = this,
  27127. series = point.series,
  27128. graphic = point.graphic,
  27129. i,
  27130. chart = series.chart,
  27131. seriesOptions = series.options;
  27132. redraw = pick(redraw, true);
  27133. /**
  27134. * @private
  27135. */
  27136. function update() {
  27137. point.applyOptions(options);
  27138. // Update visuals, #4146
  27139. // Handle dummy graphic elements for a11y, #12718
  27140. var hasDummyGraphic = graphic && point.hasDummyGraphic;
  27141. var shouldDestroyGraphic = point.y === null ? !hasDummyGraphic : hasDummyGraphic;
  27142. if (graphic && shouldDestroyGraphic) {
  27143. point.graphic = graphic.destroy();
  27144. delete point.hasDummyGraphic;
  27145. }
  27146. if (isObject(options, true)) {
  27147. // Destroy so we can get new elements
  27148. if (graphic && graphic.element) {
  27149. // "null" is also a valid symbol
  27150. if (options &&
  27151. options.marker &&
  27152. typeof options.marker.symbol !== 'undefined') {
  27153. point.graphic = graphic.destroy();
  27154. }
  27155. }
  27156. if (options && options.dataLabels && point.dataLabel) {
  27157. point.dataLabel = point.dataLabel.destroy(); // #2468
  27158. }
  27159. if (point.connector) {
  27160. point.connector = point.connector.destroy(); // #7243
  27161. }
  27162. }
  27163. // record changes in the parallel arrays
  27164. i = point.index;
  27165. series.updateParallelArrays(point, i);
  27166. // Record the options to options.data. If the old or the new config
  27167. // is an object, use point options, otherwise use raw options
  27168. // (#4701, #4916).
  27169. seriesOptions.data[i] = (isObject(seriesOptions.data[i], true) ||
  27170. isObject(options, true)) ?
  27171. point.options :
  27172. pick(options, seriesOptions.data[i]);
  27173. // redraw
  27174. series.isDirty = series.isDirtyData = true;
  27175. if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
  27176. chart.isDirtyBox = true;
  27177. }
  27178. if (seriesOptions.legendType === 'point') { // #1831, #1885
  27179. chart.isDirtyLegend = true;
  27180. }
  27181. if (redraw) {
  27182. chart.redraw(animation);
  27183. }
  27184. }
  27185. // Fire the event with a default handler of doing the update
  27186. if (runEvent === false) { // When called from setData
  27187. update();
  27188. }
  27189. else {
  27190. point.firePointEvent('update', { options: options }, update);
  27191. }
  27192. };
  27193. /**
  27194. * Remove a point and optionally redraw the series and if necessary the axes
  27195. *
  27196. * @sample highcharts/plotoptions/series-point-events-remove/
  27197. * Remove point and confirm
  27198. * @sample highcharts/members/point-remove/
  27199. * Remove pie slice
  27200. * @sample maps/members/point-remove/
  27201. * Remove selected points in Highmaps
  27202. *
  27203. * @function Highcharts.Point#remove
  27204. *
  27205. * @param {boolean} [redraw=true]
  27206. * Whether to redraw the chart or wait for an explicit call. When
  27207. * doing more operations on the chart, for example running
  27208. * `point.remove()` in a loop, it is best practice to set `redraw`
  27209. * to false and call `chart.redraw()` after.
  27210. *
  27211. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=false]
  27212. * Whether to apply animation, and optionally animation
  27213. * configuration.
  27214. */
  27215. Point.prototype.remove = function (redraw, animation) {
  27216. this.series.removePoint(this.series.data.indexOf(this), redraw, animation);
  27217. };
  27218. /**
  27219. * Toggle the selection status of a point.
  27220. *
  27221. * @see Highcharts.Chart#getSelectedPoints
  27222. *
  27223. * @sample highcharts/members/point-select/
  27224. * Select a point from a button
  27225. * @sample highcharts/chart/events-selection-points/
  27226. * Select a range of points through a drag selection
  27227. * @sample maps/series/data-id/
  27228. * Select a point in Highmaps
  27229. *
  27230. * @function Highcharts.Point#select
  27231. *
  27232. * @param {boolean} [selected]
  27233. * When `true`, the point is selected. When `false`, the point is
  27234. * unselected. When `null` or `undefined`, the selection state is toggled.
  27235. *
  27236. * @param {boolean} [accumulate=false]
  27237. * When `true`, the selection is added to other selected points.
  27238. * When `false`, other selected points are deselected. Internally in
  27239. * Highcharts, when
  27240. * [allowPointSelect](https://api.highcharts.com/highcharts/plotOptions.series.allowPointSelect)
  27241. * is `true`, selected points are accumulated on Control, Shift or Cmd
  27242. * clicking the point.
  27243. *
  27244. * @fires Highcharts.Point#event:select
  27245. * @fires Highcharts.Point#event:unselect
  27246. */
  27247. Point.prototype.select = function (selected, accumulate) {
  27248. var point = this,
  27249. series = point.series,
  27250. chart = series.chart;
  27251. selected = pick(selected, !point.selected);
  27252. this.selectedStaging = selected;
  27253. // fire the event with the default handler
  27254. point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () {
  27255. /**
  27256. * Whether the point is selected or not.
  27257. *
  27258. * @see Point#select
  27259. * @see Chart#getSelectedPoints
  27260. *
  27261. * @name Highcharts.Point#selected
  27262. * @type {boolean}
  27263. */
  27264. point.selected = point.options.selected = selected;
  27265. series.options.data[series.data.indexOf(point)] =
  27266. point.options;
  27267. point.setState(selected && 'select');
  27268. // unselect all other points unless Ctrl or Cmd + click
  27269. if (!accumulate) {
  27270. chart.getSelectedPoints().forEach(function (loopPoint) {
  27271. var loopSeries = loopPoint.series;
  27272. if (loopPoint.selected && loopPoint !== point) {
  27273. loopPoint.selected = loopPoint.options.selected =
  27274. false;
  27275. loopSeries.options.data[loopSeries.data.indexOf(loopPoint)] = loopPoint.options;
  27276. // Programatically selecting a point should restore
  27277. // normal state, but when click happened on other
  27278. // point, set inactive state to match other points
  27279. loopPoint.setState(chart.hoverPoints &&
  27280. loopSeries.options.inactiveOtherPoints ?
  27281. 'inactive' : '');
  27282. loopPoint.firePointEvent('unselect');
  27283. }
  27284. });
  27285. }
  27286. });
  27287. delete this.selectedStaging;
  27288. };
  27289. /**
  27290. * Runs on mouse over the point. Called internally from mouse and touch
  27291. * events.
  27292. *
  27293. * @function Highcharts.Point#onMouseOver
  27294. *
  27295. * @param {Highcharts.PointerEventObject} [e]
  27296. * The event arguments.
  27297. */
  27298. Point.prototype.onMouseOver = function (e) {
  27299. var point = this,
  27300. series = point.series,
  27301. chart = series.chart,
  27302. pointer = chart.pointer;
  27303. e = e ?
  27304. pointer.normalize(e) :
  27305. // In cases where onMouseOver is called directly without an event
  27306. pointer.getChartCoordinatesFromPoint(point, chart.inverted);
  27307. pointer.runPointActions(e, point);
  27308. };
  27309. /**
  27310. * Runs on mouse out from the point. Called internally from mouse and touch
  27311. * events.
  27312. *
  27313. * @function Highcharts.Point#onMouseOut
  27314. * @fires Highcharts.Point#event:mouseOut
  27315. */
  27316. Point.prototype.onMouseOut = function () {
  27317. var point = this,
  27318. chart = point.series.chart;
  27319. point.firePointEvent('mouseOut');
  27320. if (!point.series.options.inactiveOtherPoints) {
  27321. (chart.hoverPoints || []).forEach(function (p) {
  27322. p.setState();
  27323. });
  27324. }
  27325. chart.hoverPoints = chart.hoverPoint = null;
  27326. };
  27327. /**
  27328. * Import events from the series' and point's options. Only do it on
  27329. * demand, to save processing time on hovering.
  27330. *
  27331. * @private
  27332. * @function Highcharts.Point#importEvents
  27333. */
  27334. Point.prototype.importEvents = function () {
  27335. if (!this.hasImportedEvents) {
  27336. var point_1 = this,
  27337. options = merge(point_1.series.options.point,
  27338. point_1.options),
  27339. events = options.events;
  27340. point_1.events = events;
  27341. objectEach(events, function (event, eventType) {
  27342. if (isFunction(event)) {
  27343. addEvent(point_1, eventType, event);
  27344. }
  27345. });
  27346. this.hasImportedEvents = true;
  27347. }
  27348. };
  27349. /**
  27350. * Set the point's state.
  27351. *
  27352. * @function Highcharts.Point#setState
  27353. *
  27354. * @param {Highcharts.PointStateValue|""} [state]
  27355. * The new state, can be one of `'hover'`, `'select'`, `'inactive'`,
  27356. * or `''` (an empty string), `'normal'` or `undefined` to set to
  27357. * normal state.
  27358. * @param {boolean} [move]
  27359. * State for animation.
  27360. *
  27361. * @fires Highcharts.Point#event:afterSetState
  27362. */
  27363. Point.prototype.setState = function (state, move) {
  27364. var point = this,
  27365. series = point.series,
  27366. previousState = point.state,
  27367. stateOptions = (series.options.states[state || 'normal'] ||
  27368. {}),
  27369. markerOptions = (defaultOptions.plotOptions[series.type].marker &&
  27370. series.options.marker),
  27371. normalDisabled = (markerOptions && markerOptions.enabled === false),
  27372. markerStateOptions = ((markerOptions &&
  27373. markerOptions.states &&
  27374. markerOptions.states[state || 'normal']) || {}),
  27375. stateDisabled = markerStateOptions.enabled === false,
  27376. stateMarkerGraphic = series.stateMarkerGraphic,
  27377. pointMarker = point.marker || {},
  27378. chart = series.chart,
  27379. halo = series.halo,
  27380. haloOptions,
  27381. markerAttribs,
  27382. pointAttribs,
  27383. pointAttribsAnimation,
  27384. hasMarkers = (markerOptions && series.markerAttribs),
  27385. newSymbol;
  27386. state = state || ''; // empty string
  27387. if (
  27388. // already has this state
  27389. (state === point.state && !move) ||
  27390. // selected points don't respond to hover
  27391. (point.selected && state !== 'select') ||
  27392. // series' state options is disabled
  27393. (stateOptions.enabled === false) ||
  27394. // general point marker's state options is disabled
  27395. (state && (stateDisabled ||
  27396. (normalDisabled &&
  27397. markerStateOptions.enabled === false))) ||
  27398. // individual point marker's state options is disabled
  27399. (state &&
  27400. pointMarker.states &&
  27401. pointMarker.states[state] &&
  27402. pointMarker.states[state].enabled === false) // #1610
  27403. ) {
  27404. return;
  27405. }
  27406. point.state = state;
  27407. if (hasMarkers) {
  27408. markerAttribs = series.markerAttribs(point, state);
  27409. }
  27410. // Apply hover styles to the existing point
  27411. // Prevent from dummy null points (#14966)
  27412. if (point.graphic && !point.hasDummyGraphic) {
  27413. if (previousState) {
  27414. point.graphic.removeClass('highcharts-point-' + previousState);
  27415. }
  27416. if (state) {
  27417. point.graphic.addClass('highcharts-point-' + state);
  27418. }
  27419. if (!chart.styledMode) {
  27420. pointAttribs = series.pointAttribs(point, state);
  27421. pointAttribsAnimation = pick(chart.options.chart.animation, stateOptions.animation);
  27422. // Some inactive points (e.g. slices in pie) should apply
  27423. // oppacity also for it's labels
  27424. if (series.options.inactiveOtherPoints && isNumber(pointAttribs.opacity)) {
  27425. (point.dataLabels || []).forEach(function (label) {
  27426. if (label) {
  27427. label.animate({
  27428. opacity: pointAttribs.opacity
  27429. }, pointAttribsAnimation);
  27430. }
  27431. });
  27432. if (point.connector) {
  27433. point.connector.animate({
  27434. opacity: pointAttribs.opacity
  27435. }, pointAttribsAnimation);
  27436. }
  27437. }
  27438. point.graphic.animate(pointAttribs, pointAttribsAnimation);
  27439. }
  27440. if (markerAttribs) {
  27441. point.graphic.animate(markerAttribs, pick(
  27442. // Turn off globally:
  27443. chart.options.chart.animation, markerStateOptions.animation, markerOptions.animation));
  27444. }
  27445. // Zooming in from a range with no markers to a range with markers
  27446. if (stateMarkerGraphic) {
  27447. stateMarkerGraphic.hide();
  27448. }
  27449. }
  27450. else {
  27451. // if a graphic is not applied to each point in the normal state,
  27452. // create a shared graphic for the hover state
  27453. if (state && markerStateOptions) {
  27454. newSymbol = pointMarker.symbol || series.symbol;
  27455. // If the point has another symbol than the previous one, throw
  27456. // away the state marker graphic and force a new one (#1459)
  27457. if (stateMarkerGraphic &&
  27458. stateMarkerGraphic.currentSymbol !== newSymbol) {
  27459. stateMarkerGraphic = stateMarkerGraphic.destroy();
  27460. }
  27461. // Add a new state marker graphic
  27462. if (markerAttribs) {
  27463. if (!stateMarkerGraphic) {
  27464. if (newSymbol) {
  27465. series.stateMarkerGraphic = stateMarkerGraphic =
  27466. chart.renderer
  27467. .symbol(newSymbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height)
  27468. .add(series.markerGroup);
  27469. stateMarkerGraphic.currentSymbol = newSymbol;
  27470. }
  27471. // Move the existing graphic
  27472. }
  27473. else {
  27474. stateMarkerGraphic[move ? 'animate' : 'attr']({
  27475. x: markerAttribs.x,
  27476. y: markerAttribs.y
  27477. });
  27478. }
  27479. }
  27480. if (!chart.styledMode && stateMarkerGraphic) {
  27481. stateMarkerGraphic.attr(series.pointAttribs(point, state));
  27482. }
  27483. }
  27484. if (stateMarkerGraphic) {
  27485. stateMarkerGraphic[state && point.isInside ? 'show' : 'hide'](); // #2450
  27486. stateMarkerGraphic.element.point = point; // #4310
  27487. }
  27488. }
  27489. // Show me your halo
  27490. haloOptions = stateOptions.halo;
  27491. var markerGraphic = (point.graphic || stateMarkerGraphic);
  27492. var markerVisibility = (markerGraphic && markerGraphic.visibility || 'inherit');
  27493. if (haloOptions &&
  27494. haloOptions.size &&
  27495. markerGraphic &&
  27496. markerVisibility !== 'hidden' &&
  27497. !point.isCluster) {
  27498. if (!halo) {
  27499. series.halo = halo = chart.renderer.path()
  27500. // #5818, #5903, #6705
  27501. .add(markerGraphic.parentGroup);
  27502. }
  27503. halo.show()[move ? 'animate' : 'attr']({
  27504. d: point.haloPath(haloOptions.size)
  27505. });
  27506. halo.attr({
  27507. 'class': 'highcharts-halo highcharts-color-' +
  27508. pick(point.colorIndex, series.colorIndex) +
  27509. (point.className ? ' ' + point.className : ''),
  27510. 'visibility': markerVisibility,
  27511. 'zIndex': -1 // #4929, #8276
  27512. });
  27513. halo.point = point; // #6055
  27514. if (!chart.styledMode) {
  27515. halo.attr(extend({
  27516. 'fill': point.color || series.color,
  27517. 'fill-opacity': haloOptions.opacity
  27518. }, AST.filterUserAttributes(haloOptions.attributes || {})));
  27519. }
  27520. }
  27521. else if (halo && halo.point && halo.point.haloPath) {
  27522. // Animate back to 0 on the current halo point (#6055)
  27523. halo.animate({ d: halo.point.haloPath(0) }, null,
  27524. // Hide after unhovering. The `complete` callback runs in the
  27525. // halo's context (#7681).
  27526. halo.hide);
  27527. }
  27528. fireEvent(point, 'afterSetState', { state: state });
  27529. };
  27530. /**
  27531. * Get the path definition for the halo, which is usually a shadow-like
  27532. * circle around the currently hovered point.
  27533. *
  27534. * @function Highcharts.Point#haloPath
  27535. *
  27536. * @param {number} size
  27537. * The radius of the circular halo.
  27538. *
  27539. * @return {Highcharts.SVGPathArray}
  27540. * The path definition.
  27541. */
  27542. Point.prototype.haloPath = function (size) {
  27543. var series = this.series,
  27544. chart = series.chart;
  27545. return chart.renderer.symbols.circle(Math.floor(this.plotX) - size, this.plotY - size, size * 2, size * 2);
  27546. };
  27547. return Point;
  27548. }());
  27549. H.Point = Point;
  27550. return Point;
  27551. });
  27552. _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) {
  27553. /* *
  27554. *
  27555. * (c) 2010-2021 Torstein Honsi
  27556. *
  27557. * License: www.highcharts.com/license
  27558. *
  27559. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27560. *
  27561. * */
  27562. var animObject = A.animObject,
  27563. setAnimation = A.setAnimation;
  27564. var format = F.format;
  27565. var isFirefox = H.isFirefox,
  27566. marginNames = H.marginNames,
  27567. win = H.win;
  27568. var addEvent = U.addEvent,
  27569. createElement = U.createElement,
  27570. css = U.css,
  27571. defined = U.defined,
  27572. discardElement = U.discardElement,
  27573. find = U.find,
  27574. fireEvent = U.fireEvent,
  27575. isNumber = U.isNumber,
  27576. merge = U.merge,
  27577. pick = U.pick,
  27578. relativeLength = U.relativeLength,
  27579. stableSort = U.stableSort,
  27580. syncTimeout = U.syncTimeout,
  27581. wrap = U.wrap;
  27582. /**
  27583. * Gets fired when the legend item belonging to a point is clicked. The default
  27584. * action is to toggle the visibility of the point. This can be prevented by
  27585. * returning `false` or calling `event.preventDefault()`.
  27586. *
  27587. * @callback Highcharts.PointLegendItemClickCallbackFunction
  27588. *
  27589. * @param {Highcharts.Point} this
  27590. * The point on which the event occured.
  27591. *
  27592. * @param {Highcharts.PointLegendItemClickEventObject} event
  27593. * The event that occured.
  27594. */
  27595. /**
  27596. * Information about the legend click event.
  27597. *
  27598. * @interface Highcharts.PointLegendItemClickEventObject
  27599. */ /**
  27600. * Related browser event.
  27601. * @name Highcharts.PointLegendItemClickEventObject#browserEvent
  27602. * @type {Highcharts.PointerEvent}
  27603. */ /**
  27604. * Prevent the default action of toggle the visibility of the point.
  27605. * @name Highcharts.PointLegendItemClickEventObject#preventDefault
  27606. * @type {Function}
  27607. */ /**
  27608. * Related point.
  27609. * @name Highcharts.PointLegendItemClickEventObject#target
  27610. * @type {Highcharts.Point}
  27611. */ /**
  27612. * Event type.
  27613. * @name Highcharts.PointLegendItemClickEventObject#type
  27614. * @type {"legendItemClick"}
  27615. */
  27616. /**
  27617. * Gets fired when the legend item belonging to a series is clicked. The default
  27618. * action is to toggle the visibility of the series. This can be prevented by
  27619. * returning `false` or calling `event.preventDefault()`.
  27620. *
  27621. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  27622. *
  27623. * @param {Highcharts.Series} this
  27624. * The series where the event occured.
  27625. *
  27626. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  27627. * The event that occured.
  27628. */
  27629. /**
  27630. * Information about the legend click event.
  27631. *
  27632. * @interface Highcharts.SeriesLegendItemClickEventObject
  27633. */ /**
  27634. * Related browser event.
  27635. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  27636. * @type {Highcharts.PointerEvent}
  27637. */ /**
  27638. * Prevent the default action of toggle the visibility of the series.
  27639. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  27640. * @type {Function}
  27641. */ /**
  27642. * Related series.
  27643. * @name Highcharts.SeriesLegendItemClickEventObject#target
  27644. * @type {Highcharts.Series}
  27645. */ /**
  27646. * Event type.
  27647. * @name Highcharts.SeriesLegendItemClickEventObject#type
  27648. * @type {"legendItemClick"}
  27649. */
  27650. /* eslint-disable no-invalid-this, valid-jsdoc */
  27651. /**
  27652. * The overview of the chart's series. The legend object is instanciated
  27653. * internally in the chart constructor, and is available from the `chart.legend`
  27654. * property. Each chart has only one legend.
  27655. *
  27656. * @class
  27657. * @name Highcharts.Legend
  27658. *
  27659. * @param {Highcharts.Chart} chart
  27660. * The chart instance.
  27661. *
  27662. * @param {Highcharts.LegendOptions} options
  27663. * Legend options.
  27664. */
  27665. var Legend = /** @class */ (function () {
  27666. /* *
  27667. *
  27668. * Constructors
  27669. *
  27670. * */
  27671. function Legend(chart, options) {
  27672. /* *
  27673. *
  27674. * Properties
  27675. *
  27676. * */
  27677. this.allItems = [];
  27678. this.box = void 0;
  27679. this.contentGroup = void 0;
  27680. this.display = false;
  27681. this.group = void 0;
  27682. this.initialItemY = 0;
  27683. this.itemHeight = 0;
  27684. this.itemMarginBottom = 0;
  27685. this.itemMarginTop = 0;
  27686. this.itemX = 0;
  27687. this.itemY = 0;
  27688. this.lastItemY = 0;
  27689. this.lastLineHeight = 0;
  27690. this.legendHeight = 0;
  27691. this.legendWidth = 0;
  27692. this.maxItemWidth = 0;
  27693. this.maxLegendWidth = 0;
  27694. this.offsetWidth = 0;
  27695. this.options = {};
  27696. this.padding = 0;
  27697. this.pages = [];
  27698. this.proximate = false;
  27699. this.scrollGroup = void 0;
  27700. this.symbolHeight = 0;
  27701. this.symbolWidth = 0;
  27702. this.titleHeight = 0;
  27703. this.totalItemWidth = 0;
  27704. this.widthOption = 0;
  27705. this.chart = chart;
  27706. this.init(chart, options);
  27707. }
  27708. /* *
  27709. *
  27710. * Functions
  27711. *
  27712. * */
  27713. /**
  27714. * Initialize the legend.
  27715. *
  27716. * @private
  27717. * @function Highcharts.Legend#init
  27718. *
  27719. * @param {Highcharts.Chart} chart
  27720. * The chart instance.
  27721. *
  27722. * @param {Highcharts.LegendOptions} options
  27723. * Legend options.
  27724. */
  27725. Legend.prototype.init = function (chart, options) {
  27726. /**
  27727. * Chart of this legend.
  27728. *
  27729. * @readonly
  27730. * @name Highcharts.Legend#chart
  27731. * @type {Highcharts.Chart}
  27732. */
  27733. this.chart = chart;
  27734. this.setOptions(options);
  27735. if (options.enabled) {
  27736. // Render it
  27737. this.render();
  27738. // move checkboxes
  27739. addEvent(this.chart, 'endResize', function () {
  27740. this.legend.positionCheckboxes();
  27741. });
  27742. if (this.proximate) {
  27743. this.unchartrender = addEvent(this.chart, 'render', function () {
  27744. this.legend.proximatePositions();
  27745. this.legend.positionItems();
  27746. });
  27747. }
  27748. else if (this.unchartrender) {
  27749. this.unchartrender();
  27750. }
  27751. }
  27752. };
  27753. /**
  27754. * @private
  27755. * @function Highcharts.Legend#setOptions
  27756. * @param {Highcharts.LegendOptions} options
  27757. */
  27758. Legend.prototype.setOptions = function (options) {
  27759. var padding = pick(options.padding, 8);
  27760. /**
  27761. * Legend options.
  27762. *
  27763. * @readonly
  27764. * @name Highcharts.Legend#options
  27765. * @type {Highcharts.LegendOptions}
  27766. */
  27767. this.options = options;
  27768. if (!this.chart.styledMode) {
  27769. this.itemStyle = options.itemStyle;
  27770. this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
  27771. }
  27772. this.itemMarginTop = options.itemMarginTop || 0;
  27773. this.itemMarginBottom = options.itemMarginBottom || 0;
  27774. this.padding = padding;
  27775. this.initialItemY = padding - 5; // 5 is pixels above the text
  27776. this.symbolWidth = pick(options.symbolWidth, 16);
  27777. this.pages = [];
  27778. this.proximate = options.layout === 'proximate' && !this.chart.inverted;
  27779. this.baseline = void 0; // #12705: baseline has to be reset on every update
  27780. };
  27781. /**
  27782. * Update the legend with new options. Equivalent to running `chart.update`
  27783. * with a legend configuration option.
  27784. *
  27785. * @sample highcharts/legend/legend-update/
  27786. * Legend update
  27787. *
  27788. * @function Highcharts.Legend#update
  27789. *
  27790. * @param {Highcharts.LegendOptions} options
  27791. * Legend options.
  27792. *
  27793. * @param {boolean} [redraw=true]
  27794. * Whether to redraw the chart after the axis is altered. If doing more
  27795. * operations on the chart, it is a good idea to set redraw to false and
  27796. * call {@link Chart#redraw} after. Whether to redraw the chart.
  27797. *
  27798. * @fires Highcharts.Legends#event:afterUpdate
  27799. */
  27800. Legend.prototype.update = function (options, redraw) {
  27801. var chart = this.chart;
  27802. this.setOptions(merge(true, this.options, options));
  27803. this.destroy();
  27804. chart.isDirtyLegend = chart.isDirtyBox = true;
  27805. if (pick(redraw, true)) {
  27806. chart.redraw();
  27807. }
  27808. fireEvent(this, 'afterUpdate');
  27809. };
  27810. /**
  27811. * Set the colors for the legend item.
  27812. *
  27813. * @private
  27814. * @function Highcharts.Legend#colorizeItem
  27815. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  27816. * A Series or Point instance
  27817. * @param {boolean} [visible=false]
  27818. * Dimmed or colored
  27819. *
  27820. * @todo
  27821. * Make events official: Fires the event `afterColorizeItem`.
  27822. */
  27823. Legend.prototype.colorizeItem = function (item, visible) {
  27824. item.legendGroup[visible ? 'removeClass' : 'addClass']('highcharts-legend-item-hidden');
  27825. if (!this.chart.styledMode) {
  27826. var legend = this,
  27827. options = legend.options,
  27828. legendItem = item.legendItem,
  27829. legendLine = item.legendLine,
  27830. legendSymbol = item.legendSymbol,
  27831. hiddenColor = legend.itemHiddenStyle.color,
  27832. textColor = visible ?
  27833. options.itemStyle.color :
  27834. hiddenColor,
  27835. symbolColor = visible ?
  27836. (item.color || hiddenColor) :
  27837. hiddenColor,
  27838. markerOptions = item.options && item.options.marker,
  27839. symbolAttr = { fill: symbolColor };
  27840. if (legendItem) {
  27841. legendItem.css({
  27842. fill: textColor,
  27843. color: textColor // #1553, oldIE
  27844. });
  27845. }
  27846. if (legendLine) {
  27847. legendLine.attr({ stroke: symbolColor });
  27848. }
  27849. if (legendSymbol) {
  27850. // Apply marker options
  27851. if (markerOptions && legendSymbol.isMarker) { // #585
  27852. symbolAttr = item.pointAttribs();
  27853. if (!visible) {
  27854. // #6769
  27855. symbolAttr.stroke = symbolAttr.fill = hiddenColor;
  27856. }
  27857. }
  27858. legendSymbol.attr(symbolAttr);
  27859. }
  27860. }
  27861. fireEvent(this, 'afterColorizeItem', { item: item, visible: visible });
  27862. };
  27863. /**
  27864. * @private
  27865. * @function Highcharts.Legend#positionItems
  27866. */
  27867. Legend.prototype.positionItems = function () {
  27868. // Now that the legend width and height are established, put the items
  27869. // in the final position
  27870. this.allItems.forEach(this.positionItem, this);
  27871. if (!this.chart.isResizing) {
  27872. this.positionCheckboxes();
  27873. }
  27874. };
  27875. /**
  27876. * Position the legend item.
  27877. *
  27878. * @private
  27879. * @function Highcharts.Legend#positionItem
  27880. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  27881. * The item to position
  27882. */
  27883. Legend.prototype.positionItem = function (item) {
  27884. var _this = this;
  27885. var legend = this,
  27886. options = legend.options,
  27887. symbolPadding = options.symbolPadding,
  27888. ltr = !options.rtl,
  27889. legendItemPos = item._legendItemPos,
  27890. itemX = legendItemPos[0],
  27891. itemY = legendItemPos[1],
  27892. checkbox = item.checkbox,
  27893. legendGroup = item.legendGroup;
  27894. if (legendGroup && legendGroup.element) {
  27895. var attribs = {
  27896. translateX: ltr ?
  27897. itemX :
  27898. legend.legendWidth - itemX - 2 * symbolPadding - 4,
  27899. translateY: itemY
  27900. };
  27901. var complete = function () {
  27902. fireEvent(_this, 'afterPositionItem', { item: item });
  27903. };
  27904. if (defined(legendGroup.translateY)) {
  27905. legendGroup.animate(attribs, void 0, complete);
  27906. }
  27907. else {
  27908. legendGroup.attr(attribs);
  27909. complete();
  27910. }
  27911. }
  27912. if (checkbox) {
  27913. checkbox.x = itemX;
  27914. checkbox.y = itemY;
  27915. }
  27916. };
  27917. /**
  27918. * Destroy a single legend item, used internally on removing series items.
  27919. *
  27920. * @private
  27921. * @function Highcharts.Legend#destroyItem
  27922. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  27923. * The item to remove
  27924. */
  27925. Legend.prototype.destroyItem = function (item) {
  27926. var checkbox = item.checkbox;
  27927. // destroy SVG elements
  27928. ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(function (key) {
  27929. if (item[key]) {
  27930. item[key] = item[key].destroy();
  27931. }
  27932. });
  27933. if (checkbox) {
  27934. discardElement(item.checkbox);
  27935. }
  27936. };
  27937. /**
  27938. * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
  27939. * must be called after destruction.
  27940. *
  27941. * @private
  27942. * @function Highcharts.Legend#destroy
  27943. */
  27944. Legend.prototype.destroy = function () {
  27945. /**
  27946. * @private
  27947. * @param {string} key
  27948. * @return {void}
  27949. */
  27950. function destroyItems(key) {
  27951. if (this[key]) {
  27952. this[key] = this[key].destroy();
  27953. }
  27954. }
  27955. // Destroy items
  27956. this.getAllItems().forEach(function (item) {
  27957. ['legendItem', 'legendGroup'].forEach(destroyItems, item);
  27958. });
  27959. // Destroy legend elements
  27960. [
  27961. 'clipRect',
  27962. 'up',
  27963. 'down',
  27964. 'pager',
  27965. 'nav',
  27966. 'box',
  27967. 'title',
  27968. 'group'
  27969. ].forEach(destroyItems, this);
  27970. this.display = null; // Reset in .render on update.
  27971. };
  27972. /**
  27973. * Position the checkboxes after the width is determined.
  27974. *
  27975. * @private
  27976. * @function Highcharts.Legend#positionCheckboxes
  27977. */
  27978. Legend.prototype.positionCheckboxes = function () {
  27979. var alignAttr = this.group && this.group.alignAttr,
  27980. translateY,
  27981. clipHeight = this.clipHeight || this.legendHeight,
  27982. titleHeight = this.titleHeight;
  27983. if (alignAttr) {
  27984. translateY = alignAttr.translateY;
  27985. this.allItems.forEach(function (item) {
  27986. var checkbox = item.checkbox,
  27987. top;
  27988. if (checkbox) {
  27989. top = translateY + titleHeight + checkbox.y +
  27990. (this.scrollOffset || 0) + 3;
  27991. css(checkbox, {
  27992. left: (alignAttr.translateX + item.checkboxOffset +
  27993. checkbox.x - 20) + 'px',
  27994. top: top + 'px',
  27995. display: this.proximate || (top > translateY - 6 &&
  27996. top < translateY + clipHeight - 6) ?
  27997. '' :
  27998. 'none'
  27999. });
  28000. }
  28001. }, this);
  28002. }
  28003. };
  28004. /**
  28005. * Render the legend title on top of the legend.
  28006. *
  28007. * @private
  28008. * @function Highcharts.Legend#renderTitle
  28009. */
  28010. Legend.prototype.renderTitle = function () {
  28011. var options = this.options,
  28012. padding = this.padding,
  28013. titleOptions = options.title,
  28014. titleHeight = 0,
  28015. bBox;
  28016. if (titleOptions.text) {
  28017. if (!this.title) {
  28018. /**
  28019. * SVG element of the legend title.
  28020. *
  28021. * @readonly
  28022. * @name Highcharts.Legend#title
  28023. * @type {Highcharts.SVGElement}
  28024. */
  28025. this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, options.useHTML, null, 'legend-title')
  28026. .attr({ zIndex: 1 });
  28027. if (!this.chart.styledMode) {
  28028. this.title.css(titleOptions.style);
  28029. }
  28030. this.title.add(this.group);
  28031. }
  28032. // Set the max title width (#7253)
  28033. if (!titleOptions.width) {
  28034. this.title.css({
  28035. width: this.maxLegendWidth + 'px'
  28036. });
  28037. }
  28038. bBox = this.title.getBBox();
  28039. titleHeight = bBox.height;
  28040. this.offsetWidth = bBox.width; // #1717
  28041. this.contentGroup.attr({ translateY: titleHeight });
  28042. }
  28043. this.titleHeight = titleHeight;
  28044. };
  28045. /**
  28046. * Set the legend item text.
  28047. *
  28048. * @function Highcharts.Legend#setText
  28049. * @param {Highcharts.Point|Highcharts.Series} item
  28050. * The item for which to update the text in the legend.
  28051. */
  28052. Legend.prototype.setText = function (item) {
  28053. var options = this.options;
  28054. item.legendItem.attr({
  28055. text: options.labelFormat ?
  28056. format(options.labelFormat, item, this.chart) :
  28057. options.labelFormatter.call(item)
  28058. });
  28059. };
  28060. /**
  28061. * Render a single specific legend item. Called internally from the `render`
  28062. * function.
  28063. *
  28064. * @private
  28065. * @function Highcharts.Legend#renderItem
  28066. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28067. * The item to render.
  28068. */
  28069. Legend.prototype.renderItem = function (item) {
  28070. var legend = this,
  28071. chart = legend.chart,
  28072. renderer = chart.renderer,
  28073. options = legend.options,
  28074. horizontal = options.layout === 'horizontal',
  28075. symbolWidth = legend.symbolWidth,
  28076. symbolPadding = options.symbolPadding || 0,
  28077. itemStyle = legend.itemStyle,
  28078. itemHiddenStyle = legend.itemHiddenStyle,
  28079. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28080. ltr = !options.rtl,
  28081. bBox,
  28082. li = item.legendItem,
  28083. isSeries = !item.series,
  28084. series = !isSeries && item.series.drawLegendSymbol ?
  28085. item.series :
  28086. item,
  28087. seriesOptions = series.options,
  28088. showCheckbox = legend.createCheckboxForItem &&
  28089. seriesOptions &&
  28090. seriesOptions.showCheckbox,
  28091. // full width minus text width
  28092. itemExtraWidth = symbolWidth + symbolPadding +
  28093. itemDistance + (showCheckbox ? 20 : 0),
  28094. useHTML = options.useHTML,
  28095. itemClassName = item.options.className;
  28096. if (!li) { // generate it once, later move it
  28097. // Generate the group box, a group to hold the symbol and text. Text
  28098. // is to be appended in Legend class.
  28099. item.legendGroup = renderer
  28100. .g('legend-item')
  28101. .addClass('highcharts-' + series.type + '-series ' +
  28102. 'highcharts-color-' + item.colorIndex +
  28103. (itemClassName ? ' ' + itemClassName : '') +
  28104. (isSeries ?
  28105. ' highcharts-series-' + item.index :
  28106. ''))
  28107. .attr({ zIndex: 1 })
  28108. .add(legend.scrollGroup);
  28109. // Generate the list item text and add it to the group
  28110. item.legendItem = li = renderer.text('', ltr ?
  28111. symbolWidth + symbolPadding :
  28112. -symbolPadding, legend.baseline || 0, useHTML);
  28113. if (!chart.styledMode) {
  28114. // merge to prevent modifying original (#1021)
  28115. li.css(merge(item.visible ?
  28116. itemStyle :
  28117. itemHiddenStyle));
  28118. }
  28119. li
  28120. .attr({
  28121. align: ltr ? 'left' : 'right',
  28122. zIndex: 2
  28123. })
  28124. .add(item.legendGroup);
  28125. // Get the baseline for the first item - the font size is equal for
  28126. // all
  28127. if (!legend.baseline) {
  28128. legend.fontMetrics = renderer.fontMetrics(chart.styledMode ? 12 : itemStyle.fontSize, li);
  28129. legend.baseline =
  28130. legend.fontMetrics.f + 3 + legend.itemMarginTop;
  28131. li.attr('y', legend.baseline);
  28132. legend.symbolHeight =
  28133. options.symbolHeight || legend.fontMetrics.f;
  28134. if (options.squareSymbol) {
  28135. legend.symbolWidth = pick(options.symbolWidth, Math.max(legend.symbolHeight, 16));
  28136. itemExtraWidth = legend.symbolWidth + symbolPadding +
  28137. itemDistance + (showCheckbox ? 20 : 0);
  28138. if (ltr) {
  28139. li.attr('x', legend.symbolWidth + symbolPadding);
  28140. }
  28141. }
  28142. }
  28143. // Draw the legend symbol inside the group box
  28144. series.drawLegendSymbol(legend, item);
  28145. if (legend.setItemEvents) {
  28146. legend.setItemEvents(item, li, useHTML);
  28147. }
  28148. }
  28149. // Add the HTML checkbox on top
  28150. if (showCheckbox && !item.checkbox && legend.createCheckboxForItem) {
  28151. legend.createCheckboxForItem(item);
  28152. }
  28153. // Colorize the items
  28154. legend.colorizeItem(item, item.visible);
  28155. // Take care of max width and text overflow (#6659)
  28156. if (chart.styledMode || !itemStyle.width) {
  28157. li.css({
  28158. width: ((options.itemWidth ||
  28159. legend.widthOption ||
  28160. chart.spacingBox.width) - itemExtraWidth) + 'px'
  28161. });
  28162. }
  28163. // Always update the text
  28164. legend.setText(item);
  28165. // calculate the positions for the next line
  28166. bBox = li.getBBox();
  28167. item.itemWidth = item.checkboxOffset =
  28168. options.itemWidth ||
  28169. item.legendItemWidth ||
  28170. bBox.width + itemExtraWidth;
  28171. legend.maxItemWidth = Math.max(legend.maxItemWidth, item.itemWidth);
  28172. legend.totalItemWidth += item.itemWidth;
  28173. legend.itemHeight = item.itemHeight = Math.round(item.legendItemHeight || bBox.height || legend.symbolHeight);
  28174. };
  28175. /**
  28176. * Get the position of the item in the layout. We now know the
  28177. * maxItemWidth from the previous loop.
  28178. *
  28179. * @private
  28180. * @function Highcharts.Legend#layoutItem
  28181. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28182. */
  28183. Legend.prototype.layoutItem = function (item) {
  28184. var options = this.options,
  28185. padding = this.padding,
  28186. horizontal = options.layout === 'horizontal',
  28187. itemHeight = item.itemHeight,
  28188. itemMarginBottom = this.itemMarginBottom,
  28189. itemMarginTop = this.itemMarginTop,
  28190. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28191. maxLegendWidth = this.maxLegendWidth,
  28192. itemWidth = (options.alignColumns &&
  28193. this.totalItemWidth > maxLegendWidth) ?
  28194. this.maxItemWidth :
  28195. item.itemWidth;
  28196. // If the item exceeds the width, start a new line
  28197. if (horizontal &&
  28198. this.itemX - padding + itemWidth > maxLegendWidth) {
  28199. this.itemX = padding;
  28200. if (this.lastLineHeight) { // Not for the first line (#10167)
  28201. this.itemY += (itemMarginTop +
  28202. this.lastLineHeight +
  28203. itemMarginBottom);
  28204. }
  28205. this.lastLineHeight = 0; // reset for next line (#915, #3976)
  28206. }
  28207. // Set the edge positions
  28208. this.lastItemY = itemMarginTop + this.itemY + itemMarginBottom;
  28209. this.lastLineHeight = Math.max(// #915
  28210. itemHeight, this.lastLineHeight);
  28211. // cache the position of the newly generated or reordered items
  28212. item._legendItemPos = [this.itemX, this.itemY];
  28213. // advance
  28214. if (horizontal) {
  28215. this.itemX += itemWidth;
  28216. }
  28217. else {
  28218. this.itemY +=
  28219. itemMarginTop + itemHeight + itemMarginBottom;
  28220. this.lastLineHeight = itemHeight;
  28221. }
  28222. // the width of the widest item
  28223. this.offsetWidth = this.widthOption || Math.max((horizontal ? this.itemX - padding - (item.checkbox ?
  28224. // decrease by itemDistance only when no checkbox #4853
  28225. 0 :
  28226. itemDistance) : itemWidth) + padding, this.offsetWidth);
  28227. };
  28228. /**
  28229. * Get all items, which is one item per series for most series and one
  28230. * item per point for pie series and its derivatives. Fires the event
  28231. * `afterGetAllItems`.
  28232. *
  28233. * @private
  28234. * @function Highcharts.Legend#getAllItems
  28235. * @return {Array<(Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series)>}
  28236. * The current items in the legend.
  28237. * @fires Highcharts.Legend#event:afterGetAllItems
  28238. */
  28239. Legend.prototype.getAllItems = function () {
  28240. var allItems = [];
  28241. this.chart.series.forEach(function (series) {
  28242. var seriesOptions = series && series.options;
  28243. // Handle showInLegend. If the series is linked to another series,
  28244. // defaults to false.
  28245. if (series && pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? void 0 : false, true)) {
  28246. // Use points or series for the legend item depending on
  28247. // legendType
  28248. allItems = allItems.concat(series.legendItems ||
  28249. (seriesOptions.legendType === 'point' ?
  28250. series.data :
  28251. series));
  28252. }
  28253. });
  28254. fireEvent(this, 'afterGetAllItems', { allItems: allItems });
  28255. return allItems;
  28256. };
  28257. /**
  28258. * Get a short, three letter string reflecting the alignment and layout.
  28259. *
  28260. * @private
  28261. * @function Highcharts.Legend#getAlignment
  28262. * @return {string}
  28263. * The alignment, empty string if floating
  28264. */
  28265. Legend.prototype.getAlignment = function () {
  28266. var options = this.options;
  28267. // Use the first letter of each alignment option in order to detect
  28268. // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
  28269. if (this.proximate) {
  28270. return options.align.charAt(0) + 'tv';
  28271. }
  28272. return options.floating ? '' : (options.align.charAt(0) +
  28273. options.verticalAlign.charAt(0) +
  28274. options.layout.charAt(0));
  28275. };
  28276. /**
  28277. * Adjust the chart margins by reserving space for the legend on only one
  28278. * side of the chart. If the position is set to a corner, top or bottom is
  28279. * reserved for horizontal legends and left or right for vertical ones.
  28280. *
  28281. * @private
  28282. * @function Highcharts.Legend#adjustMargins
  28283. * @param {Array<number>} margin
  28284. * @param {Array<number>} spacing
  28285. */
  28286. Legend.prototype.adjustMargins = function (margin, spacing) {
  28287. var chart = this.chart,
  28288. options = this.options,
  28289. alignment = this.getAlignment();
  28290. if (alignment) {
  28291. ([
  28292. /(lth|ct|rth)/,
  28293. /(rtv|rm|rbv)/,
  28294. /(rbh|cb|lbh)/,
  28295. /(lbv|lm|ltv)/
  28296. ]).forEach(function (alignments, side) {
  28297. if (alignments.test(alignment) && !defined(margin[side])) {
  28298. // Now we have detected on which side of the chart we should
  28299. // reserve space for the legend
  28300. chart[marginNames[side]] = Math.max(chart[marginNames[side]], (chart.legend[(side + 1) % 2 ? 'legendHeight' : 'legendWidth'] +
  28301. [1, -1, -1, 1][side] * options[(side % 2) ? 'x' : 'y'] +
  28302. pick(options.margin, 12) +
  28303. spacing[side] +
  28304. (chart.titleOffset[side] || 0)));
  28305. }
  28306. });
  28307. }
  28308. };
  28309. /**
  28310. * @private
  28311. * @function Highcharts.Legend#proximatePositions
  28312. */
  28313. Legend.prototype.proximatePositions = function () {
  28314. var chart = this.chart,
  28315. boxes = [],
  28316. alignLeft = this.options.align === 'left';
  28317. this.allItems.forEach(function (item) {
  28318. var lastPoint,
  28319. height,
  28320. useFirstPoint = alignLeft,
  28321. target,
  28322. top;
  28323. if (item.yAxis) {
  28324. if (item.xAxis.options.reversed) {
  28325. useFirstPoint = !useFirstPoint;
  28326. }
  28327. if (item.points) {
  28328. lastPoint = find(useFirstPoint ?
  28329. item.points :
  28330. item.points.slice(0).reverse(), function (item) {
  28331. return isNumber(item.plotY);
  28332. });
  28333. }
  28334. height = this.itemMarginTop +
  28335. item.legendItem.getBBox().height +
  28336. this.itemMarginBottom;
  28337. top = item.yAxis.top - chart.plotTop;
  28338. if (item.visible) {
  28339. target = lastPoint ?
  28340. lastPoint.plotY :
  28341. item.yAxis.height;
  28342. target += top - 0.3 * height;
  28343. }
  28344. else {
  28345. target = top + item.yAxis.height;
  28346. }
  28347. boxes.push({
  28348. target: target,
  28349. size: height,
  28350. item: item
  28351. });
  28352. }
  28353. }, this);
  28354. H.distribute(boxes, chart.plotHeight);
  28355. boxes.forEach(function (box) {
  28356. box.item._legendItemPos[1] =
  28357. chart.plotTop - chart.spacing[0] + box.pos;
  28358. });
  28359. };
  28360. /**
  28361. * Render the legend. This method can be called both before and after
  28362. * `chart.render`. If called after, it will only rearrange items instead
  28363. * of creating new ones. Called internally on initial render and after
  28364. * redraws.
  28365. *
  28366. * @private
  28367. * @function Highcharts.Legend#render
  28368. */
  28369. Legend.prototype.render = function () {
  28370. var legend = this,
  28371. chart = legend.chart,
  28372. renderer = chart.renderer,
  28373. legendGroup = legend.group,
  28374. allItems,
  28375. display,
  28376. legendWidth,
  28377. legendHeight,
  28378. box = legend.box,
  28379. options = legend.options,
  28380. padding = legend.padding,
  28381. allowedWidth;
  28382. legend.itemX = padding;
  28383. legend.itemY = legend.initialItemY;
  28384. legend.offsetWidth = 0;
  28385. legend.lastItemY = 0;
  28386. legend.widthOption = relativeLength(options.width, chart.spacingBox.width - padding);
  28387. // Compute how wide the legend is allowed to be
  28388. allowedWidth =
  28389. chart.spacingBox.width - 2 * padding - options.x;
  28390. if (['rm', 'lm'].indexOf(legend.getAlignment().substring(0, 2)) > -1) {
  28391. allowedWidth /= 2;
  28392. }
  28393. legend.maxLegendWidth = legend.widthOption || allowedWidth;
  28394. if (!legendGroup) {
  28395. /**
  28396. * SVG group of the legend.
  28397. *
  28398. * @readonly
  28399. * @name Highcharts.Legend#group
  28400. * @type {Highcharts.SVGElement}
  28401. */
  28402. legend.group = legendGroup = renderer.g('legend')
  28403. .attr({ zIndex: 7 })
  28404. .add();
  28405. legend.contentGroup = renderer.g()
  28406. .attr({ zIndex: 1 }) // above background
  28407. .add(legendGroup);
  28408. legend.scrollGroup = renderer.g()
  28409. .add(legend.contentGroup);
  28410. }
  28411. legend.renderTitle();
  28412. // add each series or point
  28413. allItems = legend.getAllItems();
  28414. // sort by legendIndex
  28415. stableSort(allItems, function (a, b) {
  28416. return ((a.options && a.options.legendIndex) || 0) -
  28417. ((b.options && b.options.legendIndex) || 0);
  28418. });
  28419. // reversed legend
  28420. if (options.reversed) {
  28421. allItems.reverse();
  28422. }
  28423. /**
  28424. * All items for the legend, which is an array of series for most series
  28425. * and an array of points for pie series and its derivatives.
  28426. *
  28427. * @readonly
  28428. * @name Highcharts.Legend#allItems
  28429. * @type {Array<(Highcharts.Point|Highcharts.Series)>}
  28430. */
  28431. legend.allItems = allItems;
  28432. legend.display = display = !!allItems.length;
  28433. // Render the items. First we run a loop to set the text and properties
  28434. // and read all the bounding boxes. The next loop computes the item
  28435. // positions based on the bounding boxes.
  28436. legend.lastLineHeight = 0;
  28437. legend.maxItemWidth = 0;
  28438. legend.totalItemWidth = 0;
  28439. legend.itemHeight = 0;
  28440. allItems.forEach(legend.renderItem, legend);
  28441. allItems.forEach(legend.layoutItem, legend);
  28442. // Get the box
  28443. legendWidth = (legend.widthOption || legend.offsetWidth) + padding;
  28444. legendHeight = legend.lastItemY + legend.lastLineHeight +
  28445. legend.titleHeight;
  28446. legendHeight = legend.handleOverflow(legendHeight);
  28447. legendHeight += padding;
  28448. // Draw the border and/or background
  28449. if (!box) {
  28450. /**
  28451. * SVG element of the legend box.
  28452. *
  28453. * @readonly
  28454. * @name Highcharts.Legend#box
  28455. * @type {Highcharts.SVGElement}
  28456. */
  28457. legend.box = box = renderer.rect()
  28458. .addClass('highcharts-legend-box')
  28459. .attr({
  28460. r: options.borderRadius
  28461. })
  28462. .add(legendGroup);
  28463. box.isNew = true;
  28464. }
  28465. // Presentational
  28466. if (!chart.styledMode) {
  28467. box
  28468. .attr({
  28469. stroke: options.borderColor,
  28470. 'stroke-width': options.borderWidth || 0,
  28471. fill: options.backgroundColor || 'none'
  28472. })
  28473. .shadow(options.shadow);
  28474. }
  28475. if (legendWidth > 0 && legendHeight > 0) {
  28476. box[box.isNew ? 'attr' : 'animate'](box.crisp.call({}, {
  28477. x: 0,
  28478. y: 0,
  28479. width: legendWidth,
  28480. height: legendHeight
  28481. }, box.strokeWidth()));
  28482. box.isNew = false;
  28483. }
  28484. // hide the border if no items
  28485. box[display ? 'show' : 'hide']();
  28486. // Open for responsiveness
  28487. if (chart.styledMode && legendGroup.getStyle('display') === 'none') {
  28488. legendWidth = legendHeight = 0;
  28489. }
  28490. legend.legendWidth = legendWidth;
  28491. legend.legendHeight = legendHeight;
  28492. if (display) {
  28493. legend.align();
  28494. }
  28495. if (!this.proximate) {
  28496. this.positionItems();
  28497. }
  28498. fireEvent(this, 'afterRender');
  28499. };
  28500. /**
  28501. * Align the legend to chart's box.
  28502. *
  28503. * @private
  28504. * @function Highcharts.align
  28505. * @param {Highcharts.BBoxObject} alignTo
  28506. * @return {void}
  28507. */
  28508. Legend.prototype.align = function (alignTo) {
  28509. if (alignTo === void 0) { alignTo = this.chart.spacingBox; }
  28510. var chart = this.chart,
  28511. options = this.options;
  28512. // If aligning to the top and the layout is horizontal, adjust for
  28513. // the title (#7428)
  28514. var y = alignTo.y;
  28515. if (/(lth|ct|rth)/.test(this.getAlignment()) &&
  28516. chart.titleOffset[0] > 0) {
  28517. y += chart.titleOffset[0];
  28518. }
  28519. else if (/(lbh|cb|rbh)/.test(this.getAlignment()) &&
  28520. chart.titleOffset[2] > 0) {
  28521. y -= chart.titleOffset[2];
  28522. }
  28523. if (y !== alignTo.y) {
  28524. alignTo = merge(alignTo, { y: y });
  28525. }
  28526. this.group.align(merge(options, {
  28527. width: this.legendWidth,
  28528. height: this.legendHeight,
  28529. verticalAlign: this.proximate ? 'top' : options.verticalAlign
  28530. }), true, alignTo);
  28531. };
  28532. /**
  28533. * Set up the overflow handling by adding navigation with up and down arrows
  28534. * below the legend.
  28535. *
  28536. * @private
  28537. * @function Highcharts.Legend#handleOverflow
  28538. * @param {number} legendHeight
  28539. * @return {number}
  28540. */
  28541. Legend.prototype.handleOverflow = function (legendHeight) {
  28542. var legend = this,
  28543. chart = this.chart,
  28544. renderer = chart.renderer,
  28545. options = this.options,
  28546. optionsY = options.y,
  28547. alignTop = options.verticalAlign === 'top',
  28548. padding = this.padding,
  28549. spaceHeight = (chart.spacingBox.height +
  28550. (alignTop ? -optionsY : optionsY) - padding),
  28551. maxHeight = options.maxHeight,
  28552. clipHeight,
  28553. clipRect = this.clipRect,
  28554. navOptions = options.navigation,
  28555. animation = pick(navOptions.animation,
  28556. true),
  28557. arrowSize = navOptions.arrowSize || 12,
  28558. nav = this.nav,
  28559. pages = this.pages,
  28560. lastY,
  28561. allItems = this.allItems,
  28562. clipToHeight = function (height) {
  28563. if (typeof height === 'number') {
  28564. clipRect.attr({
  28565. height: height
  28566. });
  28567. }
  28568. else if (clipRect) { // Reset (#5912)
  28569. legend.clipRect = clipRect.destroy();
  28570. legend.contentGroup.clip();
  28571. }
  28572. // useHTML
  28573. if (legend.contentGroup.div) {
  28574. legend.contentGroup.div.style.clip = height ?
  28575. 'rect(' + padding + 'px,9999px,' +
  28576. (padding + height) + 'px,0)' :
  28577. 'auto';
  28578. }
  28579. }, addTracker = function (key) {
  28580. legend[key] = renderer
  28581. .circle(0, 0, arrowSize * 1.3)
  28582. .translate(arrowSize / 2, arrowSize / 2)
  28583. .add(nav);
  28584. if (!chart.styledMode) {
  28585. legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
  28586. }
  28587. return legend[key];
  28588. };
  28589. // Adjust the height
  28590. if (options.layout === 'horizontal' &&
  28591. options.verticalAlign !== 'middle' &&
  28592. !options.floating) {
  28593. spaceHeight /= 2;
  28594. }
  28595. if (maxHeight) {
  28596. spaceHeight = Math.min(spaceHeight, maxHeight);
  28597. }
  28598. // Reset the legend height and adjust the clipping rectangle
  28599. pages.length = 0;
  28600. if (legendHeight &&
  28601. spaceHeight > 0 &&
  28602. legendHeight > spaceHeight &&
  28603. navOptions.enabled !== false) {
  28604. this.clipHeight = clipHeight =
  28605. Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
  28606. this.currentPage = pick(this.currentPage, 1);
  28607. this.fullHeight = legendHeight;
  28608. // Fill pages with Y positions so that the top of each a legend item
  28609. // defines the scroll top for each page (#2098)
  28610. allItems.forEach(function (item, i) {
  28611. var y = item._legendItemPos[1],
  28612. h = Math.round(item.legendItem.getBBox().height),
  28613. len = pages.length;
  28614. if (!len || (y - pages[len - 1] > clipHeight &&
  28615. (lastY || y) !== pages[len - 1])) {
  28616. pages.push(lastY || y);
  28617. len++;
  28618. }
  28619. // Keep track of which page each item is on
  28620. item.pageIx = len - 1;
  28621. if (lastY) {
  28622. allItems[i - 1].pageIx = len - 1;
  28623. }
  28624. if (i === allItems.length - 1 &&
  28625. y + h - pages[len - 1] > clipHeight &&
  28626. y !== lastY // #2617
  28627. ) {
  28628. pages.push(y);
  28629. item.pageIx = len;
  28630. }
  28631. if (y !== lastY) {
  28632. lastY = y;
  28633. }
  28634. });
  28635. // Only apply clipping if needed. Clipping causes blurred legend in
  28636. // PDF export (#1787)
  28637. if (!clipRect) {
  28638. clipRect = legend.clipRect =
  28639. renderer.clipRect(0, padding, 9999, 0);
  28640. legend.contentGroup.clip(clipRect);
  28641. }
  28642. clipToHeight(clipHeight);
  28643. // Add navigation elements
  28644. if (!nav) {
  28645. this.nav = nav = renderer.g()
  28646. .attr({ zIndex: 1 })
  28647. .add(this.group);
  28648. this.up = renderer
  28649. .symbol('triangle', 0, 0, arrowSize, arrowSize)
  28650. .add(nav);
  28651. addTracker('upTracker')
  28652. .on('click', function () {
  28653. legend.scroll(-1, animation);
  28654. });
  28655. this.pager = renderer.text('', 15, 10)
  28656. .addClass('highcharts-legend-navigation');
  28657. if (!chart.styledMode) {
  28658. this.pager.css(navOptions.style);
  28659. }
  28660. this.pager.add(nav);
  28661. this.down = renderer
  28662. .symbol('triangle-down', 0, 0, arrowSize, arrowSize)
  28663. .add(nav);
  28664. addTracker('downTracker')
  28665. .on('click', function () {
  28666. legend.scroll(1, animation);
  28667. });
  28668. }
  28669. // Set initial position
  28670. legend.scroll(0);
  28671. legendHeight = spaceHeight;
  28672. // Reset
  28673. }
  28674. else if (nav) {
  28675. clipToHeight();
  28676. this.nav = nav.destroy(); // #6322
  28677. this.scrollGroup.attr({
  28678. translateY: 1
  28679. });
  28680. this.clipHeight = 0; // #1379
  28681. }
  28682. return legendHeight;
  28683. };
  28684. /**
  28685. * Scroll the legend by a number of pages.
  28686. *
  28687. * @private
  28688. * @function Highcharts.Legend#scroll
  28689. *
  28690. * @param {number} scrollBy
  28691. * The number of pages to scroll.
  28692. *
  28693. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  28694. * Whether and how to apply animation.
  28695. *
  28696. * @return {void}
  28697. */
  28698. Legend.prototype.scroll = function (scrollBy, animation) {
  28699. var _this = this;
  28700. var chart = this.chart,
  28701. pages = this.pages,
  28702. pageCount = pages.length,
  28703. currentPage = this.currentPage + scrollBy,
  28704. clipHeight = this.clipHeight,
  28705. navOptions = this.options.navigation,
  28706. pager = this.pager,
  28707. padding = this.padding;
  28708. // When resizing while looking at the last page
  28709. if (currentPage > pageCount) {
  28710. currentPage = pageCount;
  28711. }
  28712. if (currentPage > 0) {
  28713. if (typeof animation !== 'undefined') {
  28714. setAnimation(animation, chart);
  28715. }
  28716. this.nav.attr({
  28717. translateX: padding,
  28718. translateY: clipHeight + this.padding + 7 + this.titleHeight,
  28719. visibility: 'visible'
  28720. });
  28721. [this.up, this.upTracker].forEach(function (elem) {
  28722. elem.attr({
  28723. 'class': currentPage === 1 ?
  28724. 'highcharts-legend-nav-inactive' :
  28725. 'highcharts-legend-nav-active'
  28726. });
  28727. });
  28728. pager.attr({
  28729. text: currentPage + '/' + pageCount
  28730. });
  28731. [this.down, this.downTracker].forEach(function (elem) {
  28732. elem.attr({
  28733. // adjust to text width
  28734. x: 18 + this.pager.getBBox().width,
  28735. 'class': currentPage === pageCount ?
  28736. 'highcharts-legend-nav-inactive' :
  28737. 'highcharts-legend-nav-active'
  28738. });
  28739. }, this);
  28740. if (!chart.styledMode) {
  28741. this.up
  28742. .attr({
  28743. fill: currentPage === 1 ?
  28744. navOptions.inactiveColor :
  28745. navOptions.activeColor
  28746. });
  28747. this.upTracker
  28748. .css({
  28749. cursor: currentPage === 1 ? 'default' : 'pointer'
  28750. });
  28751. this.down
  28752. .attr({
  28753. fill: currentPage === pageCount ?
  28754. navOptions.inactiveColor :
  28755. navOptions.activeColor
  28756. });
  28757. this.downTracker
  28758. .css({
  28759. cursor: currentPage === pageCount ?
  28760. 'default' :
  28761. 'pointer'
  28762. });
  28763. }
  28764. this.scrollOffset = -pages[currentPage - 1] + this.initialItemY;
  28765. this.scrollGroup.animate({
  28766. translateY: this.scrollOffset
  28767. });
  28768. this.currentPage = currentPage;
  28769. this.positionCheckboxes();
  28770. // Fire event after scroll animation is complete
  28771. var animOptions = animObject(pick(animation,
  28772. chart.renderer.globalAnimation,
  28773. true));
  28774. syncTimeout(function () {
  28775. fireEvent(_this, 'afterScroll', { currentPage: currentPage });
  28776. }, animOptions.duration);
  28777. }
  28778. };
  28779. /**
  28780. * @private
  28781. * @function Highcharts.Legend#setItemEvents
  28782. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  28783. * @param {Highcharts.SVGElement} legendItem
  28784. * @param {boolean} [useHTML=false]
  28785. * @fires Highcharts.Point#event:legendItemClick
  28786. * @fires Highcharts.Series#event:legendItemClick
  28787. */
  28788. Legend.prototype.setItemEvents = function (item, legendItem, useHTML) {
  28789. var legend = this,
  28790. boxWrapper = legend.chart.renderer.boxWrapper,
  28791. isPoint = item instanceof Point,
  28792. activeClass = 'highcharts-legend-' +
  28793. (isPoint ? 'point' : 'series') + '-active',
  28794. styledMode = legend.chart.styledMode,
  28795. // When `useHTML`, the symbol is rendered in other group, so
  28796. // we need to apply events listeners to both places
  28797. legendItems = useHTML ?
  28798. [legendItem,
  28799. item.legendSymbol] :
  28800. [item.legendGroup];
  28801. // Set the events on the item group, or in case of useHTML, the item
  28802. // itself (#1249)
  28803. legendItems.forEach(function (element) {
  28804. if (element) {
  28805. element
  28806. .on('mouseover', function () {
  28807. if (item.visible) {
  28808. legend.allItems.forEach(function (inactiveItem) {
  28809. if (item !== inactiveItem) {
  28810. inactiveItem.setState('inactive', !isPoint);
  28811. }
  28812. });
  28813. }
  28814. item.setState('hover');
  28815. // A CSS class to dim or hide other than the hovered
  28816. // series.
  28817. // Works only if hovered series is visible (#10071).
  28818. if (item.visible) {
  28819. boxWrapper.addClass(activeClass);
  28820. }
  28821. if (!styledMode) {
  28822. legendItem.css(legend.options.itemHoverStyle);
  28823. }
  28824. })
  28825. .on('mouseout', function () {
  28826. if (!legend.chart.styledMode) {
  28827. legendItem.css(merge(item.visible ?
  28828. legend.itemStyle :
  28829. legend.itemHiddenStyle));
  28830. }
  28831. legend.allItems.forEach(function (inactiveItem) {
  28832. if (item !== inactiveItem) {
  28833. inactiveItem.setState('', !isPoint);
  28834. }
  28835. });
  28836. // A CSS class to dim or hide other than the hovered
  28837. // series.
  28838. boxWrapper.removeClass(activeClass);
  28839. item.setState();
  28840. })
  28841. .on('click', function (event) {
  28842. var strLegendItemClick = 'legendItemClick',
  28843. fnLegendItemClick = function () {
  28844. if (item.setVisible) {
  28845. item.setVisible();
  28846. }
  28847. // Reset inactive state
  28848. legend.allItems.forEach(function (inactiveItem) {
  28849. if (item !== inactiveItem) {
  28850. inactiveItem.setState(item.visible ? 'inactive' : '', !isPoint);
  28851. }
  28852. });
  28853. };
  28854. // A CSS class to dim or hide other than the hovered
  28855. // series. Event handling in iOS causes the activeClass
  28856. // to be added prior to click in some cases (#7418).
  28857. boxWrapper.removeClass(activeClass);
  28858. // Pass over the click/touch event. #4.
  28859. event = {
  28860. browserEvent: event
  28861. };
  28862. // click the name or symbol
  28863. if (item.firePointEvent) { // point
  28864. item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
  28865. }
  28866. else {
  28867. fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
  28868. }
  28869. });
  28870. }
  28871. });
  28872. };
  28873. /**
  28874. * @private
  28875. * @function Highcharts.Legend#createCheckboxForItem
  28876. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  28877. * @fires Highcharts.Series#event:checkboxClick
  28878. */
  28879. Legend.prototype.createCheckboxForItem = function (item) {
  28880. var legend = this;
  28881. item.checkbox = createElement('input', {
  28882. type: 'checkbox',
  28883. className: 'highcharts-legend-checkbox',
  28884. checked: item.selected,
  28885. defaultChecked: item.selected // required by IE7
  28886. }, legend.options.itemCheckboxStyle, legend.chart.container);
  28887. addEvent(item.checkbox, 'click', function (event) {
  28888. var target = event.target;
  28889. fireEvent(item.series || item, 'checkboxClick', {
  28890. checked: target.checked,
  28891. item: item
  28892. }, function () {
  28893. item.select();
  28894. });
  28895. });
  28896. };
  28897. return Legend;
  28898. }());
  28899. // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
  28900. // and for #2580, a similar drawing flaw in Firefox 26.
  28901. // Explore if there's a general cause for this. The problem may be related
  28902. // to nested group elements, as the legend item texts are within 4 group
  28903. // elements.
  28904. if (/Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
  28905. isFirefox) {
  28906. wrap(Legend.prototype, 'positionItem', function (proceed, item) {
  28907. var legend = this,
  28908. // If chart destroyed in sync, this is undefined (#2030)
  28909. runPositionItem = function () {
  28910. if (item._legendItemPos) {
  28911. proceed.call(legend,
  28912. item);
  28913. }
  28914. };
  28915. // Do it now, for export and to get checkbox placement
  28916. runPositionItem();
  28917. // Do it after to work around the core issue
  28918. if (!legend.bubbleLegend) {
  28919. setTimeout(runPositionItem);
  28920. }
  28921. });
  28922. }
  28923. H.Legend = Legend;
  28924. return H.Legend;
  28925. });
  28926. _registerModule(_modules, 'Core/Series/SeriesRegistry.js', [_modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, O, Point, U) {
  28927. /* *
  28928. *
  28929. * (c) 2010-2021 Torstein Honsi
  28930. *
  28931. * License: www.highcharts.com/license
  28932. *
  28933. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  28934. *
  28935. * */
  28936. var defaultOptions = O.defaultOptions;
  28937. var error = U.error,
  28938. extendClass = U.extendClass,
  28939. merge = U.merge;
  28940. /* *
  28941. *
  28942. * Namespace
  28943. *
  28944. * */
  28945. var SeriesRegistry;
  28946. (function (SeriesRegistry) {
  28947. /* *
  28948. *
  28949. * Static Properties
  28950. *
  28951. * */
  28952. /**
  28953. * @internal
  28954. * @todo Move `Globals.seriesTypes` code to her.
  28955. */
  28956. SeriesRegistry.seriesTypes = H.seriesTypes;
  28957. /* *
  28958. *
  28959. * Static Functions
  28960. *
  28961. * */
  28962. /* eslint-disable valid-jsdoc */
  28963. /**
  28964. * Internal function to initialize an individual series.
  28965. * @private
  28966. */
  28967. function getSeries(chart, options) {
  28968. if (options === void 0) { options = {}; }
  28969. var optionsChart = chart.options.chart,
  28970. type = (options.type ||
  28971. optionsChart.type ||
  28972. optionsChart.defaultSeriesType ||
  28973. ''),
  28974. SeriesClass = SeriesRegistry.seriesTypes[type];
  28975. // No such series type
  28976. if (!SeriesRegistry) {
  28977. error(17, true, chart, { missingModuleFor: type });
  28978. }
  28979. var series = new SeriesClass();
  28980. if (typeof series.init === 'function') {
  28981. series.init(chart, options);
  28982. }
  28983. return series;
  28984. }
  28985. SeriesRegistry.getSeries = getSeries;
  28986. /**
  28987. * Registers class pattern of a series.
  28988. *
  28989. * @private
  28990. */
  28991. function registerSeriesType(seriesType, seriesClass) {
  28992. var defaultPlotOptions = defaultOptions.plotOptions || {},
  28993. seriesOptions = seriesClass.defaultOptions;
  28994. if (!seriesClass.prototype.pointClass) {
  28995. seriesClass.prototype.pointClass = Point;
  28996. }
  28997. seriesClass.prototype.type = seriesType;
  28998. if (seriesOptions) {
  28999. defaultPlotOptions[seriesType] = seriesOptions;
  29000. }
  29001. SeriesRegistry.seriesTypes[seriesType] = seriesClass;
  29002. }
  29003. SeriesRegistry.registerSeriesType = registerSeriesType;
  29004. /**
  29005. * Old factory to create new series prototypes.
  29006. *
  29007. * @deprecated
  29008. * @function Highcharts.seriesType
  29009. *
  29010. * @param {string} type
  29011. * The series type name.
  29012. *
  29013. * @param {string} parent
  29014. * The parent series type name. Use `line` to inherit from the basic
  29015. * {@link Series} object.
  29016. *
  29017. * @param {Highcharts.SeriesOptionsType|Highcharts.Dictionary<*>} options
  29018. * The additional default options that are merged with the parent's options.
  29019. *
  29020. * @param {Highcharts.Dictionary<*>} [props]
  29021. * The properties (functions and primitives) to set on the new prototype.
  29022. *
  29023. * @param {Highcharts.Dictionary<*>} [pointProps]
  29024. * Members for a series-specific extension of the {@link Point} prototype if
  29025. * needed.
  29026. *
  29027. * @return {Highcharts.Series}
  29028. * The newly created prototype as extended from {@link Series} or its
  29029. * derivatives.
  29030. */
  29031. function seriesType(type, parent, options, seriesProto, pointProto) {
  29032. var defaultPlotOptions = defaultOptions.plotOptions || {};
  29033. parent = parent || '';
  29034. // Merge the options
  29035. defaultPlotOptions[type] = merge(defaultPlotOptions[parent], options);
  29036. // Create the class
  29037. registerSeriesType(type, extendClass(SeriesRegistry.seriesTypes[parent] || function () { }, seriesProto));
  29038. SeriesRegistry.seriesTypes[type].prototype.type = type;
  29039. // Create the point class if needed
  29040. if (pointProto) {
  29041. SeriesRegistry.seriesTypes[type].prototype.pointClass =
  29042. extendClass(Point, pointProto);
  29043. }
  29044. return SeriesRegistry.seriesTypes[type];
  29045. }
  29046. SeriesRegistry.seriesType = seriesType;
  29047. /* eslint-enable valid-jsdoc */
  29048. })(SeriesRegistry || (SeriesRegistry = {}));
  29049. /* *
  29050. *
  29051. * Compatibility
  29052. *
  29053. * */
  29054. H.seriesType = SeriesRegistry.seriesType;
  29055. /* *
  29056. *
  29057. * Export
  29058. *
  29059. * */
  29060. return SeriesRegistry;
  29061. });
  29062. _registerModule(_modules, 'Core/Chart/Chart.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/MSPointer.js'], _modules['Core/Options.js'], _modules['Core/Color/Palette.js'], _modules['Core/Pointer.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js'], _modules['Core/Renderer/HTML/AST.js']], function (A, Axis, F, H, Legend, MSPointer, O, palette, Pointer, SeriesRegistry, Time, U, AST) {
  29063. /* *
  29064. *
  29065. * (c) 2010-2021 Torstein Honsi
  29066. *
  29067. * License: www.highcharts.com/license
  29068. *
  29069. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29070. *
  29071. * */
  29072. var animate = A.animate,
  29073. animObject = A.animObject,
  29074. setAnimation = A.setAnimation;
  29075. var numberFormat = F.numberFormat;
  29076. var charts = H.charts,
  29077. doc = H.doc,
  29078. win = H.win;
  29079. var defaultOptions = O.defaultOptions,
  29080. defaultTime = O.defaultTime;
  29081. var seriesTypes = SeriesRegistry.seriesTypes;
  29082. var addEvent = U.addEvent,
  29083. attr = U.attr,
  29084. cleanRecursively = U.cleanRecursively,
  29085. createElement = U.createElement,
  29086. css = U.css,
  29087. defined = U.defined,
  29088. discardElement = U.discardElement,
  29089. erase = U.erase,
  29090. error = U.error,
  29091. extend = U.extend,
  29092. find = U.find,
  29093. fireEvent = U.fireEvent,
  29094. getStyle = U.getStyle,
  29095. isArray = U.isArray,
  29096. isFunction = U.isFunction,
  29097. isNumber = U.isNumber,
  29098. isObject = U.isObject,
  29099. isString = U.isString,
  29100. merge = U.merge,
  29101. objectEach = U.objectEach,
  29102. pick = U.pick,
  29103. pInt = U.pInt,
  29104. relativeLength = U.relativeLength,
  29105. removeEvent = U.removeEvent,
  29106. splat = U.splat,
  29107. syncTimeout = U.syncTimeout,
  29108. uniqueKey = U.uniqueKey;
  29109. var marginNames = H.marginNames;
  29110. /* eslint-disable no-invalid-this, valid-jsdoc */
  29111. /**
  29112. * The Chart class. The recommended constructor is {@link Highcharts#chart}.
  29113. *
  29114. * @example
  29115. * let chart = Highcharts.chart('container', {
  29116. * title: {
  29117. * text: 'My chart'
  29118. * },
  29119. * series: [{
  29120. * data: [1, 3, 2, 4]
  29121. * }]
  29122. * })
  29123. *
  29124. * @class
  29125. * @name Highcharts.Chart
  29126. *
  29127. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  29128. * The DOM element to render to, or its id.
  29129. *
  29130. * @param {Highcharts.Options} options
  29131. * The chart options structure.
  29132. *
  29133. * @param {Highcharts.ChartCallbackFunction} [callback]
  29134. * Function to run when the chart has loaded and and all external images
  29135. * are loaded. Defining a
  29136. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  29137. * handler is equivalent.
  29138. */
  29139. var Chart = /** @class */ (function () {
  29140. function Chart(a, b, c) {
  29141. this.axes = void 0;
  29142. this.axisOffset = void 0;
  29143. this.bounds = void 0;
  29144. this.chartHeight = void 0;
  29145. this.chartWidth = void 0;
  29146. this.clipBox = void 0;
  29147. this.colorCounter = void 0;
  29148. this.container = void 0;
  29149. this.index = void 0;
  29150. this.isResizing = void 0;
  29151. this.labelCollectors = void 0;
  29152. this.legend = void 0;
  29153. this.margin = void 0;
  29154. this.numberFormatter = void 0;
  29155. this.options = void 0;
  29156. this.plotBox = void 0;
  29157. this.plotHeight = void 0;
  29158. this.plotLeft = void 0;
  29159. this.plotTop = void 0;
  29160. this.plotWidth = void 0;
  29161. this.pointCount = void 0;
  29162. this.pointer = void 0;
  29163. this.renderer = void 0;
  29164. this.renderTo = void 0;
  29165. this.series = void 0;
  29166. this.sharedClips = {};
  29167. this.spacing = void 0;
  29168. this.spacingBox = void 0;
  29169. this.symbolCounter = void 0;
  29170. this.time = void 0;
  29171. this.titleOffset = void 0;
  29172. this.userOptions = void 0;
  29173. this.xAxis = void 0;
  29174. this.yAxis = void 0;
  29175. this.getArgs(a, b, c);
  29176. }
  29177. /* *
  29178. *
  29179. * Functions
  29180. *
  29181. * */
  29182. /**
  29183. * Handle the arguments passed to the constructor.
  29184. *
  29185. * @private
  29186. * @function Highcharts.Chart#getArgs
  29187. *
  29188. * @param {...Array<*>} arguments
  29189. * All arguments for the constructor.
  29190. *
  29191. * @fires Highcharts.Chart#event:init
  29192. * @fires Highcharts.Chart#event:afterInit
  29193. */
  29194. Chart.prototype.getArgs = function (a, b, c) {
  29195. // Remove the optional first argument, renderTo, and
  29196. // set it on this.
  29197. if (isString(a) || a.nodeName) {
  29198. this.renderTo = a;
  29199. this.init(b, c);
  29200. }
  29201. else {
  29202. this.init(a, b);
  29203. }
  29204. };
  29205. /**
  29206. * Overridable function that initializes the chart. The constructor's
  29207. * arguments are passed on directly.
  29208. *
  29209. * @function Highcharts.Chart#init
  29210. *
  29211. * @param {Highcharts.Options} userOptions
  29212. * Custom options.
  29213. *
  29214. * @param {Function} [callback]
  29215. * Function to run when the chart has loaded and and all external
  29216. * images are loaded.
  29217. *
  29218. * @return {void}
  29219. *
  29220. * @fires Highcharts.Chart#event:init
  29221. * @fires Highcharts.Chart#event:afterInit
  29222. */
  29223. Chart.prototype.init = function (userOptions, callback) {
  29224. // Handle regular options
  29225. var userPlotOptions = userOptions.plotOptions || {};
  29226. // Fire the event with a default function
  29227. fireEvent(this, 'init', { args: arguments }, function () {
  29228. var options = merge(defaultOptions,
  29229. userOptions); // do the merge
  29230. var optionsChart = options.chart;
  29231. // Override (by copy of user options) or clear tooltip options
  29232. // in chart.options.plotOptions (#6218)
  29233. objectEach(options.plotOptions, function (typeOptions, type) {
  29234. if (isObject(typeOptions)) { // #8766
  29235. typeOptions.tooltip = (userPlotOptions[type] && // override by copy:
  29236. merge(userPlotOptions[type].tooltip)) || void 0; // or clear
  29237. }
  29238. });
  29239. // User options have higher priority than default options
  29240. // (#6218). In case of exporting: path is changed
  29241. options.tooltip.userOptions = (userOptions.chart &&
  29242. userOptions.chart.forExport &&
  29243. userOptions.tooltip.userOptions) || userOptions.tooltip;
  29244. /**
  29245. * The original options given to the constructor or a chart factory
  29246. * like {@link Highcharts.chart} and {@link Highcharts.stockChart}.
  29247. *
  29248. * @name Highcharts.Chart#userOptions
  29249. * @type {Highcharts.Options}
  29250. */
  29251. this.userOptions = userOptions;
  29252. var chartEvents = optionsChart.events;
  29253. this.margin = [];
  29254. this.spacing = [];
  29255. // Pixel data bounds for touch zoom
  29256. this.bounds = { h: {}, v: {} };
  29257. // An array of functions that returns labels that should be
  29258. // considered for anti-collision
  29259. this.labelCollectors = [];
  29260. this.callback = callback;
  29261. this.isResizing = 0;
  29262. /**
  29263. * The options structure for the chart after merging
  29264. * {@link #defaultOptions} and {@link #userOptions}. It contains
  29265. * members for the sub elements like series, legend, tooltip etc.
  29266. *
  29267. * @name Highcharts.Chart#options
  29268. * @type {Highcharts.Options}
  29269. */
  29270. this.options = options;
  29271. /**
  29272. * All the axes in the chart.
  29273. *
  29274. * @see Highcharts.Chart.xAxis
  29275. * @see Highcharts.Chart.yAxis
  29276. *
  29277. * @name Highcharts.Chart#axes
  29278. * @type {Array<Highcharts.Axis>}
  29279. */
  29280. this.axes = [];
  29281. /**
  29282. * All the current series in the chart.
  29283. *
  29284. * @name Highcharts.Chart#series
  29285. * @type {Array<Highcharts.Series>}
  29286. */
  29287. this.series = [];
  29288. /**
  29289. * The `Time` object associated with the chart. Since v6.0.5,
  29290. * time settings can be applied individually for each chart. If
  29291. * no individual settings apply, the `Time` object is shared by
  29292. * all instances.
  29293. *
  29294. * @name Highcharts.Chart#time
  29295. * @type {Highcharts.Time}
  29296. */
  29297. this.time =
  29298. userOptions.time && Object.keys(userOptions.time).length ?
  29299. new Time(userOptions.time) :
  29300. H.time;
  29301. /**
  29302. * Callback function to override the default function that formats
  29303. * all the numbers in the chart. Returns a string with the formatted
  29304. * number.
  29305. *
  29306. * @name Highcharts.Chart#numberFormatter
  29307. * @type {Highcharts.NumberFormatterCallbackFunction}
  29308. */
  29309. this.numberFormatter = optionsChart.numberFormatter || numberFormat;
  29310. /**
  29311. * Whether the chart is in styled mode, meaning all presentatinoal
  29312. * attributes are avoided.
  29313. *
  29314. * @name Highcharts.Chart#styledMode
  29315. * @type {boolean}
  29316. */
  29317. this.styledMode = optionsChart.styledMode;
  29318. this.hasCartesianSeries = optionsChart.showAxes;
  29319. var chart = this;
  29320. /**
  29321. * Index position of the chart in the {@link Highcharts#charts}
  29322. * property.
  29323. *
  29324. * @name Highcharts.Chart#index
  29325. * @type {number}
  29326. * @readonly
  29327. */
  29328. chart.index = charts.length; // Add the chart to the global lookup
  29329. charts.push(chart);
  29330. H.chartCount++;
  29331. // Chart event handlers
  29332. if (chartEvents) {
  29333. objectEach(chartEvents, function (event, eventType) {
  29334. if (isFunction(event)) {
  29335. addEvent(chart, eventType, event);
  29336. }
  29337. });
  29338. }
  29339. /**
  29340. * A collection of the X axes in the chart.
  29341. *
  29342. * @name Highcharts.Chart#xAxis
  29343. * @type {Array<Highcharts.Axis>}
  29344. */
  29345. chart.xAxis = [];
  29346. /**
  29347. * A collection of the Y axes in the chart.
  29348. *
  29349. * @name Highcharts.Chart#yAxis
  29350. * @type {Array<Highcharts.Axis>}
  29351. *
  29352. * @todo
  29353. * Make events official: Fire the event `afterInit`.
  29354. */
  29355. chart.yAxis = [];
  29356. chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
  29357. // Fire after init but before first render, before axes and series
  29358. // have been initialized.
  29359. fireEvent(chart, 'afterInit');
  29360. chart.firstRender();
  29361. });
  29362. };
  29363. /**
  29364. * Internal function to unitialize an individual series.
  29365. *
  29366. * @private
  29367. * @function Highcharts.Chart#initSeries
  29368. */
  29369. Chart.prototype.initSeries = function (options) {
  29370. var chart = this,
  29371. optionsChart = chart.options.chart,
  29372. type = (options.type ||
  29373. optionsChart.type ||
  29374. optionsChart.defaultSeriesType),
  29375. series,
  29376. SeriesClass = seriesTypes[type];
  29377. // No such series type
  29378. if (!SeriesClass) {
  29379. error(17, true, chart, { missingModuleFor: type });
  29380. }
  29381. series = new SeriesClass();
  29382. if (typeof series.init === 'function') {
  29383. series.init(chart, options);
  29384. }
  29385. return series;
  29386. };
  29387. /**
  29388. * Internal function to set data for all series with enabled sorting.
  29389. *
  29390. * @private
  29391. * @function Highcharts.Chart#setSeriesData
  29392. */
  29393. Chart.prototype.setSeriesData = function () {
  29394. this.getSeriesOrderByLinks().forEach(function (series) {
  29395. // We need to set data for series with sorting after series init
  29396. if (!series.points && !series.data && series.enabledDataSorting) {
  29397. series.setData(series.options.data, false);
  29398. }
  29399. });
  29400. };
  29401. /**
  29402. * Sort and return chart series in order depending on the number of linked
  29403. * series.
  29404. *
  29405. * @private
  29406. * @function Highcharts.Series#getSeriesOrderByLinks
  29407. * @return {Array<Highcharts.Series>}
  29408. */
  29409. Chart.prototype.getSeriesOrderByLinks = function () {
  29410. return this.series.concat().sort(function (a, b) {
  29411. if (a.linkedSeries.length || b.linkedSeries.length) {
  29412. return b.linkedSeries.length - a.linkedSeries.length;
  29413. }
  29414. return 0;
  29415. });
  29416. };
  29417. /**
  29418. * Order all series above a given index. When series are added and ordered
  29419. * by configuration, only the last series is handled (#248, #1123, #2456,
  29420. * #6112). This function is called on series initialization and destroy.
  29421. *
  29422. * @private
  29423. * @function Highcharts.Series#orderSeries
  29424. * @param {number} [fromIndex]
  29425. * If this is given, only the series above this index are handled.
  29426. */
  29427. Chart.prototype.orderSeries = function (fromIndex) {
  29428. var series = this.series,
  29429. i = fromIndex || 0;
  29430. for (; i < series.length; i++) {
  29431. if (series[i]) {
  29432. /**
  29433. * Contains the series' index in the `Chart.series` array.
  29434. *
  29435. * @name Highcharts.Series#index
  29436. * @type {number}
  29437. * @readonly
  29438. */
  29439. series[i].index = i;
  29440. series[i].name = series[i].getName();
  29441. }
  29442. }
  29443. };
  29444. /**
  29445. * Check whether a given point is within the plot area.
  29446. *
  29447. * @function Highcharts.Chart#isInsidePlot
  29448. *
  29449. * @param {number} plotX
  29450. * Pixel x relative to the plot area.
  29451. *
  29452. * @param {number} plotY
  29453. * Pixel y relative to the plot area.
  29454. *
  29455. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  29456. * Options object.
  29457. *
  29458. * @return {boolean}
  29459. * Returns true if the given point is inside the plot area.
  29460. */
  29461. Chart.prototype.isInsidePlot = function (plotX, plotY, options) {
  29462. if (options === void 0) { options = {}; }
  29463. var _a = this,
  29464. inverted = _a.inverted,
  29465. plotBox = _a.plotBox,
  29466. plotLeft = _a.plotLeft,
  29467. plotTop = _a.plotTop,
  29468. scrollablePlotBox = _a.scrollablePlotBox,
  29469. _b = _a.scrollingContainer,
  29470. _c = _b === void 0 ? {
  29471. scrollLeft: 0,
  29472. scrollTop: 0
  29473. } : _b,
  29474. scrollLeft = _c.scrollLeft,
  29475. scrollTop = _c.scrollTop;
  29476. var series = options.series;
  29477. var box = (options.visiblePlotOnly && scrollablePlotBox) || plotBox;
  29478. var x = options.inverted ? plotY : plotX;
  29479. var y = options.inverted ? plotX : plotY;
  29480. var e = {
  29481. x: x,
  29482. y: y,
  29483. isInsidePlot: true
  29484. };
  29485. if (!options.ignoreX) {
  29486. var xAxis = (series && (inverted ? series.yAxis : series.xAxis)) || {
  29487. pos: plotLeft,
  29488. len: Infinity
  29489. };
  29490. var chartX = options.paneCoordinates ? xAxis.pos + x : plotLeft + x;
  29491. if (!(chartX >= Math.max(scrollLeft + plotLeft, xAxis.pos) &&
  29492. chartX <= Math.min(scrollLeft + plotLeft + box.width, xAxis.pos + xAxis.len))) {
  29493. e.isInsidePlot = false;
  29494. }
  29495. }
  29496. if (!options.ignoreY && e.isInsidePlot) {
  29497. var yAxis = (series && (inverted ? series.xAxis : series.yAxis)) || {
  29498. pos: plotTop,
  29499. len: Infinity
  29500. };
  29501. var chartY = options.paneCoordinates ? yAxis.pos + y : plotTop + y;
  29502. if (!(chartY >= Math.max(scrollTop + plotTop, yAxis.pos) &&
  29503. chartY <= Math.min(scrollTop + plotTop + box.height, yAxis.pos + yAxis.len))) {
  29504. e.isInsidePlot = false;
  29505. }
  29506. }
  29507. fireEvent(this, 'afterIsInsidePlot', e);
  29508. return e.isInsidePlot;
  29509. };
  29510. /**
  29511. * Redraw the chart after changes have been done to the data, axis extremes
  29512. * chart size or chart elements. All methods for updating axes, series or
  29513. * points have a parameter for redrawing the chart. This is `true` by
  29514. * default. But in many cases you want to do more than one operation on the
  29515. * chart before redrawing, for example add a number of points. In those
  29516. * cases it is a waste of resources to redraw the chart for each new point
  29517. * added. So you add the points and call `chart.redraw()` after.
  29518. *
  29519. * @function Highcharts.Chart#redraw
  29520. *
  29521. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  29522. * If or how to apply animation to the redraw.
  29523. *
  29524. * @fires Highcharts.Chart#event:afterSetExtremes
  29525. * @fires Highcharts.Chart#event:beforeRedraw
  29526. * @fires Highcharts.Chart#event:predraw
  29527. * @fires Highcharts.Chart#event:redraw
  29528. * @fires Highcharts.Chart#event:render
  29529. * @fires Highcharts.Chart#event:updatedData
  29530. */
  29531. Chart.prototype.redraw = function (animation) {
  29532. fireEvent(this, 'beforeRedraw');
  29533. var chart = this,
  29534. axes = chart.hasCartesianSeries ? chart.axes : chart.colorAxis || [],
  29535. series = chart.series,
  29536. pointer = chart.pointer,
  29537. legend = chart.legend,
  29538. legendUserOptions = chart.userOptions.legend,
  29539. redrawLegend = chart.isDirtyLegend,
  29540. hasStackedSeries,
  29541. hasDirtyStacks,
  29542. isDirtyBox = chart.isDirtyBox,
  29543. i,
  29544. serie,
  29545. renderer = chart.renderer,
  29546. isHiddenChart = renderer.isHidden(),
  29547. afterRedraw = [];
  29548. // Handle responsive rules, not only on resize (#6130)
  29549. if (chart.setResponsive) {
  29550. chart.setResponsive(false);
  29551. }
  29552. // Set the global animation. When chart.hasRendered is not true, the
  29553. // redraw call comes from a responsive rule and animation should not
  29554. // occur.
  29555. setAnimation(chart.hasRendered ? animation : false, chart);
  29556. if (isHiddenChart) {
  29557. chart.temporaryDisplay();
  29558. }
  29559. // Adjust title layout (reflow multiline text)
  29560. chart.layOutTitles();
  29561. // link stacked series
  29562. i = series.length;
  29563. while (i--) {
  29564. serie = series[i];
  29565. if (serie.options.stacking || serie.options.centerInCategory) {
  29566. hasStackedSeries = true;
  29567. if (serie.isDirty) {
  29568. hasDirtyStacks = true;
  29569. break;
  29570. }
  29571. }
  29572. }
  29573. if (hasDirtyStacks) { // mark others as dirty
  29574. i = series.length;
  29575. while (i--) {
  29576. serie = series[i];
  29577. if (serie.options.stacking) {
  29578. serie.isDirty = true;
  29579. }
  29580. }
  29581. }
  29582. // Handle updated data in the series
  29583. series.forEach(function (serie) {
  29584. if (serie.isDirty) {
  29585. if (serie.options.legendType === 'point') {
  29586. if (typeof serie.updateTotals === 'function') {
  29587. serie.updateTotals();
  29588. }
  29589. redrawLegend = true;
  29590. }
  29591. else if (legendUserOptions &&
  29592. (legendUserOptions.labelFormatter ||
  29593. legendUserOptions.labelFormat)) {
  29594. redrawLegend = true; // #2165
  29595. }
  29596. }
  29597. if (serie.isDirtyData) {
  29598. fireEvent(serie, 'updatedData');
  29599. }
  29600. });
  29601. // handle added or removed series
  29602. if (redrawLegend && legend && legend.options.enabled) {
  29603. // draw legend graphics
  29604. legend.render();
  29605. chart.isDirtyLegend = false;
  29606. }
  29607. // reset stacks
  29608. if (hasStackedSeries) {
  29609. chart.getStacks();
  29610. }
  29611. // set axes scales
  29612. axes.forEach(function (axis) {
  29613. axis.updateNames();
  29614. axis.setScale();
  29615. });
  29616. chart.getMargins(); // #3098
  29617. // If one axis is dirty, all axes must be redrawn (#792, #2169)
  29618. axes.forEach(function (axis) {
  29619. if (axis.isDirty) {
  29620. isDirtyBox = true;
  29621. }
  29622. });
  29623. // redraw axes
  29624. axes.forEach(function (axis) {
  29625. // Fire 'afterSetExtremes' only if extremes are set
  29626. var key = axis.min + ',' + axis.max;
  29627. if (axis.extKey !== key) { // #821, #4452
  29628. axis.extKey = key;
  29629. // prevent a recursive call to chart.redraw() (#1119)
  29630. afterRedraw.push(function () {
  29631. fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
  29632. delete axis.eventArgs;
  29633. });
  29634. }
  29635. if (isDirtyBox || hasStackedSeries) {
  29636. axis.redraw();
  29637. }
  29638. });
  29639. // the plot areas size has changed
  29640. if (isDirtyBox) {
  29641. chart.drawChartBox();
  29642. }
  29643. // Fire an event before redrawing series, used by the boost module to
  29644. // clear previous series renderings.
  29645. fireEvent(chart, 'predraw');
  29646. // redraw affected series
  29647. series.forEach(function (serie) {
  29648. if ((isDirtyBox || serie.isDirty) && serie.visible) {
  29649. serie.redraw();
  29650. }
  29651. // Set it here, otherwise we will have unlimited 'updatedData' calls
  29652. // for a hidden series after setData(). Fixes #6012
  29653. serie.isDirtyData = false;
  29654. });
  29655. // move tooltip or reset
  29656. if (pointer) {
  29657. pointer.reset(true);
  29658. }
  29659. // redraw if canvas
  29660. renderer.draw();
  29661. // Fire the events
  29662. fireEvent(chart, 'redraw');
  29663. fireEvent(chart, 'render');
  29664. if (isHiddenChart) {
  29665. chart.temporaryDisplay(true);
  29666. }
  29667. // Fire callbacks that are put on hold until after the redraw
  29668. afterRedraw.forEach(function (callback) {
  29669. callback.call();
  29670. });
  29671. };
  29672. /**
  29673. * Get an axis, series or point object by `id` as given in the configuration
  29674. * options. Returns `undefined` if no item is found.
  29675. *
  29676. * @sample highcharts/plotoptions/series-id/
  29677. * Get series by id
  29678. *
  29679. * @function Highcharts.Chart#get
  29680. *
  29681. * @param {string} id
  29682. * The id as given in the configuration options.
  29683. *
  29684. * @return {Highcharts.Axis|Highcharts.Series|Highcharts.Point|undefined}
  29685. * The retrieved item.
  29686. */
  29687. Chart.prototype.get = function (id) {
  29688. var ret,
  29689. series = this.series,
  29690. i;
  29691. /**
  29692. * @private
  29693. * @param {Highcharts.Axis|Highcharts.Series} item
  29694. * @return {boolean}
  29695. */
  29696. function itemById(item) {
  29697. return (item.id === id ||
  29698. (item.options && item.options.id === id));
  29699. }
  29700. ret =
  29701. // Search axes
  29702. find(this.axes, itemById) ||
  29703. // Search series
  29704. find(this.series, itemById);
  29705. // Search points
  29706. for (i = 0; !ret && i < series.length; i++) {
  29707. ret = find(series[i].points || [], itemById);
  29708. }
  29709. return ret;
  29710. };
  29711. /**
  29712. * Create the Axis instances based on the config options.
  29713. *
  29714. * @private
  29715. * @function Highcharts.Chart#getAxes
  29716. * @fires Highcharts.Chart#event:afterGetAxes
  29717. * @fires Highcharts.Chart#event:getAxes
  29718. */
  29719. Chart.prototype.getAxes = function () {
  29720. var chart = this,
  29721. options = this.options,
  29722. xAxisOptions = options.xAxis = splat(options.xAxis || {}),
  29723. yAxisOptions = options.yAxis = splat(options.yAxis || {}),
  29724. optionsArray;
  29725. fireEvent(this, 'getAxes');
  29726. // make sure the options are arrays and add some members
  29727. xAxisOptions.forEach(function (axis, i) {
  29728. axis.index = i;
  29729. axis.isX = true;
  29730. });
  29731. yAxisOptions.forEach(function (axis, i) {
  29732. axis.index = i;
  29733. });
  29734. // concatenate all axis options into one array
  29735. optionsArray = xAxisOptions.concat(yAxisOptions);
  29736. optionsArray.forEach(function (axisOptions) {
  29737. new Axis(chart, axisOptions); // eslint-disable-line no-new
  29738. });
  29739. fireEvent(this, 'afterGetAxes');
  29740. };
  29741. /**
  29742. * Returns an array of all currently selected points in the chart. Points
  29743. * can be selected by clicking or programmatically by the
  29744. * {@link Highcharts.Point#select}
  29745. * function.
  29746. *
  29747. * @sample highcharts/plotoptions/series-allowpointselect-line/
  29748. * Get selected points
  29749. *
  29750. * @function Highcharts.Chart#getSelectedPoints
  29751. *
  29752. * @return {Array<Highcharts.Point>}
  29753. * The currently selected points.
  29754. */
  29755. Chart.prototype.getSelectedPoints = function () {
  29756. var points = [];
  29757. this.series.forEach(function (serie) {
  29758. // For one-to-one points inspect series.data in order to retrieve
  29759. // points outside the visible range (#6445). For grouped data,
  29760. // inspect the generated series.points.
  29761. points = points.concat(serie.getPointsCollection().filter(function (point) {
  29762. return pick(point.selectedStaging, point.selected);
  29763. }));
  29764. });
  29765. return points;
  29766. };
  29767. /**
  29768. * Returns an array of all currently selected series in the chart. Series
  29769. * can be selected either programmatically by the
  29770. * {@link Highcharts.Series#select}
  29771. * function or by checking the checkbox next to the legend item if
  29772. * [series.showCheckBox](https://api.highcharts.com/highcharts/plotOptions.series.showCheckbox)
  29773. * is true.
  29774. *
  29775. * @sample highcharts/members/chart-getselectedseries/
  29776. * Get selected series
  29777. *
  29778. * @function Highcharts.Chart#getSelectedSeries
  29779. *
  29780. * @return {Array<Highcharts.Series>}
  29781. * The currently selected series.
  29782. */
  29783. Chart.prototype.getSelectedSeries = function () {
  29784. return this.series.filter(function (serie) {
  29785. return serie.selected;
  29786. });
  29787. };
  29788. /**
  29789. * Set a new title or subtitle for the chart.
  29790. *
  29791. * @sample highcharts/members/chart-settitle/
  29792. * Set title text and styles
  29793. *
  29794. * @function Highcharts.Chart#setTitle
  29795. *
  29796. * @param {Highcharts.TitleOptions} [titleOptions]
  29797. * New title options. The title text itself is set by the
  29798. * `titleOptions.text` property.
  29799. *
  29800. * @param {Highcharts.SubtitleOptions} [subtitleOptions]
  29801. * New subtitle options. The subtitle text itself is set by the
  29802. * `subtitleOptions.text` property.
  29803. *
  29804. * @param {boolean} [redraw]
  29805. * Whether to redraw the chart or wait for a later call to
  29806. * `chart.redraw()`.
  29807. */
  29808. Chart.prototype.setTitle = function (titleOptions, subtitleOptions, redraw) {
  29809. this.applyDescription('title', titleOptions);
  29810. this.applyDescription('subtitle', subtitleOptions);
  29811. // The initial call also adds the caption. On update, chart.update will
  29812. // relay to Chart.setCaption.
  29813. this.applyDescription('caption', void 0);
  29814. this.layOutTitles(redraw);
  29815. };
  29816. /**
  29817. * Apply a title, subtitle or caption for the chart
  29818. *
  29819. * @private
  29820. * @function Highcharts.Chart#applyDescription
  29821. * @param name {string}
  29822. * Either title, subtitle or caption
  29823. * @param {Highcharts.TitleOptions|Highcharts.SubtitleOptions|Highcharts.CaptionOptions|undefined} explicitOptions
  29824. * The options to set, will be merged with default options.
  29825. */
  29826. Chart.prototype.applyDescription = function (name, explicitOptions) {
  29827. var chart = this;
  29828. // Default style
  29829. var style = name === 'title' ? {
  29830. color: palette.neutralColor80,
  29831. fontSize: this.options.isStock ? '16px' : '18px' // #2944
  29832. } : {
  29833. color: palette.neutralColor60
  29834. };
  29835. // Merge default options with explicit options
  29836. var options = this.options[name] = merge(
  29837. // Default styles
  29838. (!this.styledMode && { style: style }),
  29839. this.options[name],
  29840. explicitOptions);
  29841. var elem = this[name];
  29842. if (elem && explicitOptions) {
  29843. this[name] = elem = elem.destroy(); // remove old
  29844. }
  29845. if (options && !elem) {
  29846. elem = this.renderer.text(options.text, 0, 0, options.useHTML)
  29847. .attr({
  29848. align: options.align,
  29849. 'class': 'highcharts-' + name,
  29850. zIndex: options.zIndex || 4
  29851. })
  29852. .add();
  29853. // Update methods, shortcut to Chart.setTitle, Chart.setSubtitle and
  29854. // Chart.setCaption
  29855. elem.update = function (updateOptions) {
  29856. var fn = {
  29857. title: 'setTitle',
  29858. subtitle: 'setSubtitle',
  29859. caption: 'setCaption'
  29860. }[name];
  29861. chart[fn](updateOptions);
  29862. };
  29863. // Presentational
  29864. if (!this.styledMode) {
  29865. elem.css(options.style);
  29866. }
  29867. /**
  29868. * The chart title. The title has an `update` method that allows
  29869. * modifying the options directly or indirectly via
  29870. * `chart.update`.
  29871. *
  29872. * @sample highcharts/members/title-update/
  29873. * Updating titles
  29874. *
  29875. * @name Highcharts.Chart#title
  29876. * @type {Highcharts.TitleObject}
  29877. */
  29878. /**
  29879. * The chart subtitle. The subtitle has an `update` method that
  29880. * allows modifying the options directly or indirectly via
  29881. * `chart.update`.
  29882. *
  29883. * @name Highcharts.Chart#subtitle
  29884. * @type {Highcharts.SubtitleObject}
  29885. */
  29886. this[name] = elem;
  29887. }
  29888. };
  29889. /**
  29890. * Internal function to lay out the chart title, subtitle and caption, and
  29891. * cache the full offset height for use in `getMargins`. The result is
  29892. * stored in `this.titleOffset`.
  29893. *
  29894. * @private
  29895. * @function Highcharts.Chart#layOutTitles
  29896. *
  29897. * @param {boolean} [redraw=true]
  29898. * @fires Highcharts.Chart#event:afterLayOutTitles
  29899. */
  29900. Chart.prototype.layOutTitles = function (redraw) {
  29901. var titleOffset = [0, 0, 0],
  29902. requiresDirtyBox,
  29903. renderer = this.renderer,
  29904. spacingBox = this.spacingBox;
  29905. // Lay out the title and the subtitle respectively
  29906. ['title', 'subtitle', 'caption'].forEach(function (key) {
  29907. var title = this[key], titleOptions = this.options[key], verticalAlign = titleOptions.verticalAlign || 'top', offset = key === 'title' ? -3 :
  29908. // Floating subtitle (#6574)
  29909. verticalAlign === 'top' ? titleOffset[0] + 2 : 0, titleSize, height;
  29910. if (title) {
  29911. if (!this.styledMode) {
  29912. titleSize = titleOptions.style.fontSize;
  29913. }
  29914. titleSize = renderer.fontMetrics(titleSize, title).b;
  29915. title
  29916. .css({
  29917. width: (titleOptions.width ||
  29918. spacingBox.width + (titleOptions.widthAdjust || 0)) + 'px'
  29919. });
  29920. // Skip the cache for HTML (#3481, #11666)
  29921. height = Math.round(title.getBBox(titleOptions.useHTML).height);
  29922. title.align(extend({
  29923. y: verticalAlign === 'bottom' ?
  29924. titleSize :
  29925. offset + titleSize,
  29926. height: height
  29927. }, titleOptions), false, 'spacingBox');
  29928. if (!titleOptions.floating) {
  29929. if (verticalAlign === 'top') {
  29930. titleOffset[0] = Math.ceil(titleOffset[0] +
  29931. height);
  29932. }
  29933. else if (verticalAlign === 'bottom') {
  29934. titleOffset[2] = Math.ceil(titleOffset[2] +
  29935. height);
  29936. }
  29937. }
  29938. }
  29939. }, this);
  29940. // Handle title.margin and caption.margin
  29941. if (titleOffset[0] &&
  29942. (this.options.title.verticalAlign || 'top') === 'top') {
  29943. titleOffset[0] += this.options.title.margin;
  29944. }
  29945. if (titleOffset[2] &&
  29946. this.options.caption.verticalAlign === 'bottom') {
  29947. titleOffset[2] += this.options.caption.margin;
  29948. }
  29949. requiresDirtyBox = (!this.titleOffset ||
  29950. this.titleOffset.join(',') !== titleOffset.join(','));
  29951. // Used in getMargins
  29952. this.titleOffset = titleOffset;
  29953. fireEvent(this, 'afterLayOutTitles');
  29954. if (!this.isDirtyBox && requiresDirtyBox) {
  29955. this.isDirtyBox = this.isDirtyLegend = requiresDirtyBox;
  29956. // Redraw if necessary (#2719, #2744)
  29957. if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
  29958. this.redraw();
  29959. }
  29960. }
  29961. };
  29962. /**
  29963. * Internal function to get the chart width and height according to options
  29964. * and container size. Sets {@link Chart.chartWidth} and
  29965. * {@link Chart.chartHeight}.
  29966. *
  29967. * @private
  29968. * @function Highcharts.Chart#getChartSize
  29969. */
  29970. Chart.prototype.getChartSize = function () {
  29971. var chart = this,
  29972. optionsChart = chart.options.chart,
  29973. widthOption = optionsChart.width,
  29974. heightOption = optionsChart.height,
  29975. renderTo = chart.renderTo;
  29976. // Get inner width and height
  29977. if (!defined(widthOption)) {
  29978. chart.containerWidth = getStyle(renderTo, 'width');
  29979. }
  29980. if (!defined(heightOption)) {
  29981. chart.containerHeight = getStyle(renderTo, 'height');
  29982. }
  29983. /**
  29984. * The current pixel width of the chart.
  29985. *
  29986. * @name Highcharts.Chart#chartWidth
  29987. * @type {number}
  29988. */
  29989. chart.chartWidth = Math.max(// #1393
  29990. 0, widthOption || chart.containerWidth || 600 // #1460
  29991. );
  29992. /**
  29993. * The current pixel height of the chart.
  29994. *
  29995. * @name Highcharts.Chart#chartHeight
  29996. * @type {number}
  29997. */
  29998. chart.chartHeight = Math.max(0, relativeLength(heightOption, chart.chartWidth) ||
  29999. (chart.containerHeight > 1 ?
  30000. chart.containerHeight :
  30001. 400));
  30002. };
  30003. /**
  30004. * If the renderTo element has no offsetWidth, most likely one or more of
  30005. * its parents are hidden. Loop up the DOM tree to temporarily display the
  30006. * parents, then save the original display properties, and when the true
  30007. * size is retrieved, reset them. Used on first render and on redraws.
  30008. *
  30009. * @private
  30010. * @function Highcharts.Chart#temporaryDisplay
  30011. *
  30012. * @param {boolean} [revert]
  30013. * Revert to the saved original styles.
  30014. */
  30015. Chart.prototype.temporaryDisplay = function (revert) {
  30016. var node = this.renderTo,
  30017. tempStyle;
  30018. if (!revert) {
  30019. while (node && node.style) {
  30020. // When rendering to a detached node, it needs to be temporarily
  30021. // attached in order to read styling and bounding boxes (#5783,
  30022. // #7024).
  30023. if (!doc.body.contains(node) && !node.parentNode) {
  30024. node.hcOrigDetached = true;
  30025. doc.body.appendChild(node);
  30026. }
  30027. if (getStyle(node, 'display', false) === 'none' ||
  30028. node.hcOricDetached) {
  30029. node.hcOrigStyle = {
  30030. display: node.style.display,
  30031. height: node.style.height,
  30032. overflow: node.style.overflow
  30033. };
  30034. tempStyle = {
  30035. display: 'block',
  30036. overflow: 'hidden'
  30037. };
  30038. if (node !== this.renderTo) {
  30039. tempStyle.height = 0;
  30040. }
  30041. css(node, tempStyle);
  30042. // If it still doesn't have an offset width after setting
  30043. // display to block, it probably has an !important priority
  30044. // #2631, 6803
  30045. if (!node.offsetWidth) {
  30046. node.style.setProperty('display', 'block', 'important');
  30047. }
  30048. }
  30049. node = node.parentNode;
  30050. if (node === doc.body) {
  30051. break;
  30052. }
  30053. }
  30054. }
  30055. else {
  30056. while (node && node.style) {
  30057. if (node.hcOrigStyle) {
  30058. css(node, node.hcOrigStyle);
  30059. delete node.hcOrigStyle;
  30060. }
  30061. if (node.hcOrigDetached) {
  30062. doc.body.removeChild(node);
  30063. node.hcOrigDetached = false;
  30064. }
  30065. node = node.parentNode;
  30066. }
  30067. }
  30068. };
  30069. /**
  30070. * Set the {@link Chart.container|chart container's} class name, in
  30071. * addition to `highcharts-container`.
  30072. *
  30073. * @function Highcharts.Chart#setClassName
  30074. *
  30075. * @param {string} [className]
  30076. * The additional class name.
  30077. */
  30078. Chart.prototype.setClassName = function (className) {
  30079. this.container.className = 'highcharts-container ' + (className || '');
  30080. };
  30081. /**
  30082. * Get the containing element, determine the size and create the inner
  30083. * container div to hold the chart.
  30084. *
  30085. * @private
  30086. * @function Highcharts.Chart#afterGetContainer
  30087. * @fires Highcharts.Chart#event:afterGetContainer
  30088. */
  30089. Chart.prototype.getContainer = function () {
  30090. var chart = this,
  30091. container,
  30092. options = chart.options,
  30093. optionsChart = options.chart,
  30094. chartWidth,
  30095. chartHeight,
  30096. renderTo = chart.renderTo,
  30097. indexAttrName = 'data-highcharts-chart',
  30098. oldChartIndex,
  30099. Ren,
  30100. containerId = uniqueKey(),
  30101. containerStyle,
  30102. key;
  30103. if (!renderTo) {
  30104. chart.renderTo = renderTo =
  30105. optionsChart.renderTo;
  30106. }
  30107. if (isString(renderTo)) {
  30108. chart.renderTo = renderTo =
  30109. doc.getElementById(renderTo);
  30110. }
  30111. // Display an error if the renderTo is wrong
  30112. if (!renderTo) {
  30113. error(13, true, chart);
  30114. }
  30115. // If the container already holds a chart, destroy it. The check for
  30116. // hasRendered is there because web pages that are saved to disk from
  30117. // the browser, will preserve the data-highcharts-chart attribute and
  30118. // the SVG contents, but not an interactive chart. So in this case,
  30119. // charts[oldChartIndex] will point to the wrong chart if any (#2609).
  30120. oldChartIndex = pInt(attr(renderTo, indexAttrName));
  30121. if (isNumber(oldChartIndex) &&
  30122. charts[oldChartIndex] &&
  30123. charts[oldChartIndex].hasRendered) {
  30124. charts[oldChartIndex].destroy();
  30125. }
  30126. // Make a reference to the chart from the div
  30127. attr(renderTo, indexAttrName, chart.index);
  30128. // remove previous chart
  30129. renderTo.innerHTML = '';
  30130. // If the container doesn't have an offsetWidth, it has or is a child of
  30131. // a node that has display:none. We need to temporarily move it out to a
  30132. // visible state to determine the size, else the legend and tooltips
  30133. // won't render properly. The skipClone option is used in sparklines as
  30134. // a micro optimization, saving about 1-2 ms each chart.
  30135. if (!optionsChart.skipClone && !renderTo.offsetWidth) {
  30136. chart.temporaryDisplay();
  30137. }
  30138. // get the width and height
  30139. chart.getChartSize();
  30140. chartWidth = chart.chartWidth;
  30141. chartHeight = chart.chartHeight;
  30142. // Allow table cells and flex-boxes to shrink without the chart blocking
  30143. // them out (#6427)
  30144. css(renderTo, { overflow: 'hidden' });
  30145. // Create the inner container
  30146. if (!chart.styledMode) {
  30147. containerStyle = extend({
  30148. position: 'relative',
  30149. // needed for context menu (avoidscrollbars) and content
  30150. // overflow in IE
  30151. overflow: 'hidden',
  30152. width: chartWidth + 'px',
  30153. height: chartHeight + 'px',
  30154. textAlign: 'left',
  30155. lineHeight: 'normal',
  30156. zIndex: 0,
  30157. '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
  30158. userSelect: 'none',
  30159. 'touch-action': 'manipulation',
  30160. outline: 'none'
  30161. }, optionsChart.style || {});
  30162. }
  30163. /**
  30164. * The containing HTML element of the chart. The container is
  30165. * dynamically inserted into the element given as the `renderTo`
  30166. * parameter in the {@link Highcharts#chart} constructor.
  30167. *
  30168. * @name Highcharts.Chart#container
  30169. * @type {Highcharts.HTMLDOMElement}
  30170. */
  30171. container = createElement('div', {
  30172. id: containerId
  30173. }, containerStyle, renderTo);
  30174. chart.container = container;
  30175. // cache the cursor (#1650)
  30176. chart._cursor = container.style.cursor;
  30177. // Initialize the renderer
  30178. Ren = H[optionsChart.renderer] || H.Renderer;
  30179. /**
  30180. * The renderer instance of the chart. Each chart instance has only one
  30181. * associated renderer.
  30182. *
  30183. * @name Highcharts.Chart#renderer
  30184. * @type {Highcharts.SVGRenderer}
  30185. */
  30186. chart.renderer = new Ren(container, chartWidth, chartHeight, null, optionsChart.forExport, options.exporting && options.exporting.allowHTML, chart.styledMode);
  30187. // Set the initial animation from the options
  30188. setAnimation(void 0, chart);
  30189. chart.setClassName(optionsChart.className);
  30190. if (!chart.styledMode) {
  30191. chart.renderer.setStyle(optionsChart.style);
  30192. }
  30193. else {
  30194. // Initialize definitions
  30195. for (key in options.defs) { // eslint-disable-line guard-for-in
  30196. this.renderer.definition(options.defs[key]);
  30197. }
  30198. }
  30199. // Add a reference to the charts index
  30200. chart.renderer.chartIndex = chart.index;
  30201. fireEvent(this, 'afterGetContainer');
  30202. };
  30203. /**
  30204. * Calculate margins by rendering axis labels in a preliminary position.
  30205. * Title, subtitle and legend have already been rendered at this stage, but
  30206. * will be moved into their final positions.
  30207. *
  30208. * @private
  30209. * @function Highcharts.Chart#getMargins
  30210. * @fires Highcharts.Chart#event:getMargins
  30211. */
  30212. Chart.prototype.getMargins = function (skipAxes) {
  30213. var _a = this,
  30214. spacing = _a.spacing,
  30215. margin = _a.margin,
  30216. titleOffset = _a.titleOffset;
  30217. this.resetMargins();
  30218. // Adjust for title and subtitle
  30219. if (titleOffset[0] && !defined(margin[0])) {
  30220. this.plotTop = Math.max(this.plotTop, titleOffset[0] + spacing[0]);
  30221. }
  30222. if (titleOffset[2] && !defined(margin[2])) {
  30223. this.marginBottom = Math.max(this.marginBottom, titleOffset[2] + spacing[2]);
  30224. }
  30225. // Adjust for legend
  30226. if (this.legend && this.legend.display) {
  30227. this.legend.adjustMargins(margin, spacing);
  30228. }
  30229. fireEvent(this, 'getMargins');
  30230. if (!skipAxes) {
  30231. this.getAxisMargins();
  30232. }
  30233. };
  30234. /**
  30235. * @private
  30236. * @function Highcharts.Chart#getAxisMargins
  30237. */
  30238. Chart.prototype.getAxisMargins = function () {
  30239. var chart = this,
  30240. // [top, right, bottom, left]
  30241. axisOffset = chart.axisOffset = [0, 0, 0, 0],
  30242. colorAxis = chart.colorAxis,
  30243. margin = chart.margin,
  30244. getOffset = function (axes) {
  30245. axes.forEach(function (axis) {
  30246. if (axis.visible) {
  30247. axis.getOffset();
  30248. }
  30249. });
  30250. };
  30251. // pre-render axes to get labels offset width
  30252. if (chart.hasCartesianSeries) {
  30253. getOffset(chart.axes);
  30254. }
  30255. else if (colorAxis && colorAxis.length) {
  30256. getOffset(colorAxis);
  30257. }
  30258. // Add the axis offsets
  30259. marginNames.forEach(function (m, side) {
  30260. if (!defined(margin[side])) {
  30261. chart[m] += axisOffset[side];
  30262. }
  30263. });
  30264. chart.setChartSize();
  30265. };
  30266. /**
  30267. * Reflows the chart to its container. By default, the chart reflows
  30268. * automatically to its container following a `window.resize` event, as per
  30269. * the [chart.reflow](https://api.highcharts.com/highcharts/chart.reflow)
  30270. * option. However, there are no reliable events for div resize, so if the
  30271. * container is resized without a window resize event, this must be called
  30272. * explicitly.
  30273. *
  30274. * @sample highcharts/members/chart-reflow/
  30275. * Resize div and reflow
  30276. * @sample highcharts/chart/events-container/
  30277. * Pop up and reflow
  30278. *
  30279. * @function Highcharts.Chart#reflow
  30280. *
  30281. * @param {global.Event} [e]
  30282. * Event arguments. Used primarily when the function is called
  30283. * internally as a response to window resize.
  30284. */
  30285. Chart.prototype.reflow = function (e) {
  30286. var chart = this, optionsChart = chart.options.chart, renderTo = chart.renderTo, hasUserSize = (defined(optionsChart.width) &&
  30287. defined(optionsChart.height)), width = optionsChart.width || getStyle(renderTo, 'width'), height = optionsChart.height || getStyle(renderTo, 'height'), target = e ? e.target : win;
  30288. delete chart.pointer.chartPosition;
  30289. // Width and height checks for display:none. Target is doc in IE8 and
  30290. // Opera, win in Firefox, Chrome and IE9.
  30291. if (!hasUserSize &&
  30292. !chart.isPrinting &&
  30293. width &&
  30294. height &&
  30295. (target === win || target === doc)) {
  30296. if (width !== chart.containerWidth ||
  30297. height !== chart.containerHeight) {
  30298. U.clearTimeout(chart.reflowTimeout);
  30299. // When called from window.resize, e is set, else it's called
  30300. // directly (#2224)
  30301. chart.reflowTimeout = syncTimeout(function () {
  30302. // Set size, it may have been destroyed in the meantime
  30303. // (#1257)
  30304. if (chart.container) {
  30305. chart.setSize(void 0, void 0, false);
  30306. }
  30307. }, e ? 100 : 0);
  30308. }
  30309. chart.containerWidth = width;
  30310. chart.containerHeight = height;
  30311. }
  30312. };
  30313. /**
  30314. * Toggle the event handlers necessary for auto resizing, depending on the
  30315. * `chart.reflow` option.
  30316. *
  30317. * @private
  30318. * @function Highcharts.Chart#setReflow
  30319. */
  30320. Chart.prototype.setReflow = function (reflow) {
  30321. var chart = this;
  30322. if (reflow !== false && !this.unbindReflow) {
  30323. this.unbindReflow = addEvent(win, 'resize', function (e) {
  30324. // a removed event listener still runs in Edge and IE if the
  30325. // listener was removed while the event runs, so check if the
  30326. // chart is not destroyed (#11609)
  30327. if (chart.options) {
  30328. chart.reflow(e);
  30329. }
  30330. });
  30331. addEvent(this, 'destroy', this.unbindReflow);
  30332. }
  30333. else if (reflow === false && this.unbindReflow) {
  30334. // Unbind and unset
  30335. this.unbindReflow = this.unbindReflow();
  30336. }
  30337. // The following will add listeners to re-fit the chart before and after
  30338. // printing (#2284). However it only works in WebKit. Should have worked
  30339. // in Firefox, but not supported in IE.
  30340. /*
  30341. if (win.matchMedia) {
  30342. win.matchMedia('print').addListener(function reflow() {
  30343. chart.reflow();
  30344. });
  30345. }
  30346. //*/
  30347. };
  30348. /**
  30349. * Resize the chart to a given width and height. In order to set the width
  30350. * only, the height argument may be skipped. To set the height only, pass
  30351. * `undefined` for the width.
  30352. *
  30353. * @sample highcharts/members/chart-setsize-button/
  30354. * Test resizing from buttons
  30355. * @sample highcharts/members/chart-setsize-jquery-resizable/
  30356. * Add a jQuery UI resizable
  30357. * @sample stock/members/chart-setsize/
  30358. * Highcharts Stock with UI resizable
  30359. *
  30360. * @function Highcharts.Chart#setSize
  30361. *
  30362. * @param {number|null} [width]
  30363. * The new pixel width of the chart. Since v4.2.6, the argument can
  30364. * be `undefined` in order to preserve the current value (when
  30365. * setting height only), or `null` to adapt to the width of the
  30366. * containing element.
  30367. *
  30368. * @param {number|null} [height]
  30369. * The new pixel height of the chart. Since v4.2.6, the argument can
  30370. * be `undefined` in order to preserve the current value, or `null`
  30371. * in order to adapt to the height of the containing element.
  30372. *
  30373. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  30374. * Whether and how to apply animation.
  30375. *
  30376. * @return {void}
  30377. *
  30378. * @fires Highcharts.Chart#event:endResize
  30379. * @fires Highcharts.Chart#event:resize
  30380. */
  30381. Chart.prototype.setSize = function (width, height, animation) {
  30382. var chart = this,
  30383. renderer = chart.renderer,
  30384. globalAnimation;
  30385. // Handle the isResizing counter
  30386. chart.isResizing += 1;
  30387. // set the animation for the current process
  30388. setAnimation(animation, chart);
  30389. globalAnimation = renderer.globalAnimation;
  30390. chart.oldChartHeight = chart.chartHeight;
  30391. chart.oldChartWidth = chart.chartWidth;
  30392. if (typeof width !== 'undefined') {
  30393. chart.options.chart.width = width;
  30394. }
  30395. if (typeof height !== 'undefined') {
  30396. chart.options.chart.height = height;
  30397. }
  30398. chart.getChartSize();
  30399. // Resize the container with the global animation applied if enabled
  30400. // (#2503)
  30401. if (!chart.styledMode) {
  30402. (globalAnimation ? animate : css)(chart.container, {
  30403. width: chart.chartWidth + 'px',
  30404. height: chart.chartHeight + 'px'
  30405. }, globalAnimation);
  30406. }
  30407. chart.setChartSize(true);
  30408. renderer.setSize(chart.chartWidth, chart.chartHeight, globalAnimation);
  30409. // handle axes
  30410. chart.axes.forEach(function (axis) {
  30411. axis.isDirty = true;
  30412. axis.setScale();
  30413. });
  30414. chart.isDirtyLegend = true; // force legend redraw
  30415. chart.isDirtyBox = true; // force redraw of plot and chart border
  30416. chart.layOutTitles(); // #2857
  30417. chart.getMargins();
  30418. chart.redraw(globalAnimation);
  30419. chart.oldChartHeight = null;
  30420. fireEvent(chart, 'resize');
  30421. // Fire endResize and set isResizing back. If animation is disabled,
  30422. // fire without delay
  30423. syncTimeout(function () {
  30424. if (chart) {
  30425. fireEvent(chart, 'endResize', null, function () {
  30426. chart.isResizing -= 1;
  30427. });
  30428. }
  30429. }, animObject(globalAnimation).duration);
  30430. };
  30431. /**
  30432. * Set the public chart properties. This is done before and after the
  30433. * pre-render to determine margin sizes.
  30434. *
  30435. * @private
  30436. * @function Highcharts.Chart#setChartSize
  30437. * @fires Highcharts.Chart#event:afterSetChartSize
  30438. */
  30439. Chart.prototype.setChartSize = function (skipAxes) {
  30440. var chart = this,
  30441. inverted = chart.inverted,
  30442. renderer = chart.renderer,
  30443. chartWidth = chart.chartWidth,
  30444. chartHeight = chart.chartHeight,
  30445. optionsChart = chart.options.chart,
  30446. spacing = chart.spacing,
  30447. clipOffset = chart.clipOffset,
  30448. clipX,
  30449. clipY,
  30450. plotLeft,
  30451. plotTop,
  30452. plotWidth,
  30453. plotHeight,
  30454. plotBorderWidth;
  30455. /**
  30456. * The current left position of the plot area in pixels.
  30457. *
  30458. * @name Highcharts.Chart#plotLeft
  30459. * @type {number}
  30460. */
  30461. chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
  30462. /**
  30463. * The current top position of the plot area in pixels.
  30464. *
  30465. * @name Highcharts.Chart#plotTop
  30466. * @type {number}
  30467. */
  30468. chart.plotTop = plotTop = Math.round(chart.plotTop);
  30469. /**
  30470. * The current width of the plot area in pixels.
  30471. *
  30472. * @name Highcharts.Chart#plotWidth
  30473. * @type {number}
  30474. */
  30475. chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
  30476. /**
  30477. * The current height of the plot area in pixels.
  30478. *
  30479. * @name Highcharts.Chart#plotHeight
  30480. * @type {number}
  30481. */
  30482. chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
  30483. chart.plotSizeX = inverted ? plotHeight : plotWidth;
  30484. chart.plotSizeY = inverted ? plotWidth : plotHeight;
  30485. chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
  30486. // Set boxes used for alignment
  30487. chart.spacingBox = renderer.spacingBox = {
  30488. x: spacing[3],
  30489. y: spacing[0],
  30490. width: chartWidth - spacing[3] - spacing[1],
  30491. height: chartHeight - spacing[0] - spacing[2]
  30492. };
  30493. chart.plotBox = renderer.plotBox = {
  30494. x: plotLeft,
  30495. y: plotTop,
  30496. width: plotWidth,
  30497. height: plotHeight
  30498. };
  30499. plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
  30500. clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
  30501. clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
  30502. chart.clipBox = {
  30503. x: clipX,
  30504. y: clipY,
  30505. width: Math.floor(chart.plotSizeX -
  30506. Math.max(plotBorderWidth, clipOffset[1]) / 2 -
  30507. clipX),
  30508. height: Math.max(0, Math.floor(chart.plotSizeY -
  30509. Math.max(plotBorderWidth, clipOffset[2]) / 2 -
  30510. clipY))
  30511. };
  30512. if (!skipAxes) {
  30513. chart.axes.forEach(function (axis) {
  30514. axis.setAxisSize();
  30515. axis.setAxisTranslation();
  30516. });
  30517. renderer.alignElements();
  30518. }
  30519. fireEvent(chart, 'afterSetChartSize', { skipAxes: skipAxes });
  30520. };
  30521. /**
  30522. * Initial margins before auto size margins are applied.
  30523. *
  30524. * @private
  30525. * @function Highcharts.Chart#resetMargins
  30526. */
  30527. Chart.prototype.resetMargins = function () {
  30528. fireEvent(this, 'resetMargins');
  30529. var chart = this,
  30530. chartOptions = chart.options.chart;
  30531. // Create margin and spacing array
  30532. ['margin', 'spacing'].forEach(function splashArrays(target) {
  30533. var value = chartOptions[target],
  30534. values = isObject(value) ? value : [value,
  30535. value,
  30536. value,
  30537. value];
  30538. [
  30539. 'Top',
  30540. 'Right',
  30541. 'Bottom',
  30542. 'Left'
  30543. ].forEach(function (sideName, side) {
  30544. chart[target][side] = pick(chartOptions[target + sideName], values[side]);
  30545. });
  30546. });
  30547. // Set margin names like chart.plotTop, chart.plotLeft,
  30548. // chart.marginRight, chart.marginBottom.
  30549. marginNames.forEach(function (m, side) {
  30550. chart[m] = pick(chart.margin[side], chart.spacing[side]);
  30551. });
  30552. chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
  30553. chart.clipOffset = [0, 0, 0, 0];
  30554. };
  30555. /**
  30556. * Internal function to draw or redraw the borders and backgrounds for chart
  30557. * and plot area.
  30558. *
  30559. * @private
  30560. * @function Highcharts.Chart#drawChartBox
  30561. * @fires Highcharts.Chart#event:afterDrawChartBox
  30562. */
  30563. Chart.prototype.drawChartBox = function () {
  30564. var chart = this,
  30565. optionsChart = chart.options.chart,
  30566. renderer = chart.renderer,
  30567. chartWidth = chart.chartWidth,
  30568. chartHeight = chart.chartHeight,
  30569. chartBackground = chart.chartBackground,
  30570. plotBackground = chart.plotBackground,
  30571. plotBorder = chart.plotBorder,
  30572. chartBorderWidth,
  30573. styledMode = chart.styledMode,
  30574. plotBGImage = chart.plotBGImage,
  30575. chartBackgroundColor = optionsChart.backgroundColor,
  30576. plotBackgroundColor = optionsChart.plotBackgroundColor,
  30577. plotBackgroundImage = optionsChart.plotBackgroundImage,
  30578. mgn,
  30579. bgAttr,
  30580. plotLeft = chart.plotLeft,
  30581. plotTop = chart.plotTop,
  30582. plotWidth = chart.plotWidth,
  30583. plotHeight = chart.plotHeight,
  30584. plotBox = chart.plotBox,
  30585. clipRect = chart.clipRect,
  30586. clipBox = chart.clipBox,
  30587. verb = 'animate';
  30588. // Chart area
  30589. if (!chartBackground) {
  30590. chart.chartBackground = chartBackground = renderer.rect()
  30591. .addClass('highcharts-background')
  30592. .add();
  30593. verb = 'attr';
  30594. }
  30595. if (!styledMode) {
  30596. // Presentational
  30597. chartBorderWidth = optionsChart.borderWidth || 0;
  30598. mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
  30599. bgAttr = {
  30600. fill: chartBackgroundColor || 'none'
  30601. };
  30602. if (chartBorderWidth || chartBackground['stroke-width']) { // #980
  30603. bgAttr.stroke = optionsChart.borderColor;
  30604. bgAttr['stroke-width'] = chartBorderWidth;
  30605. }
  30606. chartBackground
  30607. .attr(bgAttr)
  30608. .shadow(optionsChart.shadow);
  30609. }
  30610. else {
  30611. chartBorderWidth = mgn = chartBackground.strokeWidth();
  30612. }
  30613. chartBackground[verb]({
  30614. x: mgn / 2,
  30615. y: mgn / 2,
  30616. width: chartWidth - mgn - chartBorderWidth % 2,
  30617. height: chartHeight - mgn - chartBorderWidth % 2,
  30618. r: optionsChart.borderRadius
  30619. });
  30620. // Plot background
  30621. verb = 'animate';
  30622. if (!plotBackground) {
  30623. verb = 'attr';
  30624. chart.plotBackground = plotBackground = renderer.rect()
  30625. .addClass('highcharts-plot-background')
  30626. .add();
  30627. }
  30628. plotBackground[verb](plotBox);
  30629. if (!styledMode) {
  30630. // Presentational attributes for the background
  30631. plotBackground
  30632. .attr({
  30633. fill: plotBackgroundColor || 'none'
  30634. })
  30635. .shadow(optionsChart.plotShadow);
  30636. // Create the background image
  30637. if (plotBackgroundImage) {
  30638. if (!plotBGImage) {
  30639. chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight).add();
  30640. }
  30641. else {
  30642. if (plotBackgroundImage !== plotBGImage.attr('href')) {
  30643. plotBGImage.attr('href', plotBackgroundImage);
  30644. }
  30645. plotBGImage.animate(plotBox);
  30646. }
  30647. }
  30648. }
  30649. // Plot clip
  30650. if (!clipRect) {
  30651. chart.clipRect = renderer.clipRect(clipBox);
  30652. }
  30653. else {
  30654. clipRect.animate({
  30655. width: clipBox.width,
  30656. height: clipBox.height
  30657. });
  30658. }
  30659. // Plot area border
  30660. verb = 'animate';
  30661. if (!plotBorder) {
  30662. verb = 'attr';
  30663. chart.plotBorder = plotBorder = renderer.rect()
  30664. .addClass('highcharts-plot-border')
  30665. .attr({
  30666. zIndex: 1 // Above the grid
  30667. })
  30668. .add();
  30669. }
  30670. if (!styledMode) {
  30671. // Presentational
  30672. plotBorder.attr({
  30673. stroke: optionsChart.plotBorderColor,
  30674. 'stroke-width': optionsChart.plotBorderWidth || 0,
  30675. fill: 'none'
  30676. });
  30677. }
  30678. plotBorder[verb](plotBorder.crisp({
  30679. x: plotLeft,
  30680. y: plotTop,
  30681. width: plotWidth,
  30682. height: plotHeight
  30683. }, -plotBorder.strokeWidth())); // #3282 plotBorder should be negative;
  30684. // reset
  30685. chart.isDirtyBox = false;
  30686. fireEvent(this, 'afterDrawChartBox');
  30687. };
  30688. /**
  30689. * Detect whether a certain chart property is needed based on inspecting its
  30690. * options and series. This mainly applies to the chart.inverted property,
  30691. * and in extensions to the chart.angular and chart.polar properties.
  30692. *
  30693. * @private
  30694. * @function Highcharts.Chart#propFromSeries
  30695. * @return {void}
  30696. */
  30697. Chart.prototype.propFromSeries = function () {
  30698. var chart = this,
  30699. optionsChart = chart.options.chart,
  30700. klass,
  30701. seriesOptions = chart.options.series,
  30702. i,
  30703. value;
  30704. /**
  30705. * The flag is set to `true` if a series of the chart is inverted.
  30706. *
  30707. * @name Highcharts.Chart#inverted
  30708. * @type {boolean|undefined}
  30709. */
  30710. ['inverted', 'angular', 'polar'].forEach(function (key) {
  30711. // The default series type's class
  30712. klass = seriesTypes[(optionsChart.type || optionsChart.defaultSeriesType)];
  30713. // Get the value from available chart-wide properties
  30714. value =
  30715. // It is set in the options:
  30716. optionsChart[key] ||
  30717. // The default series class:
  30718. (klass && klass.prototype[key]);
  30719. // requires it
  30720. // 4. Check if any the chart's series require it
  30721. i = seriesOptions && seriesOptions.length;
  30722. while (!value && i--) {
  30723. klass = seriesTypes[seriesOptions[i].type];
  30724. if (klass && klass.prototype[key]) {
  30725. value = true;
  30726. }
  30727. }
  30728. // Set the chart property
  30729. chart[key] = value;
  30730. });
  30731. };
  30732. /**
  30733. * Internal function to link two or more series together, based on the
  30734. * `linkedTo` option. This is done from `Chart.render`, and after
  30735. * `Chart.addSeries` and `Series.remove`.
  30736. *
  30737. * @private
  30738. * @function Highcharts.Chart#linkSeries
  30739. * @fires Highcharts.Chart#event:afterLinkSeries
  30740. */
  30741. Chart.prototype.linkSeries = function () {
  30742. var chart = this,
  30743. chartSeries = chart.series;
  30744. // Reset links
  30745. chartSeries.forEach(function (series) {
  30746. series.linkedSeries.length = 0;
  30747. });
  30748. // Apply new links
  30749. chartSeries.forEach(function (series) {
  30750. var linkedTo = series.options.linkedTo;
  30751. if (isString(linkedTo)) {
  30752. if (linkedTo === ':previous') {
  30753. linkedTo = chart.series[series.index - 1];
  30754. }
  30755. else {
  30756. linkedTo = chart.get(linkedTo);
  30757. }
  30758. // #3341 avoid mutual linking
  30759. if (linkedTo && linkedTo.linkedParent !== series) {
  30760. linkedTo.linkedSeries.push(series);
  30761. series.linkedParent = linkedTo;
  30762. if (linkedTo.enabledDataSorting) {
  30763. series.setDataSortingOptions();
  30764. }
  30765. series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
  30766. }
  30767. }
  30768. });
  30769. fireEvent(this, 'afterLinkSeries');
  30770. };
  30771. /**
  30772. * Render series for the chart.
  30773. *
  30774. * @private
  30775. * @function Highcharts.Chart#renderSeries
  30776. */
  30777. Chart.prototype.renderSeries = function () {
  30778. this.series.forEach(function (serie) {
  30779. serie.translate();
  30780. serie.render();
  30781. });
  30782. };
  30783. /**
  30784. * Render labels for the chart.
  30785. *
  30786. * @private
  30787. * @function Highcharts.Chart#renderLabels
  30788. */
  30789. Chart.prototype.renderLabels = function () {
  30790. var chart = this,
  30791. labels = chart.options.labels;
  30792. if (labels.items) {
  30793. labels.items.forEach(function (label) {
  30794. var style = extend(labels.style,
  30795. label.style),
  30796. x = pInt(style.left) + chart.plotLeft,
  30797. y = pInt(style.top) + chart.plotTop + 12;
  30798. // delete to prevent rewriting in IE
  30799. delete style.left;
  30800. delete style.top;
  30801. chart.renderer.text(label.html, x, y)
  30802. .attr({ zIndex: 2 })
  30803. .css(style)
  30804. .add();
  30805. });
  30806. }
  30807. };
  30808. /**
  30809. * Render all graphics for the chart. Runs internally on initialization.
  30810. *
  30811. * @private
  30812. * @function Highcharts.Chart#render
  30813. */
  30814. Chart.prototype.render = function () {
  30815. var chart = this,
  30816. axes = chart.axes,
  30817. colorAxis = chart.colorAxis,
  30818. renderer = chart.renderer,
  30819. options = chart.options,
  30820. correction = 0, // correction for X axis labels
  30821. tempWidth,
  30822. tempHeight,
  30823. redoHorizontal,
  30824. redoVertical,
  30825. renderAxes = function (axes) {
  30826. axes.forEach(function (axis) {
  30827. if (axis.visible) {
  30828. axis.render();
  30829. }
  30830. });
  30831. };
  30832. // Title
  30833. chart.setTitle();
  30834. /**
  30835. * The overview of the chart's series.
  30836. *
  30837. * @name Highcharts.Chart#legend
  30838. * @type {Highcharts.Legend}
  30839. */
  30840. chart.legend = new Legend(chart, options.legend);
  30841. // Get stacks
  30842. if (chart.getStacks) {
  30843. chart.getStacks();
  30844. }
  30845. // Get chart margins
  30846. chart.getMargins(true);
  30847. chart.setChartSize();
  30848. // Record preliminary dimensions for later comparison
  30849. tempWidth = chart.plotWidth;
  30850. axes.some(function (axis) {
  30851. if (axis.horiz &&
  30852. axis.visible &&
  30853. axis.options.labels.enabled &&
  30854. axis.series.length) {
  30855. // 21 is the most common correction for X axis labels
  30856. correction = 21;
  30857. return true;
  30858. }
  30859. });
  30860. // use Math.max to prevent negative plotHeight
  30861. chart.plotHeight = Math.max(chart.plotHeight - correction, 0);
  30862. tempHeight = chart.plotHeight;
  30863. // Get margins by pre-rendering axes
  30864. axes.forEach(function (axis) {
  30865. axis.setScale();
  30866. });
  30867. chart.getAxisMargins();
  30868. // If the plot area size has changed significantly, calculate tick
  30869. // positions again
  30870. redoHorizontal = tempWidth / chart.plotWidth > 1.1;
  30871. // Height is more sensitive, use lower threshold
  30872. redoVertical = tempHeight / chart.plotHeight > 1.05;
  30873. if (redoHorizontal || redoVertical) {
  30874. axes.forEach(function (axis) {
  30875. if ((axis.horiz && redoHorizontal) ||
  30876. (!axis.horiz && redoVertical)) {
  30877. // update to reflect the new margins
  30878. axis.setTickInterval(true);
  30879. }
  30880. });
  30881. chart.getMargins(); // second pass to check for new labels
  30882. }
  30883. // Draw the borders and backgrounds
  30884. chart.drawChartBox();
  30885. // Axes
  30886. if (chart.hasCartesianSeries) {
  30887. renderAxes(axes);
  30888. }
  30889. else if (colorAxis && colorAxis.length) {
  30890. renderAxes(colorAxis);
  30891. }
  30892. // The series
  30893. if (!chart.seriesGroup) {
  30894. chart.seriesGroup = renderer.g('series-group')
  30895. .attr({ zIndex: 3 })
  30896. .add();
  30897. }
  30898. chart.renderSeries();
  30899. // Labels
  30900. chart.renderLabels();
  30901. // Credits
  30902. chart.addCredits();
  30903. // Handle responsiveness
  30904. if (chart.setResponsive) {
  30905. chart.setResponsive();
  30906. }
  30907. // Set flag
  30908. chart.hasRendered = true;
  30909. };
  30910. /**
  30911. * Set a new credits label for the chart.
  30912. *
  30913. * @sample highcharts/credits/credits-update/
  30914. * Add and update credits
  30915. *
  30916. * @function Highcharts.Chart#addCredits
  30917. *
  30918. * @param {Highcharts.CreditsOptions} [credits]
  30919. * A configuration object for the new credits.
  30920. */
  30921. Chart.prototype.addCredits = function (credits) {
  30922. var chart = this,
  30923. creds = merge(true,
  30924. this.options.credits,
  30925. credits);
  30926. if (creds.enabled && !this.credits) {
  30927. /**
  30928. * The chart's credits label. The label has an `update` method that
  30929. * allows setting new options as per the
  30930. * [credits options set](https://api.highcharts.com/highcharts/credits).
  30931. *
  30932. * @name Highcharts.Chart#credits
  30933. * @type {Highcharts.SVGElement}
  30934. */
  30935. this.credits = this.renderer.text(creds.text + (this.mapCredits || ''), 0, 0)
  30936. .addClass('highcharts-credits')
  30937. .on('click', function () {
  30938. if (creds.href) {
  30939. win.location.href = creds.href;
  30940. }
  30941. })
  30942. .attr({
  30943. align: creds.position.align,
  30944. zIndex: 8
  30945. });
  30946. if (!chart.styledMode) {
  30947. this.credits.css(creds.style);
  30948. }
  30949. this.credits
  30950. .add()
  30951. .align(creds.position);
  30952. // Dynamically update
  30953. this.credits.update = function (options) {
  30954. chart.credits = chart.credits.destroy();
  30955. chart.addCredits(options);
  30956. };
  30957. }
  30958. };
  30959. /**
  30960. * Remove the chart and purge memory. This method is called internally
  30961. * before adding a second chart into the same container, as well as on
  30962. * window unload to prevent leaks.
  30963. *
  30964. * @sample highcharts/members/chart-destroy/
  30965. * Destroy the chart from a button
  30966. * @sample stock/members/chart-destroy/
  30967. * Destroy with Highcharts Stock
  30968. *
  30969. * @function Highcharts.Chart#destroy
  30970. *
  30971. * @fires Highcharts.Chart#event:destroy
  30972. */
  30973. Chart.prototype.destroy = function () {
  30974. var chart = this,
  30975. axes = chart.axes,
  30976. series = chart.series,
  30977. container = chart.container,
  30978. i,
  30979. parentNode = container && container.parentNode;
  30980. // fire the chart.destoy event
  30981. fireEvent(chart, 'destroy');
  30982. // Delete the chart from charts lookup array
  30983. if (chart.renderer.forExport) {
  30984. erase(charts, chart); // #6569
  30985. }
  30986. else {
  30987. charts[chart.index] = void 0;
  30988. }
  30989. H.chartCount--;
  30990. chart.renderTo.removeAttribute('data-highcharts-chart');
  30991. // remove events
  30992. removeEvent(chart);
  30993. // ==== Destroy collections:
  30994. // Destroy axes
  30995. i = axes.length;
  30996. while (i--) {
  30997. axes[i] = axes[i].destroy();
  30998. }
  30999. // Destroy scroller & scroller series before destroying base series
  31000. if (this.scroller && this.scroller.destroy) {
  31001. this.scroller.destroy();
  31002. }
  31003. // Destroy each series
  31004. i = series.length;
  31005. while (i--) {
  31006. series[i] = series[i].destroy();
  31007. }
  31008. // ==== Destroy chart properties:
  31009. [
  31010. 'title', 'subtitle', 'chartBackground', 'plotBackground',
  31011. 'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
  31012. 'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
  31013. 'renderer'
  31014. ].forEach(function (name) {
  31015. var prop = chart[name];
  31016. if (prop && prop.destroy) {
  31017. chart[name] = prop.destroy();
  31018. }
  31019. });
  31020. // Remove container and all SVG, check container as it can break in IE
  31021. // when destroyed before finished loading
  31022. if (container) {
  31023. container.innerHTML = '';
  31024. removeEvent(container);
  31025. if (parentNode) {
  31026. discardElement(container);
  31027. }
  31028. }
  31029. // clean it all up
  31030. objectEach(chart, function (val, key) {
  31031. delete chart[key];
  31032. });
  31033. };
  31034. /**
  31035. * Prepare for first rendering after all data are loaded.
  31036. *
  31037. * @private
  31038. * @function Highcharts.Chart#firstRender
  31039. * @fires Highcharts.Chart#event:beforeRender
  31040. */
  31041. Chart.prototype.firstRender = function () {
  31042. var chart = this,
  31043. options = chart.options;
  31044. // Hook for oldIE to check whether the chart is ready to render
  31045. if (chart.isReadyToRender && !chart.isReadyToRender()) {
  31046. return;
  31047. }
  31048. // Create the container
  31049. chart.getContainer();
  31050. chart.resetMargins();
  31051. chart.setChartSize();
  31052. // Set the common chart properties (mainly invert) from the given series
  31053. chart.propFromSeries();
  31054. // get axes
  31055. chart.getAxes();
  31056. // Initialize the series
  31057. (isArray(options.series) ? options.series : []).forEach(
  31058. // #9680
  31059. function (serieOptions) {
  31060. chart.initSeries(serieOptions);
  31061. });
  31062. chart.linkSeries();
  31063. chart.setSeriesData();
  31064. // Run an event after axes and series are initialized, but before
  31065. // render. At this stage, the series data is indexed and cached in the
  31066. // xData and yData arrays, so we can access those before rendering. Used
  31067. // in Highcharts Stock.
  31068. fireEvent(chart, 'beforeRender');
  31069. // depends on inverted and on margins being set
  31070. if (Pointer) {
  31071. if (!H.hasTouch && (win.PointerEvent || win.MSPointerEvent)) {
  31072. chart.pointer = new MSPointer(chart, options);
  31073. }
  31074. else {
  31075. /**
  31076. * The Pointer that keeps track of mouse and touch interaction.
  31077. *
  31078. * @memberof Highcharts.Chart
  31079. * @name pointer
  31080. * @type {Highcharts.Pointer}
  31081. * @instance
  31082. */
  31083. chart.pointer = new Pointer(chart, options);
  31084. }
  31085. }
  31086. chart.render();
  31087. chart.pointer.getChartPosition(); // #14973
  31088. // Fire the load event if there are no external images
  31089. if (!chart.renderer.imgCount && !chart.hasLoaded) {
  31090. chart.onload();
  31091. }
  31092. // If the chart was rendered outside the top container, put it back in
  31093. // (#3679)
  31094. chart.temporaryDisplay(true);
  31095. };
  31096. /**
  31097. * Internal function that runs on chart load, async if any images are loaded
  31098. * in the chart. Runs the callbacks and triggers the `load` and `render`
  31099. * events.
  31100. *
  31101. * @private
  31102. * @function Highcharts.Chart#onload
  31103. * @fires Highcharts.Chart#event:load
  31104. * @fires Highcharts.Chart#event:render
  31105. */
  31106. Chart.prototype.onload = function () {
  31107. // Run callbacks, first the ones registered by modules, then user's one
  31108. this.callbacks.concat([this.callback]).forEach(function (fn) {
  31109. // Chart destroyed in its own callback (#3600)
  31110. if (fn && typeof this.index !== 'undefined') {
  31111. fn.apply(this, [this]);
  31112. }
  31113. }, this);
  31114. fireEvent(this, 'load');
  31115. fireEvent(this, 'render');
  31116. // Set up auto resize, check for not destroyed (#6068)
  31117. if (defined(this.index)) {
  31118. this.setReflow(this.options.chart.reflow);
  31119. }
  31120. // Don't run again
  31121. this.hasLoaded = true;
  31122. };
  31123. /**
  31124. * Add a series to the chart after render time. Note that this method should
  31125. * never be used when adding data synchronously at chart render time, as it
  31126. * adds expense to the calculations and rendering. When adding data at the
  31127. * same time as the chart is initialized, add the series as a configuration
  31128. * option instead. With multiple axes, the `offset` is dynamically adjusted.
  31129. *
  31130. * @sample highcharts/members/chart-addseries/
  31131. * Add a series from a button
  31132. * @sample stock/members/chart-addseries/
  31133. * Add a series in Highcharts Stock
  31134. *
  31135. * @function Highcharts.Chart#addSeries
  31136. *
  31137. * @param {Highcharts.SeriesOptionsType} options
  31138. * The config options for the series.
  31139. *
  31140. * @param {boolean} [redraw=true]
  31141. * Whether to redraw the chart after adding.
  31142. *
  31143. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  31144. * Whether to apply animation, and optionally animation
  31145. * configuration.
  31146. *
  31147. * @return {Highcharts.Series}
  31148. * The newly created series object.
  31149. *
  31150. * @fires Highcharts.Chart#event:addSeries
  31151. * @fires Highcharts.Chart#event:afterAddSeries
  31152. */
  31153. Chart.prototype.addSeries = function (options, redraw, animation) {
  31154. var series,
  31155. chart = this;
  31156. if (options) { // <- not necessary
  31157. redraw = pick(redraw, true); // defaults to true
  31158. fireEvent(chart, 'addSeries', { options: options }, function () {
  31159. series = chart.initSeries(options);
  31160. chart.isDirtyLegend = true;
  31161. chart.linkSeries();
  31162. if (series.enabledDataSorting) {
  31163. // We need to call `setData` after `linkSeries`
  31164. series.setData(options.data, false);
  31165. }
  31166. fireEvent(chart, 'afterAddSeries', { series: series });
  31167. if (redraw) {
  31168. chart.redraw(animation);
  31169. }
  31170. });
  31171. }
  31172. return series;
  31173. };
  31174. /**
  31175. * Add an axis to the chart after render time. Note that this method should
  31176. * never be used when adding data synchronously at chart render time, as it
  31177. * adds expense to the calculations and rendering. When adding data at the
  31178. * same time as the chart is initialized, add the axis as a configuration
  31179. * option instead.
  31180. *
  31181. * @sample highcharts/members/chart-addaxis/
  31182. * Add and remove axes
  31183. *
  31184. * @function Highcharts.Chart#addAxis
  31185. *
  31186. * @param {Highcharts.AxisOptions} options
  31187. * The axis options.
  31188. *
  31189. * @param {boolean} [isX=false]
  31190. * Whether it is an X axis or a value axis.
  31191. *
  31192. * @param {boolean} [redraw=true]
  31193. * Whether to redraw the chart after adding.
  31194. *
  31195. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31196. * Whether and how to apply animation in the redraw.
  31197. *
  31198. * @return {Highcharts.Axis}
  31199. * The newly generated Axis object.
  31200. */
  31201. Chart.prototype.addAxis = function (options, isX, redraw, animation) {
  31202. return this.createAxis(isX ? 'xAxis' : 'yAxis', { axis: options, redraw: redraw, animation: animation });
  31203. };
  31204. /**
  31205. * Add a color axis to the chart after render time. Note that this method
  31206. * should never be used when adding data synchronously at chart render time,
  31207. * as it adds expense to the calculations and rendering. When adding data at
  31208. * the same time as the chart is initialized, add the axis as a
  31209. * configuration option instead.
  31210. *
  31211. * @sample highcharts/members/chart-addaxis/
  31212. * Add and remove axes
  31213. *
  31214. * @function Highcharts.Chart#addColorAxis
  31215. *
  31216. * @param {Highcharts.ColorAxisOptions} options
  31217. * The axis options.
  31218. *
  31219. * @param {boolean} [redraw=true]
  31220. * Whether to redraw the chart after adding.
  31221. *
  31222. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31223. * Whether and how to apply animation in the redraw.
  31224. *
  31225. * @return {Highcharts.ColorAxis}
  31226. * The newly generated Axis object.
  31227. */
  31228. Chart.prototype.addColorAxis = function (options, redraw, animation) {
  31229. return this.createAxis('colorAxis', { axis: options, redraw: redraw, animation: animation });
  31230. };
  31231. /**
  31232. * Factory for creating different axis types.
  31233. *
  31234. * @private
  31235. * @function Highcharts.Chart#createAxis
  31236. *
  31237. * @param {string} type
  31238. * An axis type.
  31239. *
  31240. * @param {...Array<*>} arguments
  31241. * All arguments for the constructor.
  31242. *
  31243. * @return {Highcharts.Axis | Highcharts.ColorAxis}
  31244. * The newly generated Axis object.
  31245. */
  31246. Chart.prototype.createAxis = function (type, options) {
  31247. var chartOptions = this.options,
  31248. isColorAxis = type === 'colorAxis',
  31249. axisOptions = options.axis,
  31250. redraw = options.redraw,
  31251. animation = options.animation,
  31252. userOptions = merge(axisOptions, {
  31253. index: this[type].length,
  31254. isX: type === 'xAxis'
  31255. }),
  31256. axis;
  31257. if (isColorAxis) {
  31258. axis = new H.ColorAxis(this, userOptions);
  31259. }
  31260. else {
  31261. axis = new Axis(this, userOptions);
  31262. }
  31263. if (isColorAxis) {
  31264. this.isDirtyLegend = true;
  31265. // Clear before 'bindAxes' (#11924)
  31266. this.axes.forEach(function (axis) {
  31267. axis.series = [];
  31268. });
  31269. this.series.forEach(function (series) {
  31270. series.bindAxes();
  31271. series.isDirtyData = true;
  31272. });
  31273. }
  31274. if (pick(redraw, true)) {
  31275. this.redraw(animation);
  31276. }
  31277. return axis;
  31278. };
  31279. /**
  31280. * Dim the chart and show a loading text or symbol. Options for the loading
  31281. * screen are defined in {@link
  31282. * https://api.highcharts.com/highcharts/loading|the loading options}.
  31283. *
  31284. * @sample highcharts/members/chart-hideloading/
  31285. * Show and hide loading from a button
  31286. * @sample highcharts/members/chart-showloading/
  31287. * Apply different text labels
  31288. * @sample stock/members/chart-show-hide-loading/
  31289. * Toggle loading in Highcharts Stock
  31290. *
  31291. * @function Highcharts.Chart#showLoading
  31292. *
  31293. * @param {string} [str]
  31294. * An optional text to show in the loading label instead of the
  31295. * default one. The default text is set in
  31296. * [lang.loading](https://api.highcharts.com/highcharts/lang.loading).
  31297. */
  31298. Chart.prototype.showLoading = function (str) {
  31299. var chart = this,
  31300. options = chart.options,
  31301. loadingDiv = chart.loadingDiv,
  31302. loadingSpan = chart.loadingSpan,
  31303. loadingOptions = options.loading,
  31304. setLoadingSize = function () {
  31305. if (loadingDiv) {
  31306. css(loadingDiv, {
  31307. left: chart.plotLeft + 'px',
  31308. top: chart.plotTop + 'px',
  31309. width: chart.plotWidth + 'px',
  31310. height: chart.plotHeight + 'px'
  31311. });
  31312. }
  31313. };
  31314. // create the layer at the first call
  31315. if (!loadingDiv) {
  31316. chart.loadingDiv = loadingDiv = createElement('div', {
  31317. className: 'highcharts-loading highcharts-loading-hidden'
  31318. }, null, chart.container);
  31319. }
  31320. if (!loadingSpan) {
  31321. chart.loadingSpan = loadingSpan = createElement('span', { className: 'highcharts-loading-inner' }, null, loadingDiv);
  31322. addEvent(chart, 'redraw', setLoadingSize); // #1080
  31323. }
  31324. loadingDiv.className = 'highcharts-loading';
  31325. // Update text
  31326. AST.setElementHTML(loadingSpan, pick(str, options.lang.loading, ''));
  31327. if (!chart.styledMode) {
  31328. // Update visuals
  31329. css(loadingDiv, extend(loadingOptions.style, {
  31330. zIndex: 10
  31331. }));
  31332. css(loadingSpan, loadingOptions.labelStyle);
  31333. // Show it
  31334. if (!chart.loadingShown) {
  31335. css(loadingDiv, {
  31336. opacity: 0,
  31337. display: ''
  31338. });
  31339. animate(loadingDiv, {
  31340. opacity: loadingOptions.style.opacity || 0.5
  31341. }, {
  31342. duration: loadingOptions.showDuration || 0
  31343. });
  31344. }
  31345. }
  31346. chart.loadingShown = true;
  31347. setLoadingSize();
  31348. };
  31349. /**
  31350. * Hide the loading layer.
  31351. *
  31352. * @see Highcharts.Chart#showLoading
  31353. *
  31354. * @sample highcharts/members/chart-hideloading/
  31355. * Show and hide loading from a button
  31356. * @sample stock/members/chart-show-hide-loading/
  31357. * Toggle loading in Highcharts Stock
  31358. *
  31359. * @function Highcharts.Chart#hideLoading
  31360. */
  31361. Chart.prototype.hideLoading = function () {
  31362. var options = this.options,
  31363. loadingDiv = this.loadingDiv;
  31364. if (loadingDiv) {
  31365. loadingDiv.className =
  31366. 'highcharts-loading highcharts-loading-hidden';
  31367. if (!this.styledMode) {
  31368. animate(loadingDiv, {
  31369. opacity: 0
  31370. }, {
  31371. duration: options.loading.hideDuration || 100,
  31372. complete: function () {
  31373. css(loadingDiv, { display: 'none' });
  31374. }
  31375. });
  31376. }
  31377. }
  31378. this.loadingShown = false;
  31379. };
  31380. /**
  31381. * A generic function to update any element of the chart. Elements can be
  31382. * enabled and disabled, moved, re-styled, re-formatted etc.
  31383. *
  31384. * A special case is configuration objects that take arrays, for example
  31385. * [xAxis](https://api.highcharts.com/highcharts/xAxis),
  31386. * [yAxis](https://api.highcharts.com/highcharts/yAxis) or
  31387. * [series](https://api.highcharts.com/highcharts/series). For these
  31388. * collections, an `id` option is used to map the new option set to an
  31389. * existing object. If an existing object of the same id is not found, the
  31390. * corresponding item is updated. So for example, running `chart.update`
  31391. * with a series item without an id, will cause the existing chart's series
  31392. * with the same index in the series array to be updated. When the
  31393. * `oneToOne` parameter is true, `chart.update` will also take care of
  31394. * adding and removing items from the collection. Read more under the
  31395. * parameter description below.
  31396. *
  31397. * Note that when changing series data, `chart.update` may mutate the passed
  31398. * data options.
  31399. *
  31400. * See also the
  31401. * [responsive option set](https://api.highcharts.com/highcharts/responsive).
  31402. * Switching between `responsive.rules` basically runs `chart.update` under
  31403. * the hood.
  31404. *
  31405. * @sample highcharts/members/chart-update/
  31406. * Update chart geometry
  31407. *
  31408. * @function Highcharts.Chart#update
  31409. *
  31410. * @param {Highcharts.Options} options
  31411. * A configuration object for the new chart options.
  31412. *
  31413. * @param {boolean} [redraw=true]
  31414. * Whether to redraw the chart.
  31415. *
  31416. * @param {boolean} [oneToOne=false]
  31417. * When `true`, the `series`, `xAxis`, `yAxis` and `annotations`
  31418. * collections will be updated one to one, and items will be either
  31419. * added or removed to match the new updated options. For example,
  31420. * if the chart has two series and we call `chart.update` with a
  31421. * configuration containing three series, one will be added. If we
  31422. * call `chart.update` with one series, one will be removed. Setting
  31423. * an empty `series` array will remove all series, but leaving out
  31424. * the`series` property will leave all series untouched. If the
  31425. * series have id's, the new series options will be matched by id,
  31426. * and the remaining ones removed.
  31427. *
  31428. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31429. * Whether to apply animation, and optionally animation
  31430. * configuration.
  31431. *
  31432. * @fires Highcharts.Chart#event:update
  31433. * @fires Highcharts.Chart#event:afterUpdate
  31434. */
  31435. Chart.prototype.update = function (options, redraw, oneToOne, animation) {
  31436. var chart = this,
  31437. adders = {
  31438. credits: 'addCredits',
  31439. title: 'setTitle',
  31440. subtitle: 'setSubtitle',
  31441. caption: 'setCaption'
  31442. },
  31443. optionsChart,
  31444. updateAllAxes,
  31445. updateAllSeries,
  31446. newWidth,
  31447. newHeight,
  31448. runSetSize,
  31449. isResponsiveOptions = options.isResponsiveOptions,
  31450. itemsForRemoval = [];
  31451. fireEvent(chart, 'update', { options: options });
  31452. // If there are responsive rules in action, undo the responsive rules
  31453. // before we apply the updated options and replay the responsive rules
  31454. // on top from the chart.redraw function (#9617).
  31455. if (!isResponsiveOptions) {
  31456. chart.setResponsive(false, true);
  31457. }
  31458. options = cleanRecursively(options, chart.options);
  31459. chart.userOptions = merge(chart.userOptions, options);
  31460. // If the top-level chart option is present, some special updates are
  31461. // required
  31462. optionsChart = options.chart;
  31463. if (optionsChart) {
  31464. merge(true, chart.options.chart, optionsChart);
  31465. // Setter function
  31466. if ('className' in optionsChart) {
  31467. chart.setClassName(optionsChart.className);
  31468. }
  31469. if ('reflow' in optionsChart) {
  31470. chart.setReflow(optionsChart.reflow);
  31471. }
  31472. if ('inverted' in optionsChart ||
  31473. 'polar' in optionsChart ||
  31474. 'type' in optionsChart) {
  31475. // Parse options.chart.inverted and options.chart.polar together
  31476. // with the available series.
  31477. chart.propFromSeries();
  31478. updateAllAxes = true;
  31479. }
  31480. if ('alignTicks' in optionsChart) { // #6452
  31481. updateAllAxes = true;
  31482. }
  31483. objectEach(optionsChart, function (val, key) {
  31484. if (chart.propsRequireUpdateSeries.indexOf('chart.' + key) !==
  31485. -1) {
  31486. updateAllSeries = true;
  31487. }
  31488. // Only dirty box
  31489. if (chart.propsRequireDirtyBox.indexOf(key) !== -1) {
  31490. chart.isDirtyBox = true;
  31491. }
  31492. // Chart setSize
  31493. if (chart.propsRequireReflow.indexOf(key) !== -1) {
  31494. if (isResponsiveOptions) {
  31495. chart.isDirtyBox = true;
  31496. }
  31497. else {
  31498. runSetSize = true;
  31499. }
  31500. }
  31501. });
  31502. if (!chart.styledMode && 'style' in optionsChart) {
  31503. chart.renderer.setStyle(optionsChart.style);
  31504. }
  31505. }
  31506. // Moved up, because tooltip needs updated plotOptions (#6218)
  31507. if (!chart.styledMode && options.colors) {
  31508. this.options.colors = options.colors;
  31509. }
  31510. if (options.time) {
  31511. // Maintaining legacy global time. If the chart is instanciated
  31512. // first with global time, then updated with time options, we need
  31513. // to create a new Time instance to avoid mutating the global time
  31514. // (#10536).
  31515. if (this.time === defaultTime) {
  31516. this.time = new Time(options.time);
  31517. }
  31518. // If we're updating, the time class is different from other chart
  31519. // classes (chart.legend, chart.tooltip etc) in that it doesn't know
  31520. // about the chart. The other chart[something].update functions also
  31521. // set the chart.options[something]. For the time class however we
  31522. // need to update the chart options separately. #14230.
  31523. merge(true, chart.options.time, options.time);
  31524. }
  31525. // Some option stuctures correspond one-to-one to chart objects that
  31526. // have update methods, for example
  31527. // options.credits => chart.credits
  31528. // options.legend => chart.legend
  31529. // options.title => chart.title
  31530. // options.tooltip => chart.tooltip
  31531. // options.subtitle => chart.subtitle
  31532. // options.mapNavigation => chart.mapNavigation
  31533. // options.navigator => chart.navigator
  31534. // options.scrollbar => chart.scrollbar
  31535. objectEach(options, function (val, key) {
  31536. if (chart[key] &&
  31537. typeof chart[key].update === 'function') {
  31538. chart[key].update(val, false);
  31539. // If a one-to-one object does not exist, look for an adder function
  31540. }
  31541. else if (typeof chart[adders[key]] === 'function') {
  31542. chart[adders[key]](val);
  31543. // Else, just merge the options. For nodes like loading, noData,
  31544. // plotOptions
  31545. }
  31546. else if (key !== 'colors' &&
  31547. chart.collectionsWithUpdate.indexOf(key) === -1) {
  31548. merge(true, chart.options[key], options[key]);
  31549. }
  31550. if (key !== 'chart' &&
  31551. chart.propsRequireUpdateSeries.indexOf(key) !== -1) {
  31552. updateAllSeries = true;
  31553. }
  31554. });
  31555. // Setters for collections. For axes and series, each item is referred
  31556. // by an id. If the id is not found, it defaults to the corresponding
  31557. // item in the collection, so setting one series without an id, will
  31558. // update the first series in the chart. Setting two series without
  31559. // an id will update the first and the second respectively (#6019)
  31560. // chart.update and responsive.
  31561. this.collectionsWithUpdate.forEach(function (coll) {
  31562. var indexMap;
  31563. if (options[coll]) {
  31564. // In stock charts, the navigator series are also part of the
  31565. // chart.series array, but those series should not be handled
  31566. // here (#8196) and neither should the navigator axis (#9671).
  31567. indexMap = [];
  31568. chart[coll].forEach(function (s, i) {
  31569. if (!s.options.isInternal) {
  31570. indexMap.push(pick(s.options.index, i));
  31571. }
  31572. });
  31573. splat(options[coll]).forEach(function (newOptions, i) {
  31574. var hasId = defined(newOptions.id);
  31575. var item;
  31576. // Match by id
  31577. if (hasId) {
  31578. item = chart.get(newOptions.id);
  31579. }
  31580. // No match by id found, match by index instead
  31581. if (!item && chart[coll]) {
  31582. item = chart[coll][indexMap ? indexMap[i] : i];
  31583. // Check if we grabbed an item with an exising but
  31584. // different id (#13541)
  31585. if (item && hasId && defined(item.options.id)) {
  31586. item = void 0;
  31587. }
  31588. }
  31589. if (item && item.coll === coll) {
  31590. item.update(newOptions, false);
  31591. if (oneToOne) {
  31592. item.touched = true;
  31593. }
  31594. }
  31595. // If oneToOne and no matching item is found, add one
  31596. if (!item && oneToOne && chart.collectionsWithInit[coll]) {
  31597. chart.collectionsWithInit[coll][0].apply(chart,
  31598. // [newOptions, ...extraArguments, redraw=false]
  31599. [
  31600. newOptions
  31601. ].concat(
  31602. // Not all initializers require extra args
  31603. chart.collectionsWithInit[coll][1] || []).concat([
  31604. false
  31605. ])).touched = true;
  31606. }
  31607. });
  31608. // Add items for removal
  31609. if (oneToOne) {
  31610. chart[coll].forEach(function (item) {
  31611. if (!item.touched && !item.options.isInternal) {
  31612. itemsForRemoval.push(item);
  31613. }
  31614. else {
  31615. delete item.touched;
  31616. }
  31617. });
  31618. }
  31619. }
  31620. });
  31621. itemsForRemoval.forEach(function (item) {
  31622. if (item.chart) { // #9097, avoid removing twice
  31623. item.remove(false);
  31624. }
  31625. });
  31626. if (updateAllAxes) {
  31627. chart.axes.forEach(function (axis) {
  31628. axis.update({}, false);
  31629. });
  31630. }
  31631. // Certain options require the whole series structure to be thrown away
  31632. // and rebuilt
  31633. if (updateAllSeries) {
  31634. chart.getSeriesOrderByLinks().forEach(function (series) {
  31635. // Avoid removed navigator series
  31636. if (series.chart) {
  31637. series.update({}, false);
  31638. }
  31639. }, this);
  31640. }
  31641. // Update size. Redraw is forced.
  31642. newWidth = optionsChart && optionsChart.width;
  31643. newHeight = optionsChart && optionsChart.height;
  31644. if (isString(newHeight)) {
  31645. newHeight = relativeLength(newHeight, newWidth || chart.chartWidth);
  31646. }
  31647. if (
  31648. // In this case, run chart.setSize with newWidth and newHeight which
  31649. // are undefined, only for reflowing chart elements because margin
  31650. // or spacing has been set (#8190)
  31651. runSetSize ||
  31652. // In this case, the size is actually set
  31653. (isNumber(newWidth) && newWidth !== chart.chartWidth) ||
  31654. (isNumber(newHeight) && newHeight !== chart.chartHeight)) {
  31655. chart.setSize(newWidth, newHeight, animation);
  31656. }
  31657. else if (pick(redraw, true)) {
  31658. chart.redraw(animation);
  31659. }
  31660. fireEvent(chart, 'afterUpdate', {
  31661. options: options,
  31662. redraw: redraw,
  31663. animation: animation
  31664. });
  31665. };
  31666. /**
  31667. * Shortcut to set the subtitle options. This can also be done from {@link
  31668. * Chart#update} or {@link Chart#setTitle}.
  31669. *
  31670. * @function Highcharts.Chart#setSubtitle
  31671. *
  31672. * @param {Highcharts.SubtitleOptions} options
  31673. * New subtitle options. The subtitle text itself is set by the
  31674. * `options.text` property.
  31675. */
  31676. Chart.prototype.setSubtitle = function (options, redraw) {
  31677. this.applyDescription('subtitle', options);
  31678. this.layOutTitles(redraw);
  31679. };
  31680. /**
  31681. * Set the caption options. This can also be done from {@link
  31682. * Chart#update}.
  31683. *
  31684. * @function Highcharts.Chart#setCaption
  31685. *
  31686. * @param {Highcharts.CaptionOptions} options
  31687. * New caption options. The caption text itself is set by the
  31688. * `options.text` property.
  31689. */
  31690. Chart.prototype.setCaption = function (options, redraw) {
  31691. this.applyDescription('caption', options);
  31692. this.layOutTitles(redraw);
  31693. };
  31694. /**
  31695. * Display the zoom button, so users can reset zoom to the default view
  31696. * settings.
  31697. *
  31698. * @function Highcharts.Chart#showResetZoom
  31699. *
  31700. * @fires Highcharts.Chart#event:afterShowResetZoom
  31701. * @fires Highcharts.Chart#event:beforeShowResetZoom
  31702. */
  31703. Chart.prototype.showResetZoom = function () {
  31704. var chart = this,
  31705. lang = defaultOptions.lang,
  31706. btnOptions = chart.options.chart.resetZoomButton,
  31707. theme = btnOptions.theme,
  31708. states = theme.states,
  31709. alignTo = (btnOptions.relativeTo === 'chart' ||
  31710. btnOptions.relativeTo === 'spacingBox' ?
  31711. null :
  31712. 'scrollablePlotBox');
  31713. /**
  31714. * @private
  31715. */
  31716. function zoomOut() {
  31717. chart.zoomOut();
  31718. }
  31719. fireEvent(this, 'beforeShowResetZoom', null, function () {
  31720. chart.resetZoomButton = chart.renderer
  31721. .button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
  31722. .attr({
  31723. align: btnOptions.position.align,
  31724. title: lang.resetZoomTitle
  31725. })
  31726. .addClass('highcharts-reset-zoom')
  31727. .add()
  31728. .align(btnOptions.position, false, alignTo);
  31729. });
  31730. fireEvent(this, 'afterShowResetZoom');
  31731. };
  31732. /**
  31733. * Zoom the chart out after a user has zoomed in. See also
  31734. * [Axis.setExtremes](/class-reference/Highcharts.Axis#setExtremes).
  31735. *
  31736. * @function Highcharts.Chart#zoomOut
  31737. *
  31738. * @fires Highcharts.Chart#event:selection
  31739. */
  31740. Chart.prototype.zoomOut = function () {
  31741. fireEvent(this, 'selection', { resetSelection: true }, this.zoom);
  31742. };
  31743. /**
  31744. * Zoom into a given portion of the chart given by axis coordinates.
  31745. *
  31746. * @private
  31747. * @function Highcharts.Chart#zoom
  31748. * @param {Highcharts.SelectEventObject} event
  31749. */
  31750. Chart.prototype.zoom = function (event) {
  31751. var chart = this,
  31752. hasZoomed,
  31753. pointer = chart.pointer,
  31754. displayButton = false,
  31755. mouseDownPos = chart.inverted ? pointer.mouseDownX : pointer.mouseDownY,
  31756. resetZoomButton;
  31757. // If zoom is called with no arguments, reset the axes
  31758. if (!event || event.resetSelection) {
  31759. chart.axes.forEach(function (axis) {
  31760. hasZoomed = axis.zoom();
  31761. });
  31762. pointer.initiated = false; // #6804
  31763. }
  31764. else { // else, zoom in on all axes
  31765. event.xAxis.concat(event.yAxis).forEach(function (axisData) {
  31766. var axis = axisData.axis,
  31767. axisStartPos = chart.inverted ? axis.left : axis.top,
  31768. axisEndPos = chart.inverted ?
  31769. axisStartPos + axis.width : axisStartPos + axis.height,
  31770. isXAxis = axis.isXAxis,
  31771. isWithinPane = false;
  31772. // Check if zoomed area is within the pane (#1289).
  31773. // In case of multiple panes only one pane should be zoomed.
  31774. if ((!isXAxis &&
  31775. mouseDownPos >= axisStartPos &&
  31776. mouseDownPos <= axisEndPos) ||
  31777. isXAxis ||
  31778. !defined(mouseDownPos)) {
  31779. isWithinPane = true;
  31780. }
  31781. // don't zoom more than minRange
  31782. if (pointer[isXAxis ? 'zoomX' : 'zoomY'] && isWithinPane) {
  31783. hasZoomed = axis.zoom(axisData.min, axisData.max);
  31784. if (axis.displayBtn) {
  31785. displayButton = true;
  31786. }
  31787. }
  31788. });
  31789. }
  31790. // Show or hide the Reset zoom button
  31791. resetZoomButton = chart.resetZoomButton;
  31792. if (displayButton && !resetZoomButton) {
  31793. chart.showResetZoom();
  31794. }
  31795. else if (!displayButton && isObject(resetZoomButton)) {
  31796. chart.resetZoomButton = resetZoomButton.destroy();
  31797. }
  31798. // Redraw
  31799. if (hasZoomed) {
  31800. chart.redraw(pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100));
  31801. }
  31802. };
  31803. /**
  31804. * Pan the chart by dragging the mouse across the pane. This function is
  31805. * called on mouse move, and the distance to pan is computed from chartX
  31806. * compared to the first chartX position in the dragging operation.
  31807. *
  31808. * @private
  31809. * @function Highcharts.Chart#pan
  31810. * @param {Highcharts.PointerEventObject} e
  31811. * @param {string} panning
  31812. */
  31813. Chart.prototype.pan = function (e, panning) {
  31814. var chart = this,
  31815. hoverPoints = chart.hoverPoints,
  31816. panningOptions,
  31817. chartOptions = chart.options.chart,
  31818. hasMapNavigation = chart.options.mapNavigation &&
  31819. chart.options.mapNavigation.enabled,
  31820. doRedraw,
  31821. type;
  31822. if (typeof panning === 'object') {
  31823. panningOptions = panning;
  31824. }
  31825. else {
  31826. panningOptions = {
  31827. enabled: panning,
  31828. type: 'x'
  31829. };
  31830. }
  31831. if (chartOptions && chartOptions.panning) {
  31832. chartOptions.panning = panningOptions;
  31833. }
  31834. type = panningOptions.type;
  31835. fireEvent(this, 'pan', { originalEvent: e }, function () {
  31836. // remove active points for shared tooltip
  31837. if (hoverPoints) {
  31838. hoverPoints.forEach(function (point) {
  31839. point.setState();
  31840. });
  31841. }
  31842. // panning axis mapping
  31843. var xy = [1]; // x
  31844. if (type === 'xy') {
  31845. xy = [1, 0];
  31846. }
  31847. else if (type === 'y') {
  31848. xy = [0];
  31849. }
  31850. xy.forEach(function (isX) {
  31851. var axis = chart[isX ? 'xAxis' : 'yAxis'][0], horiz = axis.horiz, mousePos = e[horiz ? 'chartX' : 'chartY'], mouseDown = horiz ? 'mouseDownX' : 'mouseDownY', startPos = chart[mouseDown], halfPointRange = (axis.pointRange || 0) / 2, pointRangeDirection = (axis.reversed && !chart.inverted) ||
  31852. (!axis.reversed && chart.inverted) ?
  31853. -1 :
  31854. 1, extremes = axis.getExtremes(), panMin = axis.toValue(startPos - mousePos, true) +
  31855. halfPointRange * pointRangeDirection, panMax = axis.toValue(startPos + axis.len - mousePos, true) -
  31856. halfPointRange * pointRangeDirection, flipped = panMax < panMin, newMin = flipped ? panMax : panMin, newMax = flipped ? panMin : panMax, hasVerticalPanning = axis.hasVerticalPanning(), paddedMin, paddedMax, spill, panningState = axis.panningState;
  31857. // General calculations of panning state.
  31858. // This is related to using vertical panning. (#11315).
  31859. if (hasVerticalPanning &&
  31860. !isX && (!panningState || panningState.isDirty)) {
  31861. axis.series.forEach(function (series) {
  31862. var processedData = series.getProcessedData(true),
  31863. dataExtremes = series.getExtremes(processedData.yData,
  31864. true);
  31865. if (!panningState) {
  31866. panningState = {
  31867. startMin: Number.MAX_VALUE,
  31868. startMax: -Number.MAX_VALUE
  31869. };
  31870. }
  31871. if (isNumber(dataExtremes.dataMin) &&
  31872. isNumber(dataExtremes.dataMax)) {
  31873. panningState.startMin = Math.min(pick(series.options.threshold, Infinity), dataExtremes.dataMin, panningState.startMin);
  31874. panningState.startMax = Math.max(pick(series.options.threshold, -Infinity), dataExtremes.dataMax, panningState.startMax);
  31875. }
  31876. });
  31877. }
  31878. paddedMin = Math.min(pick(panningState && panningState.startMin, extremes.dataMin), halfPointRange ?
  31879. extremes.min :
  31880. axis.toValue(axis.toPixels(extremes.min) -
  31881. axis.minPixelPadding));
  31882. paddedMax = Math.max(pick(panningState && panningState.startMax, extremes.dataMax), halfPointRange ?
  31883. extremes.max :
  31884. axis.toValue(axis.toPixels(extremes.max) +
  31885. axis.minPixelPadding));
  31886. axis.panningState = panningState;
  31887. // It is not necessary to calculate extremes on ordinal axis,
  31888. // because they are already calculated, so we don't want to
  31889. // override them.
  31890. if (!axis.isOrdinal) {
  31891. // If the new range spills over, either to the min or max,
  31892. // adjust the new range.
  31893. spill = paddedMin - newMin;
  31894. if (spill > 0) {
  31895. newMax += spill;
  31896. newMin = paddedMin;
  31897. }
  31898. spill = newMax - paddedMax;
  31899. if (spill > 0) {
  31900. newMax = paddedMax;
  31901. newMin -= spill;
  31902. }
  31903. // Set new extremes if they are actually new
  31904. if (axis.series.length &&
  31905. newMin !== extremes.min &&
  31906. newMax !== extremes.max &&
  31907. newMin >= paddedMin &&
  31908. newMax <= paddedMax) {
  31909. axis.setExtremes(newMin, newMax, false, false, { trigger: 'pan' });
  31910. if (!chart.resetZoomButton &&
  31911. !hasMapNavigation &&
  31912. // Show reset zoom button only when both newMin and
  31913. // newMax values are between padded axis range.
  31914. newMin !== paddedMin &&
  31915. newMax !== paddedMax &&
  31916. type.match('y')) {
  31917. chart.showResetZoom();
  31918. axis.displayBtn = false;
  31919. }
  31920. doRedraw = true;
  31921. }
  31922. // set new reference for next run:
  31923. chart[mouseDown] = mousePos;
  31924. }
  31925. });
  31926. if (doRedraw) {
  31927. chart.redraw(false);
  31928. }
  31929. css(chart.container, { cursor: 'move' });
  31930. });
  31931. };
  31932. return Chart;
  31933. }());
  31934. extend(Chart.prototype, {
  31935. // Hook for adding callbacks in modules
  31936. callbacks: [],
  31937. /**
  31938. * These collections (arrays) implement `Chart.addSomethig` method used in
  31939. * chart.update() to create new object in the collection. Equivalent for
  31940. * deleting is resolved by simple `Somethig.remove()`.
  31941. *
  31942. * Note: We need to define these references after initializers are bound to
  31943. * chart's prototype.
  31944. */
  31945. collectionsWithInit: {
  31946. // collectionName: [ initializingMethod, [extraArguments] ]
  31947. xAxis: [Chart.prototype.addAxis, [true]],
  31948. yAxis: [Chart.prototype.addAxis, [false]],
  31949. series: [Chart.prototype.addSeries]
  31950. },
  31951. /**
  31952. * These collections (arrays) implement update() methods with support for
  31953. * one-to-one option.
  31954. */
  31955. collectionsWithUpdate: [
  31956. 'xAxis',
  31957. 'yAxis',
  31958. 'zAxis',
  31959. 'series'
  31960. ],
  31961. /**
  31962. * These properties cause isDirtyBox to be set to true when updating. Can be
  31963. * extended from plugins.
  31964. */
  31965. propsRequireDirtyBox: [
  31966. 'backgroundColor',
  31967. 'borderColor',
  31968. 'borderWidth',
  31969. 'borderRadius',
  31970. 'plotBackgroundColor',
  31971. 'plotBackgroundImage',
  31972. 'plotBorderColor',
  31973. 'plotBorderWidth',
  31974. 'plotShadow',
  31975. 'shadow'
  31976. ],
  31977. /**
  31978. * These properties require a full reflow of chart elements, best
  31979. * implemented through running `Chart.setSize` internally (#8190).
  31980. * @type {Array}
  31981. */
  31982. propsRequireReflow: [
  31983. 'margin',
  31984. 'marginTop',
  31985. 'marginRight',
  31986. 'marginBottom',
  31987. 'marginLeft',
  31988. 'spacing',
  31989. 'spacingTop',
  31990. 'spacingRight',
  31991. 'spacingBottom',
  31992. 'spacingLeft'
  31993. ],
  31994. /**
  31995. * These properties cause all series to be updated when updating. Can be
  31996. * extended from plugins.
  31997. */
  31998. propsRequireUpdateSeries: [
  31999. 'chart.inverted',
  32000. 'chart.polar',
  32001. 'chart.ignoreHiddenSeries',
  32002. 'chart.type',
  32003. 'colors',
  32004. 'plotOptions',
  32005. 'time',
  32006. 'tooltip'
  32007. ]
  32008. });
  32009. /**
  32010. * Factory function for basic charts.
  32011. *
  32012. * @example
  32013. * // Render a chart in to div#container
  32014. * let chart = Highcharts.chart('container', {
  32015. * title: {
  32016. * text: 'My chart'
  32017. * },
  32018. * series: [{
  32019. * data: [1, 3, 2, 4]
  32020. * }]
  32021. * });
  32022. *
  32023. * @function Highcharts.chart
  32024. *
  32025. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  32026. * The DOM element to render to, or its id.
  32027. *
  32028. * @param {Highcharts.Options} options
  32029. * The chart options structure.
  32030. *
  32031. * @param {Highcharts.ChartCallbackFunction} [callback]
  32032. * Function to run when the chart has loaded and and all external images
  32033. * are loaded. Defining a
  32034. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  32035. * handler is equivalent.
  32036. *
  32037. * @return {Highcharts.Chart}
  32038. * Returns the Chart object.
  32039. */
  32040. function chart(a, b, c) {
  32041. return new Chart(a, b, c);
  32042. }
  32043. H.chart = chart;
  32044. H.Chart = Chart;
  32045. /* *
  32046. *
  32047. * Export
  32048. *
  32049. * */
  32050. /* *
  32051. *
  32052. * API Declarations
  32053. *
  32054. * */
  32055. /**
  32056. * Callback for chart constructors.
  32057. *
  32058. * @callback Highcharts.ChartCallbackFunction
  32059. *
  32060. * @param {Highcharts.Chart} chart
  32061. * Created chart.
  32062. */
  32063. /**
  32064. * Format a number and return a string based on input settings.
  32065. *
  32066. * @callback Highcharts.NumberFormatterCallbackFunction
  32067. *
  32068. * @param {number} number
  32069. * The input number to format.
  32070. *
  32071. * @param {number} decimals
  32072. * The amount of decimals. A value of -1 preserves the amount in the
  32073. * input number.
  32074. *
  32075. * @param {string} [decimalPoint]
  32076. * The decimal point, defaults to the one given in the lang options, or
  32077. * a dot.
  32078. *
  32079. * @param {string} [thousandsSep]
  32080. * The thousands separator, defaults to the one given in the lang
  32081. * options, or a space character.
  32082. *
  32083. * @return {string} The formatted number.
  32084. */
  32085. /**
  32086. * The chart title. The title has an `update` method that allows modifying the
  32087. * options directly or indirectly via `chart.update`.
  32088. *
  32089. * @interface Highcharts.TitleObject
  32090. * @extends Highcharts.SVGElement
  32091. */ /**
  32092. * Modify options for the title.
  32093. *
  32094. * @function Highcharts.TitleObject#update
  32095. *
  32096. * @param {Highcharts.TitleOptions} titleOptions
  32097. * Options to modify.
  32098. *
  32099. * @param {boolean} [redraw=true]
  32100. * Whether to redraw the chart after the title is altered. If doing more
  32101. * operations on the chart, it is a good idea to set redraw to false and
  32102. * call {@link Chart#redraw} after.
  32103. */
  32104. /**
  32105. * The chart subtitle. The subtitle has an `update` method that
  32106. * allows modifying the options directly or indirectly via
  32107. * `chart.update`.
  32108. *
  32109. * @interface Highcharts.SubtitleObject
  32110. * @extends Highcharts.SVGElement
  32111. */ /**
  32112. * Modify options for the subtitle.
  32113. *
  32114. * @function Highcharts.SubtitleObject#update
  32115. *
  32116. * @param {Highcharts.SubtitleOptions} subtitleOptions
  32117. * Options to modify.
  32118. *
  32119. * @param {boolean} [redraw=true]
  32120. * Whether to redraw the chart after the subtitle is altered. If doing
  32121. * more operations on the chart, it is a good idea to set redraw to false
  32122. * and call {@link Chart#redraw} after.
  32123. */
  32124. /**
  32125. * The chart caption. The caption has an `update` method that
  32126. * allows modifying the options directly or indirectly via
  32127. * `chart.update`.
  32128. *
  32129. * @interface Highcharts.CaptionObject
  32130. * @extends Highcharts.SVGElement
  32131. */ /**
  32132. * Modify options for the caption.
  32133. *
  32134. * @function Highcharts.CaptionObject#update
  32135. *
  32136. * @param {Highcharts.CaptionOptions} captionOptions
  32137. * Options to modify.
  32138. *
  32139. * @param {boolean} [redraw=true]
  32140. * Whether to redraw the chart after the caption is altered. If doing
  32141. * more operations on the chart, it is a good idea to set redraw to false
  32142. * and call {@link Chart#redraw} after.
  32143. */
  32144. /**
  32145. * @interface Highcharts.ChartIsInsideOptionsObject
  32146. */ /**
  32147. * @name Highcharts.ChartIsInsideOptionsObject#ignoreX
  32148. * @type {boolean|undefined}
  32149. */ /**
  32150. * @name Highcharts.ChartIsInsideOptionsObject#ignoreY
  32151. * @type {boolean|undefined}
  32152. */ /**
  32153. * @name Highcharts.ChartIsInsideOptionsObject#inverted
  32154. * @type {boolean|undefined}
  32155. */ /**
  32156. * @name Highcharts.ChartIsInsideOptionsObject#paneCoordinates
  32157. * @type {boolean|undefined}
  32158. */ /**
  32159. * @name Highcharts.ChartIsInsideOptionsObject#series
  32160. * @type {Highcharts.Series|undefined}
  32161. */ /**
  32162. * @name Highcharts.ChartIsInsideOptionsObject#visiblePlotOnly
  32163. * @type {boolean|undefined}
  32164. */
  32165. ''; // include doclets above in transpilat
  32166. return Chart;
  32167. });
  32168. _registerModule(_modules, 'Mixins/LegendSymbol.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  32169. /* *
  32170. *
  32171. * (c) 2010-2021 Torstein Honsi
  32172. *
  32173. * License: www.highcharts.com/license
  32174. *
  32175. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32176. *
  32177. * */
  32178. var merge = U.merge,
  32179. pick = U.pick;
  32180. /* eslint-disable valid-jsdoc */
  32181. /**
  32182. * Legend symbol mixin.
  32183. *
  32184. * @private
  32185. * @mixin Highcharts.LegendSymbolMixin
  32186. */
  32187. var LegendSymbolMixin = H.LegendSymbolMixin = {
  32188. /**
  32189. * Get the series' symbol in the legend
  32190. *
  32191. * @private
  32192. * @function Highcharts.LegendSymbolMixin.drawRectangle
  32193. *
  32194. * @param {Highcharts.Legend} legend
  32195. * The legend object
  32196. *
  32197. * @param {Highcharts.Point|Highcharts.Series} item
  32198. * The series (this) or point
  32199. */
  32200. drawRectangle: function (legend,
  32201. item) {
  32202. var options = legend.options,
  32203. symbolHeight = legend.symbolHeight,
  32204. square = options.squareSymbol,
  32205. symbolWidth = square ? symbolHeight : legend.symbolWidth;
  32206. item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, // #3988
  32207. symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2))
  32208. .addClass('highcharts-point')
  32209. .attr({
  32210. zIndex: 3
  32211. }).add(item.legendGroup);
  32212. },
  32213. /**
  32214. * Get the series' symbol in the legend. This method should be overridable
  32215. * to create custom symbols through
  32216. * Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
  32217. *
  32218. * @private
  32219. * @function Highcharts.LegendSymbolMixin.drawLineMarker
  32220. *
  32221. * @param {Highcharts.Legend} legend
  32222. * The legend object.
  32223. */
  32224. drawLineMarker: function (legend) {
  32225. var options = this.options,
  32226. markerOptions = options.marker,
  32227. radius,
  32228. legendSymbol,
  32229. symbolWidth = legend.symbolWidth,
  32230. symbolHeight = legend.symbolHeight,
  32231. generalRadius = symbolHeight / 2,
  32232. renderer = this.chart.renderer,
  32233. legendItemGroup = this.legendGroup,
  32234. verticalCenter = legend.baseline -
  32235. Math.round(legend.fontMetrics.b * 0.3),
  32236. attr = {};
  32237. // Draw the line
  32238. if (!this.chart.styledMode) {
  32239. attr = {
  32240. 'stroke-width': options.lineWidth || 0
  32241. };
  32242. if (options.dashStyle) {
  32243. attr.dashstyle = options.dashStyle;
  32244. }
  32245. }
  32246. this.legendLine = renderer
  32247. .path([
  32248. ['M', 0, verticalCenter],
  32249. ['L', symbolWidth, verticalCenter]
  32250. ])
  32251. .addClass('highcharts-graph')
  32252. .attr(attr)
  32253. .add(legendItemGroup);
  32254. // Draw the marker
  32255. if (markerOptions && markerOptions.enabled !== false && symbolWidth) {
  32256. // Do not allow the marker to be larger than the symbolHeight
  32257. radius = Math.min(pick(markerOptions.radius, generalRadius), generalRadius);
  32258. // Restrict symbol markers size
  32259. if (this.symbol.indexOf('url') === 0) {
  32260. markerOptions = merge(markerOptions, {
  32261. width: symbolHeight,
  32262. height: symbolHeight
  32263. });
  32264. radius = 0;
  32265. }
  32266. this.legendSymbol = legendSymbol = renderer.symbol(this.symbol, (symbolWidth / 2) - radius, verticalCenter - radius, 2 * radius, 2 * radius, markerOptions)
  32267. .addClass('highcharts-point')
  32268. .add(legendItemGroup);
  32269. legendSymbol.isMarker = true;
  32270. }
  32271. }
  32272. };
  32273. return LegendSymbolMixin;
  32274. });
  32275. _registerModule(_modules, 'Core/Series/Series.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Options.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, H, LegendSymbolMixin, O, palette, Point, SeriesRegistry, SVGElement, U) {
  32276. /* *
  32277. *
  32278. * (c) 2010-2021 Torstein Honsi
  32279. *
  32280. * License: www.highcharts.com/license
  32281. *
  32282. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32283. *
  32284. * */
  32285. var animObject = A.animObject,
  32286. setAnimation = A.setAnimation;
  32287. var hasTouch = H.hasTouch,
  32288. svg = H.svg,
  32289. win = H.win;
  32290. var defaultOptions = O.defaultOptions;
  32291. var seriesTypes = SeriesRegistry.seriesTypes;
  32292. var addEvent = U.addEvent,
  32293. arrayMax = U.arrayMax,
  32294. arrayMin = U.arrayMin,
  32295. clamp = U.clamp,
  32296. cleanRecursively = U.cleanRecursively,
  32297. correctFloat = U.correctFloat,
  32298. defined = U.defined,
  32299. erase = U.erase,
  32300. error = U.error,
  32301. extend = U.extend,
  32302. find = U.find,
  32303. fireEvent = U.fireEvent,
  32304. getNestedProperty = U.getNestedProperty,
  32305. isArray = U.isArray,
  32306. isFunction = U.isFunction,
  32307. isNumber = U.isNumber,
  32308. isString = U.isString,
  32309. merge = U.merge,
  32310. objectEach = U.objectEach,
  32311. pick = U.pick,
  32312. removeEvent = U.removeEvent,
  32313. splat = U.splat,
  32314. syncTimeout = U.syncTimeout;
  32315. /* *
  32316. *
  32317. * Class
  32318. *
  32319. * */
  32320. /**
  32321. * This is the base series prototype that all other series types inherit from.
  32322. * A new series is initialized either through the
  32323. * [series](https://api.highcharts.com/highcharts/series)
  32324. * option structure, or after the chart is initialized, through
  32325. * {@link Highcharts.Chart#addSeries}.
  32326. *
  32327. * The object can be accessed in a number of ways. All series and point event
  32328. * handlers give a reference to the `series` object. The chart object has a
  32329. * {@link Highcharts.Chart#series|series} property that is a collection of all
  32330. * the chart's series. The point objects and axis objects also have the same
  32331. * reference.
  32332. *
  32333. * Another way to reference the series programmatically is by `id`. Add an id
  32334. * in the series configuration options, and get the series object by
  32335. * {@link Highcharts.Chart#get}.
  32336. *
  32337. * Configuration options for the series are given in three levels. Options for
  32338. * all series in a chart are given in the
  32339. * [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
  32340. * object. Then options for all series of a specific type
  32341. * are given in the plotOptions of that type, for example `plotOptions.line`.
  32342. * Next, options for one single series are given in the series array, or as
  32343. * arguments to `chart.addSeries`.
  32344. *
  32345. * The data in the series is stored in various arrays.
  32346. *
  32347. * - First, `series.options.data` contains all the original config options for
  32348. * each point whether added by options or methods like `series.addPoint`.
  32349. *
  32350. * - Next, `series.data` contains those values converted to points, but in case
  32351. * the series data length exceeds the `cropThreshold`, or if the data is
  32352. * grouped, `series.data` doesn't contain all the points. It only contains the
  32353. * points that have been created on demand.
  32354. *
  32355. * - Then there's `series.points` that contains all currently visible point
  32356. * objects. In case of cropping, the cropped-away points are not part of this
  32357. * array. The `series.points` array starts at `series.cropStart` compared to
  32358. * `series.data` and `series.options.data`. If however the series data is
  32359. * grouped, these can't be correlated one to one.
  32360. *
  32361. * - `series.xData` and `series.processedXData` contain clean x values,
  32362. * equivalent to `series.data` and `series.points`.
  32363. *
  32364. * - `series.yData` and `series.processedYData` contain clean y values,
  32365. * equivalent to `series.data` and `series.points`.
  32366. *
  32367. * @class
  32368. * @name Highcharts.Series
  32369. *
  32370. * @param {Highcharts.Chart} chart
  32371. * The chart instance.
  32372. *
  32373. * @param {Highcharts.SeriesOptionsType|object} options
  32374. * The series options.
  32375. */
  32376. var Series = /** @class */ (function () {
  32377. function Series() {
  32378. /* *
  32379. *
  32380. * Static Functions
  32381. *
  32382. * */
  32383. this._i = void 0;
  32384. this.chart = void 0;
  32385. this.data = void 0;
  32386. this.eventOptions = void 0;
  32387. this.eventsToUnbind = void 0;
  32388. this.index = void 0;
  32389. this.linkedSeries = void 0;
  32390. this.options = void 0;
  32391. this.points = void 0;
  32392. this.processedXData = void 0;
  32393. this.processedYData = void 0;
  32394. this.tooltipOptions = void 0;
  32395. this.userOptions = void 0;
  32396. this.xAxis = void 0;
  32397. this.yAxis = void 0;
  32398. this.zones = void 0;
  32399. /** eslint-enable valid-jsdoc */
  32400. }
  32401. /* *
  32402. *
  32403. * Functions
  32404. *
  32405. * */
  32406. /* eslint-disable valid-jsdoc */
  32407. Series.prototype.init = function (chart, userOptions) {
  32408. fireEvent(this, 'init', { options: userOptions });
  32409. var series = this,
  32410. events,
  32411. chartSeries = chart.series,
  32412. lastSeries;
  32413. // A lookup over those events that are added by _options_ (not
  32414. // programmatically). These are updated through Series.update()
  32415. // (#10861).
  32416. this.eventOptions = this.eventOptions || {};
  32417. // The 'eventsToUnbind' property moved from prototype into the
  32418. // Series init to avoid reference to the same array between
  32419. // the different series and charts. #12959, #13937
  32420. this.eventsToUnbind = [];
  32421. /**
  32422. * Read only. The chart that the series belongs to.
  32423. *
  32424. * @name Highcharts.Series#chart
  32425. * @type {Highcharts.Chart}
  32426. */
  32427. series.chart = chart;
  32428. /**
  32429. * Read only. The series' type, like "line", "area", "column" etc.
  32430. * The type in the series options anc can be altered using
  32431. * {@link Series#update}.
  32432. *
  32433. * @name Highcharts.Series#type
  32434. * @type {string}
  32435. */
  32436. /**
  32437. * Read only. The series' current options. To update, use
  32438. * {@link Series#update}.
  32439. *
  32440. * @name Highcharts.Series#options
  32441. * @type {Highcharts.SeriesOptionsType}
  32442. */
  32443. series.options = series.setOptions(userOptions);
  32444. var options = series.options;
  32445. series.linkedSeries = [];
  32446. // bind the axes
  32447. series.bindAxes();
  32448. extend(series, {
  32449. /**
  32450. * The series name as given in the options. Defaults to
  32451. * "Series {n}".
  32452. *
  32453. * @name Highcharts.Series#name
  32454. * @type {string}
  32455. */
  32456. name: options.name,
  32457. state: '',
  32458. /**
  32459. * Read only. The series' visibility state as set by {@link
  32460. * Series#show}, {@link Series#hide}, or in the initial
  32461. * configuration.
  32462. *
  32463. * @name Highcharts.Series#visible
  32464. * @type {boolean}
  32465. */
  32466. visible: options.visible !== false,
  32467. /**
  32468. * Read only. The series' selected state as set by {@link
  32469. * Highcharts.Series#select}.
  32470. *
  32471. * @name Highcharts.Series#selected
  32472. * @type {boolean}
  32473. */
  32474. selected: options.selected === true // false by default
  32475. });
  32476. // Register event listeners
  32477. events = options.events;
  32478. objectEach(events, function (event, eventType) {
  32479. if (isFunction(event)) {
  32480. // If event does not exist, or is changed by Series.update
  32481. if (series.eventOptions[eventType] !== event) {
  32482. // Remove existing if set by option
  32483. if (isFunction(series.eventOptions[eventType])) {
  32484. removeEvent(series, eventType, series.eventOptions[eventType]);
  32485. }
  32486. series.eventOptions[eventType] = event;
  32487. addEvent(series, eventType, event);
  32488. }
  32489. }
  32490. });
  32491. if ((events && events.click) ||
  32492. (options.point &&
  32493. options.point.events &&
  32494. options.point.events.click) ||
  32495. options.allowPointSelect) {
  32496. chart.runTrackerClick = true;
  32497. }
  32498. series.getColor();
  32499. series.getSymbol();
  32500. // Initialize the parallel data arrays
  32501. series.parallelArrays.forEach(function (key) {
  32502. if (!series[key + 'Data']) {
  32503. series[key + 'Data'] = [];
  32504. }
  32505. });
  32506. // Mark cartesian
  32507. if (series.isCartesian) {
  32508. chart.hasCartesianSeries = true;
  32509. }
  32510. // Get the index and register the series in the chart. The index is
  32511. // one more than the current latest series index (#5960).
  32512. if (chartSeries.length) {
  32513. lastSeries = chartSeries[chartSeries.length - 1];
  32514. }
  32515. series._i = pick(lastSeries && lastSeries._i, -1) + 1;
  32516. series.opacity = series.options.opacity;
  32517. // Insert the series and re-order all series above the insertion
  32518. // point.
  32519. chart.orderSeries(this.insert(chartSeries));
  32520. // Set options for series with sorting and set data later.
  32521. if (options.dataSorting && options.dataSorting.enabled) {
  32522. series.setDataSortingOptions();
  32523. }
  32524. else if (!series.points && !series.data) {
  32525. series.setData(options.data, false);
  32526. }
  32527. fireEvent(this, 'afterInit');
  32528. };
  32529. /**
  32530. * Check whether the series item is itself or inherits from a certain
  32531. * series type.
  32532. *
  32533. * @function Highcharts.Series#is
  32534. * @param {string} type The type of series to check for, can be either
  32535. * featured or custom series types. For example `column`, `pie`,
  32536. * `ohlc` etc.
  32537. *
  32538. * @return {boolean}
  32539. * True if this item is or inherits from the given type.
  32540. */
  32541. Series.prototype.is = function (type) {
  32542. return seriesTypes[type] && this instanceof seriesTypes[type];
  32543. };
  32544. /**
  32545. * Insert the series in a collection with other series, either the chart
  32546. * series or yAxis series, in the correct order according to the index
  32547. * option. Used internally when adding series.
  32548. *
  32549. * @private
  32550. * @function Highcharts.Series#insert
  32551. * @param {Array<Highcharts.Series>} collection
  32552. * A collection of series, like `chart.series` or `xAxis.series`.
  32553. * @return {number}
  32554. * The index of the series in the collection.
  32555. */
  32556. Series.prototype.insert = function (collection) {
  32557. var indexOption = this.options.index,
  32558. i;
  32559. // Insert by index option
  32560. if (isNumber(indexOption)) {
  32561. i = collection.length;
  32562. while (i--) {
  32563. // Loop down until the interted element has higher index
  32564. if (indexOption >=
  32565. pick(collection[i].options.index, collection[i]._i)) {
  32566. collection.splice(i + 1, 0, this);
  32567. break;
  32568. }
  32569. }
  32570. if (i === -1) {
  32571. collection.unshift(this);
  32572. }
  32573. i = i + 1;
  32574. // Or just push it to the end
  32575. }
  32576. else {
  32577. collection.push(this);
  32578. }
  32579. return pick(i, collection.length - 1);
  32580. };
  32581. /**
  32582. * Set the xAxis and yAxis properties of cartesian series, and register
  32583. * the series in the `axis.series` array.
  32584. *
  32585. * @private
  32586. * @function Highcharts.Series#bindAxes
  32587. */
  32588. Series.prototype.bindAxes = function () {
  32589. var series = this,
  32590. seriesOptions = series.options,
  32591. chart = series.chart,
  32592. axisOptions;
  32593. fireEvent(this, 'bindAxes', null, function () {
  32594. // repeat for xAxis and yAxis
  32595. (series.axisTypes || []).forEach(function (AXIS) {
  32596. var index = 0;
  32597. // loop through the chart's axis objects
  32598. chart[AXIS].forEach(function (axis) {
  32599. axisOptions = axis.options;
  32600. // apply if the series xAxis or yAxis option mathches
  32601. // the number of the axis, or if undefined, use the
  32602. // first axis
  32603. if ((seriesOptions[AXIS] === index &&
  32604. !axisOptions.isInternal) ||
  32605. (typeof seriesOptions[AXIS] !==
  32606. 'undefined' &&
  32607. seriesOptions[AXIS] === axisOptions.id) ||
  32608. (typeof seriesOptions[AXIS] ===
  32609. 'undefined' &&
  32610. axisOptions.index === 0)) {
  32611. // register this series in the axis.series lookup
  32612. series.insert(axis.series);
  32613. // set this series.xAxis or series.yAxis reference
  32614. /**
  32615. * Read only. The unique xAxis object associated
  32616. * with the series.
  32617. *
  32618. * @name Highcharts.Series#xAxis
  32619. * @type {Highcharts.Axis}
  32620. */
  32621. /**
  32622. * Read only. The unique yAxis object associated
  32623. * with the series.
  32624. *
  32625. * @name Highcharts.Series#yAxis
  32626. * @type {Highcharts.Axis}
  32627. */
  32628. series[AXIS] = axis;
  32629. // mark dirty for redraw
  32630. axis.isDirty = true;
  32631. }
  32632. if (!axisOptions.isInternal) {
  32633. index++;
  32634. }
  32635. });
  32636. // The series needs an X and an Y axis
  32637. if (!series[AXIS] &&
  32638. series.optionalAxis !== AXIS) {
  32639. error(18, true, chart);
  32640. }
  32641. });
  32642. });
  32643. fireEvent(this, 'afterBindAxes');
  32644. };
  32645. /**
  32646. * For simple series types like line and column, the data values are
  32647. * held in arrays like xData and yData for quick lookup to find extremes
  32648. * and more. For multidimensional series like bubble and map, this can
  32649. * be extended with arrays like zData and valueData by adding to the
  32650. * `series.parallelArrays` array.
  32651. *
  32652. * @private
  32653. * @function Highcharts.Series#updateParallelArrays
  32654. */
  32655. Series.prototype.updateParallelArrays = function (point, i) {
  32656. var series = point.series,
  32657. args = arguments,
  32658. fn = isNumber(i) ?
  32659. // Insert the value in the given position
  32660. function (key) {
  32661. var val = key === 'y' && series.toYData ?
  32662. series.toYData(point) :
  32663. point[key];
  32664. series[key + 'Data'][i] = val;
  32665. } :
  32666. // Apply the method specified in i with the following
  32667. // arguments as arguments
  32668. function (key) {
  32669. Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
  32670. };
  32671. series.parallelArrays.forEach(fn);
  32672. };
  32673. /**
  32674. * Define hasData functions for series. These return true if there
  32675. * are data points on this series within the plot area.
  32676. *
  32677. * @private
  32678. * @function Highcharts.Series#hasData
  32679. * @return {boolean}
  32680. */
  32681. Series.prototype.hasData = function () {
  32682. return ((this.visible &&
  32683. typeof this.dataMax !== 'undefined' &&
  32684. typeof this.dataMin !== 'undefined') || ( // #3703
  32685. this.visible &&
  32686. this.yData &&
  32687. this.yData.length > 0) // #9758
  32688. );
  32689. };
  32690. /**
  32691. * Return an auto incremented x value based on the pointStart and
  32692. * pointInterval options. This is only used if an x value is not given
  32693. * for the point that calls autoIncrement.
  32694. *
  32695. * @private
  32696. * @function Highcharts.Series#autoIncrement
  32697. * @return {number}
  32698. */
  32699. Series.prototype.autoIncrement = function () {
  32700. var options = this.options,
  32701. xIncrement = this.xIncrement,
  32702. date,
  32703. pointInterval,
  32704. pointIntervalUnit = options.pointIntervalUnit,
  32705. time = this.chart.time;
  32706. xIncrement = pick(xIncrement, options.pointStart, 0);
  32707. this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
  32708. // Added code for pointInterval strings
  32709. if (pointIntervalUnit) {
  32710. date = new time.Date(xIncrement);
  32711. if (pointIntervalUnit === 'day') {
  32712. time.set('Date', date, time.get('Date', date) + pointInterval);
  32713. }
  32714. else if (pointIntervalUnit === 'month') {
  32715. time.set('Month', date, time.get('Month', date) + pointInterval);
  32716. }
  32717. else if (pointIntervalUnit === 'year') {
  32718. time.set('FullYear', date, time.get('FullYear', date) + pointInterval);
  32719. }
  32720. pointInterval = date.getTime() - xIncrement;
  32721. }
  32722. this.xIncrement = xIncrement + pointInterval;
  32723. return xIncrement;
  32724. };
  32725. /**
  32726. * Internal function to set properties for series if data sorting is
  32727. * enabled.
  32728. *
  32729. * @private
  32730. * @function Highcharts.Series#setDataSortingOptions
  32731. */
  32732. Series.prototype.setDataSortingOptions = function () {
  32733. var options = this.options;
  32734. extend(this, {
  32735. requireSorting: false,
  32736. sorted: false,
  32737. enabledDataSorting: true,
  32738. allowDG: false
  32739. });
  32740. // To allow unsorted data for column series.
  32741. if (!defined(options.pointRange)) {
  32742. options.pointRange = 1;
  32743. }
  32744. };
  32745. /**
  32746. * Set the series options by merging from the options tree. Called
  32747. * internally on initializing and updating series. This function will
  32748. * not redraw the series. For API usage, use {@link Series#update}.
  32749. * @private
  32750. * @function Highcharts.Series#setOptions
  32751. *
  32752. * @param {Highcharts.SeriesOptionsType} itemOptions
  32753. * The series options.
  32754. *
  32755. * @return {Highcharts.SeriesOptionsType}
  32756. *
  32757. * @fires Highcharts.Series#event:afterSetOptions
  32758. */
  32759. Series.prototype.setOptions = function (itemOptions) {
  32760. var chart = this.chart,
  32761. chartOptions = chart.options,
  32762. plotOptions = chartOptions.plotOptions,
  32763. userOptions = chart.userOptions || {},
  32764. seriesUserOptions = merge(itemOptions),
  32765. options,
  32766. zones,
  32767. zone,
  32768. styledMode = chart.styledMode,
  32769. e = {
  32770. plotOptions: plotOptions,
  32771. userOptions: seriesUserOptions
  32772. };
  32773. fireEvent(this, 'setOptions', e);
  32774. // These may be modified by the event
  32775. var typeOptions = e.plotOptions[this.type],
  32776. userPlotOptions = (userOptions.plotOptions || {});
  32777. // use copy to prevent undetected changes (#9762)
  32778. /**
  32779. * Contains series options by the user without defaults.
  32780. * @name Highcharts.Series#userOptions
  32781. * @type {Highcharts.SeriesOptionsType}
  32782. */
  32783. this.userOptions = e.userOptions;
  32784. options = merge(typeOptions, plotOptions.series,
  32785. // #3881, chart instance plotOptions[type] should trump
  32786. // plotOptions.series
  32787. userOptions.plotOptions &&
  32788. userOptions.plotOptions[this.type], seriesUserOptions);
  32789. // The tooltip options are merged between global and series specific
  32790. // options. Importance order asscendingly:
  32791. // globals: (1)tooltip, (2)plotOptions.series,
  32792. // (3)plotOptions[this.type]
  32793. // init userOptions with possible later updates: 4-6 like 1-3 and
  32794. // (7)this series options
  32795. this.tooltipOptions = merge(defaultOptions.tooltip, // 1
  32796. defaultOptions.plotOptions.series &&
  32797. defaultOptions.plotOptions.series.tooltip, // 2
  32798. defaultOptions.plotOptions[this.type].tooltip, // 3
  32799. chartOptions.tooltip.userOptions, // 4
  32800. plotOptions.series &&
  32801. plotOptions.series.tooltip, // 5
  32802. plotOptions[this.type].tooltip, // 6
  32803. seriesUserOptions.tooltip // 7
  32804. );
  32805. // When shared tooltip, stickyTracking is true by default,
  32806. // unless user says otherwise.
  32807. this.stickyTracking = pick(seriesUserOptions.stickyTracking, userPlotOptions[this.type] &&
  32808. userPlotOptions[this.type].stickyTracking, userPlotOptions.series && userPlotOptions.series.stickyTracking, (this.tooltipOptions.shared && !this.noSharedTooltip ?
  32809. true :
  32810. options.stickyTracking));
  32811. // Delete marker object if not allowed (#1125)
  32812. if (typeOptions.marker === null) {
  32813. delete options.marker;
  32814. }
  32815. // Handle color zones
  32816. this.zoneAxis = options.zoneAxis;
  32817. zones = this.zones = (options.zones || []).slice();
  32818. if ((options.negativeColor || options.negativeFillColor) &&
  32819. !options.zones) {
  32820. zone = {
  32821. value: options[this.zoneAxis + 'Threshold'] ||
  32822. options.threshold ||
  32823. 0,
  32824. className: 'highcharts-negative'
  32825. };
  32826. if (!styledMode) {
  32827. zone.color = options.negativeColor;
  32828. zone.fillColor = options.negativeFillColor;
  32829. }
  32830. zones.push(zone);
  32831. }
  32832. if (zones.length) { // Push one extra zone for the rest
  32833. if (defined(zones[zones.length - 1].value)) {
  32834. zones.push(styledMode ? {} : {
  32835. color: this.color,
  32836. fillColor: this.fillColor
  32837. });
  32838. }
  32839. }
  32840. fireEvent(this, 'afterSetOptions', { options: options });
  32841. return options;
  32842. };
  32843. /**
  32844. * Return series name in "Series {Number}" format or the one defined by
  32845. * a user. This method can be simply overridden as series name format
  32846. * can vary (e.g. technical indicators).
  32847. *
  32848. * @function Highcharts.Series#getName
  32849. *
  32850. * @return {string}
  32851. * The series name.
  32852. */
  32853. Series.prototype.getName = function () {
  32854. // #4119
  32855. return pick(this.options.name, 'Series ' + (this.index + 1));
  32856. };
  32857. /**
  32858. * @private
  32859. * @function Highcharts.Series#getCyclic
  32860. */
  32861. Series.prototype.getCyclic = function (prop, value, defaults) {
  32862. 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;
  32863. if (!value) {
  32864. // Pick up either the colorIndex option, or the _colorIndex
  32865. // after Series.update()
  32866. setting = pick(userOptions[indexName], userOptions['_' + indexName]);
  32867. if (defined(setting)) { // after Series.update()
  32868. i = setting;
  32869. }
  32870. else {
  32871. // #6138
  32872. if (!chart.series.length) {
  32873. chart[counterName] = 0;
  32874. }
  32875. userOptions['_' + indexName] = i =
  32876. chart[counterName] % len;
  32877. chart[counterName] += 1;
  32878. }
  32879. if (defaults) {
  32880. value = defaults[i];
  32881. }
  32882. }
  32883. // Set the colorIndex
  32884. if (typeof i !== 'undefined') {
  32885. this[indexName] = i;
  32886. }
  32887. this[prop] = value;
  32888. };
  32889. /**
  32890. * Get the series' color based on either the options or pulled from
  32891. * global options.
  32892. *
  32893. * @private
  32894. * @function Highcharts.Series#getColor
  32895. */
  32896. Series.prototype.getColor = function () {
  32897. if (this.chart.styledMode) {
  32898. this.getCyclic('color');
  32899. }
  32900. else if (this.options.colorByPoint) {
  32901. this.color = palette.neutralColor20;
  32902. }
  32903. else {
  32904. this.getCyclic('color', this.options.color ||
  32905. defaultOptions.plotOptions[this.type].color, this.chart.options.colors);
  32906. }
  32907. };
  32908. /**
  32909. * Get all points' instances created for this series.
  32910. *
  32911. * @private
  32912. * @function Highcharts.Series#getPointsCollection
  32913. * @return {Array<Highcharts.Point>}
  32914. */
  32915. Series.prototype.getPointsCollection = function () {
  32916. return (this.hasGroupedData ? this.points : this.data) || [];
  32917. };
  32918. /**
  32919. * Get the series' symbol based on either the options or pulled from
  32920. * global options.
  32921. *
  32922. * @private
  32923. * @function Highcharts.Series#getSymbol
  32924. * @return {void}
  32925. */
  32926. Series.prototype.getSymbol = function () {
  32927. var seriesMarkerOption = this.options.marker;
  32928. this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
  32929. };
  32930. /**
  32931. * Finds the index of an existing point that matches the given point
  32932. * options.
  32933. *
  32934. * @private
  32935. * @function Highcharts.Series#findPointIndex
  32936. * @param {Highcharts.PointOptionsObject} optionsObject
  32937. * The options of the point.
  32938. * @param {number} fromIndex
  32939. * The index to start searching from, used for optimizing
  32940. * series with required sorting.
  32941. * @returns {number|undefined}
  32942. * Returns the index of a matching point, or undefined if no
  32943. * match is found.
  32944. */
  32945. Series.prototype.findPointIndex = function (optionsObject, fromIndex) {
  32946. var id = optionsObject.id,
  32947. x = optionsObject.x,
  32948. oldData = this.points,
  32949. matchingPoint,
  32950. matchedById,
  32951. pointIndex,
  32952. matchKey,
  32953. dataSorting = this.options.dataSorting;
  32954. if (id) {
  32955. matchingPoint = this.chart.get(id);
  32956. }
  32957. else if (this.linkedParent || this.enabledDataSorting) {
  32958. matchKey = (dataSorting && dataSorting.matchByName) ?
  32959. 'name' : 'index';
  32960. matchingPoint = find(oldData, function (oldPoint) {
  32961. return !oldPoint.touched && oldPoint[matchKey] ===
  32962. optionsObject[matchKey];
  32963. });
  32964. // Add unmatched point as a new point
  32965. if (!matchingPoint) {
  32966. return void 0;
  32967. }
  32968. }
  32969. if (matchingPoint) {
  32970. pointIndex = matchingPoint && matchingPoint.index;
  32971. if (typeof pointIndex !== 'undefined') {
  32972. matchedById = true;
  32973. }
  32974. }
  32975. // Search for the same X in the existing data set
  32976. if (typeof pointIndex === 'undefined' && isNumber(x)) {
  32977. pointIndex = this.xData.indexOf(x, fromIndex);
  32978. }
  32979. // Reduce pointIndex if data is cropped
  32980. if (pointIndex !== -1 &&
  32981. typeof pointIndex !== 'undefined' &&
  32982. this.cropped) {
  32983. pointIndex = (pointIndex >= this.cropStart) ?
  32984. pointIndex - this.cropStart : pointIndex;
  32985. }
  32986. if (!matchedById &&
  32987. oldData[pointIndex] && oldData[pointIndex].touched) {
  32988. pointIndex = void 0;
  32989. }
  32990. return pointIndex;
  32991. };
  32992. /**
  32993. * Internal function called from setData. If the point count is the same
  32994. * as is was, or if there are overlapping X values, just run
  32995. * Point.update which is cheaper, allows animation, and keeps references
  32996. * to points. This also allows adding or removing points if the X-es
  32997. * don't match.
  32998. *
  32999. * @private
  33000. * @function Highcharts.Series#updateData
  33001. */
  33002. Series.prototype.updateData = function (data, animation) {
  33003. var options = this.options,
  33004. dataSorting = options.dataSorting,
  33005. oldData = this.points,
  33006. pointsToAdd = [],
  33007. hasUpdatedByKey,
  33008. i,
  33009. point,
  33010. lastIndex,
  33011. requireSorting = this.requireSorting,
  33012. equalLength = data.length === oldData.length,
  33013. succeeded = true;
  33014. this.xIncrement = null;
  33015. // Iterate the new data
  33016. data.forEach(function (pointOptions, i) {
  33017. var id,
  33018. x,
  33019. pointIndex,
  33020. optionsObject = (defined(pointOptions) &&
  33021. this.pointClass.prototype.optionsToObject.call({ series: this },
  33022. pointOptions)) || {};
  33023. // Get the x of the new data point
  33024. x = optionsObject.x;
  33025. id = optionsObject.id;
  33026. if (id || isNumber(x)) {
  33027. pointIndex = this.findPointIndex(optionsObject, lastIndex);
  33028. // Matching X not found
  33029. // or used already due to ununique x values (#8995),
  33030. // add point (but later)
  33031. if (pointIndex === -1 ||
  33032. typeof pointIndex === 'undefined') {
  33033. pointsToAdd.push(pointOptions);
  33034. // Matching X found, update
  33035. }
  33036. else if (oldData[pointIndex] &&
  33037. pointOptions !== options.data[pointIndex]) {
  33038. oldData[pointIndex].update(pointOptions, false, null, false);
  33039. // Mark it touched, below we will remove all points that
  33040. // are not touched.
  33041. oldData[pointIndex].touched = true;
  33042. // Speed optimize by only searching after last known
  33043. // index. Performs ~20% bettor on large data sets.
  33044. if (requireSorting) {
  33045. lastIndex = pointIndex + 1;
  33046. }
  33047. // Point exists, no changes, don't remove it
  33048. }
  33049. else if (oldData[pointIndex]) {
  33050. oldData[pointIndex].touched = true;
  33051. }
  33052. // If the length is equal and some of the nodes had a
  33053. // match in the same position, we don't want to remove
  33054. // non-matches.
  33055. if (!equalLength ||
  33056. i !== pointIndex ||
  33057. (dataSorting && dataSorting.enabled) ||
  33058. this.hasDerivedData) {
  33059. hasUpdatedByKey = true;
  33060. }
  33061. }
  33062. else {
  33063. // Gather all points that are not matched
  33064. pointsToAdd.push(pointOptions);
  33065. }
  33066. }, this);
  33067. // Remove points that don't exist in the updated data set
  33068. if (hasUpdatedByKey) {
  33069. i = oldData.length;
  33070. while (i--) {
  33071. point = oldData[i];
  33072. if (point && !point.touched && point.remove) {
  33073. point.remove(false, animation);
  33074. }
  33075. }
  33076. // If we did not find keys (ids or x-values), and the length is the
  33077. // same, update one-to-one
  33078. }
  33079. else if (equalLength && (!dataSorting || !dataSorting.enabled)) {
  33080. data.forEach(function (point, i) {
  33081. // .update doesn't exist on a linked, hidden series (#3709)
  33082. // (#10187)
  33083. if (oldData[i].update && point !== oldData[i].y) {
  33084. oldData[i].update(point, false, null, false);
  33085. }
  33086. });
  33087. // Don't add new points since those configs are used above
  33088. pointsToAdd.length = 0;
  33089. // Did not succeed in updating data
  33090. }
  33091. else {
  33092. succeeded = false;
  33093. }
  33094. oldData.forEach(function (point) {
  33095. if (point) {
  33096. point.touched = false;
  33097. }
  33098. });
  33099. if (!succeeded) {
  33100. return false;
  33101. }
  33102. // Add new points
  33103. pointsToAdd.forEach(function (point) {
  33104. this.addPoint(point, false, null, null, false);
  33105. }, this);
  33106. if (this.xIncrement === null &&
  33107. this.xData &&
  33108. this.xData.length) {
  33109. this.xIncrement = arrayMax(this.xData);
  33110. this.autoIncrement();
  33111. }
  33112. return true;
  33113. };
  33114. /**
  33115. * Apply a new set of data to the series and optionally redraw it. The
  33116. * new data array is passed by reference (except in case of
  33117. * `updatePoints`), and may later be mutated when updating the chart
  33118. * data.
  33119. *
  33120. * Note the difference in behaviour when setting the same amount of
  33121. * points, or a different amount of points, as handled by the
  33122. * `updatePoints` parameter.
  33123. *
  33124. * @sample highcharts/members/series-setdata/
  33125. * Set new data from a button
  33126. * @sample highcharts/members/series-setdata-pie/
  33127. * Set data in a pie
  33128. * @sample stock/members/series-setdata/
  33129. * Set new data in Highcharts Stock
  33130. * @sample maps/members/series-setdata/
  33131. * Set new data in Highmaps
  33132. *
  33133. * @function Highcharts.Series#setData
  33134. *
  33135. * @param {Array<Highcharts.PointOptionsType>} data
  33136. * Takes an array of data in the same format as described under
  33137. * `series.{type}.data` for the given series type, for example a
  33138. * line series would take data in the form described under
  33139. * [series.line.data](https://api.highcharts.com/highcharts/series.line.data).
  33140. *
  33141. * @param {boolean} [redraw=true]
  33142. * Whether to redraw the chart after the series is altered. If
  33143. * doing more operations on the chart, it is a good idea to set
  33144. * redraw to false and call {@link Chart#redraw} after.
  33145. *
  33146. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  33147. * When the updated data is the same length as the existing data,
  33148. * points will be updated by default, and animation visualizes
  33149. * how the points are changed. Set false to disable animation, or
  33150. * a configuration object to set duration or easing.
  33151. *
  33152. * @param {boolean} [updatePoints=true]
  33153. * When this is true, points will be updated instead of replaced
  33154. * whenever possible. This occurs a) when the updated data is the
  33155. * same length as the existing data, b) when points are matched
  33156. * by their id's, or c) when points can be matched by X values.
  33157. * This allows updating with animation and performs better. In
  33158. * this case, the original array is not passed by reference. Set
  33159. * `false` to prevent.
  33160. */
  33161. Series.prototype.setData = function (data, redraw, animation, updatePoints) {
  33162. var series = this,
  33163. oldData = series.points,
  33164. oldDataLength = (oldData && oldData.length) || 0,
  33165. dataLength,
  33166. options = series.options,
  33167. chart = series.chart,
  33168. dataSorting = options.dataSorting,
  33169. firstPoint = null,
  33170. xAxis = series.xAxis,
  33171. i,
  33172. turboThreshold = options.turboThreshold,
  33173. pt,
  33174. xData = this.xData,
  33175. yData = this.yData,
  33176. pointArrayMap = series.pointArrayMap,
  33177. valueCount = pointArrayMap && pointArrayMap.length,
  33178. keys = options.keys,
  33179. indexOfX = 0,
  33180. indexOfY = 1,
  33181. updatedData;
  33182. data = data || [];
  33183. dataLength = data.length;
  33184. redraw = pick(redraw, true);
  33185. if (dataSorting && dataSorting.enabled) {
  33186. data = this.sortData(data);
  33187. }
  33188. // First try to run Point.update which is cheaper, allows animation,
  33189. // and keeps references to points.
  33190. if (updatePoints !== false &&
  33191. dataLength &&
  33192. oldDataLength &&
  33193. !series.cropped &&
  33194. !series.hasGroupedData &&
  33195. series.visible &&
  33196. // Soft updating has no benefit in boost, and causes JS error
  33197. // (#8355)
  33198. !series.isSeriesBoosting) {
  33199. updatedData = this.updateData(data, animation);
  33200. }
  33201. if (!updatedData) {
  33202. // Reset properties
  33203. series.xIncrement = null;
  33204. series.colorCounter = 0; // for series with colorByPoint (#1547)
  33205. // Update parallel arrays
  33206. this.parallelArrays.forEach(function (key) {
  33207. series[key + 'Data'].length = 0;
  33208. });
  33209. // In turbo mode, only one- or twodimensional arrays of numbers
  33210. // are allowed. The first value is tested, and we assume that
  33211. // all the rest are defined the same way. Although the 'for'
  33212. // loops are similar, they are repeated inside each if-else
  33213. // conditional for max performance.
  33214. if (turboThreshold && dataLength > turboThreshold) {
  33215. firstPoint = series.getFirstValidPoint(data);
  33216. if (isNumber(firstPoint)) { // assume all points are numbers
  33217. for (i = 0; i < dataLength; i++) {
  33218. xData[i] = this.autoIncrement();
  33219. yData[i] = data[i];
  33220. }
  33221. // Assume all points are arrays when first point is
  33222. }
  33223. else if (isArray(firstPoint)) {
  33224. if (valueCount) { // [x, low, high] or [x, o, h, l, c]
  33225. for (i = 0; i < dataLength; i++) {
  33226. pt = data[i];
  33227. xData[i] = pt[0];
  33228. yData[i] =
  33229. pt.slice(1, valueCount + 1);
  33230. }
  33231. }
  33232. else { // [x, y]
  33233. if (keys) {
  33234. indexOfX = keys.indexOf('x');
  33235. indexOfY = keys.indexOf('y');
  33236. indexOfX = indexOfX >= 0 ? indexOfX : 0;
  33237. indexOfY = indexOfY >= 0 ? indexOfY : 1;
  33238. }
  33239. for (i = 0; i < dataLength; i++) {
  33240. pt = data[i];
  33241. xData[i] = pt[indexOfX];
  33242. yData[i] = pt[indexOfY];
  33243. }
  33244. }
  33245. }
  33246. else {
  33247. // Highcharts expects configs to be numbers or arrays in
  33248. // turbo mode
  33249. error(12, false, chart);
  33250. }
  33251. }
  33252. else {
  33253. for (i = 0; i < dataLength; i++) {
  33254. // stray commas in oldIE:
  33255. if (typeof data[i] !== 'undefined') {
  33256. pt = { series: series };
  33257. series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
  33258. series.updateParallelArrays(pt, i);
  33259. }
  33260. }
  33261. }
  33262. // Forgetting to cast strings to numbers is a common caveat when
  33263. // handling CSV or JSON
  33264. if (yData && isString(yData[0])) {
  33265. error(14, true, chart);
  33266. }
  33267. series.data = [];
  33268. series.options.data = series.userOptions.data = data;
  33269. // destroy old points
  33270. i = oldDataLength;
  33271. while (i--) {
  33272. if (oldData[i] && oldData[i].destroy) {
  33273. oldData[i].destroy();
  33274. }
  33275. }
  33276. // reset minRange (#878)
  33277. if (xAxis) {
  33278. xAxis.minRange = xAxis.userMinRange;
  33279. }
  33280. // redraw
  33281. series.isDirty = chart.isDirtyBox = true;
  33282. series.isDirtyData = !!oldData;
  33283. animation = false;
  33284. }
  33285. // Typically for pie series, points need to be processed and
  33286. // generated prior to rendering the legend
  33287. if (options.legendType === 'point') {
  33288. this.processData();
  33289. this.generatePoints();
  33290. }
  33291. if (redraw) {
  33292. chart.redraw(animation);
  33293. }
  33294. };
  33295. /**
  33296. * Internal function to sort series data
  33297. *
  33298. * @private
  33299. * @function Highcharts.Series#sortData
  33300. *
  33301. * @param {Array<Highcharts.PointOptionsType>} data
  33302. * Force data grouping.
  33303. *
  33304. * @return {Array<Highcharts.PointOptionsObject>}
  33305. */
  33306. Series.prototype.sortData = function (data) {
  33307. var series = this,
  33308. options = series.options,
  33309. dataSorting = options.dataSorting,
  33310. sortKey = dataSorting.sortKey || 'y',
  33311. sortedData,
  33312. getPointOptionsObject = function (series,
  33313. pointOptions) {
  33314. return (defined(pointOptions) &&
  33315. series.pointClass.prototype.optionsToObject.call({
  33316. series: series
  33317. },
  33318. pointOptions)) || {};
  33319. };
  33320. data.forEach(function (pointOptions, i) {
  33321. data[i] = getPointOptionsObject(series, pointOptions);
  33322. data[i].index = i;
  33323. }, this);
  33324. // Sorting
  33325. sortedData = data.concat().sort(function (a, b) {
  33326. var aValue = getNestedProperty(sortKey,
  33327. a);
  33328. var bValue = getNestedProperty(sortKey,
  33329. b);
  33330. return bValue < aValue ? -1 : bValue > aValue ? 1 : 0;
  33331. });
  33332. // Set x value depending on the position in the array
  33333. sortedData.forEach(function (point, i) {
  33334. point.x = i;
  33335. }, this);
  33336. // Set the same x for linked series points if they don't have their
  33337. // own sorting
  33338. if (series.linkedSeries) {
  33339. series.linkedSeries.forEach(function (linkedSeries) {
  33340. var options = linkedSeries.options,
  33341. seriesData = options.data;
  33342. if ((!options.dataSorting ||
  33343. !options.dataSorting.enabled) &&
  33344. seriesData) {
  33345. seriesData.forEach(function (pointOptions, i) {
  33346. seriesData[i] = getPointOptionsObject(linkedSeries, pointOptions);
  33347. if (data[i]) {
  33348. seriesData[i].x = data[i].x;
  33349. seriesData[i].index = i;
  33350. }
  33351. });
  33352. linkedSeries.setData(seriesData, false);
  33353. }
  33354. });
  33355. }
  33356. return data;
  33357. };
  33358. /**
  33359. * Internal function to process the data by cropping away unused data
  33360. * points if the series is longer than the crop threshold. This saves
  33361. * computing time for large series.
  33362. *
  33363. * @private
  33364. * @function Highcharts.Series#getProcessedData
  33365. * @param {boolean} [forceExtremesFromAll]
  33366. * Force getting extremes of a total series data range.
  33367. * @return {Highcharts.SeriesProcessedDataObject}
  33368. */
  33369. Series.prototype.getProcessedData = function (forceExtremesFromAll) {
  33370. var series = this,
  33371. // copied during slice operation:
  33372. processedXData = series.xData,
  33373. processedYData = series.yData,
  33374. dataLength = processedXData.length,
  33375. croppedData,
  33376. cropStart = 0,
  33377. cropped,
  33378. distance,
  33379. closestPointRange,
  33380. xAxis = series.xAxis,
  33381. i, // loop variable
  33382. options = series.options,
  33383. cropThreshold = options.cropThreshold,
  33384. getExtremesFromAll = forceExtremesFromAll ||
  33385. series.getExtremesFromAll ||
  33386. options.getExtremesFromAll, // #4599
  33387. isCartesian = series.isCartesian,
  33388. xExtremes,
  33389. val2lin = xAxis && xAxis.val2lin,
  33390. isLog = !!(xAxis && xAxis.logarithmic),
  33391. throwOnUnsorted = series.requireSorting,
  33392. min,
  33393. max;
  33394. if (xAxis) {
  33395. // corrected for log axis (#3053)
  33396. xExtremes = xAxis.getExtremes();
  33397. min = xExtremes.min;
  33398. max = xExtremes.max;
  33399. }
  33400. // optionally filter out points outside the plot area
  33401. if (isCartesian &&
  33402. series.sorted &&
  33403. !getExtremesFromAll &&
  33404. (!cropThreshold ||
  33405. dataLength > cropThreshold ||
  33406. series.forceCrop)) {
  33407. // it's outside current extremes
  33408. if (processedXData[dataLength - 1] < min ||
  33409. processedXData[0] > max) {
  33410. processedXData = [];
  33411. processedYData = [];
  33412. // only crop if it's actually spilling out
  33413. }
  33414. else if (series.yData && (processedXData[0] < min ||
  33415. processedXData[dataLength - 1] > max)) {
  33416. croppedData = this.cropData(series.xData, series.yData, min, max);
  33417. processedXData = croppedData.xData;
  33418. processedYData = croppedData.yData;
  33419. cropStart = croppedData.start;
  33420. cropped = true;
  33421. }
  33422. }
  33423. // Find the closest distance between processed points
  33424. i = processedXData.length || 1;
  33425. while (--i) {
  33426. distance = (isLog ?
  33427. (val2lin(processedXData[i]) -
  33428. val2lin(processedXData[i - 1])) :
  33429. (processedXData[i] -
  33430. processedXData[i - 1]));
  33431. if (distance > 0 &&
  33432. (typeof closestPointRange === 'undefined' ||
  33433. distance < closestPointRange)) {
  33434. closestPointRange = distance;
  33435. // Unsorted data is not supported by the line tooltip, as well
  33436. // as data grouping and navigation in Stock charts (#725) and
  33437. // width calculation of columns (#1900)
  33438. }
  33439. else if (distance < 0 && throwOnUnsorted) {
  33440. error(15, false, series.chart);
  33441. throwOnUnsorted = false; // Only once
  33442. }
  33443. }
  33444. return {
  33445. xData: processedXData,
  33446. yData: processedYData,
  33447. cropped: cropped,
  33448. cropStart: cropStart,
  33449. closestPointRange: closestPointRange
  33450. };
  33451. };
  33452. /**
  33453. * Internal function to apply processed data.
  33454. * In Highcharts Stock, this function is extended to provide data grouping.
  33455. *
  33456. * @private
  33457. * @function Highcharts.Series#processData
  33458. * @param {boolean} [force]
  33459. * Force data grouping.
  33460. * @return {boolean|undefined}
  33461. */
  33462. Series.prototype.processData = function (force) {
  33463. var series = this,
  33464. xAxis = series.xAxis,
  33465. processedData;
  33466. // If the series data or axes haven't changed, don't go through
  33467. // this. Return false to pass the message on to override methods
  33468. // like in data grouping.
  33469. if (series.isCartesian &&
  33470. !series.isDirty &&
  33471. !xAxis.isDirty &&
  33472. !series.yAxis.isDirty &&
  33473. !force) {
  33474. return false;
  33475. }
  33476. processedData = series.getProcessedData();
  33477. // Record the properties
  33478. series.cropped = processedData.cropped; // undefined or true
  33479. series.cropStart = processedData.cropStart;
  33480. series.processedXData = processedData.xData;
  33481. series.processedYData = processedData.yData;
  33482. series.closestPointRange = series.basePointRange = processedData.closestPointRange;
  33483. };
  33484. /**
  33485. * Iterate over xData and crop values between min and max. Returns
  33486. * object containing crop start/end cropped xData with corresponding
  33487. * part of yData, dataMin and dataMax within the cropped range.
  33488. *
  33489. * @private
  33490. * @function Highcharts.Series#cropData
  33491. * @param {Array<number>} xData
  33492. * @param {Array<number>} yData
  33493. * @param {number} min
  33494. * @param {number} max
  33495. * @param {number} [cropShoulder]
  33496. * @return {Highcharts.SeriesCropDataObject}
  33497. */
  33498. Series.prototype.cropData = function (xData, yData, min, max, cropShoulder) {
  33499. var dataLength = xData.length,
  33500. cropStart = 0,
  33501. cropEnd = dataLength,
  33502. i,
  33503. j;
  33504. // line-type series need one point outside
  33505. cropShoulder = pick(cropShoulder, this.cropShoulder);
  33506. // iterate up to find slice start
  33507. for (i = 0; i < dataLength; i++) {
  33508. if (xData[i] >= min) {
  33509. cropStart = Math.max(0, i - cropShoulder);
  33510. break;
  33511. }
  33512. }
  33513. // proceed to find slice end
  33514. for (j = i; j < dataLength; j++) {
  33515. if (xData[j] > max) {
  33516. cropEnd = j + cropShoulder;
  33517. break;
  33518. }
  33519. }
  33520. return {
  33521. xData: xData.slice(cropStart, cropEnd),
  33522. yData: yData.slice(cropStart, cropEnd),
  33523. start: cropStart,
  33524. end: cropEnd
  33525. };
  33526. };
  33527. /**
  33528. * Generate the data point after the data has been processed by cropping
  33529. * away unused points and optionally grouped in Highcharts Stock.
  33530. *
  33531. * @private
  33532. * @function Highcharts.Series#generatePoints
  33533. */
  33534. Series.prototype.generatePoints = function () {
  33535. var series = this,
  33536. options = series.options,
  33537. dataOptions = options.data,
  33538. data = series.data,
  33539. dataLength,
  33540. processedXData = series.processedXData,
  33541. processedYData = series.processedYData,
  33542. PointClass = series.pointClass,
  33543. processedDataLength = processedXData.length,
  33544. cropStart = series.cropStart || 0,
  33545. cursor,
  33546. hasGroupedData = series.hasGroupedData,
  33547. keys = options.keys,
  33548. point,
  33549. points = [],
  33550. i,
  33551. groupCropStartIndex = (options.dataGrouping &&
  33552. options.dataGrouping.groupAll ?
  33553. cropStart :
  33554. 0);
  33555. if (!data && !hasGroupedData) {
  33556. var arr = [];
  33557. arr.length = dataOptions.length;
  33558. data = series.data = arr;
  33559. }
  33560. if (keys && hasGroupedData) {
  33561. // grouped data has already applied keys (#6590)
  33562. series.options.keys = false;
  33563. }
  33564. for (i = 0; i < processedDataLength; i++) {
  33565. cursor = cropStart + i;
  33566. if (!hasGroupedData) {
  33567. point = data[cursor];
  33568. // #970:
  33569. if (!point &&
  33570. typeof dataOptions[cursor] !== 'undefined') {
  33571. data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
  33572. }
  33573. }
  33574. else {
  33575. // splat the y data in case of ohlc data array
  33576. point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
  33577. /**
  33578. * Highcharts Stock only. If a point object is created by data
  33579. * grouping, it doesn't reflect actual points in the raw
  33580. * data. In this case, the `dataGroup` property holds
  33581. * information that points back to the raw data.
  33582. *
  33583. * - `dataGroup.start` is the index of the first raw data
  33584. * point in the group.
  33585. *
  33586. * - `dataGroup.length` is the amount of points in the
  33587. * group.
  33588. *
  33589. * @product highstock
  33590. *
  33591. * @name Highcharts.Point#dataGroup
  33592. * @type {Highcharts.DataGroupingInfoObject|undefined}
  33593. */
  33594. point.dataGroup = series.groupMap[groupCropStartIndex + i];
  33595. if (point.dataGroup.options) {
  33596. point.options = point.dataGroup.options;
  33597. extend(point, point.dataGroup.options);
  33598. // Collision of props and options (#9770)
  33599. delete point.dataLabels;
  33600. }
  33601. }
  33602. if (point) { // #6279
  33603. /**
  33604. * Contains the point's index in the `Series.points` array.
  33605. *
  33606. * @name Highcharts.Point#index
  33607. * @type {number}
  33608. * @readonly
  33609. */
  33610. // For faster access in Point.update
  33611. point.index = hasGroupedData ? (groupCropStartIndex + i) : cursor;
  33612. points[i] = point;
  33613. }
  33614. }
  33615. // restore keys options (#6590)
  33616. series.options.keys = keys;
  33617. // Hide cropped-away points - this only runs when the number of
  33618. // points is above cropThreshold, or when swithching view from
  33619. // non-grouped data to grouped data (#637)
  33620. if (data &&
  33621. (processedDataLength !== (dataLength = data.length) ||
  33622. hasGroupedData)) {
  33623. for (i = 0; i < dataLength; i++) {
  33624. // when has grouped data, clear all points
  33625. if (i === cropStart && !hasGroupedData) {
  33626. i += processedDataLength;
  33627. }
  33628. if (data[i]) {
  33629. data[i].destroyElements();
  33630. data[i].plotX = void 0; // #1003
  33631. }
  33632. }
  33633. }
  33634. /**
  33635. * Read only. An array containing those values converted to points.
  33636. * In case the series data length exceeds the `cropThreshold`, or if
  33637. * the data is grouped, `series.data` doesn't contain all the
  33638. * points. Also, in case a series is hidden, the `data` array may be
  33639. * empty. To access raw values, `series.options.data` will always be
  33640. * up to date. `Series.data` only contains the points that have been
  33641. * created on demand. To modify the data, use
  33642. * {@link Highcharts.Series#setData} or
  33643. * {@link Highcharts.Point#update}.
  33644. *
  33645. * @see Series.points
  33646. *
  33647. * @name Highcharts.Series#data
  33648. * @type {Array<Highcharts.Point>}
  33649. */
  33650. series.data = data;
  33651. /**
  33652. * An array containing all currently visible point objects. In case
  33653. * of cropping, the cropped-away points are not part of this array.
  33654. * The `series.points` array starts at `series.cropStart` compared
  33655. * to `series.data` and `series.options.data`. If however the series
  33656. * data is grouped, these can't be correlated one to one. To modify
  33657. * the data, use {@link Highcharts.Series#setData} or
  33658. * {@link Highcharts.Point#update}.
  33659. *
  33660. * @name Highcharts.Series#points
  33661. * @type {Array<Highcharts.Point>}
  33662. */
  33663. series.points = points;
  33664. fireEvent(this, 'afterGeneratePoints');
  33665. };
  33666. /**
  33667. * Get current X extremes for the visible data.
  33668. *
  33669. * @private
  33670. * @function Highcharts.Series#getXExtremes
  33671. *
  33672. * @param {Array<number>} xData
  33673. * The data to inspect. Defaults to the current data within the visible
  33674. * range.
  33675. *
  33676. * @return {Highcharts.RangeObject}
  33677. */
  33678. Series.prototype.getXExtremes = function (xData) {
  33679. return {
  33680. min: arrayMin(xData),
  33681. max: arrayMax(xData)
  33682. };
  33683. };
  33684. /**
  33685. * Calculate Y extremes for the visible data. The result is returned
  33686. * as an object with `dataMin` and `dataMax` properties.
  33687. *
  33688. * @private
  33689. * @function Highcharts.Series#getExtremes
  33690. *
  33691. * @param {Array<number>} [yData]
  33692. * The data to inspect. Defaults to the current data within the visible
  33693. * range.
  33694. * @param {boolean} [forceExtremesFromAll]
  33695. * Force getting extremes of a total series data range.
  33696. *
  33697. * @return {Highcharts.DataExtremesObject}
  33698. */
  33699. Series.prototype.getExtremes = function (yData, forceExtremesFromAll) {
  33700. var xAxis = this.xAxis,
  33701. yAxis = this.yAxis,
  33702. xData = this.processedXData || this.xData,
  33703. yDataLength,
  33704. activeYData = [],
  33705. activeCounter = 0,
  33706. // #2117, need to compensate for log X axis
  33707. xExtremes,
  33708. xMin = 0,
  33709. xMax = 0,
  33710. validValue,
  33711. withinRange,
  33712. // Handle X outside the viewed area. This does not work with
  33713. // non-sorted data like scatter (#7639).
  33714. shoulder = this.requireSorting ? this.cropShoulder : 0,
  33715. positiveValuesOnly = yAxis ? yAxis.positiveValuesOnly : false,
  33716. x,
  33717. y,
  33718. i,
  33719. j;
  33720. yData = yData || this.stackedYData || this.processedYData || [];
  33721. yDataLength = yData.length;
  33722. if (xAxis) {
  33723. xExtremes = xAxis.getExtremes();
  33724. xMin = xExtremes.min;
  33725. xMax = xExtremes.max;
  33726. }
  33727. for (i = 0; i < yDataLength; i++) {
  33728. x = xData[i];
  33729. y = yData[i];
  33730. // For points within the visible range, including the first
  33731. // point outside the visible range (#7061), consider y extremes.
  33732. validValue = ((isNumber(y) || isArray(y)) &&
  33733. ((y.length || y > 0) || !positiveValuesOnly));
  33734. withinRange = (forceExtremesFromAll ||
  33735. this.getExtremesFromAll ||
  33736. this.options.getExtremesFromAll ||
  33737. this.cropped ||
  33738. !xAxis || // for colorAxis support
  33739. ((xData[i + shoulder] || x) >= xMin &&
  33740. (xData[i - shoulder] || x) <= xMax));
  33741. if (validValue && withinRange) {
  33742. j = y.length;
  33743. if (j) { // array, like ohlc or range data
  33744. while (j--) {
  33745. if (isNumber(y[j])) { // #7380, #11513
  33746. activeYData[activeCounter++] = y[j];
  33747. }
  33748. }
  33749. }
  33750. else {
  33751. activeYData[activeCounter++] = y;
  33752. }
  33753. }
  33754. }
  33755. var dataExtremes = {
  33756. dataMin: arrayMin(activeYData),
  33757. dataMax: arrayMax(activeYData)
  33758. };
  33759. fireEvent(this, 'afterGetExtremes', { dataExtremes: dataExtremes });
  33760. return dataExtremes;
  33761. };
  33762. /**
  33763. * Set the current data extremes as `dataMin` and `dataMax` on the
  33764. * Series item. Use this only when the series properties should be
  33765. * updated.
  33766. *
  33767. * @private
  33768. * @function Highcharts.Series#applyExtremes
  33769. */
  33770. Series.prototype.applyExtremes = function () {
  33771. var dataExtremes = this.getExtremes();
  33772. /**
  33773. * Contains the minimum value of the series' data point. Some series
  33774. * types like `networkgraph` do not support this property as they
  33775. * lack a `y`-value.
  33776. * @name Highcharts.Series#dataMin
  33777. * @type {number|undefined}
  33778. * @readonly
  33779. */
  33780. this.dataMin = dataExtremes.dataMin;
  33781. /**
  33782. * Contains the maximum value of the series' data point. Some series
  33783. * types like `networkgraph` do not support this property as they
  33784. * lack a `y`-value.
  33785. * @name Highcharts.Series#dataMax
  33786. * @type {number|undefined}
  33787. * @readonly
  33788. */
  33789. this.dataMax = dataExtremes.dataMax;
  33790. return dataExtremes;
  33791. };
  33792. /**
  33793. * Find and return the first non null point in the data
  33794. *
  33795. * @private
  33796. * @function Highcharts.Series.getFirstValidPoint
  33797. *
  33798. * @param {Array<Highcharts.PointOptionsType>} data
  33799. * Array of options for points
  33800. *
  33801. * @return {Highcharts.PointOptionsType}
  33802. */
  33803. Series.prototype.getFirstValidPoint = function (data) {
  33804. var firstPoint = null,
  33805. dataLength = data.length,
  33806. i = 0;
  33807. while (firstPoint === null && i < dataLength) {
  33808. firstPoint = data[i];
  33809. i++;
  33810. }
  33811. return firstPoint;
  33812. };
  33813. /**
  33814. * Translate data points from raw data values to chart specific
  33815. * positioning data needed later in the `drawPoints` and `drawGraph`
  33816. * functions. This function can be overridden in plugins and custom
  33817. * series type implementations.
  33818. *
  33819. * @function Highcharts.Series#translate
  33820. *
  33821. * @fires Highcharts.Series#events:translate
  33822. */
  33823. Series.prototype.translate = function () {
  33824. if (!this.processedXData) { // hidden series
  33825. this.processData();
  33826. }
  33827. this.generatePoints();
  33828. var series = this,
  33829. options = series.options,
  33830. stacking = options.stacking,
  33831. xAxis = series.xAxis,
  33832. categories = xAxis.categories,
  33833. enabledDataSorting = series.enabledDataSorting,
  33834. yAxis = series.yAxis,
  33835. points = series.points,
  33836. dataLength = points.length,
  33837. hasModifyValue = !!series.modifyValue,
  33838. i,
  33839. pointPlacement = series.pointPlacementToXValue(), // #7860
  33840. dynamicallyPlaced = Boolean(pointPlacement),
  33841. threshold = options.threshold,
  33842. stackThreshold = options.startFromThreshold ? threshold : 0,
  33843. plotX,
  33844. lastPlotX,
  33845. stackIndicator,
  33846. zoneAxis = this.zoneAxis || 'y',
  33847. closestPointRangePx = Number.MAX_VALUE;
  33848. /**
  33849. * Plotted coordinates need to be within a limited range. Drawing
  33850. * too far outside the viewport causes various rendering issues
  33851. * (#3201, #3923, #7555).
  33852. * @private
  33853. */
  33854. function limitedRange(val) {
  33855. return clamp(val, -1e5, 1e5);
  33856. }
  33857. // Translate each point
  33858. for (i = 0; i < dataLength; i++) {
  33859. var point = points[i],
  33860. xValue = point.x,
  33861. yValue = point.y,
  33862. yBottom = point.low,
  33863. stack = stacking && yAxis.stacking && yAxis.stacking.stacks[(series.negStacks &&
  33864. yValue <
  33865. (stackThreshold ? 0 : threshold) ?
  33866. '-' :
  33867. '') + series.stackKey],
  33868. pointStack = void 0,
  33869. stackValues = void 0;
  33870. if (yAxis.positiveValuesOnly && !yAxis.validatePositiveValue(yValue) ||
  33871. xAxis.positiveValuesOnly && !xAxis.validatePositiveValue(xValue)) {
  33872. point.isNull = true;
  33873. }
  33874. // Get the plotX translation
  33875. point.plotX = plotX = correctFloat(// #5236
  33876. limitedRange(xAxis.translate(// #3923
  33877. xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags')) // #3923
  33878. );
  33879. // Calculate the bottom y value for stacked series
  33880. if (stacking &&
  33881. series.visible &&
  33882. stack &&
  33883. stack[xValue]) {
  33884. stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
  33885. if (!point.isNull) {
  33886. pointStack = stack[xValue];
  33887. stackValues =
  33888. pointStack.points[stackIndicator.key];
  33889. }
  33890. }
  33891. if (isArray(stackValues)) {
  33892. yBottom = stackValues[0];
  33893. yValue = stackValues[1];
  33894. if (yBottom === stackThreshold &&
  33895. stackIndicator.key ===
  33896. stack[xValue].base) {
  33897. yBottom = pick((isNumber(threshold) && threshold), yAxis.min);
  33898. }
  33899. // #1200, #1232
  33900. if (yAxis.positiveValuesOnly && yBottom <= 0) {
  33901. yBottom = null;
  33902. }
  33903. point.total = point.stackTotal = pointStack.total;
  33904. point.percentage =
  33905. pointStack.total &&
  33906. (point.y / pointStack.total * 100);
  33907. point.stackY = yValue;
  33908. // Place the stack label
  33909. // in case of variwide series (where widths of points are
  33910. // different in most cases), stack labels are positioned
  33911. // wrongly, so the call of the setOffset is omited here and
  33912. // labels are correctly positioned later, at the end of the
  33913. // variwide's translate function (#10962)
  33914. if (!series.irregularWidths) {
  33915. pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
  33916. }
  33917. }
  33918. // Set translated yBottom or remove it
  33919. point.yBottom = defined(yBottom) ?
  33920. limitedRange(yAxis.translate(yBottom, 0, 1, 0, 1)) :
  33921. null;
  33922. // general hook, used for Highcharts Stock compare mode
  33923. if (hasModifyValue) {
  33924. yValue = series.modifyValue(yValue, point);
  33925. }
  33926. // Set the the plotY value, reset it for redraws
  33927. // #3201
  33928. point.plotY = void 0;
  33929. if (isNumber(yValue)) {
  33930. var translated = yAxis.translate(yValue,
  33931. false,
  33932. true,
  33933. false,
  33934. true);
  33935. if (typeof translated !== 'undefined') {
  33936. point.plotY = limitedRange(translated);
  33937. }
  33938. }
  33939. point.isInside = this.isPointInside(point);
  33940. // Set client related positions for mouse tracking
  33941. point.clientX = dynamicallyPlaced ?
  33942. correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) :
  33943. plotX; // #1514, #5383, #5518
  33944. // Negative points. For bubble charts, this means negative z
  33945. // values (#9728)
  33946. point.negative = point[zoneAxis] < (options[zoneAxis + 'Threshold'] ||
  33947. threshold ||
  33948. 0);
  33949. // some API data
  33950. point.category = (categories &&
  33951. typeof categories[point.x] !== 'undefined' ?
  33952. categories[point.x] :
  33953. point.x);
  33954. // Determine auto enabling of markers (#3635, #5099)
  33955. if (!point.isNull && point.visible !== false) {
  33956. if (typeof lastPlotX !== 'undefined') {
  33957. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
  33958. }
  33959. lastPlotX = plotX;
  33960. }
  33961. // Find point zone
  33962. point.zone = (this.zones.length && point.getZone());
  33963. // Animate new points with data sorting
  33964. if (!point.graphic && series.group && enabledDataSorting) {
  33965. point.isNew = true;
  33966. }
  33967. }
  33968. series.closestPointRangePx = closestPointRangePx;
  33969. fireEvent(this, 'afterTranslate');
  33970. };
  33971. /**
  33972. * Return the series points with null points filtered out.
  33973. *
  33974. * @function Highcharts.Series#getValidPoints
  33975. *
  33976. * @param {Array<Highcharts.Point>} [points]
  33977. * The points to inspect, defaults to {@link Series.points}.
  33978. *
  33979. * @param {boolean} [insideOnly=false]
  33980. * Whether to inspect only the points that are inside the visible view.
  33981. *
  33982. * @param {boolean} [allowNull=false]
  33983. * Whether to allow null points to pass as valid points.
  33984. *
  33985. * @return {Array<Highcharts.Point>}
  33986. * The valid points.
  33987. */
  33988. Series.prototype.getValidPoints = function (points, insideOnly, allowNull) {
  33989. var chart = this.chart;
  33990. // #3916, #5029, #5085
  33991. return (points || this.points || []).filter(function (point) {
  33992. if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, { inverted: chart.inverted })) {
  33993. return false;
  33994. }
  33995. return point.visible !== false &&
  33996. (allowNull || !point.isNull);
  33997. });
  33998. };
  33999. /**
  34000. * Get the clipping for the series. Could be called for a series to
  34001. * initiate animating the clip or to set the final clip (only width
  34002. * and x).
  34003. *
  34004. * @private
  34005. * @function Highcharts.Series#getClip
  34006. *
  34007. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  34008. * Initialize the animation.
  34009. *
  34010. * @param {boolean} [finalBox]
  34011. * Final size for the clip - end state for the animation.
  34012. *
  34013. * @return {Highcharts.Dictionary<number>}
  34014. */
  34015. Series.prototype.getClipBox = function (animation, finalBox) {
  34016. var series = this,
  34017. options = series.options,
  34018. chart = series.chart,
  34019. inverted = chart.inverted,
  34020. xAxis = series.xAxis,
  34021. yAxis = xAxis && series.yAxis,
  34022. clipBox,
  34023. scrollablePlotAreaOptions = chart.options.chart.scrollablePlotArea || {};
  34024. if (animation && options.clip === false && yAxis) {
  34025. // support for not clipped series animation (#10450)
  34026. clipBox = inverted ? {
  34027. y: -chart.chartWidth + yAxis.len + yAxis.pos,
  34028. height: chart.chartWidth,
  34029. width: chart.chartHeight,
  34030. x: -chart.chartHeight + xAxis.len + xAxis.pos
  34031. } : {
  34032. y: -yAxis.pos,
  34033. height: chart.chartHeight,
  34034. width: chart.chartWidth,
  34035. x: -xAxis.pos
  34036. };
  34037. // x and width will be changed later when setting for animation
  34038. // initial state in Series.setClip
  34039. }
  34040. else {
  34041. clipBox = series.clipBox || chart.clipBox;
  34042. if (finalBox) {
  34043. clipBox.width = chart.plotSizeX;
  34044. clipBox.x = (chart.scrollablePixelsX || 0) *
  34045. (scrollablePlotAreaOptions.scrollPositionX || 0);
  34046. }
  34047. }
  34048. return !finalBox ? clipBox : {
  34049. width: clipBox.width,
  34050. x: clipBox.x
  34051. };
  34052. };
  34053. /**
  34054. * Get the shared clip key, creating it if it doesn't exist.
  34055. *
  34056. * @private
  34057. * @function Highcharts.Series#getSharedClipKey
  34058. */
  34059. Series.prototype.getSharedClipKey = function (animation) {
  34060. if (this.sharedClipKey) {
  34061. return this.sharedClipKey;
  34062. }
  34063. var sharedClipKey = [
  34064. animation && animation.duration,
  34065. animation && animation.easing,
  34066. animation && animation.defer,
  34067. this.getClipBox(animation).height,
  34068. this.options.xAxis,
  34069. this.options.yAxis
  34070. ].join(',');
  34071. if (this.options.clip !== false || animation) {
  34072. this.sharedClipKey = sharedClipKey;
  34073. }
  34074. return sharedClipKey;
  34075. };
  34076. /**
  34077. * Set the clipping for the series. For animated series it is called
  34078. * twice, first to initiate animating the clip then the second time
  34079. * without the animation to set the final clip.
  34080. *
  34081. * @private
  34082. * @function Highcharts.Series#setClip
  34083. */
  34084. Series.prototype.setClip = function (animation) {
  34085. var chart = this.chart,
  34086. options = this.options,
  34087. renderer = chart.renderer,
  34088. inverted = chart.inverted,
  34089. seriesClipBox = this.clipBox,
  34090. clipBox = this.getClipBox(animation),
  34091. sharedClipKey = this.getSharedClipKey(animation), // #4526
  34092. clipRect = chart.sharedClips[sharedClipKey],
  34093. markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34094. if (animation) {
  34095. clipBox.width = 0;
  34096. if (inverted) {
  34097. clipBox.x = chart.plotHeight +
  34098. (options.clip !== false ? 0 : chart.plotTop);
  34099. }
  34100. }
  34101. // If a clipping rectangle with the same properties is currently
  34102. // present in the chart, use that.
  34103. if (!clipRect) {
  34104. // When animation is set, prepare the initial positions
  34105. if (animation) {
  34106. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect =
  34107. renderer.clipRect(
  34108. // include the width of the first marker
  34109. inverted ? (chart.plotSizeX || 0) + 99 : -99, inverted ? -chart.plotLeft : -chart.plotTop, 99, inverted ? chart.chartWidth : chart.chartHeight);
  34110. }
  34111. chart.sharedClips[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
  34112. // Create hashmap for series indexes
  34113. clipRect.count = { length: 0 };
  34114. // When the series is rendered again before starting animating, in
  34115. // compliance to a responsive rule
  34116. }
  34117. else if (!chart.hasLoaded) {
  34118. clipRect.attr(clipBox);
  34119. }
  34120. if (animation) {
  34121. if (!clipRect.count[this.index]) {
  34122. clipRect.count[this.index] = true;
  34123. clipRect.count.length += 1;
  34124. }
  34125. }
  34126. if (options.clip !== false || animation) {
  34127. this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
  34128. this.markerGroup.clip(markerClipRect);
  34129. }
  34130. // Remove the shared clipping rectangle when all series are shown
  34131. if (!animation) {
  34132. if (clipRect.count[this.index]) {
  34133. delete clipRect.count[this.index];
  34134. clipRect.count.length -= 1;
  34135. }
  34136. if (clipRect.count.length === 0) {
  34137. if (!seriesClipBox) {
  34138. chart.sharedClips[sharedClipKey] = clipRect.destroy();
  34139. }
  34140. if (markerClipRect) {
  34141. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect.destroy();
  34142. }
  34143. }
  34144. }
  34145. };
  34146. /**
  34147. * Animate in the series. Called internally twice. First with the `init`
  34148. * parameter set to true, which sets up the initial state of the
  34149. * animation. Then when ready, it is called with the `init` parameter
  34150. * undefined, in order to perform the actual animation. After the
  34151. * second run, the function is removed.
  34152. *
  34153. * @function Highcharts.Series#animate
  34154. *
  34155. * @param {boolean} [init]
  34156. * Initialize the animation.
  34157. */
  34158. Series.prototype.animate = function (init) {
  34159. var series = this,
  34160. chart = series.chart,
  34161. animation = animObject(series.options.animation),
  34162. sharedClipKey = this.sharedClipKey;
  34163. // Initialize the animation. Set up the clipping rectangle.
  34164. if (init) {
  34165. series.setClip(animation);
  34166. // Run the animation
  34167. }
  34168. else if (sharedClipKey) {
  34169. var clipRect = chart.sharedClips[sharedClipKey];
  34170. var markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34171. var finalBox = series.getClipBox(animation,
  34172. true);
  34173. if (clipRect) {
  34174. clipRect.animate(finalBox, animation);
  34175. }
  34176. if (markerClipRect) {
  34177. markerClipRect.animate({
  34178. width: finalBox.width + 99,
  34179. x: finalBox.x - (chart.inverted ? 0 : 99)
  34180. }, animation);
  34181. }
  34182. }
  34183. };
  34184. /**
  34185. * This runs after animation to land on the final plot clipping.
  34186. *
  34187. * @private
  34188. * @function Highcharts.Series#afterAnimate
  34189. *
  34190. * @fires Highcharts.Series#event:afterAnimate
  34191. */
  34192. Series.prototype.afterAnimate = function () {
  34193. this.setClip();
  34194. fireEvent(this, 'afterAnimate');
  34195. this.finishedAnimating = true;
  34196. };
  34197. /**
  34198. * Draw the markers for line-like series types, and columns or other
  34199. * graphical representation for {@link Point} objects for other series
  34200. * types. The resulting element is typically stored as
  34201. * {@link Point.graphic}, and is created on the first call and updated
  34202. * and moved on subsequent calls.
  34203. *
  34204. * @function Highcharts.Series#drawPoints
  34205. */
  34206. Series.prototype.drawPoints = function () {
  34207. var series = this,
  34208. points = series.points,
  34209. chart = series.chart,
  34210. i,
  34211. point,
  34212. graphic,
  34213. verb,
  34214. options = series.options,
  34215. seriesMarkerOptions = options.marker,
  34216. pointMarkerOptions,
  34217. hasPointMarker,
  34218. markerGroup = (series[series.specialGroup] ||
  34219. series.markerGroup),
  34220. xAxis = series.xAxis,
  34221. markerAttribs,
  34222. globallyEnabled = pick(seriesMarkerOptions.enabled, !xAxis || xAxis.isRadial ? true : null,
  34223. // Use larger or equal as radius is null in bubbles (#6321)
  34224. series.closestPointRangePx >= (seriesMarkerOptions.enabledThreshold *
  34225. seriesMarkerOptions.radius));
  34226. if (seriesMarkerOptions.enabled !== false ||
  34227. series._hasPointMarkers) {
  34228. for (i = 0; i < points.length; i++) {
  34229. point = points[i];
  34230. graphic = point.graphic;
  34231. verb = graphic ? 'animate' : 'attr';
  34232. pointMarkerOptions = point.marker || {};
  34233. hasPointMarker = !!point.marker;
  34234. var shouldDrawMarker = ((globallyEnabled &&
  34235. typeof pointMarkerOptions.enabled === 'undefined') || pointMarkerOptions.enabled) && !point.isNull && point.visible !== false;
  34236. // only draw the point if y is defined
  34237. if (shouldDrawMarker) {
  34238. // Shortcuts
  34239. var symbol = pick(pointMarkerOptions.symbol,
  34240. series.symbol);
  34241. markerAttribs = series.markerAttribs(point, (point.selected && 'select'));
  34242. // Set starting position for point sliding animation.
  34243. if (series.enabledDataSorting) {
  34244. point.startXPos = xAxis.reversed ?
  34245. -(markerAttribs.width || 0) :
  34246. xAxis.width;
  34247. }
  34248. var isInside = point.isInside !== false;
  34249. if (graphic) { // update
  34250. // Since the marker group isn't clipped, each
  34251. // individual marker must be toggled
  34252. graphic[isInside ? 'show' : 'hide'](isInside)
  34253. .animate(markerAttribs);
  34254. }
  34255. else if (isInside &&
  34256. ((markerAttribs.width || 0) > 0 || point.hasImage)) {
  34257. /**
  34258. * The graphic representation of the point.
  34259. * Typically this is a simple shape, like a `rect`
  34260. * for column charts or `path` for line markers, but
  34261. * for some complex series types like boxplot or 3D
  34262. * charts, the graphic may be a `g` element
  34263. * containing other shapes. The graphic is generated
  34264. * the first time {@link Series#drawPoints} runs,
  34265. * and updated and moved on subsequent runs.
  34266. *
  34267. * @name Point#graphic
  34268. * @type {SVGElement}
  34269. */
  34270. point.graphic = graphic = chart.renderer
  34271. .symbol(symbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height, hasPointMarker ?
  34272. pointMarkerOptions :
  34273. seriesMarkerOptions)
  34274. .add(markerGroup);
  34275. // Sliding animation for new points
  34276. if (series.enabledDataSorting &&
  34277. chart.hasRendered) {
  34278. graphic.attr({
  34279. x: point.startXPos
  34280. });
  34281. verb = 'animate';
  34282. }
  34283. }
  34284. if (graphic && verb === 'animate') { // update
  34285. // Since the marker group isn't clipped, each
  34286. // individual marker must be toggled
  34287. graphic[isInside ? 'show' : 'hide'](isInside)
  34288. .animate(markerAttribs);
  34289. }
  34290. // Presentational attributes
  34291. if (graphic && !chart.styledMode) {
  34292. graphic[verb](series.pointAttribs(point, (point.selected && 'select')));
  34293. }
  34294. if (graphic) {
  34295. graphic.addClass(point.getClassName(), true);
  34296. }
  34297. }
  34298. else if (graphic) {
  34299. point.graphic = graphic.destroy(); // #1269
  34300. }
  34301. }
  34302. }
  34303. };
  34304. /**
  34305. * Get non-presentational attributes for a point. Used internally for
  34306. * both styled mode and classic. Can be overridden for different series
  34307. * types.
  34308. *
  34309. * @see Series#pointAttribs
  34310. *
  34311. * @function Highcharts.Series#markerAttribs
  34312. *
  34313. * @param {Highcharts.Point} point
  34314. * The Point to inspect.
  34315. *
  34316. * @param {string} [state]
  34317. * The state, can be either `hover`, `select` or undefined.
  34318. *
  34319. * @return {Highcharts.SVGAttributes}
  34320. * A hash containing those attributes that are not settable from CSS.
  34321. */
  34322. Series.prototype.markerAttribs = function (point, state) {
  34323. var seriesOptions = this.options,
  34324. seriesMarkerOptions = seriesOptions.marker,
  34325. seriesStateOptions,
  34326. pointMarkerOptions = point.marker || {},
  34327. symbol = (pointMarkerOptions.symbol ||
  34328. seriesMarkerOptions.symbol),
  34329. pointStateOptions,
  34330. radius = pick(pointMarkerOptions.radius,
  34331. seriesMarkerOptions.radius),
  34332. attribs;
  34333. // Handle hover and select states
  34334. if (state) {
  34335. seriesStateOptions = seriesMarkerOptions.states[state];
  34336. pointStateOptions = pointMarkerOptions.states &&
  34337. pointMarkerOptions.states[state];
  34338. radius = pick(pointStateOptions && pointStateOptions.radius, seriesStateOptions && seriesStateOptions.radius, radius + (seriesStateOptions && seriesStateOptions.radiusPlus ||
  34339. 0));
  34340. }
  34341. point.hasImage = symbol && symbol.indexOf('url') === 0;
  34342. if (point.hasImage) {
  34343. radius = 0; // and subsequently width and height is not set
  34344. }
  34345. attribs = {
  34346. // Math.floor for #1843:
  34347. x: seriesOptions.crisp ?
  34348. Math.floor(point.plotX - radius) :
  34349. point.plotX - radius,
  34350. y: point.plotY - radius
  34351. };
  34352. if (radius) {
  34353. attribs.width = attribs.height = 2 * radius;
  34354. }
  34355. return attribs;
  34356. };
  34357. /**
  34358. * Internal function to get presentational attributes for each point.
  34359. * Unlike {@link Series#markerAttribs}, this function should return
  34360. * those attributes that can also be set in CSS. In styled mode,
  34361. * `pointAttribs` won't be called.
  34362. *
  34363. * @private
  34364. * @function Highcharts.Series#pointAttribs
  34365. *
  34366. * @param {Highcharts.Point} [point]
  34367. * The point instance to inspect.
  34368. *
  34369. * @param {string} [state]
  34370. * The point state, can be either `hover`, `select` or 'normal'. If
  34371. * undefined, normal state is assumed.
  34372. *
  34373. * @return {Highcharts.SVGAttributes}
  34374. * The presentational attributes to be set on the point.
  34375. */
  34376. Series.prototype.pointAttribs = function (point, state) {
  34377. var seriesMarkerOptions = this.options.marker,
  34378. seriesStateOptions,
  34379. pointOptions = point && point.options,
  34380. pointMarkerOptions = ((pointOptions && pointOptions.marker) || {}),
  34381. pointStateOptions,
  34382. color = this.color,
  34383. pointColorOption = pointOptions && pointOptions.color,
  34384. pointColor = point && point.color,
  34385. strokeWidth = pick(pointMarkerOptions.lineWidth,
  34386. seriesMarkerOptions.lineWidth),
  34387. zoneColor = point && point.zone && point.zone.color,
  34388. fill,
  34389. stroke,
  34390. opacity = 1;
  34391. color = (pointColorOption ||
  34392. zoneColor ||
  34393. pointColor ||
  34394. color);
  34395. fill = (pointMarkerOptions.fillColor ||
  34396. seriesMarkerOptions.fillColor ||
  34397. color);
  34398. stroke = (pointMarkerOptions.lineColor ||
  34399. seriesMarkerOptions.lineColor ||
  34400. color);
  34401. // Handle hover and select states
  34402. state = state || 'normal';
  34403. if (state) {
  34404. seriesStateOptions = seriesMarkerOptions.states[state];
  34405. pointStateOptions = (pointMarkerOptions.states &&
  34406. pointMarkerOptions.states[state]) || {};
  34407. strokeWidth = pick(pointStateOptions.lineWidth, seriesStateOptions.lineWidth, strokeWidth + pick(pointStateOptions.lineWidthPlus, seriesStateOptions.lineWidthPlus, 0));
  34408. fill = (pointStateOptions.fillColor ||
  34409. seriesStateOptions.fillColor ||
  34410. fill);
  34411. stroke = (pointStateOptions.lineColor ||
  34412. seriesStateOptions.lineColor ||
  34413. stroke);
  34414. opacity = pick(pointStateOptions.opacity, seriesStateOptions.opacity, opacity);
  34415. }
  34416. return {
  34417. 'stroke': stroke,
  34418. 'stroke-width': strokeWidth,
  34419. 'fill': fill,
  34420. 'opacity': opacity
  34421. };
  34422. };
  34423. /**
  34424. * Clear DOM objects and free up memory.
  34425. *
  34426. * @private
  34427. * @function Highcharts.Series#destroy
  34428. *
  34429. * @fires Highcharts.Series#event:destroy
  34430. */
  34431. Series.prototype.destroy = function (keepEventsForUpdate) {
  34432. var series = this,
  34433. chart = series.chart,
  34434. issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
  34435. destroy,
  34436. i,
  34437. data = series.data || [],
  34438. point,
  34439. axis;
  34440. // add event hook
  34441. fireEvent(series, 'destroy');
  34442. // remove events
  34443. this.removeEvents(keepEventsForUpdate);
  34444. // erase from axes
  34445. (series.axisTypes || []).forEach(function (AXIS) {
  34446. axis = series[AXIS];
  34447. if (axis && axis.series) {
  34448. erase(axis.series, series);
  34449. axis.isDirty = axis.forceRedraw = true;
  34450. }
  34451. });
  34452. // remove legend items
  34453. if (series.legendItem) {
  34454. series.chart.legend.destroyItem(series);
  34455. }
  34456. // destroy all points with their elements
  34457. i = data.length;
  34458. while (i--) {
  34459. point = data[i];
  34460. if (point && point.destroy) {
  34461. point.destroy();
  34462. }
  34463. }
  34464. if (series.clips) {
  34465. series.clips.forEach(function (clip) { return clip.destroy(); });
  34466. }
  34467. // Clear the animation timeout if we are destroying the series
  34468. // during initial animation
  34469. U.clearTimeout(series.animationTimeout);
  34470. // Destroy all SVGElements associated to the series
  34471. objectEach(series, function (val, prop) {
  34472. // Survive provides a hook for not destroying
  34473. if (val instanceof SVGElement && !val.survive) {
  34474. // issue 134 workaround
  34475. destroy = issue134 && prop === 'group' ?
  34476. 'hide' :
  34477. 'destroy';
  34478. val[destroy]();
  34479. }
  34480. });
  34481. // remove from hoverSeries
  34482. if (chart.hoverSeries === series) {
  34483. chart.hoverSeries = void 0;
  34484. }
  34485. erase(chart.series, series);
  34486. chart.orderSeries();
  34487. // clear all members
  34488. objectEach(series, function (val, prop) {
  34489. if (!keepEventsForUpdate || prop !== 'hcEvents') {
  34490. delete series[prop];
  34491. }
  34492. });
  34493. };
  34494. /**
  34495. * Clip the graphs into zones for colors and styling.
  34496. *
  34497. * @private
  34498. * @function Highcharts.Series#applyZones
  34499. */
  34500. Series.prototype.applyZones = function () {
  34501. var series = this,
  34502. chart = this.chart,
  34503. renderer = chart.renderer,
  34504. zones = this.zones,
  34505. translatedFrom,
  34506. translatedTo,
  34507. clips = (this.clips || []),
  34508. clipAttr,
  34509. graph = this.graph,
  34510. area = this.area,
  34511. chartSizeMax = Math.max(chart.chartWidth,
  34512. chart.chartHeight),
  34513. axis = this[(this.zoneAxis || 'y') + 'Axis'],
  34514. extremes,
  34515. reversed,
  34516. inverted = chart.inverted,
  34517. horiz,
  34518. pxRange,
  34519. pxPosMin,
  34520. pxPosMax,
  34521. ignoreZones = false,
  34522. zoneArea,
  34523. zoneGraph;
  34524. if (zones.length &&
  34525. (graph || area) &&
  34526. axis &&
  34527. typeof axis.min !== 'undefined') {
  34528. reversed = axis.reversed;
  34529. horiz = axis.horiz;
  34530. // The use of the Color Threshold assumes there are no gaps
  34531. // so it is safe to hide the original graph and area
  34532. // unless it is not waterfall series, then use showLine property
  34533. // to set lines between columns to be visible (#7862)
  34534. if (graph && !this.showLine) {
  34535. graph.hide();
  34536. }
  34537. if (area) {
  34538. area.hide();
  34539. }
  34540. // Create the clips
  34541. extremes = axis.getExtremes();
  34542. zones.forEach(function (threshold, i) {
  34543. translatedFrom = reversed ?
  34544. (horiz ? chart.plotWidth : 0) :
  34545. (horiz ? 0 : (axis.toPixels(extremes.min) || 0));
  34546. translatedFrom = clamp(pick(translatedTo, translatedFrom), 0, chartSizeMax);
  34547. translatedTo = clamp(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true) || 0), 0, chartSizeMax);
  34548. if (ignoreZones) {
  34549. translatedFrom = translatedTo =
  34550. axis.toPixels(extremes.max);
  34551. }
  34552. pxRange = Math.abs(translatedFrom - translatedTo);
  34553. pxPosMin = Math.min(translatedFrom, translatedTo);
  34554. pxPosMax = Math.max(translatedFrom, translatedTo);
  34555. if (axis.isXAxis) {
  34556. clipAttr = {
  34557. x: inverted ? pxPosMax : pxPosMin,
  34558. y: 0,
  34559. width: pxRange,
  34560. height: chartSizeMax
  34561. };
  34562. if (!horiz) {
  34563. clipAttr.x = chart.plotHeight - clipAttr.x;
  34564. }
  34565. }
  34566. else {
  34567. clipAttr = {
  34568. x: 0,
  34569. y: inverted ? pxPosMax : pxPosMin,
  34570. width: chartSizeMax,
  34571. height: pxRange
  34572. };
  34573. if (horiz) {
  34574. clipAttr.y = chart.plotWidth - clipAttr.y;
  34575. }
  34576. }
  34577. // VML SUPPPORT
  34578. if (inverted && renderer.isVML) {
  34579. if (axis.isXAxis) {
  34580. clipAttr = {
  34581. x: 0,
  34582. y: reversed ? pxPosMin : pxPosMax,
  34583. height: clipAttr.width,
  34584. width: chart.chartWidth
  34585. };
  34586. }
  34587. else {
  34588. clipAttr = {
  34589. x: (clipAttr.y -
  34590. chart.plotLeft -
  34591. chart.spacingBox.x),
  34592. y: 0,
  34593. width: clipAttr.height,
  34594. height: chart.chartHeight
  34595. };
  34596. }
  34597. }
  34598. // END OF VML SUPPORT
  34599. if (clips[i]) {
  34600. clips[i].animate(clipAttr);
  34601. }
  34602. else {
  34603. clips[i] = renderer.clipRect(clipAttr);
  34604. }
  34605. // when no data, graph zone is not applied and after setData
  34606. // clip was ignored. As a result, it should be applied each
  34607. // time.
  34608. zoneArea = series['zone-area-' + i];
  34609. zoneGraph = series['zone-graph-' + i];
  34610. if (graph && zoneGraph) {
  34611. zoneGraph.clip(clips[i]);
  34612. }
  34613. if (area && zoneArea) {
  34614. zoneArea.clip(clips[i]);
  34615. }
  34616. // if this zone extends out of the axis, ignore the others
  34617. ignoreZones = threshold.value > extremes.max;
  34618. // Clear translatedTo for indicators
  34619. if (series.resetZones && translatedTo === 0) {
  34620. translatedTo = void 0;
  34621. }
  34622. });
  34623. this.clips = clips;
  34624. }
  34625. else if (series.visible) {
  34626. // If zones were removed, restore graph and area
  34627. if (graph) {
  34628. graph.show(true);
  34629. }
  34630. if (area) {
  34631. area.show(true);
  34632. }
  34633. }
  34634. };
  34635. /**
  34636. * Initialize and perform group inversion on series.group and
  34637. * series.markerGroup.
  34638. *
  34639. * @private
  34640. * @function Highcharts.Series#invertGroups
  34641. */
  34642. Series.prototype.invertGroups = function (inverted) {
  34643. var series = this,
  34644. chart = series.chart;
  34645. /**
  34646. * @private
  34647. */
  34648. function setInvert() {
  34649. ['group', 'markerGroup'].forEach(function (groupName) {
  34650. if (series[groupName]) {
  34651. // VML/HTML needs explicit attributes for flipping
  34652. if (chart.renderer.isVML) {
  34653. series[groupName].attr({
  34654. width: series.yAxis.len,
  34655. height: series.xAxis.len
  34656. });
  34657. }
  34658. series[groupName].width = series.yAxis.len;
  34659. series[groupName].height = series.xAxis.len;
  34660. // If inverted polar, don't invert series group
  34661. series[groupName].invert(series.isRadialSeries ? false : inverted);
  34662. }
  34663. });
  34664. }
  34665. // Pie, go away (#1736)
  34666. if (!series.xAxis) {
  34667. return;
  34668. }
  34669. // A fixed size is needed for inversion to work
  34670. series.eventsToUnbind.push(addEvent(chart, 'resize', setInvert));
  34671. // Do it now
  34672. setInvert();
  34673. // On subsequent render and redraw, just do setInvert without
  34674. // setting up events again
  34675. series.invertGroups = setInvert;
  34676. };
  34677. /**
  34678. * General abstraction for creating plot groups like series.group,
  34679. * series.dataLabelsGroup and series.markerGroup. On subsequent calls,
  34680. * the group will only be adjusted to the updated plot size.
  34681. *
  34682. * @private
  34683. * @function Highcharts.Series#plotGroup
  34684. */
  34685. Series.prototype.plotGroup = function (prop, name, visibility, zIndex, parent) {
  34686. var group = this[prop],
  34687. isNew = !group,
  34688. attrs = {
  34689. visibility: visibility,
  34690. zIndex: zIndex || 0.1 // IE8 and pointer logic use this
  34691. };
  34692. // Avoid setting undefined opacity, or in styled mode
  34693. if (typeof this.opacity !== 'undefined' &&
  34694. !this.chart.styledMode && this.state !== 'inactive' // #13719
  34695. ) {
  34696. attrs.opacity = this.opacity;
  34697. }
  34698. // Generate it on first call
  34699. if (isNew) {
  34700. this[prop] = group = this.chart.renderer
  34701. .g()
  34702. .add(parent);
  34703. }
  34704. // Add the class names, and replace existing ones as response to
  34705. // Series.update (#6660)
  34706. group.addClass(('highcharts-' + name +
  34707. ' highcharts-series-' + this.index +
  34708. ' highcharts-' + this.type + '-series ' +
  34709. (defined(this.colorIndex) ?
  34710. 'highcharts-color-' + this.colorIndex + ' ' :
  34711. '') +
  34712. (this.options.className || '') +
  34713. (group.hasClass('highcharts-tracker') ?
  34714. ' highcharts-tracker' :
  34715. '')), true);
  34716. // Place it on first and subsequent (redraw) calls
  34717. group.attr(attrs)[isNew ? 'attr' : 'animate'](this.getPlotBox());
  34718. return group;
  34719. };
  34720. /**
  34721. * Get the translation and scale for the plot area of this series.
  34722. *
  34723. * @function Highcharts.Series#getPlotBox
  34724. *
  34725. * @return {Highcharts.SeriesPlotBoxObject}
  34726. */
  34727. Series.prototype.getPlotBox = function () {
  34728. var chart = this.chart,
  34729. xAxis = this.xAxis,
  34730. yAxis = this.yAxis;
  34731. // Swap axes for inverted (#2339)
  34732. if (chart.inverted) {
  34733. xAxis = yAxis;
  34734. yAxis = this.xAxis;
  34735. }
  34736. return {
  34737. translateX: xAxis ? xAxis.left : chart.plotLeft,
  34738. translateY: yAxis ? yAxis.top : chart.plotTop,
  34739. scaleX: 1,
  34740. scaleY: 1
  34741. };
  34742. };
  34743. /**
  34744. * Removes the event handlers attached previously with addEvents.
  34745. * @private
  34746. * @function Highcharts.Series#removeEvents
  34747. */
  34748. Series.prototype.removeEvents = function (keepEventsForUpdate) {
  34749. var series = this;
  34750. if (!keepEventsForUpdate) {
  34751. // remove all events
  34752. removeEvent(series);
  34753. }
  34754. if (series.eventsToUnbind.length) {
  34755. // remove only internal events for proper update
  34756. // #12355 - solves problem with multiple destroy events
  34757. series.eventsToUnbind.forEach(function (unbind) {
  34758. unbind();
  34759. });
  34760. series.eventsToUnbind.length = 0;
  34761. }
  34762. };
  34763. /**
  34764. * Render the graph and markers. Called internally when first rendering
  34765. * and later when redrawing the chart. This function can be extended in
  34766. * plugins, but normally shouldn't be called directly.
  34767. *
  34768. * @function Highcharts.Series#render
  34769. *
  34770. * @fires Highcharts.Series#event:afterRender
  34771. */
  34772. Series.prototype.render = function () {
  34773. var series = this,
  34774. chart = series.chart,
  34775. group,
  34776. options = series.options,
  34777. animOptions = animObject(options.animation),
  34778. // Animation doesn't work in IE8 quirks when the group div is
  34779. // hidden, and looks bad in other oldIE
  34780. animDuration = (!series.finishedAnimating &&
  34781. chart.renderer.isSVG &&
  34782. animOptions.duration),
  34783. visibility = series.visible ?
  34784. 'inherit' : 'hidden', // #2597
  34785. zIndex = options.zIndex,
  34786. hasRendered = series.hasRendered,
  34787. chartSeriesGroup = chart.seriesGroup,
  34788. inverted = chart.inverted;
  34789. fireEvent(this, 'render');
  34790. // the group
  34791. group = series.plotGroup('group', 'series', visibility, zIndex, chartSeriesGroup);
  34792. series.markerGroup = series.plotGroup('markerGroup', 'markers', visibility, zIndex, chartSeriesGroup);
  34793. // initiate the animation
  34794. if (animDuration && series.animate) {
  34795. series.animate(true);
  34796. }
  34797. // SVGRenderer needs to know this before drawing elements (#1089,
  34798. // #1795)
  34799. group.inverted = pick(series.invertible, series.isCartesian) ?
  34800. inverted : false;
  34801. // Draw the graph if any
  34802. if (series.drawGraph) {
  34803. series.drawGraph();
  34804. series.applyZones();
  34805. }
  34806. // Draw the points
  34807. if (series.visible) {
  34808. series.drawPoints();
  34809. }
  34810. /* series.points.forEach(function (point) {
  34811. if (point.redraw) {
  34812. point.redraw();
  34813. }
  34814. }); */
  34815. // Draw the data labels
  34816. if (series.drawDataLabels) {
  34817. series.drawDataLabels();
  34818. }
  34819. // In pie charts, slices are added to the DOM, but actual rendering
  34820. // is postponed until labels reserved their space
  34821. if (series.redrawPoints) {
  34822. series.redrawPoints();
  34823. }
  34824. // draw the mouse tracking area
  34825. if (series.drawTracker &&
  34826. series.options.enableMouseTracking !== false) {
  34827. series.drawTracker();
  34828. }
  34829. // Handle inverted series and tracker groups
  34830. series.invertGroups(inverted);
  34831. // Initial clipping, must be defined after inverting groups for VML.
  34832. // Applies to columns etc. (#3839).
  34833. if (options.clip !== false &&
  34834. !series.sharedClipKey &&
  34835. !hasRendered) {
  34836. group.clip(chart.clipRect);
  34837. }
  34838. // Run the animation
  34839. if (animDuration && series.animate) {
  34840. series.animate();
  34841. }
  34842. // Call the afterAnimate function on animation complete (but don't
  34843. // overwrite the animation.complete option which should be available
  34844. // to the user).
  34845. if (!hasRendered) {
  34846. // Additional time if defer is defined before afterAnimate
  34847. // will be triggered
  34848. if (animDuration && animOptions.defer) {
  34849. animDuration += animOptions.defer;
  34850. }
  34851. series.animationTimeout = syncTimeout(function () {
  34852. series.afterAnimate();
  34853. }, animDuration || 0);
  34854. }
  34855. // Means data is in accordance with what you see
  34856. series.isDirty = false;
  34857. // (See #322) series.isDirty = series.isDirtyData = false; // means
  34858. // data is in accordance with what you see
  34859. series.hasRendered = true;
  34860. fireEvent(series, 'afterRender');
  34861. };
  34862. /**
  34863. * Redraw the series. This function is called internally from
  34864. * `chart.redraw` and normally shouldn't be called directly.
  34865. * @private
  34866. * @function Highcharts.Series#redraw
  34867. */
  34868. Series.prototype.redraw = function () {
  34869. var series = this,
  34870. chart = series.chart,
  34871. // cache it here as it is set to false in render, but used after
  34872. wasDirty = series.isDirty || series.isDirtyData,
  34873. group = series.group,
  34874. xAxis = series.xAxis,
  34875. yAxis = series.yAxis;
  34876. // reposition on resize
  34877. if (group) {
  34878. if (chart.inverted) {
  34879. group.attr({
  34880. width: chart.plotWidth,
  34881. height: chart.plotHeight
  34882. });
  34883. }
  34884. group.animate({
  34885. translateX: pick(xAxis && xAxis.left, chart.plotLeft),
  34886. translateY: pick(yAxis && yAxis.top, chart.plotTop)
  34887. });
  34888. }
  34889. series.translate();
  34890. series.render();
  34891. if (wasDirty) { // #3868, #3945
  34892. delete this.kdTree;
  34893. }
  34894. };
  34895. /**
  34896. * @private
  34897. * @function Highcharts.Series#searchPoint
  34898. */
  34899. Series.prototype.searchPoint = function (e, compareX) {
  34900. var series = this,
  34901. xAxis = series.xAxis,
  34902. yAxis = series.yAxis,
  34903. inverted = series.chart.inverted;
  34904. return this.searchKDTree({
  34905. clientX: inverted ?
  34906. xAxis.len - e.chartY + xAxis.pos :
  34907. e.chartX - xAxis.pos,
  34908. plotY: inverted ?
  34909. yAxis.len - e.chartX + yAxis.pos :
  34910. e.chartY - yAxis.pos
  34911. }, compareX, e);
  34912. };
  34913. /**
  34914. * Build the k-d-tree that is used by mouse and touch interaction to get
  34915. * the closest point. Line-like series typically have a one-dimensional
  34916. * tree where points are searched along the X axis, while scatter-like
  34917. * series typically search in two dimensions, X and Y.
  34918. *
  34919. * @private
  34920. * @function Highcharts.Series#buildKDTree
  34921. */
  34922. Series.prototype.buildKDTree = function (e) {
  34923. // Prevent multiple k-d-trees from being built simultaneously
  34924. // (#6235)
  34925. this.buildingKdTree = true;
  34926. var series = this,
  34927. dimensions = series.options.findNearestPointBy
  34928. .indexOf('y') > -1 ? 2 : 1;
  34929. /**
  34930. * Internal function
  34931. * @private
  34932. */
  34933. function _kdtree(points, depth, dimensions) {
  34934. var axis,
  34935. median,
  34936. length = points && points.length;
  34937. if (length) {
  34938. // alternate between the axis
  34939. axis = series.kdAxisArray[depth % dimensions];
  34940. // sort point array
  34941. points.sort(function (a, b) {
  34942. return a[axis] - b[axis];
  34943. });
  34944. median = Math.floor(length / 2);
  34945. // build and return nod
  34946. return {
  34947. point: points[median],
  34948. left: _kdtree(points.slice(0, median), depth + 1, dimensions),
  34949. right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
  34950. };
  34951. }
  34952. }
  34953. /**
  34954. * Start the recursive build process with a clone of the points
  34955. * array and null points filtered out. (#3873)
  34956. * @private
  34957. */
  34958. function startRecursive() {
  34959. series.kdTree = _kdtree(series.getValidPoints(null,
  34960. // For line-type series restrict to plot area, but
  34961. // column-type series not (#3916, #4511)
  34962. !series.directTouch), dimensions, dimensions);
  34963. series.buildingKdTree = false;
  34964. }
  34965. delete series.kdTree;
  34966. // For testing tooltips, don't build async. Also if touchstart, we
  34967. // may be dealing with click events on mobile, so don't delay
  34968. // (#6817).
  34969. syncTimeout(startRecursive, series.options.kdNow || (e && e.type === 'touchstart') ? 0 : 1);
  34970. };
  34971. /**
  34972. * @private
  34973. * @function Highcharts.Series#searchKDTree
  34974. */
  34975. Series.prototype.searchKDTree = function (point, compareX, e) {
  34976. var series = this,
  34977. kdX = this.kdAxisArray[0],
  34978. kdY = this.kdAxisArray[1],
  34979. kdComparer = compareX ? 'distX' : 'dist',
  34980. kdDimensions = series.options.findNearestPointBy
  34981. .indexOf('y') > -1 ? 2 : 1;
  34982. /**
  34983. * Set the one and two dimensional distance on the point object.
  34984. * @private
  34985. */
  34986. function setDistance(p1, p2) {
  34987. var x = (defined(p1[kdX]) &&
  34988. defined(p2[kdX])) ?
  34989. Math.pow(p1[kdX] - p2[kdX], 2) :
  34990. null,
  34991. y = (defined(p1[kdY]) &&
  34992. defined(p2[kdY])) ?
  34993. Math.pow(p1[kdY] - p2[kdY], 2) :
  34994. null,
  34995. r = (x || 0) + (y || 0);
  34996. p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
  34997. p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
  34998. }
  34999. /**
  35000. * @private
  35001. */
  35002. function _search(search, tree, depth, dimensions) {
  35003. var point = tree.point,
  35004. axis = series.kdAxisArray[depth % dimensions],
  35005. tdist,
  35006. sideA,
  35007. sideB,
  35008. ret = point,
  35009. nPoint1,
  35010. nPoint2;
  35011. setDistance(search, point);
  35012. // Pick side based on distance to splitting point
  35013. tdist = search[axis] - point[axis];
  35014. sideA = tdist < 0 ? 'left' : 'right';
  35015. sideB = tdist < 0 ? 'right' : 'left';
  35016. // End of tree
  35017. if (tree[sideA]) {
  35018. nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
  35019. ret = (nPoint1[kdComparer] <
  35020. ret[kdComparer] ?
  35021. nPoint1 :
  35022. point);
  35023. }
  35024. if (tree[sideB]) {
  35025. // compare distance to current best to splitting point to
  35026. // decide wether to check side B or not
  35027. if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
  35028. nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
  35029. ret = (nPoint2[kdComparer] <
  35030. ret[kdComparer] ?
  35031. nPoint2 :
  35032. ret);
  35033. }
  35034. }
  35035. return ret;
  35036. }
  35037. if (!this.kdTree && !this.buildingKdTree) {
  35038. this.buildKDTree(e);
  35039. }
  35040. if (this.kdTree) {
  35041. return _search(point, this.kdTree, kdDimensions, kdDimensions);
  35042. }
  35043. };
  35044. /**
  35045. * @private
  35046. * @function Highcharts.Series#pointPlacementToXValue
  35047. */
  35048. Series.prototype.pointPlacementToXValue = function () {
  35049. var _a = this,
  35050. _b = _a.options,
  35051. pointPlacement = _b.pointPlacement,
  35052. pointRange = _b.pointRange,
  35053. axis = _a.xAxis;
  35054. var factor = pointPlacement;
  35055. // Point placement is relative to each series pointRange (#5889)
  35056. if (factor === 'between') {
  35057. factor = axis.reversed ? -0.5 : 0.5; // #11955
  35058. }
  35059. return isNumber(factor) ?
  35060. factor * (pointRange || axis.pointRange) :
  35061. 0;
  35062. };
  35063. /**
  35064. * @private
  35065. * @function Highcharts.Series#isPointInside
  35066. */
  35067. Series.prototype.isPointInside = function (point) {
  35068. var isInside = typeof point.plotY !== 'undefined' &&
  35069. typeof point.plotX !== 'undefined' &&
  35070. point.plotY >= 0 &&
  35071. point.plotY <= this.yAxis.len && // #3519
  35072. point.plotX >= 0 &&
  35073. point.plotX <= this.xAxis.len;
  35074. return isInside;
  35075. };
  35076. /**
  35077. * Draw the tracker object that sits above all data labels and markers to
  35078. * track mouse events on the graph or points. For the line type charts
  35079. * the tracker uses the same graphPath, but with a greater stroke width
  35080. * for better control.
  35081. * @private
  35082. */
  35083. Series.prototype.drawTracker = function () {
  35084. var series = this,
  35085. options = series.options,
  35086. trackByArea = options.trackByArea,
  35087. trackerPath = [].concat(trackByArea ?
  35088. series.areaPath :
  35089. series.graphPath),
  35090. // trackerPathLength = trackerPath.length,
  35091. chart = series.chart,
  35092. pointer = chart.pointer,
  35093. renderer = chart.renderer,
  35094. snap = chart.options.tooltip.snap,
  35095. tracker = series.tracker,
  35096. i,
  35097. onMouseOver = function (e) {
  35098. if (chart.hoverSeries !== series) {
  35099. series.onMouseOver();
  35100. }
  35101. },
  35102. /*
  35103. * Empirical lowest possible opacities for TRACKER_FILL for an
  35104. * element to stay invisible but clickable
  35105. * IE6: 0.002
  35106. * IE7: 0.002
  35107. * IE8: 0.002
  35108. * IE9: 0.00000000001 (unlimited)
  35109. * IE10: 0.0001 (exporting only)
  35110. * FF: 0.00000000001 (unlimited)
  35111. * Chrome: 0.000001
  35112. * Safari: 0.000001
  35113. * Opera: 0.00000000001 (unlimited)
  35114. */
  35115. TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
  35116. // Draw the tracker
  35117. if (tracker) {
  35118. tracker.attr({ d: trackerPath });
  35119. }
  35120. else if (series.graph) { // create
  35121. series.tracker = renderer.path(trackerPath)
  35122. .attr({
  35123. visibility: series.visible ? 'visible' : 'hidden',
  35124. zIndex: 2
  35125. })
  35126. .addClass(trackByArea ?
  35127. 'highcharts-tracker-area' :
  35128. 'highcharts-tracker-line')
  35129. .add(series.group);
  35130. if (!chart.styledMode) {
  35131. series.tracker.attr({
  35132. 'stroke-linecap': 'round',
  35133. 'stroke-linejoin': 'round',
  35134. stroke: TRACKER_FILL,
  35135. fill: trackByArea ? TRACKER_FILL : 'none',
  35136. 'stroke-width': series.graph.strokeWidth() +
  35137. (trackByArea ? 0 : 2 * snap)
  35138. });
  35139. }
  35140. // The tracker is added to the series group, which is clipped, but
  35141. // is covered by the marker group. So the marker group also needs to
  35142. // capture events.
  35143. [
  35144. series.tracker,
  35145. series.markerGroup,
  35146. series.dataLabelsGroup
  35147. ].forEach(function (tracker) {
  35148. if (tracker) {
  35149. tracker.addClass('highcharts-tracker')
  35150. .on('mouseover', onMouseOver)
  35151. .on('mouseout', function (e) {
  35152. pointer.onTrackerMouseOut(e);
  35153. });
  35154. if (options.cursor && !chart.styledMode) {
  35155. tracker.css({ cursor: options.cursor });
  35156. }
  35157. if (hasTouch) {
  35158. tracker.on('touchstart', onMouseOver);
  35159. }
  35160. }
  35161. });
  35162. }
  35163. fireEvent(this, 'afterDrawTracker');
  35164. };
  35165. /**
  35166. * Add a point to the series after render time. The point can be added at
  35167. * the end, or by giving it an X value, to the start or in the middle of the
  35168. * series.
  35169. *
  35170. * @sample highcharts/members/series-addpoint-append/
  35171. * Append point
  35172. * @sample highcharts/members/series-addpoint-append-and-shift/
  35173. * Append and shift
  35174. * @sample highcharts/members/series-addpoint-x-and-y/
  35175. * Both X and Y values given
  35176. * @sample highcharts/members/series-addpoint-pie/
  35177. * Append pie slice
  35178. * @sample stock/members/series-addpoint/
  35179. * Append 100 points in Highcharts Stock
  35180. * @sample stock/members/series-addpoint-shift/
  35181. * Append and shift in Highcharts Stock
  35182. * @sample maps/members/series-addpoint/
  35183. * Add a point in Highmaps
  35184. *
  35185. * @function Highcharts.Series#addPoint
  35186. *
  35187. * @param {Highcharts.PointOptionsType} options
  35188. * The point options. If options is a single number, a point with
  35189. * that y value is appended to the series. If it is an array, it will
  35190. * be interpreted as x and y values respectively. If it is an
  35191. * object, advanced options as outlined under `series.data` are
  35192. * applied.
  35193. *
  35194. * @param {boolean} [redraw=true]
  35195. * Whether to redraw the chart after the point is added. When adding
  35196. * more than one point, it is highly recommended that the redraw
  35197. * option be set to false, and instead {@link Chart#redraw} is
  35198. * explicitly called after the adding of points is finished.
  35199. * Otherwise, the chart will redraw after adding each point.
  35200. *
  35201. * @param {boolean} [shift=false]
  35202. * If true, a point is shifted off the start of the series as one is
  35203. * appended to the end.
  35204. *
  35205. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35206. * Whether to apply animation, and optionally animation
  35207. * configuration.
  35208. *
  35209. * @param {boolean} [withEvent=true]
  35210. * Used internally, whether to fire the series `addPoint` event.
  35211. *
  35212. * @fires Highcharts.Series#event:addPoint
  35213. */
  35214. Series.prototype.addPoint = function (options, redraw, shift, animation, withEvent) {
  35215. var series = this,
  35216. seriesOptions = series.options,
  35217. data = series.data,
  35218. chart = series.chart,
  35219. xAxis = series.xAxis,
  35220. names = xAxis && xAxis.hasNames && xAxis.names,
  35221. dataOptions = seriesOptions.data,
  35222. point,
  35223. xData = series.xData,
  35224. isInTheMiddle,
  35225. i,
  35226. x;
  35227. // Optional redraw, defaults to true
  35228. redraw = pick(redraw, true);
  35229. // Get options and push the point to xData, yData and series.options. In
  35230. // series.generatePoints the Point instance will be created on demand
  35231. // and pushed to the series.data array.
  35232. point = { series: series };
  35233. series.pointClass.prototype.applyOptions.apply(point, [options]);
  35234. x = point.x;
  35235. // Get the insertion point
  35236. i = xData.length;
  35237. if (series.requireSorting && x < xData[i - 1]) {
  35238. isInTheMiddle = true;
  35239. while (i && xData[i - 1] > x) {
  35240. i--;
  35241. }
  35242. }
  35243. // Insert undefined item
  35244. series.updateParallelArrays(point, 'splice', i, 0, 0);
  35245. // Update it
  35246. series.updateParallelArrays(point, i);
  35247. if (names && point.name) {
  35248. names[x] = point.name;
  35249. }
  35250. dataOptions.splice(i, 0, options);
  35251. if (isInTheMiddle) {
  35252. series.data.splice(i, 0, null);
  35253. series.processData();
  35254. }
  35255. // Generate points to be added to the legend (#1329)
  35256. if (seriesOptions.legendType === 'point') {
  35257. series.generatePoints();
  35258. }
  35259. // Shift the first point off the parallel arrays
  35260. if (shift) {
  35261. if (data[0] && data[0].remove) {
  35262. data[0].remove(false);
  35263. }
  35264. else {
  35265. data.shift();
  35266. series.updateParallelArrays(point, 'shift');
  35267. dataOptions.shift();
  35268. }
  35269. }
  35270. // Fire event
  35271. if (withEvent !== false) {
  35272. fireEvent(series, 'addPoint', { point: point });
  35273. }
  35274. // redraw
  35275. series.isDirty = true;
  35276. series.isDirtyData = true;
  35277. if (redraw) {
  35278. chart.redraw(animation); // Animation is set anyway on redraw, #5665
  35279. }
  35280. };
  35281. /**
  35282. * Remove a point from the series. Unlike the
  35283. * {@link Highcharts.Point#remove} method, this can also be done on a point
  35284. * that is not instanciated because it is outside the view or subject to
  35285. * Highcharts Stock data grouping.
  35286. *
  35287. * @sample highcharts/members/series-removepoint/
  35288. * Remove cropped point
  35289. *
  35290. * @function Highcharts.Series#removePoint
  35291. *
  35292. * @param {number} i
  35293. * The index of the point in the {@link Highcharts.Series.data|data}
  35294. * array.
  35295. *
  35296. * @param {boolean} [redraw=true]
  35297. * Whether to redraw the chart after the point is added. When
  35298. * removing more than one point, it is highly recommended that the
  35299. * `redraw` option be set to `false`, and instead {@link
  35300. * Highcharts.Chart#redraw} is explicitly called after the adding of
  35301. * points is finished.
  35302. *
  35303. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35304. * Whether and optionally how the series should be animated.
  35305. *
  35306. * @fires Highcharts.Point#event:remove
  35307. */
  35308. Series.prototype.removePoint = function (i, redraw, animation) {
  35309. var series = this,
  35310. data = series.data,
  35311. point = data[i],
  35312. points = series.points,
  35313. chart = series.chart,
  35314. remove = function () {
  35315. if (points && points.length === data.length) { // #4935
  35316. points.splice(i, 1);
  35317. }
  35318. data.splice(i, 1);
  35319. series.options.data.splice(i, 1);
  35320. series.updateParallelArrays(point || { series: series }, 'splice', i, 1);
  35321. if (point) {
  35322. point.destroy();
  35323. }
  35324. // redraw
  35325. series.isDirty = true;
  35326. series.isDirtyData = true;
  35327. if (redraw) {
  35328. chart.redraw();
  35329. }
  35330. };
  35331. setAnimation(animation, chart);
  35332. redraw = pick(redraw, true);
  35333. // Fire the event with a default handler of removing the point
  35334. if (point) {
  35335. point.firePointEvent('remove', null, remove);
  35336. }
  35337. else {
  35338. remove();
  35339. }
  35340. };
  35341. /**
  35342. * Remove a series and optionally redraw the chart.
  35343. *
  35344. * @sample highcharts/members/series-remove/
  35345. * Remove first series from a button
  35346. *
  35347. * @function Highcharts.Series#remove
  35348. *
  35349. * @param {boolean} [redraw=true]
  35350. * Whether to redraw the chart or wait for an explicit call to
  35351. * {@link Highcharts.Chart#redraw}.
  35352. *
  35353. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35354. * Whether to apply animation, and optionally animation
  35355. * configuration.
  35356. *
  35357. * @param {boolean} [withEvent=true]
  35358. * Used internally, whether to fire the series `remove` event.
  35359. *
  35360. * @fires Highcharts.Series#event:remove
  35361. */
  35362. Series.prototype.remove = function (redraw, animation, withEvent, keepEvents) {
  35363. var series = this,
  35364. chart = series.chart;
  35365. /**
  35366. * @private
  35367. */
  35368. function remove() {
  35369. // Destroy elements
  35370. series.destroy(keepEvents);
  35371. // Redraw
  35372. chart.isDirtyLegend = chart.isDirtyBox = true;
  35373. chart.linkSeries();
  35374. if (pick(redraw, true)) {
  35375. chart.redraw(animation);
  35376. }
  35377. }
  35378. // Fire the event with a default handler of removing the point
  35379. if (withEvent !== false) {
  35380. fireEvent(series, 'remove', null, remove);
  35381. }
  35382. else {
  35383. remove();
  35384. }
  35385. };
  35386. /**
  35387. * Update the series with a new set of options. For a clean and precise
  35388. * handling of new options, all methods and elements from the series are
  35389. * removed, and it is initialized from scratch. Therefore, this method is
  35390. * more performance expensive than some other utility methods like {@link
  35391. * Series#setData} or {@link Series#setVisible}.
  35392. *
  35393. * Note that `Series.update` may mutate the passed `data` options.
  35394. *
  35395. * @sample highcharts/members/series-update/
  35396. * Updating series options
  35397. * @sample maps/members/series-update/
  35398. * Update series options in Highmaps
  35399. *
  35400. * @function Highcharts.Series#update
  35401. *
  35402. * @param {Highcharts.SeriesOptionsType} options
  35403. * New options that will be merged with the series' existing options.
  35404. *
  35405. * @param {boolean} [redraw=true]
  35406. * Whether to redraw the chart after the series is altered. If doing
  35407. * more operations on the chart, it is a good idea to set redraw to
  35408. * false and call {@link Chart#redraw} after.
  35409. *
  35410. * @fires Highcharts.Series#event:update
  35411. * @fires Highcharts.Series#event:afterUpdate
  35412. */
  35413. Series.prototype.update = function (options, redraw) {
  35414. options = cleanRecursively(options, this.userOptions);
  35415. fireEvent(this, 'update', { options: options });
  35416. var series = this,
  35417. chart = series.chart,
  35418. // must use user options when changing type because series.options
  35419. // is merged in with type specific plotOptions
  35420. oldOptions = series.userOptions,
  35421. seriesOptions,
  35422. initialType = series.initialType || series.type,
  35423. plotOptions = chart.options.plotOptions,
  35424. newType = (options.type ||
  35425. oldOptions.type ||
  35426. chart.options.chart.type),
  35427. keepPoints = !(
  35428. // Indicators, histograms etc recalculate the data. It should be
  35429. // possible to omit this.
  35430. this.hasDerivedData ||
  35431. // New type requires new point classes
  35432. (newType && newType !== this.type) ||
  35433. // New options affecting how the data points are built
  35434. typeof options.pointStart !== 'undefined' ||
  35435. typeof options.pointInterval !== 'undefined' ||
  35436. // Changes to data grouping requires new points in new group
  35437. series.hasOptionChanged('dataGrouping') ||
  35438. series.hasOptionChanged('pointStart') ||
  35439. series.hasOptionChanged('pointInterval') ||
  35440. series.hasOptionChanged('pointIntervalUnit') ||
  35441. series.hasOptionChanged('keys')),
  35442. initialSeriesProto = seriesTypes[initialType].prototype,
  35443. n,
  35444. groups = [
  35445. 'group',
  35446. 'markerGroup',
  35447. 'dataLabelsGroup',
  35448. 'transformGroup'
  35449. ],
  35450. preserve = [
  35451. 'eventOptions',
  35452. 'navigatorSeries',
  35453. 'baseSeries'
  35454. ],
  35455. // Animation must be enabled when calling update before the initial
  35456. // animation has first run. This happens when calling update
  35457. // directly after chart initialization, or when applying responsive
  35458. // rules (#6912).
  35459. animation = series.finishedAnimating && { animation: false },
  35460. kinds = {};
  35461. newType = newType || initialType;
  35462. if (keepPoints) {
  35463. preserve.push('data', 'isDirtyData', 'points', 'processedXData', 'processedYData', 'xIncrement', 'cropped', '_hasPointMarkers', '_hasPointLabels', 'clips', // #15420
  35464. // Networkgraph (#14397)
  35465. 'nodes', 'layout',
  35466. // Map specific, consider moving it to series-specific preserve-
  35467. // properties (#10617)
  35468. 'mapMap', 'mapData', 'minY', 'maxY', 'minX', 'maxX');
  35469. if (options.visible !== false) {
  35470. preserve.push('area', 'graph');
  35471. }
  35472. series.parallelArrays.forEach(function (key) {
  35473. preserve.push(key + 'Data');
  35474. });
  35475. if (options.data) {
  35476. // setData uses dataSorting options so we need to update them
  35477. // earlier
  35478. if (options.dataSorting) {
  35479. extend(series.options.dataSorting, options.dataSorting);
  35480. }
  35481. this.setData(options.data, false);
  35482. }
  35483. }
  35484. // Do the merge, with some forced options
  35485. options = merge(oldOptions, animation, {
  35486. // When oldOptions.index is null it should't be cleared.
  35487. // Otherwise navigator series will have wrong indexes (#10193).
  35488. index: typeof oldOptions.index === 'undefined' ?
  35489. series.index : oldOptions.index,
  35490. pointStart: pick(
  35491. // when updating from blank (#7933)
  35492. plotOptions && plotOptions.series && plotOptions.series.pointStart, oldOptions.pointStart,
  35493. // when updating after addPoint
  35494. series.xData[0])
  35495. }, (!keepPoints && { data: series.options.data }), options);
  35496. // Merge does not merge arrays, but replaces them. Since points were
  35497. // updated, `series.options.data` has correct merged options, use it:
  35498. if (keepPoints && options.data) {
  35499. options.data = series.options.data;
  35500. }
  35501. // Make sure preserved properties are not destroyed (#3094)
  35502. preserve = groups.concat(preserve);
  35503. preserve.forEach(function (prop) {
  35504. preserve[prop] = series[prop];
  35505. delete series[prop];
  35506. });
  35507. var casting = false;
  35508. if (seriesTypes[newType]) {
  35509. casting = newType !== series.type;
  35510. // Destroy the series and delete all properties, it will be
  35511. // reinserted within the `init` call below
  35512. series.remove(false, false, false, true);
  35513. if (casting) {
  35514. // Modern browsers including IE11
  35515. // @todo slow, consider alternatives mentioned:
  35516. // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
  35517. if (Object.setPrototypeOf) {
  35518. Object.setPrototypeOf(series, seriesTypes[newType].prototype);
  35519. // Legacy (IE < 11)
  35520. }
  35521. else {
  35522. var ownEvents = Object.hasOwnProperty.call(series, 'hcEvents') &&
  35523. series.hcEvents;
  35524. for (n in initialSeriesProto) { // eslint-disable-line guard-for-in
  35525. series[n] = void 0;
  35526. }
  35527. // Reinsert all methods and properties from the new type
  35528. // prototype (#2270, #3719).
  35529. extend(series, seriesTypes[newType].prototype);
  35530. // The events are tied to the prototype chain, don't copy if
  35531. // they're not the series' own
  35532. if (ownEvents) {
  35533. series.hcEvents = ownEvents;
  35534. }
  35535. else {
  35536. delete series.hcEvents;
  35537. }
  35538. }
  35539. }
  35540. }
  35541. else {
  35542. error(17, true, chart, { missingModuleFor: newType });
  35543. }
  35544. // Re-register groups (#3094) and other preserved properties
  35545. preserve.forEach(function (prop) {
  35546. series[prop] = preserve[prop];
  35547. });
  35548. series.init(chart, options);
  35549. // Remove particular elements of the points. Check `series.options`
  35550. // because we need to consider the options being set on plotOptions as
  35551. // well.
  35552. if (keepPoints && this.points) {
  35553. seriesOptions = series.options;
  35554. // What kind of elements to destroy
  35555. if (seriesOptions.visible === false) {
  35556. kinds.graphic = 1;
  35557. kinds.dataLabel = 1;
  35558. }
  35559. else if (!series._hasPointLabels) {
  35560. var marker = seriesOptions.marker,
  35561. dataLabels = seriesOptions.dataLabels;
  35562. if (marker && (marker.enabled === false ||
  35563. 'symbol' in marker // #10870
  35564. )) {
  35565. kinds.graphic = 1;
  35566. }
  35567. if (dataLabels &&
  35568. dataLabels.enabled === false) {
  35569. kinds.dataLabel = 1;
  35570. }
  35571. }
  35572. this.points.forEach(function (point) {
  35573. if (point && point.series) {
  35574. point.resolveColor();
  35575. // Destroy elements in order to recreate based on updated
  35576. // series options.
  35577. if (Object.keys(kinds).length) {
  35578. point.destroyElements(kinds);
  35579. }
  35580. if (seriesOptions.showInLegend === false &&
  35581. point.legendItem) {
  35582. chart.legend.destroyItem(point);
  35583. }
  35584. }
  35585. }, this);
  35586. }
  35587. series.initialType = initialType;
  35588. chart.linkSeries(); // Links are lost in series.remove (#3028)
  35589. // #15383: Fire updatedData if the type has changed to keep linked
  35590. // series such as indicators updated
  35591. if (casting && series.linkedSeries.length) {
  35592. series.isDirtyData = true;
  35593. }
  35594. fireEvent(this, 'afterUpdate');
  35595. if (pick(redraw, true)) {
  35596. chart.redraw(keepPoints ? void 0 : false);
  35597. }
  35598. };
  35599. /**
  35600. * Used from within series.update
  35601. * @private
  35602. */
  35603. Series.prototype.setName = function (name) {
  35604. this.name = this.options.name = this.userOptions.name = name;
  35605. this.chart.isDirtyLegend = true;
  35606. };
  35607. /**
  35608. * Check if the option has changed.
  35609. * @private
  35610. */
  35611. Series.prototype.hasOptionChanged = function (optionName) {
  35612. var chart = this.chart,
  35613. option = this.options[optionName],
  35614. plotOptions = chart.options.plotOptions,
  35615. oldOption = this.userOptions[optionName];
  35616. if (oldOption) {
  35617. return option !== oldOption;
  35618. }
  35619. return option !==
  35620. pick(plotOptions && plotOptions[this.type] && plotOptions[this.type][optionName], plotOptions && plotOptions.series && plotOptions.series[optionName], option);
  35621. };
  35622. /**
  35623. * Runs on mouse over the series graphical items.
  35624. *
  35625. * @function Highcharts.Series#onMouseOver
  35626. * @fires Highcharts.Series#event:mouseOver
  35627. */
  35628. Series.prototype.onMouseOver = function () {
  35629. var series = this,
  35630. chart = series.chart,
  35631. hoverSeries = chart.hoverSeries,
  35632. pointer = chart.pointer;
  35633. pointer.setHoverChartIndex();
  35634. // set normal state to previous series
  35635. if (hoverSeries && hoverSeries !== series) {
  35636. hoverSeries.onMouseOut();
  35637. }
  35638. // trigger the event, but to save processing time,
  35639. // only if defined
  35640. if (series.options.events.mouseOver) {
  35641. fireEvent(series, 'mouseOver');
  35642. }
  35643. // hover this
  35644. series.setState('hover');
  35645. /**
  35646. * Contains the original hovered series.
  35647. *
  35648. * @name Highcharts.Chart#hoverSeries
  35649. * @type {Highcharts.Series|null}
  35650. */
  35651. chart.hoverSeries = series;
  35652. };
  35653. /**
  35654. * Runs on mouse out of the series graphical items.
  35655. *
  35656. * @function Highcharts.Series#onMouseOut
  35657. *
  35658. * @fires Highcharts.Series#event:mouseOut
  35659. */
  35660. Series.prototype.onMouseOut = function () {
  35661. // trigger the event only if listeners exist
  35662. var series = this,
  35663. options = series.options,
  35664. chart = series.chart,
  35665. tooltip = chart.tooltip,
  35666. hoverPoint = chart.hoverPoint;
  35667. // #182, set to null before the mouseOut event fires
  35668. chart.hoverSeries = null;
  35669. // trigger mouse out on the point, which must be in this series
  35670. if (hoverPoint) {
  35671. hoverPoint.onMouseOut();
  35672. }
  35673. // fire the mouse out event
  35674. if (series && options.events.mouseOut) {
  35675. fireEvent(series, 'mouseOut');
  35676. }
  35677. // hide the tooltip
  35678. if (tooltip &&
  35679. !series.stickyTracking &&
  35680. (!tooltip.shared || series.noSharedTooltip)) {
  35681. tooltip.hide();
  35682. }
  35683. // Reset all inactive states
  35684. chart.series.forEach(function (s) {
  35685. s.setState('', true);
  35686. });
  35687. };
  35688. /**
  35689. * Set the state of the series. Called internally on mouse interaction
  35690. * operations, but it can also be called directly to visually
  35691. * highlight a series.
  35692. *
  35693. * @function Highcharts.Series#setState
  35694. *
  35695. * @param {Highcharts.SeriesStateValue|""} [state]
  35696. * The new state, can be either `'hover'`, `'inactive'`, `'select'`,
  35697. * or `''` (an empty string), `'normal'` or `undefined` to set to
  35698. * normal state.
  35699. * @param {boolean} [inherit]
  35700. * Determines if state should be inherited by points too.
  35701. */
  35702. Series.prototype.setState = function (state, inherit) {
  35703. var series = this,
  35704. options = series.options,
  35705. graph = series.graph,
  35706. inactiveOtherPoints = options.inactiveOtherPoints,
  35707. stateOptions = options.states,
  35708. lineWidth = options.lineWidth,
  35709. opacity = options.opacity,
  35710. // By default a quick animation to hover/inactive,
  35711. // slower to un-hover
  35712. stateAnimation = pick((stateOptions[state || 'normal'] &&
  35713. stateOptions[state || 'normal'].animation),
  35714. series.chart.options.chart.animation),
  35715. attribs,
  35716. i = 0;
  35717. state = state || '';
  35718. if (series.state !== state) {
  35719. // Toggle class names
  35720. [
  35721. series.group,
  35722. series.markerGroup,
  35723. series.dataLabelsGroup
  35724. ].forEach(function (group) {
  35725. if (group) {
  35726. // Old state
  35727. if (series.state) {
  35728. group.removeClass('highcharts-series-' + series.state);
  35729. }
  35730. // New state
  35731. if (state) {
  35732. group.addClass('highcharts-series-' + state);
  35733. }
  35734. }
  35735. });
  35736. series.state = state;
  35737. if (!series.chart.styledMode) {
  35738. if (stateOptions[state] &&
  35739. stateOptions[state].enabled === false) {
  35740. return;
  35741. }
  35742. if (state) {
  35743. lineWidth = (stateOptions[state].lineWidth ||
  35744. lineWidth + (stateOptions[state].lineWidthPlus || 0)); // #4035
  35745. opacity = pick(stateOptions[state].opacity, opacity);
  35746. }
  35747. if (graph && !graph.dashstyle) {
  35748. attribs = {
  35749. 'stroke-width': lineWidth
  35750. };
  35751. // Animate the graph stroke-width.
  35752. graph.animate(attribs, stateAnimation);
  35753. while (series['zone-graph-' + i]) {
  35754. series['zone-graph-' + i].animate(attribs, stateAnimation);
  35755. i = i + 1;
  35756. }
  35757. }
  35758. // For some types (pie, networkgraph, sankey) opacity is
  35759. // resolved on a point level
  35760. if (!inactiveOtherPoints) {
  35761. [
  35762. series.group,
  35763. series.markerGroup,
  35764. series.dataLabelsGroup,
  35765. series.labelBySeries
  35766. ].forEach(function (group) {
  35767. if (group) {
  35768. group.animate({
  35769. opacity: opacity
  35770. }, stateAnimation);
  35771. }
  35772. });
  35773. }
  35774. }
  35775. }
  35776. // Don't loop over points on a series that doesn't apply inactive state
  35777. // to siblings markers (e.g. line, column)
  35778. if (inherit && inactiveOtherPoints && series.points) {
  35779. series.setAllPointsToState(state || void 0);
  35780. }
  35781. };
  35782. /**
  35783. * Set the state for all points in the series.
  35784. *
  35785. * @function Highcharts.Series#setAllPointsToState
  35786. *
  35787. * @private
  35788. *
  35789. * @param {string} [state]
  35790. * Can be either `hover` or undefined to set to normal state.
  35791. */
  35792. Series.prototype.setAllPointsToState = function (state) {
  35793. this.points.forEach(function (point) {
  35794. if (point.setState) {
  35795. point.setState(state);
  35796. }
  35797. });
  35798. };
  35799. /**
  35800. * Show or hide the series.
  35801. *
  35802. * @function Highcharts.Series#setVisible
  35803. *
  35804. * @param {boolean} [visible]
  35805. * True to show the series, false to hide. If undefined, the visibility is
  35806. * toggled.
  35807. *
  35808. * @param {boolean} [redraw=true]
  35809. * Whether to redraw the chart after the series is altered. If doing more
  35810. * operations on the chart, it is a good idea to set redraw to false and
  35811. * call {@link Chart#redraw|chart.redraw()} after.
  35812. *
  35813. * @fires Highcharts.Series#event:hide
  35814. * @fires Highcharts.Series#event:show
  35815. */
  35816. Series.prototype.setVisible = function (vis, redraw) {
  35817. var series = this,
  35818. chart = series.chart,
  35819. legendItem = series.legendItem,
  35820. showOrHide,
  35821. ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
  35822. oldVisibility = series.visible;
  35823. // if called without an argument, toggle visibility
  35824. series.visible =
  35825. vis =
  35826. series.options.visible =
  35827. series.userOptions.visible =
  35828. typeof vis === 'undefined' ? !oldVisibility : vis; // #5618
  35829. showOrHide = vis ? 'show' : 'hide';
  35830. // show or hide elements
  35831. [
  35832. 'group',
  35833. 'dataLabelsGroup',
  35834. 'markerGroup',
  35835. 'tracker',
  35836. 'tt'
  35837. ].forEach(function (key) {
  35838. if (series[key]) {
  35839. series[key][showOrHide]();
  35840. }
  35841. });
  35842. // hide tooltip (#1361)
  35843. if (chart.hoverSeries === series ||
  35844. (chart.hoverPoint && chart.hoverPoint.series) === series) {
  35845. series.onMouseOut();
  35846. }
  35847. if (legendItem) {
  35848. chart.legend.colorizeItem(series, vis);
  35849. }
  35850. // rescale or adapt to resized chart
  35851. series.isDirty = true;
  35852. // in a stack, all other series are affected
  35853. if (series.options.stacking) {
  35854. chart.series.forEach(function (otherSeries) {
  35855. if (otherSeries.options.stacking && otherSeries.visible) {
  35856. otherSeries.isDirty = true;
  35857. }
  35858. });
  35859. }
  35860. // show or hide linked series
  35861. series.linkedSeries.forEach(function (otherSeries) {
  35862. otherSeries.setVisible(vis, false);
  35863. });
  35864. if (ignoreHiddenSeries) {
  35865. chart.isDirtyBox = true;
  35866. }
  35867. fireEvent(series, showOrHide);
  35868. if (redraw !== false) {
  35869. chart.redraw();
  35870. }
  35871. };
  35872. /**
  35873. * Show the series if hidden.
  35874. *
  35875. * @sample highcharts/members/series-hide/
  35876. * Toggle visibility from a button
  35877. *
  35878. * @function Highcharts.Series#show
  35879. * @fires Highcharts.Series#event:show
  35880. */
  35881. Series.prototype.show = function () {
  35882. this.setVisible(true);
  35883. };
  35884. /**
  35885. * Hide the series if visible. If the
  35886. * [chart.ignoreHiddenSeries](https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries)
  35887. * option is true, the chart is redrawn without this series.
  35888. *
  35889. * @sample highcharts/members/series-hide/
  35890. * Toggle visibility from a button
  35891. *
  35892. * @function Highcharts.Series#hide
  35893. * @fires Highcharts.Series#event:hide
  35894. */
  35895. Series.prototype.hide = function () {
  35896. this.setVisible(false);
  35897. };
  35898. /**
  35899. * Select or unselect the series. This means its
  35900. * {@link Highcharts.Series.selected|selected}
  35901. * property is set, the checkbox in the legend is toggled and when selected,
  35902. * the series is returned by the {@link Highcharts.Chart#getSelectedSeries}
  35903. * function.
  35904. *
  35905. * @sample highcharts/members/series-select/
  35906. * Select a series from a button
  35907. *
  35908. * @function Highcharts.Series#select
  35909. *
  35910. * @param {boolean} [selected]
  35911. * True to select the series, false to unselect. If undefined, the selection
  35912. * state is toggled.
  35913. *
  35914. * @fires Highcharts.Series#event:select
  35915. * @fires Highcharts.Series#event:unselect
  35916. */
  35917. Series.prototype.select = function (selected) {
  35918. var series = this;
  35919. series.selected =
  35920. selected =
  35921. this.options.selected = (typeof selected === 'undefined' ?
  35922. !series.selected :
  35923. selected);
  35924. if (series.checkbox) {
  35925. series.checkbox.checked = selected;
  35926. }
  35927. fireEvent(series, selected ? 'select' : 'unselect');
  35928. };
  35929. /**
  35930. * Checks if a tooltip should be shown for a given point.
  35931. *
  35932. * @private
  35933. * @param {number} plotX
  35934. * @param {number} plotY
  35935. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  35936. * @return {boolean}
  35937. */
  35938. Series.prototype.shouldShowTooltip = function (plotX, plotY, options) {
  35939. if (options === void 0) { options = {}; }
  35940. options.series = this;
  35941. options.visiblePlotOnly = true;
  35942. return this.chart.isInsidePlot(plotX, plotY, options);
  35943. };
  35944. /**
  35945. * General options for all series types.
  35946. *
  35947. * @optionparent plotOptions.series
  35948. */
  35949. Series.defaultOptions = {
  35950. // base series options
  35951. /**
  35952. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  35953. * of a line graph. Round means that lines are rounded in the ends and
  35954. * bends.
  35955. *
  35956. * @type {Highcharts.SeriesLinecapValue}
  35957. * @default round
  35958. * @since 3.0.7
  35959. * @apioption plotOptions.line.linecap
  35960. */
  35961. /**
  35962. * Pixel width of the graph line.
  35963. *
  35964. * @see In styled mode, the line stroke-width can be set with the
  35965. * `.highcharts-graph` class name.
  35966. *
  35967. * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
  35968. * On all series
  35969. * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
  35970. * On one single series
  35971. *
  35972. * @product highcharts highstock
  35973. *
  35974. * @private
  35975. */
  35976. lineWidth: 2,
  35977. /**
  35978. * For some series, there is a limit that shuts down initial animation
  35979. * by default when the total number of points in the chart is too high.
  35980. * For example, for a column chart and its derivatives, animation does
  35981. * not run if there is more than 250 points totally. To disable this
  35982. * cap, set `animationLimit` to `Infinity`.
  35983. *
  35984. * @type {number}
  35985. * @apioption plotOptions.series.animationLimit
  35986. */
  35987. /**
  35988. * Allow this series' points to be selected by clicking on the graphic
  35989. * (columns, point markers, pie slices, map areas etc).
  35990. *
  35991. * The selected points can be handled by point select and unselect
  35992. * events, or collectively by the [getSelectedPoints
  35993. * ](/class-reference/Highcharts.Chart#getSelectedPoints) function.
  35994. *
  35995. * And alternative way of selecting points is through dragging.
  35996. *
  35997. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
  35998. * Line
  35999. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-column/
  36000. * Column
  36001. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
  36002. * Pie
  36003. * @sample {highcharts} highcharts/chart/events-selection-points/
  36004. * Select a range of points through a drag selection
  36005. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36006. * Map area
  36007. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36008. * Map bubble
  36009. *
  36010. * @since 1.2.0
  36011. *
  36012. * @private
  36013. */
  36014. allowPointSelect: false,
  36015. /**
  36016. * When true, each point or column edge is rounded to its nearest pixel
  36017. * in order to render sharp on screen. In some cases, when there are a
  36018. * lot of densely packed columns, this leads to visible difference
  36019. * in column widths or distance between columns. In these cases,
  36020. * setting `crisp` to `false` may look better, even though each column
  36021. * is rendered blurry.
  36022. *
  36023. * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
  36024. * Crisp is false
  36025. *
  36026. * @since 5.0.10
  36027. * @product highcharts highstock gantt
  36028. *
  36029. * @private
  36030. */
  36031. crisp: true,
  36032. /**
  36033. * If true, a checkbox is displayed next to the legend item to allow
  36034. * selecting the series. The state of the checkbox is determined by
  36035. * the `selected` option.
  36036. *
  36037. * @productdesc {highmaps}
  36038. * Note that if a `colorAxis` is defined, the color axis is represented
  36039. * in the legend, not the series.
  36040. *
  36041. * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
  36042. * Show select box
  36043. *
  36044. * @since 1.2.0
  36045. *
  36046. * @private
  36047. */
  36048. showCheckbox: false,
  36049. /**
  36050. * Enable or disable the initial animation when a series is displayed.
  36051. * The animation can also be set as a configuration object. Please
  36052. * note that this option only applies to the initial animation of the
  36053. * series itself. For other animations, see [chart.animation](
  36054. * #chart.animation) and the animation parameter under the API methods.
  36055. * The following properties are supported:
  36056. *
  36057. * - `defer`: The animation delay time in milliseconds.
  36058. *
  36059. * - `duration`: The duration of the animation in milliseconds.
  36060. *
  36061. * - `easing`: Can be a string reference to an easing function set on
  36062. * the `Math` object or a function. See the _Custom easing function_
  36063. * demo below.
  36064. *
  36065. * Due to poor performance, animation is disabled in old IE browsers
  36066. * for several chart types.
  36067. *
  36068. * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
  36069. * Animation disabled
  36070. * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
  36071. * Slower animation
  36072. * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
  36073. * Custom easing function
  36074. * @sample {highstock} stock/plotoptions/animation-slower/
  36075. * Slower animation
  36076. * @sample {highstock} stock/plotoptions/animation-easing/
  36077. * Custom easing function
  36078. * @sample {highmaps} maps/plotoptions/series-animation-true/
  36079. * Animation enabled on map series
  36080. * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
  36081. * Disabled on mapbubble series
  36082. *
  36083. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36084. * @default {highcharts} true
  36085. * @default {highstock} true
  36086. * @default {highmaps} false
  36087. *
  36088. * @private
  36089. */
  36090. animation: {
  36091. /** @internal */
  36092. duration: 1000
  36093. },
  36094. /**
  36095. * @default 0
  36096. * @type {number}
  36097. * @since 8.2.0
  36098. * @apioption plotOptions.series.animation.defer
  36099. */
  36100. /**
  36101. * An additional class name to apply to the series' graphical elements.
  36102. * This option does not replace default class names of the graphical
  36103. * element.
  36104. *
  36105. * @type {string}
  36106. * @since 5.0.0
  36107. * @apioption plotOptions.series.className
  36108. */
  36109. /**
  36110. * Disable this option to allow series rendering in the whole plotting
  36111. * area.
  36112. *
  36113. * **Note:** Clipping should be always enabled when
  36114. * [chart.zoomType](#chart.zoomType) is set
  36115. *
  36116. * @sample {highcharts} highcharts/plotoptions/series-clip/
  36117. * Disabled clipping
  36118. *
  36119. * @default true
  36120. * @type {boolean}
  36121. * @since 3.0.0
  36122. * @apioption plotOptions.series.clip
  36123. */
  36124. /**
  36125. * The main color of the series. In line type series it applies to the
  36126. * line and the point markers unless otherwise specified. In bar type
  36127. * series it applies to the bars unless a color is specified per point.
  36128. * The default value is pulled from the `options.colors` array.
  36129. *
  36130. * In styled mode, the color can be defined by the
  36131. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  36132. * color can be set with the `.highcharts-series`,
  36133. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  36134. * `.highcharts-series-{n}` class, or individual classes given by the
  36135. * `className` option.
  36136. *
  36137. * @productdesc {highmaps}
  36138. * In maps, the series color is rarely used, as most choropleth maps use
  36139. * the color to denote the value of each point. The series color can
  36140. * however be used in a map with multiple series holding categorized
  36141. * data.
  36142. *
  36143. * @sample {highcharts} highcharts/plotoptions/series-color-general/
  36144. * General plot option
  36145. * @sample {highcharts} highcharts/plotoptions/series-color-specific/
  36146. * One specific series
  36147. * @sample {highcharts} highcharts/plotoptions/series-color-area/
  36148. * Area color
  36149. * @sample {highcharts} highcharts/series/infographic/
  36150. * Pattern fill
  36151. * @sample {highmaps} maps/demo/category-map/
  36152. * Category map by multiple series
  36153. *
  36154. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36155. * @apioption plotOptions.series.color
  36156. */
  36157. /**
  36158. * Styled mode only. A specific color index to use for the series, so
  36159. * its graphic representations are given the class name
  36160. * `highcharts-color-{n}`.
  36161. *
  36162. * @type {number}
  36163. * @since 5.0.0
  36164. * @apioption plotOptions.series.colorIndex
  36165. */
  36166. /**
  36167. * Whether to connect a graph line across null points, or render a gap
  36168. * between the two points on either side of the null.
  36169. *
  36170. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
  36171. * False by default
  36172. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
  36173. * True
  36174. *
  36175. * @type {boolean}
  36176. * @default false
  36177. * @product highcharts highstock
  36178. * @apioption plotOptions.series.connectNulls
  36179. */
  36180. /**
  36181. * You can set the cursor to "pointer" if you have click events attached
  36182. * to the series, to signal to the user that the points and lines can
  36183. * be clicked.
  36184. *
  36185. * In styled mode, the series cursor can be set with the same classes
  36186. * as listed under [series.color](#plotOptions.series.color).
  36187. *
  36188. * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
  36189. * On line graph
  36190. * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
  36191. * On columns
  36192. * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
  36193. * On scatter markers
  36194. * @sample {highstock} stock/plotoptions/cursor/
  36195. * Pointer on a line graph
  36196. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36197. * Map area
  36198. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36199. * Map bubble
  36200. *
  36201. * @type {string|Highcharts.CursorValue}
  36202. * @apioption plotOptions.series.cursor
  36203. */
  36204. /**
  36205. * A reserved subspace to store options and values for customized
  36206. * functionality. Here you can add additional data for your own event
  36207. * callbacks and formatter callbacks.
  36208. *
  36209. * @sample {highcharts} highcharts/point/custom/
  36210. * Point and series with custom data
  36211. *
  36212. * @type {Highcharts.Dictionary<*>}
  36213. * @apioption plotOptions.series.custom
  36214. */
  36215. /**
  36216. * Name of the dash style to use for the graph, or for some series types
  36217. * the outline of each shape.
  36218. *
  36219. * In styled mode, the
  36220. * [stroke dash-array](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-dashstyle/)
  36221. * can be set with the same classes as listed under
  36222. * [series.color](#plotOptions.series.color).
  36223. *
  36224. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  36225. * Possible values demonstrated
  36226. * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
  36227. * Chart suitable for printing in black and white
  36228. * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
  36229. * Possible values demonstrated
  36230. * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
  36231. * Possible values demonstrated
  36232. * @sample {highmaps} maps/plotoptions/series-dashstyle/
  36233. * Dotted borders on a map
  36234. *
  36235. * @type {Highcharts.DashStyleValue}
  36236. * @default Solid
  36237. * @since 2.1
  36238. * @apioption plotOptions.series.dashStyle
  36239. */
  36240. /**
  36241. * A description of the series to add to the screen reader information
  36242. * about the series.
  36243. *
  36244. * @type {string}
  36245. * @since 5.0.0
  36246. * @requires modules/accessibility
  36247. * @apioption plotOptions.series.description
  36248. */
  36249. /**
  36250. * Options for the series data sorting.
  36251. *
  36252. * @type {Highcharts.DataSortingOptionsObject}
  36253. * @since 8.0.0
  36254. * @product highcharts highstock
  36255. * @apioption plotOptions.series.dataSorting
  36256. */
  36257. /**
  36258. * Enable or disable data sorting for the series. Use [xAxis.reversed](
  36259. * #xAxis.reversed) to change the sorting order.
  36260. *
  36261. * @sample {highcharts} highcharts/datasorting/animation/
  36262. * Data sorting in scatter-3d
  36263. * @sample {highcharts} highcharts/datasorting/labels-animation/
  36264. * Axis labels animation
  36265. * @sample {highcharts} highcharts/datasorting/dependent-sorting/
  36266. * Dependent series sorting
  36267. * @sample {highcharts} highcharts/datasorting/independent-sorting/
  36268. * Independent series sorting
  36269. *
  36270. * @type {boolean}
  36271. * @since 8.0.0
  36272. * @apioption plotOptions.series.dataSorting.enabled
  36273. */
  36274. /**
  36275. * Whether to allow matching points by name in an update. If this option
  36276. * is disabled, points will be matched by order.
  36277. *
  36278. * @sample {highcharts} highcharts/datasorting/match-by-name/
  36279. * Enabled match by name
  36280. *
  36281. * @type {boolean}
  36282. * @since 8.0.0
  36283. * @apioption plotOptions.series.dataSorting.matchByName
  36284. */
  36285. /**
  36286. * Determines what data value should be used to sort by.
  36287. *
  36288. * @sample {highcharts} highcharts/datasorting/sort-key/
  36289. * Sort key as `z` value
  36290. *
  36291. * @type {string}
  36292. * @since 8.0.0
  36293. * @default y
  36294. * @apioption plotOptions.series.dataSorting.sortKey
  36295. */
  36296. /**
  36297. * Enable or disable the mouse tracking for a specific series. This
  36298. * includes point tooltips and click events on graphs and points. For
  36299. * large datasets it improves performance.
  36300. *
  36301. * @sample {highcharts} highcharts/plotoptions/series-enablemousetracking-false/
  36302. * No mouse tracking
  36303. * @sample {highmaps} maps/plotoptions/series-enablemousetracking-false/
  36304. * No mouse tracking
  36305. *
  36306. * @type {boolean}
  36307. * @default true
  36308. * @apioption plotOptions.series.enableMouseTracking
  36309. */
  36310. /**
  36311. * Whether to use the Y extremes of the total chart width or only the
  36312. * zoomed area when zooming in on parts of the X axis. By default, the
  36313. * Y axis adjusts to the min and max of the visible data. Cartesian
  36314. * series only.
  36315. *
  36316. * @type {boolean}
  36317. * @default false
  36318. * @since 4.1.6
  36319. * @product highcharts highstock gantt
  36320. * @apioption plotOptions.series.getExtremesFromAll
  36321. */
  36322. /**
  36323. * An array specifying which option maps to which key in the data point
  36324. * array. This makes it convenient to work with unstructured data arrays
  36325. * from different sources.
  36326. *
  36327. * @see [series.data](#series.line.data)
  36328. *
  36329. * @sample {highcharts|highstock} highcharts/series/data-keys/
  36330. * An extended data array with keys
  36331. * @sample {highcharts|highstock} highcharts/series/data-nested-keys/
  36332. * Nested keys used to access object properties
  36333. *
  36334. * @type {Array<string>}
  36335. * @since 4.1.6
  36336. * @apioption plotOptions.series.keys
  36337. */
  36338. /**
  36339. * The line cap used for line ends and line joins on the graph.
  36340. *
  36341. * @type {Highcharts.SeriesLinecapValue}
  36342. * @default round
  36343. * @product highcharts highstock
  36344. * @apioption plotOptions.series.linecap
  36345. */
  36346. /**
  36347. * The [id](#series.id) of another series to link to. Additionally,
  36348. * the value can be ":previous" to link to the previous series. When
  36349. * two series are linked, only the first one appears in the legend.
  36350. * Toggling the visibility of this also toggles the linked series.
  36351. *
  36352. * If master series uses data sorting and linked series does not have
  36353. * its own sorting definition, the linked series will be sorted in the
  36354. * same order as the master one.
  36355. *
  36356. * @sample {highcharts|highstock} highcharts/demo/arearange-line/
  36357. * Linked series
  36358. *
  36359. * @type {string}
  36360. * @since 3.0
  36361. * @product highcharts highstock gantt
  36362. * @apioption plotOptions.series.linkedTo
  36363. */
  36364. /**
  36365. * Options for the corresponding navigator series if `showInNavigator`
  36366. * is `true` for this series. Available options are the same as any
  36367. * series, documented at [plotOptions](#plotOptions.series) and
  36368. * [series](#series).
  36369. *
  36370. * These options are merged with options in [navigator.series](
  36371. * #navigator.series), and will take precedence if the same option is
  36372. * defined both places.
  36373. *
  36374. * @see [navigator.series](#navigator.series)
  36375. *
  36376. * @type {Highcharts.PlotSeriesOptions}
  36377. * @since 5.0.0
  36378. * @product highstock
  36379. * @apioption plotOptions.series.navigatorOptions
  36380. */
  36381. /**
  36382. * The color for the parts of the graph or points that are below the
  36383. * [threshold](#plotOptions.series.threshold). Note that `zones` takes
  36384. * precedence over the negative color. Using `negativeColor` is
  36385. * equivalent to applying a zone with value of 0.
  36386. *
  36387. * @see In styled mode, a negative color is applied by setting this option
  36388. * to `true` combined with the `.highcharts-negative` class name.
  36389. *
  36390. * @sample {highcharts} highcharts/plotoptions/series-negative-color/
  36391. * Spline, area and column
  36392. * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
  36393. * Arearange
  36394. * @sample {highcharts} highcharts/css/series-negative-color/
  36395. * Styled mode
  36396. * @sample {highstock} highcharts/plotoptions/series-negative-color/
  36397. * Spline, area and column
  36398. * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
  36399. * Arearange
  36400. * @sample {highmaps} highcharts/plotoptions/series-negative-color/
  36401. * Spline, area and column
  36402. * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
  36403. * Arearange
  36404. *
  36405. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36406. * @since 3.0
  36407. * @apioption plotOptions.series.negativeColor
  36408. */
  36409. /**
  36410. * Same as
  36411. * [accessibility.pointDescriptionFormatter](#accessibility.pointDescriptionFormatter),
  36412. * but for an individual series. Overrides the chart wide configuration.
  36413. *
  36414. * @type {Function}
  36415. * @since 5.0.12
  36416. * @apioption plotOptions.series.pointDescriptionFormatter
  36417. */
  36418. /**
  36419. * If no x values are given for the points in a series, `pointInterval`
  36420. * defines the interval of the x values. For example, if a series
  36421. * contains one value every decade starting from year 0, set
  36422. * `pointInterval` to `10`. In true `datetime` axes, the `pointInterval`
  36423. * is set in milliseconds.
  36424. *
  36425. * It can be also be combined with `pointIntervalUnit` to draw irregular
  36426. * time intervals.
  36427. *
  36428. * Please note that this options applies to the _series data_, not the
  36429. * interval of the axis ticks, which is independent.
  36430. *
  36431. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36432. * Datetime X axis
  36433. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36434. * Using pointStart and pointInterval
  36435. *
  36436. * @type {number}
  36437. * @default 1
  36438. * @product highcharts highstock gantt
  36439. * @apioption plotOptions.series.pointInterval
  36440. */
  36441. /**
  36442. * On datetime series, this allows for setting the
  36443. * [pointInterval](#plotOptions.series.pointInterval) to irregular time
  36444. * units, `day`, `month` and `year`. A day is usually the same as 24
  36445. * hours, but `pointIntervalUnit` also takes the DST crossover into
  36446. * consideration when dealing with local time. Combine this option with
  36447. * `pointInterval` to draw weeks, quarters, 6 months, 10 years etc.
  36448. *
  36449. * Please note that this options applies to the _series data_, not the
  36450. * interval of the axis ticks, which is independent.
  36451. *
  36452. * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
  36453. * One point a month
  36454. * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
  36455. * One point a month
  36456. *
  36457. * @type {string}
  36458. * @since 4.1.0
  36459. * @product highcharts highstock gantt
  36460. * @validvalue ["day", "month", "year"]
  36461. * @apioption plotOptions.series.pointIntervalUnit
  36462. */
  36463. /**
  36464. * Possible values: `"on"`, `"between"`, `number`.
  36465. *
  36466. * In a column chart, when pointPlacement is `"on"`, the point will not
  36467. * create any padding of the X axis. In a polar column chart this means
  36468. * that the first column points directly north. If the pointPlacement is
  36469. * `"between"`, the columns will be laid out between ticks. This is
  36470. * useful for example for visualising an amount between two points in
  36471. * time or in a certain sector of a polar chart.
  36472. *
  36473. * Since Highcharts 3.0.2, the point placement can also be numeric,
  36474. * where 0 is on the axis value, -0.5 is between this value and the
  36475. * previous, and 0.5 is between this value and the next. Unlike the
  36476. * textual options, numeric point placement options won't affect axis
  36477. * padding.
  36478. *
  36479. * Note that pointPlacement needs a [pointRange](
  36480. * #plotOptions.series.pointRange) to work. For column series this is
  36481. * computed, but for line-type series it needs to be set.
  36482. *
  36483. * For the `xrange` series type and gantt charts, if the Y axis is a
  36484. * category axis, the `pointPlacement` applies to the Y axis rather than
  36485. * the (typically datetime) X axis.
  36486. *
  36487. * Defaults to `undefined` in cartesian charts, `"between"` in polar
  36488. * charts.
  36489. *
  36490. * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
  36491. *
  36492. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-between/
  36493. * Between in a column chart
  36494. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-numeric/
  36495. * Numeric placement for custom layout
  36496. * @sample {highcharts|highstock} maps/plotoptions/heatmap-pointplacement/
  36497. * Placement in heatmap
  36498. *
  36499. * @type {string|number}
  36500. * @since 2.3.0
  36501. * @product highcharts highstock gantt
  36502. * @apioption plotOptions.series.pointPlacement
  36503. */
  36504. /**
  36505. * If no x values are given for the points in a series, pointStart
  36506. * defines on what value to start. For example, if a series contains one
  36507. * yearly value starting from 1945, set pointStart to 1945.
  36508. *
  36509. * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
  36510. * Linear
  36511. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36512. * Datetime
  36513. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36514. * Using pointStart and pointInterval
  36515. *
  36516. * @type {number}
  36517. * @default 0
  36518. * @product highcharts highstock gantt
  36519. * @apioption plotOptions.series.pointStart
  36520. */
  36521. /**
  36522. * Whether to select the series initially. If `showCheckbox` is true,
  36523. * the checkbox next to the series name in the legend will be checked
  36524. * for a selected series.
  36525. *
  36526. * @sample {highcharts} highcharts/plotoptions/series-selected/
  36527. * One out of two series selected
  36528. *
  36529. * @type {boolean}
  36530. * @default false
  36531. * @since 1.2.0
  36532. * @apioption plotOptions.series.selected
  36533. */
  36534. /**
  36535. * Whether to apply a drop shadow to the graph line. Since 2.3 the
  36536. * shadow can be an object configuration containing `color`, `offsetX`,
  36537. * `offsetY`, `opacity` and `width`.
  36538. *
  36539. * @sample {highcharts} highcharts/plotoptions/series-shadow/
  36540. * Shadow enabled
  36541. *
  36542. * @type {boolean|Highcharts.ShadowOptionsObject}
  36543. * @default false
  36544. * @apioption plotOptions.series.shadow
  36545. */
  36546. /**
  36547. * Whether to display this particular series or series type in the
  36548. * legend. Standalone series are shown in legend by default, and linked
  36549. * series are not. Since v7.2.0 it is possible to show series that use
  36550. * colorAxis by setting this option to `true`.
  36551. *
  36552. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  36553. * One series in the legend, one hidden
  36554. *
  36555. * @type {boolean}
  36556. * @apioption plotOptions.series.showInLegend
  36557. */
  36558. /**
  36559. * Whether or not to show the series in the navigator. Takes precedence
  36560. * over [navigator.baseSeries](#navigator.baseSeries) if defined.
  36561. *
  36562. * @type {boolean}
  36563. * @since 5.0.0
  36564. * @product highstock
  36565. * @apioption plotOptions.series.showInNavigator
  36566. */
  36567. /**
  36568. * If set to `true`, the accessibility module will skip past the points
  36569. * in this series for keyboard navigation.
  36570. *
  36571. * @type {boolean}
  36572. * @since 5.0.12
  36573. * @apioption plotOptions.series.skipKeyboardNavigation
  36574. */
  36575. /**
  36576. * Whether to stack the values of each series on top of each other.
  36577. * Possible values are `undefined` to disable, `"normal"` to stack by
  36578. * value or `"percent"`.
  36579. *
  36580. * When stacking is enabled, data must be sorted
  36581. * in ascending X order.
  36582. *
  36583. * Some stacking options are related to specific series types. In the
  36584. * streamgraph series type, the stacking option is set to `"stream"`.
  36585. * The second one is `"overlap"`, which only applies to waterfall
  36586. * series.
  36587. *
  36588. * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
  36589. *
  36590. * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
  36591. * Line
  36592. * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
  36593. * Column
  36594. * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
  36595. * Bar
  36596. * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
  36597. * Area
  36598. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
  36599. * Line
  36600. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-column/
  36601. * Column
  36602. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
  36603. * Bar
  36604. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
  36605. * Area
  36606. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-normal-stacking
  36607. * Waterfall with normal stacking
  36608. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-overlap-stacking
  36609. * Waterfall with overlap stacking
  36610. * @sample {highstock} stock/plotoptions/stacking/
  36611. * Area
  36612. *
  36613. * @type {string}
  36614. * @product highcharts highstock
  36615. * @validvalue ["normal", "overlap", "percent", "stream"]
  36616. * @apioption plotOptions.series.stacking
  36617. */
  36618. /**
  36619. * Whether to apply steps to the line. Possible values are `left`,
  36620. * `center` and `right`.
  36621. *
  36622. * @sample {highcharts} highcharts/plotoptions/line-step/
  36623. * Different step line options
  36624. * @sample {highcharts} highcharts/plotoptions/area-step/
  36625. * Stepped, stacked area
  36626. * @sample {highstock} stock/plotoptions/line-step/
  36627. * Step line
  36628. *
  36629. * @type {string}
  36630. * @since 1.2.5
  36631. * @product highcharts highstock
  36632. * @validvalue ["left", "center", "right"]
  36633. * @apioption plotOptions.series.step
  36634. */
  36635. /**
  36636. * The threshold, also called zero level or base level. For line type
  36637. * series this is only used in conjunction with
  36638. * [negativeColor](#plotOptions.series.negativeColor).
  36639. *
  36640. * @see [softThreshold](#plotOptions.series.softThreshold).
  36641. *
  36642. * @type {number|null}
  36643. * @default 0
  36644. * @since 3.0
  36645. * @product highcharts highstock
  36646. * @apioption plotOptions.series.threshold
  36647. */
  36648. /**
  36649. * Set the initial visibility of the series.
  36650. *
  36651. * @sample {highcharts} highcharts/plotoptions/series-visible/
  36652. * Two series, one hidden and one visible
  36653. * @sample {highstock} stock/plotoptions/series-visibility/
  36654. * Hidden series
  36655. *
  36656. * @type {boolean}
  36657. * @default true
  36658. * @apioption plotOptions.series.visible
  36659. */
  36660. /**
  36661. * Defines the Axis on which the zones are applied.
  36662. *
  36663. * @see [zones](#plotOptions.series.zones)
  36664. *
  36665. * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
  36666. * Zones on the X-Axis
  36667. * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
  36668. * Zones on the X-Axis
  36669. *
  36670. * @type {string}
  36671. * @default y
  36672. * @since 4.1.0
  36673. * @product highcharts highstock
  36674. * @apioption plotOptions.series.zoneAxis
  36675. */
  36676. /**
  36677. * General event handlers for the series items. These event hooks can
  36678. * also be attached to the series at run time using the
  36679. * `Highcharts.addEvent` function.
  36680. *
  36681. * @declare Highcharts.SeriesEventsOptionsObject
  36682. *
  36683. * @private
  36684. */
  36685. events: {},
  36686. /**
  36687. * Fires after the series has finished its initial animation, or in case
  36688. * animation is disabled, immediately as the series is displayed.
  36689. *
  36690. * @sample {highcharts} highcharts/plotoptions/series-events-afteranimate/
  36691. * Show label after animate
  36692. * @sample {highstock} highcharts/plotoptions/series-events-afteranimate/
  36693. * Show label after animate
  36694. *
  36695. * @type {Highcharts.SeriesAfterAnimateCallbackFunction}
  36696. * @since 4.0
  36697. * @product highcharts highstock gantt
  36698. * @context Highcharts.Series
  36699. * @apioption plotOptions.series.events.afterAnimate
  36700. */
  36701. /**
  36702. * Fires when the checkbox next to the series' name in the legend is
  36703. * clicked. One parameter, `event`, is passed to the function. The state
  36704. * of the checkbox is found by `event.checked`. The checked item is
  36705. * found by `event.item`. Return `false` to prevent the default action
  36706. * which is to toggle the select state of the series.
  36707. *
  36708. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  36709. * Alert checkbox status
  36710. *
  36711. * @type {Highcharts.SeriesCheckboxClickCallbackFunction}
  36712. * @since 1.2.0
  36713. * @context Highcharts.Series
  36714. * @apioption plotOptions.series.events.checkboxClick
  36715. */
  36716. /**
  36717. * Fires when the series is clicked. One parameter, `event`, is passed
  36718. * to the function, containing common event information. Additionally,
  36719. * `event.point` holds a pointer to the nearest point on the graph.
  36720. *
  36721. * @sample {highcharts} highcharts/plotoptions/series-events-click/
  36722. * Alert click info
  36723. * @sample {highstock} stock/plotoptions/series-events-click/
  36724. * Alert click info
  36725. * @sample {highmaps} maps/plotoptions/series-events-click/
  36726. * Display click info in subtitle
  36727. *
  36728. * @type {Highcharts.SeriesClickCallbackFunction}
  36729. * @context Highcharts.Series
  36730. * @apioption plotOptions.series.events.click
  36731. */
  36732. /**
  36733. * Fires when the series is hidden after chart generation time, either
  36734. * by clicking the legend item or by calling `.hide()`.
  36735. *
  36736. * @sample {highcharts} highcharts/plotoptions/series-events-hide/
  36737. * Alert when the series is hidden by clicking the legend item
  36738. *
  36739. * @type {Highcharts.SeriesHideCallbackFunction}
  36740. * @since 1.2.0
  36741. * @context Highcharts.Series
  36742. * @apioption plotOptions.series.events.hide
  36743. */
  36744. /**
  36745. * Fires when the legend item belonging to the series is clicked. One
  36746. * parameter, `event`, is passed to the function. The default action
  36747. * is to toggle the visibility of the series. This can be prevented
  36748. * by returning `false` or calling `event.preventDefault()`.
  36749. *
  36750. * @sample {highcharts} highcharts/plotoptions/series-events-legenditemclick/
  36751. * Confirm hiding and showing
  36752. *
  36753. * @type {Highcharts.SeriesLegendItemClickCallbackFunction}
  36754. * @context Highcharts.Series
  36755. * @apioption plotOptions.series.events.legendItemClick
  36756. */
  36757. /**
  36758. * Fires when the mouse leaves the graph. One parameter, `event`, is
  36759. * passed to the function, containing common event information. If the
  36760. * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
  36761. * doesn't happen before the mouse enters another graph or leaves the
  36762. * plot area.
  36763. *
  36764. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  36765. * With sticky tracking by default
  36766. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  36767. * Without sticky tracking
  36768. *
  36769. * @type {Highcharts.SeriesMouseOutCallbackFunction}
  36770. * @context Highcharts.Series
  36771. * @apioption plotOptions.series.events.mouseOut
  36772. */
  36773. /**
  36774. * Fires when the mouse enters the graph. One parameter, `event`, is
  36775. * passed to the function, containing common event information.
  36776. *
  36777. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  36778. * With sticky tracking by default
  36779. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  36780. * Without sticky tracking
  36781. *
  36782. * @type {Highcharts.SeriesMouseOverCallbackFunction}
  36783. * @context Highcharts.Series
  36784. * @apioption plotOptions.series.events.mouseOver
  36785. */
  36786. /**
  36787. * Fires when the series is shown after chart generation time, either
  36788. * by clicking the legend item or by calling `.show()`.
  36789. *
  36790. * @sample {highcharts} highcharts/plotoptions/series-events-show/
  36791. * Alert when the series is shown by clicking the legend item.
  36792. *
  36793. * @type {Highcharts.SeriesShowCallbackFunction}
  36794. * @since 1.2.0
  36795. * @context Highcharts.Series
  36796. * @apioption plotOptions.series.events.show
  36797. */
  36798. /**
  36799. * Options for the point markers of line-like series. Properties like
  36800. * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
  36801. * of the markers. Other series types, like column series, don't have
  36802. * markers, but have visual options on the series level instead.
  36803. *
  36804. * In styled mode, the markers can be styled with the
  36805. * `.highcharts-point`, `.highcharts-point-hover` and
  36806. * `.highcharts-point-select` class names.
  36807. *
  36808. * @declare Highcharts.PointMarkerOptionsObject
  36809. *
  36810. * @private
  36811. */
  36812. marker: {
  36813. /**
  36814. * Enable or disable the point marker. If `undefined`, the markers
  36815. * are hidden when the data is dense, and shown for more widespread
  36816. * data points.
  36817. *
  36818. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
  36819. * Disabled markers
  36820. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled-false/
  36821. * Disabled in normal state but enabled on hover
  36822. * @sample {highstock} stock/plotoptions/series-marker/
  36823. * Enabled markers
  36824. *
  36825. * @type {boolean}
  36826. * @default {highcharts} undefined
  36827. * @default {highstock} false
  36828. * @apioption plotOptions.series.marker.enabled
  36829. */
  36830. /**
  36831. * The threshold for how dense the point markers should be before
  36832. * they are hidden, given that `enabled` is not defined. The number
  36833. * indicates the horizontal distance between the two closest points
  36834. * in the series, as multiples of the `marker.radius`. In other
  36835. * words, the default value of 2 means points are hidden if
  36836. * overlapping horizontally.
  36837. *
  36838. * @sample highcharts/plotoptions/series-marker-enabledthreshold
  36839. * A higher threshold
  36840. *
  36841. * @since 6.0.5
  36842. */
  36843. enabledThreshold: 2,
  36844. /**
  36845. * The fill color of the point marker. When `undefined`, the series'
  36846. * or point's color is used.
  36847. *
  36848. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  36849. * White fill
  36850. *
  36851. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36852. * @apioption plotOptions.series.marker.fillColor
  36853. */
  36854. /**
  36855. * Image markers only. Set the image width explicitly. When using
  36856. * this option, a `width` must also be set.
  36857. *
  36858. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  36859. * Fixed width and height
  36860. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  36861. * Fixed width and height
  36862. *
  36863. * @type {number}
  36864. * @since 4.0.4
  36865. * @apioption plotOptions.series.marker.height
  36866. */
  36867. /**
  36868. * The color of the point marker's outline. When `undefined`, the
  36869. * series' or point's color is used.
  36870. *
  36871. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  36872. * Inherit from series color (undefined)
  36873. *
  36874. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36875. */
  36876. lineColor: palette.backgroundColor,
  36877. /**
  36878. * The width of the point marker's outline.
  36879. *
  36880. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  36881. * 2px blue marker
  36882. */
  36883. lineWidth: 0,
  36884. /**
  36885. * The radius of the point marker.
  36886. *
  36887. * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
  36888. * Bigger markers
  36889. *
  36890. * @default {highstock} 2
  36891. * @default {highcharts} 4
  36892. *
  36893. */
  36894. radius: 4,
  36895. /**
  36896. * A predefined shape or symbol for the marker. When undefined, the
  36897. * symbol is pulled from options.symbols. Other possible values are
  36898. * `'circle'`, `'square'`,`'diamond'`, `'triangle'` and
  36899. * `'triangle-down'`.
  36900. *
  36901. * Additionally, the URL to a graphic can be given on this form:
  36902. * `'url(graphic.png)'`. Note that for the image to be applied to
  36903. * exported charts, its URL needs to be accessible by the export
  36904. * server.
  36905. *
  36906. * Custom callbacks for symbol path generation can also be added to
  36907. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  36908. * used by its method name, as shown in the demo.
  36909. *
  36910. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  36911. * Predefined, graphic and custom markers
  36912. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  36913. * Predefined, graphic and custom markers
  36914. *
  36915. * @type {string}
  36916. * @apioption plotOptions.series.marker.symbol
  36917. */
  36918. /**
  36919. * Image markers only. Set the image width explicitly. When using
  36920. * this option, a `height` must also be set.
  36921. *
  36922. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  36923. * Fixed width and height
  36924. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  36925. * Fixed width and height
  36926. *
  36927. * @type {number}
  36928. * @since 4.0.4
  36929. * @apioption plotOptions.series.marker.width
  36930. */
  36931. /**
  36932. * States for a single point marker.
  36933. *
  36934. * @declare Highcharts.PointStatesOptionsObject
  36935. */
  36936. states: {
  36937. /**
  36938. * The normal state of a single point marker. Currently only
  36939. * used for setting animation when returning to normal state
  36940. * from hover.
  36941. *
  36942. * @declare Highcharts.PointStatesNormalOptionsObject
  36943. */
  36944. normal: {
  36945. /**
  36946. * Animation when returning to normal state after hovering.
  36947. *
  36948. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36949. */
  36950. animation: true
  36951. },
  36952. /**
  36953. * The hover state for a single point marker.
  36954. *
  36955. * @declare Highcharts.PointStatesHoverOptionsObject
  36956. */
  36957. hover: {
  36958. /**
  36959. * Animation when hovering over the marker.
  36960. *
  36961. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36962. */
  36963. animation: {
  36964. /** @internal */
  36965. duration: 50
  36966. },
  36967. /**
  36968. * Enable or disable the point marker.
  36969. *
  36970. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-enabled/
  36971. * Disabled hover state
  36972. */
  36973. enabled: true,
  36974. /**
  36975. * The fill color of the marker in hover state. When
  36976. * `undefined`, the series' or point's fillColor for normal
  36977. * state is used.
  36978. *
  36979. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36980. * @apioption plotOptions.series.marker.states.hover.fillColor
  36981. */
  36982. /**
  36983. * The color of the point marker's outline. When
  36984. * `undefined`, the series' or point's lineColor for normal
  36985. * state is used.
  36986. *
  36987. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linecolor/
  36988. * White fill color, black line color
  36989. *
  36990. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36991. * @apioption plotOptions.series.marker.states.hover.lineColor
  36992. */
  36993. /**
  36994. * The width of the point marker's outline. When
  36995. * `undefined`, the series' or point's lineWidth for normal
  36996. * state is used.
  36997. *
  36998. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linewidth/
  36999. * 3px line width
  37000. *
  37001. * @type {number}
  37002. * @apioption plotOptions.series.marker.states.hover.lineWidth
  37003. */
  37004. /**
  37005. * The radius of the point marker. In hover state, it
  37006. * defaults to the normal state's radius + 2 as per the
  37007. * [radiusPlus](#plotOptions.series.marker.states.hover.radiusPlus)
  37008. * option.
  37009. *
  37010. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/
  37011. * 10px radius
  37012. *
  37013. * @type {number}
  37014. * @apioption plotOptions.series.marker.states.hover.radius
  37015. */
  37016. /**
  37017. * The number of pixels to increase the radius of the
  37018. * hovered point.
  37019. *
  37020. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37021. * 5 pixels greater radius on hover
  37022. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37023. * 5 pixels greater radius on hover
  37024. *
  37025. * @since 4.0.3
  37026. */
  37027. radiusPlus: 2,
  37028. /**
  37029. * The additional line width for a hovered point.
  37030. *
  37031. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37032. * 2 pixels wider on hover
  37033. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37034. * 2 pixels wider on hover
  37035. *
  37036. * @since 4.0.3
  37037. */
  37038. lineWidthPlus: 1
  37039. },
  37040. /**
  37041. * The appearance of the point marker when selected. In order to
  37042. * allow a point to be selected, set the
  37043. * `series.allowPointSelect` option to true.
  37044. *
  37045. * @declare Highcharts.PointStatesSelectOptionsObject
  37046. */
  37047. select: {
  37048. /**
  37049. * Enable or disable visible feedback for selection.
  37050. *
  37051. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
  37052. * Disabled select state
  37053. *
  37054. * @type {boolean}
  37055. * @default true
  37056. * @apioption plotOptions.series.marker.states.select.enabled
  37057. */
  37058. /**
  37059. * The radius of the point marker. In hover state, it
  37060. * defaults to the normal state's radius + 2.
  37061. *
  37062. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
  37063. * 10px radius for selected points
  37064. *
  37065. * @type {number}
  37066. * @apioption plotOptions.series.marker.states.select.radius
  37067. */
  37068. /**
  37069. * The fill color of the point marker.
  37070. *
  37071. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
  37072. * Solid red discs for selected points
  37073. *
  37074. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37075. */
  37076. fillColor: palette.neutralColor20,
  37077. /**
  37078. * The color of the point marker's outline. When
  37079. * `undefined`, the series' or point's color is used.
  37080. *
  37081. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
  37082. * Red line color for selected points
  37083. *
  37084. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37085. */
  37086. lineColor: palette.neutralColor100,
  37087. /**
  37088. * The width of the point marker's outline.
  37089. *
  37090. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
  37091. * 3px line width for selected points
  37092. */
  37093. lineWidth: 2
  37094. }
  37095. }
  37096. },
  37097. /**
  37098. * Properties for each single point.
  37099. *
  37100. * @declare Highcharts.PlotSeriesPointOptions
  37101. *
  37102. * @private
  37103. */
  37104. point: {
  37105. /**
  37106. * Fires when a point is clicked. One parameter, `event`, is passed
  37107. * to the function, containing common event information.
  37108. *
  37109. * If the `series.allowPointSelect` option is true, the default
  37110. * action for the point's click event is to toggle the point's
  37111. * select state. Returning `false` cancels this action.
  37112. *
  37113. * @sample {highcharts} highcharts/plotoptions/series-point-events-click/
  37114. * Click marker to alert values
  37115. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/
  37116. * Click column
  37117. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/
  37118. * Go to URL
  37119. * @sample {highmaps} maps/plotoptions/series-point-events-click/
  37120. * Click marker to display values
  37121. * @sample {highmaps} maps/plotoptions/series-point-events-click-url/
  37122. * Go to URL
  37123. *
  37124. * @type {Highcharts.PointClickCallbackFunction}
  37125. * @context Highcharts.Point
  37126. * @apioption plotOptions.series.point.events.click
  37127. */
  37128. /**
  37129. * Fires when the mouse leaves the area close to the point. One
  37130. * parameter, `event`, is passed to the function, containing common
  37131. * event information.
  37132. *
  37133. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37134. * Show values in the chart's corner on mouse over
  37135. *
  37136. * @type {Highcharts.PointMouseOutCallbackFunction}
  37137. * @context Highcharts.Point
  37138. * @apioption plotOptions.series.point.events.mouseOut
  37139. */
  37140. /**
  37141. * Fires when the mouse enters the area close to the point. One
  37142. * parameter, `event`, is passed to the function, containing common
  37143. * event information.
  37144. *
  37145. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37146. * Show values in the chart's corner on mouse over
  37147. *
  37148. * @type {Highcharts.PointMouseOverCallbackFunction}
  37149. * @context Highcharts.Point
  37150. * @apioption plotOptions.series.point.events.mouseOver
  37151. */
  37152. /**
  37153. * Fires when the point is removed using the `.remove()` method. One
  37154. * parameter, `event`, is passed to the function. Returning `false`
  37155. * cancels the operation.
  37156. *
  37157. * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/
  37158. * Remove point and confirm
  37159. *
  37160. * @type {Highcharts.PointRemoveCallbackFunction}
  37161. * @since 1.2.0
  37162. * @context Highcharts.Point
  37163. * @apioption plotOptions.series.point.events.remove
  37164. */
  37165. /**
  37166. * Fires when the point is selected either programmatically or
  37167. * following a click on the point. One parameter, `event`, is passed
  37168. * to the function. Returning `false` cancels the operation.
  37169. *
  37170. * @sample {highcharts} highcharts/plotoptions/series-point-events-select/
  37171. * Report the last selected point
  37172. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37173. * Report select and unselect
  37174. *
  37175. * @type {Highcharts.PointSelectCallbackFunction}
  37176. * @since 1.2.0
  37177. * @context Highcharts.Point
  37178. * @apioption plotOptions.series.point.events.select
  37179. */
  37180. /**
  37181. * Fires when the point is unselected either programmatically or
  37182. * following a click on the point. One parameter, `event`, is passed
  37183. * to the function.
  37184. * Returning `false` cancels the operation.
  37185. *
  37186. * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/
  37187. * Report the last unselected point
  37188. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37189. * Report select and unselect
  37190. *
  37191. * @type {Highcharts.PointUnselectCallbackFunction}
  37192. * @since 1.2.0
  37193. * @context Highcharts.Point
  37194. * @apioption plotOptions.series.point.events.unselect
  37195. */
  37196. /**
  37197. * Fires when the point is updated programmatically through the
  37198. * `.update()` method. One parameter, `event`, is passed to the
  37199. * function. The new point options can be accessed through
  37200. * `event.options`. Returning `false` cancels the operation.
  37201. *
  37202. * @sample {highcharts} highcharts/plotoptions/series-point-events-update/
  37203. * Confirm point updating
  37204. *
  37205. * @type {Highcharts.PointUpdateCallbackFunction}
  37206. * @since 1.2.0
  37207. * @context Highcharts.Point
  37208. * @apioption plotOptions.series.point.events.update
  37209. */
  37210. /**
  37211. * Events for each single point.
  37212. *
  37213. * @declare Highcharts.PointEventsOptionsObject
  37214. */
  37215. events: {}
  37216. },
  37217. /**
  37218. * Options for the series data labels, appearing next to each data
  37219. * point.
  37220. *
  37221. * Since v6.2.0, multiple data labels can be applied to each single
  37222. * point by defining them as an array of configs.
  37223. *
  37224. * In styled mode, the data labels can be styled with the
  37225. * `.highcharts-data-label-box` and `.highcharts-data-label` class names
  37226. * ([see example](https://www.highcharts.com/samples/highcharts/css/series-datalabels)).
  37227. *
  37228. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled
  37229. * Data labels enabled
  37230. * @sample {highcharts} highcharts/plotoptions/series-datalabels-multiple
  37231. * Multiple data labels on a bar series
  37232. * @sample {highcharts} highcharts/css/series-datalabels
  37233. * Style mode example
  37234. *
  37235. * @type {*|Array<*>}
  37236. * @product highcharts highstock highmaps gantt
  37237. *
  37238. * @private
  37239. */
  37240. dataLabels: {
  37241. /**
  37242. * Enable or disable the initial animation when a series is
  37243. * displayed for the `dataLabels`. The animation can also be set as
  37244. * a configuration object. Please note that this option only
  37245. * applies to the initial animation.
  37246. * For other animations, see [chart.animation](#chart.animation)
  37247. * and the animation parameter under the API methods.
  37248. * The following properties are supported:
  37249. *
  37250. * - `defer`: The animation delay time in milliseconds.
  37251. *
  37252. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  37253. * Animation defer settings
  37254. *
  37255. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37256. * @since 8.2.0
  37257. * @apioption plotOptions.series.dataLabels.animation
  37258. */
  37259. animation: {},
  37260. /**
  37261. * The animation delay time in milliseconds.
  37262. * Set to `0` renders dataLabel immediately.
  37263. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  37264. *
  37265. * @type {number}
  37266. * @since 8.2.0
  37267. * @apioption plotOptions.series.dataLabels.animation.defer
  37268. */
  37269. /**
  37270. * The alignment of the data label compared to the point. If
  37271. * `right`, the right side of the label should be touching the
  37272. * point. For points with an extent, like columns, the alignments
  37273. * also dictates how to align it inside the box, as given with the
  37274. * [inside](#plotOptions.column.dataLabels.inside)
  37275. * option. Can be one of `left`, `center` or `right`.
  37276. *
  37277. * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/
  37278. * Left aligned
  37279. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  37280. * Data labels inside the bar
  37281. *
  37282. * @type {Highcharts.AlignValue|null}
  37283. */
  37284. align: 'center',
  37285. /**
  37286. * Whether to allow data labels to overlap. To make the labels less
  37287. * sensitive for overlapping, the
  37288. * [dataLabels.padding](#plotOptions.series.dataLabels.padding)
  37289. * can be set to 0.
  37290. *
  37291. * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/
  37292. * Don't allow overlap
  37293. *
  37294. * @type {boolean}
  37295. * @default false
  37296. * @since 4.1.0
  37297. * @apioption plotOptions.series.dataLabels.allowOverlap
  37298. */
  37299. /**
  37300. * The background color or gradient for the data label.
  37301. *
  37302. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37303. * Data labels box options
  37304. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37305. * Data labels box options
  37306. *
  37307. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37308. * @since 2.2.1
  37309. * @apioption plotOptions.series.dataLabels.backgroundColor
  37310. */
  37311. /**
  37312. * The border color for the data label. Defaults to `undefined`.
  37313. *
  37314. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37315. * Data labels box options
  37316. *
  37317. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37318. * @since 2.2.1
  37319. * @apioption plotOptions.series.dataLabels.borderColor
  37320. */
  37321. /**
  37322. * The border radius in pixels for the data label.
  37323. *
  37324. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37325. * Data labels box options
  37326. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37327. * Data labels box options
  37328. *
  37329. * @type {number}
  37330. * @default 0
  37331. * @since 2.2.1
  37332. * @apioption plotOptions.series.dataLabels.borderRadius
  37333. */
  37334. /**
  37335. * The border width in pixels for the data label.
  37336. *
  37337. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37338. * Data labels box options
  37339. *
  37340. * @type {number}
  37341. * @default 0
  37342. * @since 2.2.1
  37343. * @apioption plotOptions.series.dataLabels.borderWidth
  37344. */
  37345. /**
  37346. * A class name for the data label. Particularly in styled mode,
  37347. * this can be used to give each series' or point's data label
  37348. * unique styling. In addition to this option, a default color class
  37349. * name is added so that we can give the labels a contrast text
  37350. * shadow.
  37351. *
  37352. * @sample {highcharts} highcharts/css/data-label-contrast/
  37353. * Contrast text shadow
  37354. * @sample {highcharts} highcharts/css/series-datalabels/
  37355. * Styling by CSS
  37356. *
  37357. * @type {string}
  37358. * @since 5.0.0
  37359. * @apioption plotOptions.series.dataLabels.className
  37360. */
  37361. /**
  37362. * The text color for the data labels. Defaults to `undefined`. For
  37363. * certain series types, like column or map, the data labels can be
  37364. * drawn inside the points. In this case the data label will be
  37365. * drawn with maximum contrast by default. Additionally, it will be
  37366. * given a `text-outline` style with the opposite color, to further
  37367. * increase the contrast. This can be overridden by setting the
  37368. * `text-outline` style to `none` in the `dataLabels.style` option.
  37369. *
  37370. * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
  37371. * Red data labels
  37372. * @sample {highmaps} maps/demo/color-axis/
  37373. * White data labels
  37374. *
  37375. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37376. * @apioption plotOptions.series.dataLabels.color
  37377. */
  37378. /**
  37379. * Whether to hide data labels that are outside the plot area. By
  37380. * default, the data label is moved inside the plot area according
  37381. * to the
  37382. * [overflow](#plotOptions.series.dataLabels.overflow)
  37383. * option.
  37384. *
  37385. * @type {boolean}
  37386. * @default true
  37387. * @since 2.3.3
  37388. * @apioption plotOptions.series.dataLabels.crop
  37389. */
  37390. /**
  37391. * Whether to defer displaying the data labels until the initial
  37392. * series animation has finished. Setting to `false` renders the
  37393. * data label immediately. If set to `true` inherits the defer
  37394. * time set in [plotOptions.series.animation](#plotOptions.series.animation).
  37395. * If set to a number, a defer time is specified in milliseconds.
  37396. *
  37397. * @sample highcharts/plotoptions/animation-defer
  37398. * Set defer time
  37399. *
  37400. * @since 4.0.0
  37401. * @type {boolean|number}
  37402. * @product highcharts highstock gantt
  37403. */
  37404. defer: true,
  37405. /**
  37406. * Enable or disable the data labels.
  37407. *
  37408. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/
  37409. * Data labels enabled
  37410. * @sample {highmaps} maps/demo/color-axis/
  37411. * Data labels enabled
  37412. *
  37413. * @type {boolean}
  37414. * @default false
  37415. * @apioption plotOptions.series.dataLabels.enabled
  37416. */
  37417. /**
  37418. * A declarative filter to control of which data labels to display.
  37419. * The declarative filter is designed for use when callback
  37420. * functions are not available, like when the chart options require
  37421. * a pure JSON structure or for use with graphical editors. For
  37422. * programmatic control, use the `formatter` instead, and return
  37423. * `undefined` to disable a single data label.
  37424. *
  37425. * @example
  37426. * filter: {
  37427. * property: 'percentage',
  37428. * operator: '>',
  37429. * value: 4
  37430. * }
  37431. *
  37432. * @sample {highcharts} highcharts/demo/pie-monochrome
  37433. * Data labels filtered by percentage
  37434. *
  37435. * @declare Highcharts.DataLabelsFilterOptionsObject
  37436. * @since 6.0.3
  37437. * @apioption plotOptions.series.dataLabels.filter
  37438. */
  37439. /**
  37440. * The operator to compare by. Can be one of `>`, `<`, `>=`, `<=`,
  37441. * `==`, and `===`.
  37442. *
  37443. * @type {string}
  37444. * @validvalue [">", "<", ">=", "<=", "==", "==="]
  37445. * @apioption plotOptions.series.dataLabels.filter.operator
  37446. */
  37447. /**
  37448. * The point property to filter by. Point options are passed
  37449. * directly to properties, additionally there are `y` value,
  37450. * `percentage` and others listed under {@link Highcharts.Point}
  37451. * members.
  37452. *
  37453. * @type {string}
  37454. * @apioption plotOptions.series.dataLabels.filter.property
  37455. */
  37456. /**
  37457. * The value to compare against.
  37458. *
  37459. * @type {number}
  37460. * @apioption plotOptions.series.dataLabels.filter.value
  37461. */
  37462. /**
  37463. * A
  37464. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  37465. * for the data label. Available variables are the same as for
  37466. * `formatter`.
  37467. *
  37468. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37469. * Add a unit
  37470. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37471. * Formatted value in the data label
  37472. *
  37473. * @type {string}
  37474. * @default y
  37475. * @default point.value
  37476. * @since 3.0
  37477. * @apioption plotOptions.series.dataLabels.format
  37478. */
  37479. // eslint-disable-next-line valid-jsdoc
  37480. /**
  37481. * Callback JavaScript function to format the data label. Note that
  37482. * if a `format` is defined, the format takes precedence and the
  37483. * formatter is ignored.
  37484. *
  37485. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37486. * Formatted value
  37487. *
  37488. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37489. */
  37490. formatter: function () {
  37491. var numberFormatter = this.series.chart.numberFormatter;
  37492. return typeof this.y !== 'number' ? '' : numberFormatter(this.y, -1);
  37493. },
  37494. /**
  37495. * For points with an extent, like columns or map areas, whether to
  37496. * align the data label inside the box or to the actual value point.
  37497. * Defaults to `false` in most cases, `true` in stacked columns.
  37498. *
  37499. * @type {boolean}
  37500. * @since 3.0
  37501. * @apioption plotOptions.series.dataLabels.inside
  37502. */
  37503. /**
  37504. * Format for points with the value of null. Works analogously to
  37505. * [format](#plotOptions.series.dataLabels.format). `nullFormat` can
  37506. * be applied only to series which support displaying null points.
  37507. *
  37508. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37509. * Format data label and tooltip for null point.
  37510. *
  37511. * @type {boolean|string}
  37512. * @since 7.1.0
  37513. * @apioption plotOptions.series.dataLabels.nullFormat
  37514. */
  37515. /**
  37516. * Callback JavaScript function that defines formatting for points
  37517. * with the value of null. Works analogously to
  37518. * [formatter](#plotOptions.series.dataLabels.formatter).
  37519. * `nullPointFormatter` can be applied only to series which support
  37520. * displaying null points.
  37521. *
  37522. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37523. * Format data label and tooltip for null point.
  37524. *
  37525. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37526. * @since 7.1.0
  37527. * @apioption plotOptions.series.dataLabels.nullFormatter
  37528. */
  37529. /**
  37530. * How to handle data labels that flow outside the plot area. The
  37531. * default is `"justify"`, which aligns them inside the plot area.
  37532. * For columns and bars, this means it will be moved inside the bar.
  37533. * To display data labels outside the plot area, set `crop` to
  37534. * `false` and `overflow` to `"allow"`.
  37535. *
  37536. * @type {Highcharts.DataLabelsOverflowValue}
  37537. * @default justify
  37538. * @since 3.0.6
  37539. * @apioption plotOptions.series.dataLabels.overflow
  37540. */
  37541. /**
  37542. * When either the `borderWidth` or the `backgroundColor` is set,
  37543. * this is the padding within the box.
  37544. *
  37545. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37546. * Data labels box options
  37547. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37548. * Data labels box options
  37549. *
  37550. * @since 2.2.1
  37551. */
  37552. padding: 5,
  37553. /**
  37554. * Aligns data labels relative to points. If `center` alignment is
  37555. * not possible, it defaults to `right`.
  37556. *
  37557. * @type {Highcharts.AlignValue}
  37558. * @default center
  37559. * @apioption plotOptions.series.dataLabels.position
  37560. */
  37561. /**
  37562. * Text rotation in degrees. Note that due to a more complex
  37563. * structure, backgrounds, borders and padding will be lost on a
  37564. * rotated data label.
  37565. *
  37566. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37567. * Vertical labels
  37568. *
  37569. * @type {number}
  37570. * @default 0
  37571. * @apioption plotOptions.series.dataLabels.rotation
  37572. */
  37573. /**
  37574. * The shadow of the box. Works best with `borderWidth` or
  37575. * `backgroundColor`. Since 2.3 the shadow can be an object
  37576. * configuration containing `color`, `offsetX`, `offsetY`, `opacity`
  37577. * and `width`.
  37578. *
  37579. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37580. * Data labels box options
  37581. *
  37582. * @type {boolean|Highcharts.ShadowOptionsObject}
  37583. * @default false
  37584. * @since 2.2.1
  37585. * @apioption plotOptions.series.dataLabels.shadow
  37586. */
  37587. /**
  37588. * The name of a symbol to use for the border around the label.
  37589. * Symbols are predefined functions on the Renderer object.
  37590. *
  37591. * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/
  37592. * A callout for annotations
  37593. *
  37594. * @type {string}
  37595. * @default square
  37596. * @since 4.1.2
  37597. * @apioption plotOptions.series.dataLabels.shape
  37598. */
  37599. /**
  37600. * Styles for the label. The default `color` setting is
  37601. * `"contrast"`, which is a pseudo color that Highcharts picks up
  37602. * and applies the maximum contrast to the underlying point item,
  37603. * for example the bar in a bar chart.
  37604. *
  37605. * The `textOutline` is a pseudo property that applies an outline of
  37606. * the given width with the given color, which by default is the
  37607. * maximum contrast to the text. So a bright text color will result
  37608. * in a black text outline for maximum readability on a mixed
  37609. * background. In some cases, especially with grayscale text, the
  37610. * text outline doesn't work well, in which cases it can be disabled
  37611. * by setting it to `"none"`. When `useHTML` is true, the
  37612. * `textOutline` will not be picked up. In this, case, the same
  37613. * effect can be acheived through the `text-shadow` CSS property.
  37614. *
  37615. * For some series types, where each point has an extent, like for
  37616. * example tree maps, the data label may overflow the point. There
  37617. * are two strategies for handling overflow. By default, the text
  37618. * will wrap to multiple lines. The other strategy is to set
  37619. * `style.textOverflow` to `ellipsis`, which will keep the text on
  37620. * one line plus it will break inside long words.
  37621. *
  37622. * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
  37623. * Bold labels
  37624. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow/
  37625. * Long labels truncated with an ellipsis in a pie
  37626. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap/
  37627. * Long labels are wrapped in a pie
  37628. * @sample {highmaps} maps/demo/color-axis/
  37629. * Bold labels
  37630. *
  37631. * @type {Highcharts.CSSObject}
  37632. * @since 4.1.0
  37633. * @apioption plotOptions.series.dataLabels.style
  37634. */
  37635. style: {
  37636. /** @internal */
  37637. fontSize: '11px',
  37638. /** @internal */
  37639. fontWeight: 'bold',
  37640. /** @internal */
  37641. color: 'contrast',
  37642. /** @internal */
  37643. textOutline: '1px contrast'
  37644. },
  37645. /**
  37646. * Options for a label text which should follow marker's shape.
  37647. * Border and background are disabled for a label that follows a
  37648. * path.
  37649. *
  37650. * **Note:** Only SVG-based renderer supports this option. Setting
  37651. * `useHTML` to true will disable this option.
  37652. *
  37653. * @declare Highcharts.DataLabelsTextPathOptionsObject
  37654. * @since 7.1.0
  37655. * @apioption plotOptions.series.dataLabels.textPath
  37656. */
  37657. /**
  37658. * Presentation attributes for the text path.
  37659. *
  37660. * @type {Highcharts.SVGAttributes}
  37661. * @since 7.1.0
  37662. * @apioption plotOptions.series.dataLabels.textPath.attributes
  37663. */
  37664. /**
  37665. * Enable or disable `textPath` option for link's or marker's data
  37666. * labels.
  37667. *
  37668. * @type {boolean}
  37669. * @since 7.1.0
  37670. * @apioption plotOptions.series.dataLabels.textPath.enabled
  37671. */
  37672. /**
  37673. * Whether to
  37674. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  37675. * to render the labels.
  37676. *
  37677. * @type {boolean}
  37678. * @default false
  37679. * @apioption plotOptions.series.dataLabels.useHTML
  37680. */
  37681. /**
  37682. * The vertical alignment of a data label. Can be one of `top`,
  37683. * `middle` or `bottom`. The default value depends on the data, for
  37684. * instance in a column chart, the label is above positive values
  37685. * and below negative values.
  37686. *
  37687. * @type {Highcharts.VerticalAlignValue|null}
  37688. * @since 2.3.3
  37689. */
  37690. verticalAlign: 'bottom',
  37691. /**
  37692. * The x position offset of the label relative to the point in
  37693. * pixels.
  37694. *
  37695. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37696. * Vertical and positioned
  37697. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  37698. * Data labels inside the bar
  37699. */
  37700. x: 0,
  37701. /**
  37702. * The Z index of the data labels. The default Z index puts it above
  37703. * the series. Use a Z index of 2 to display it behind the series.
  37704. *
  37705. * @type {number}
  37706. * @default 6
  37707. * @since 2.3.5
  37708. * @apioption plotOptions.series.dataLabels.z
  37709. */
  37710. /**
  37711. * The y position offset of the label relative to the point in
  37712. * pixels.
  37713. *
  37714. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37715. * Vertical and positioned
  37716. */
  37717. y: 0
  37718. },
  37719. /**
  37720. * When the series contains less points than the crop threshold, all
  37721. * points are drawn, even if the points fall outside the visible plot
  37722. * area at the current zoom. The advantage of drawing all points
  37723. * (including markers and columns), is that animation is performed on
  37724. * updates. On the other hand, when the series contains more points than
  37725. * the crop threshold, the series data is cropped to only contain points
  37726. * that fall within the plot area. The advantage of cropping away
  37727. * invisible points is to increase performance on large series.
  37728. *
  37729. * @since 2.2
  37730. * @product highcharts highstock
  37731. *
  37732. * @private
  37733. */
  37734. cropThreshold: 300,
  37735. /**
  37736. * Opacity of a series parts: line, fill (e.g. area) and dataLabels.
  37737. *
  37738. * @see [states.inactive.opacity](#plotOptions.series.states.inactive.opacity)
  37739. *
  37740. * @since 7.1.0
  37741. *
  37742. * @private
  37743. */
  37744. opacity: 1,
  37745. /**
  37746. * The width of each point on the x axis. For example in a column chart
  37747. * with one value each day, the pointRange would be 1 day (= 24 * 3600
  37748. * * 1000 milliseconds). This is normally computed automatically, but
  37749. * this option can be used to override the automatic value.
  37750. *
  37751. * @product highstock
  37752. *
  37753. * @private
  37754. */
  37755. pointRange: 0,
  37756. /**
  37757. * When this is true, the series will not cause the Y axis to cross
  37758. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  37759. * unless the data actually crosses the plane.
  37760. *
  37761. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  37762. * 3 will make the Y axis show negative values according to the
  37763. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  37764. * at 0.
  37765. *
  37766. * @since 4.1.9
  37767. * @product highcharts highstock
  37768. *
  37769. * @private
  37770. */
  37771. softThreshold: true,
  37772. /**
  37773. * @declare Highcharts.SeriesStatesOptionsObject
  37774. *
  37775. * @private
  37776. */
  37777. states: {
  37778. /**
  37779. * The normal state of a series, or for point items in column, pie
  37780. * and similar series. Currently only used for setting animation
  37781. * when returning to normal state from hover.
  37782. *
  37783. * @declare Highcharts.SeriesStatesNormalOptionsObject
  37784. */
  37785. normal: {
  37786. /**
  37787. * Animation when returning to normal state after hovering.
  37788. *
  37789. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37790. */
  37791. animation: true
  37792. },
  37793. /**
  37794. * Options for the hovered series. These settings override the
  37795. * normal state options when a series is moused over or touched.
  37796. *
  37797. * @declare Highcharts.SeriesStatesHoverOptionsObject
  37798. */
  37799. hover: {
  37800. /**
  37801. * Enable separate styles for the hovered series to visualize
  37802. * that the user hovers either the series itself or the legend.
  37803. *
  37804. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/
  37805. * Line
  37806. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/
  37807. * Column
  37808. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/
  37809. * Pie
  37810. *
  37811. * @type {boolean}
  37812. * @default true
  37813. * @since 1.2
  37814. * @apioption plotOptions.series.states.hover.enabled
  37815. */
  37816. /**
  37817. * Animation setting for hovering the graph in line-type series.
  37818. *
  37819. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37820. * @since 5.0.8
  37821. * @product highcharts highstock
  37822. */
  37823. animation: {
  37824. /**
  37825. * The duration of the hover animation in milliseconds. By
  37826. * default the hover state animates quickly in, and slowly
  37827. * back to normal.
  37828. *
  37829. * @internal
  37830. */
  37831. duration: 50
  37832. },
  37833. /**
  37834. * Pixel width of the graph line. By default this property is
  37835. * undefined, and the `lineWidthPlus` property dictates how much
  37836. * to increase the linewidth from normal state.
  37837. *
  37838. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
  37839. * 5px line on hover
  37840. *
  37841. * @type {number}
  37842. * @product highcharts highstock
  37843. * @apioption plotOptions.series.states.hover.lineWidth
  37844. */
  37845. /**
  37846. * The additional line width for the graph of a hovered series.
  37847. *
  37848. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37849. * 5 pixels wider
  37850. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37851. * 5 pixels wider
  37852. *
  37853. * @since 4.0.3
  37854. * @product highcharts highstock
  37855. */
  37856. lineWidthPlus: 1,
  37857. /**
  37858. * In Highcharts 1.0, the appearance of all markers belonging
  37859. * to the hovered series. For settings on the hover state of the
  37860. * individual point, see
  37861. * [marker.states.hover](#plotOptions.series.marker.states.hover).
  37862. *
  37863. * @deprecated
  37864. *
  37865. * @extends plotOptions.series.marker
  37866. * @excluding states
  37867. * @product highcharts highstock
  37868. */
  37869. marker: {
  37870. // lineWidth: base + 1,
  37871. // radius: base + 1
  37872. },
  37873. /**
  37874. * Options for the halo appearing around the hovered point in
  37875. * line-type series as well as outside the hovered slice in pie
  37876. * charts. By default the halo is filled by the current point or
  37877. * series color with an opacity of 0.25\. The halo can be
  37878. * disabled by setting the `halo` option to `null`.
  37879. *
  37880. * In styled mode, the halo is styled with the
  37881. * `.highcharts-halo` class, with colors inherited from
  37882. * `.highcharts-color-{n}`.
  37883. *
  37884. * @sample {highcharts} highcharts/plotoptions/halo/
  37885. * Halo options
  37886. * @sample {highstock} highcharts/plotoptions/halo/
  37887. * Halo options
  37888. *
  37889. * @declare Highcharts.SeriesStatesHoverHaloOptionsObject
  37890. * @type {null|*}
  37891. * @since 4.0
  37892. * @product highcharts highstock
  37893. */
  37894. halo: {
  37895. /**
  37896. * A collection of SVG attributes to override the appearance
  37897. * of the halo, for example `fill`, `stroke` and
  37898. * `stroke-width`.
  37899. *
  37900. * @type {Highcharts.SVGAttributes}
  37901. * @since 4.0
  37902. * @product highcharts highstock
  37903. * @apioption plotOptions.series.states.hover.halo.attributes
  37904. */
  37905. /**
  37906. * The pixel size of the halo. For point markers this is the
  37907. * radius of the halo. For pie slices it is the width of the
  37908. * halo outside the slice. For bubbles it defaults to 5 and
  37909. * is the width of the halo outside the bubble.
  37910. *
  37911. * @since 4.0
  37912. * @product highcharts highstock
  37913. */
  37914. size: 10,
  37915. /**
  37916. * Opacity for the halo unless a specific fill is overridden
  37917. * using the `attributes` setting. Note that Highcharts is
  37918. * only able to apply opacity to colors of hex or rgb(a)
  37919. * formats.
  37920. *
  37921. * @since 4.0
  37922. * @product highcharts highstock
  37923. */
  37924. opacity: 0.25
  37925. }
  37926. },
  37927. /**
  37928. * Specific options for point in selected states, after being
  37929. * selected by
  37930. * [allowPointSelect](#plotOptions.series.allowPointSelect)
  37931. * or programmatically.
  37932. *
  37933. * @sample maps/plotoptions/series-allowpointselect/
  37934. * Allow point select demo
  37935. *
  37936. * @declare Highcharts.SeriesStatesSelectOptionsObject
  37937. * @extends plotOptions.series.states.hover
  37938. * @excluding brightness
  37939. */
  37940. select: {
  37941. animation: {
  37942. /** @internal */
  37943. duration: 0
  37944. }
  37945. },
  37946. /**
  37947. * The opposite state of a hover for series.
  37948. *
  37949. * @sample highcharts/plotoptions/series-states-inactive-disabled
  37950. * Disabled inactive state
  37951. *
  37952. * @declare Highcharts.SeriesStatesInactiveOptionsObject
  37953. */
  37954. inactive: {
  37955. /**
  37956. * Enable or disable the inactive state for a series
  37957. *
  37958. * @sample highcharts/plotoptions/series-states-inactive-disabled
  37959. * Disabled inactive state
  37960. *
  37961. * @type {boolean}
  37962. * @default true
  37963. * @apioption plotOptions.series.states.inactive.enabled
  37964. */
  37965. /**
  37966. * The animation for entering the inactive state.
  37967. *
  37968. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37969. */
  37970. animation: {
  37971. /** @internal */
  37972. duration: 50
  37973. },
  37974. /**
  37975. * Opacity of series elements (dataLabels, line, area).
  37976. *
  37977. * @type {number}
  37978. */
  37979. opacity: 0.2
  37980. }
  37981. },
  37982. /**
  37983. * Sticky tracking of mouse events. When true, the `mouseOut` event on a
  37984. * series isn't triggered until the mouse moves over another series, or
  37985. * out of the plot area. When false, the `mouseOut` event on a series is
  37986. * triggered when the mouse leaves the area around the series' graph or
  37987. * markers. This also implies the tooltip when not shared. When
  37988. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  37989. * will be hidden when moving the mouse between series. Defaults to true
  37990. * for line and area type series, but to false for columns, pies etc.
  37991. *
  37992. * **Note:** The boost module will force this option because of
  37993. * technical limitations.
  37994. *
  37995. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
  37996. * True by default
  37997. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
  37998. * False
  37999. *
  38000. * @default {highcharts} true
  38001. * @default {highstock} true
  38002. * @default {highmaps} false
  38003. * @since 2.0
  38004. *
  38005. * @private
  38006. */
  38007. stickyTracking: true,
  38008. /**
  38009. * A configuration object for the tooltip rendering of each single
  38010. * series. Properties are inherited from [tooltip](#tooltip), but only
  38011. * the following properties can be defined on a series level.
  38012. *
  38013. * @declare Highcharts.SeriesTooltipOptionsObject
  38014. * @since 2.3
  38015. * @extends tooltip
  38016. * @excluding animation, backgroundColor, borderColor, borderRadius,
  38017. * borderWidth, className, crosshairs, enabled, formatter,
  38018. * headerShape, hideDelay, outside, padding, positioner,
  38019. * shadow, shape, shared, snap, split, stickOnContact,
  38020. * style, useHTML
  38021. * @apioption plotOptions.series.tooltip
  38022. */
  38023. /**
  38024. * When a series contains a data array that is longer than this, only
  38025. * one dimensional arrays of numbers, or two dimensional arrays with
  38026. * x and y values are allowed. Also, only the first point is tested,
  38027. * and the rest are assumed to be the same format. This saves expensive
  38028. * data checking and indexing in long series. Set it to `0` disable.
  38029. *
  38030. * Note:
  38031. * In boost mode turbo threshold is forced. Only array of numbers or
  38032. * two dimensional arrays are allowed.
  38033. *
  38034. * @since 2.2
  38035. * @product highcharts highstock gantt
  38036. *
  38037. * @private
  38038. */
  38039. turboThreshold: 1000,
  38040. /**
  38041. * An array defining zones within a series. Zones can be applied to the
  38042. * X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
  38043. * option. The zone definitions have to be in ascending order regarding
  38044. * to the value.
  38045. *
  38046. * In styled mode, the color zones are styled with the
  38047. * `.highcharts-zone-{n}` class, or custom classed from the `className`
  38048. * option
  38049. * ([view live demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-zones/)).
  38050. *
  38051. * @see [zoneAxis](#plotOptions.series.zoneAxis)
  38052. *
  38053. * @sample {highcharts} highcharts/series/color-zones-simple/
  38054. * Color zones
  38055. * @sample {highstock} highcharts/series/color-zones-simple/
  38056. * Color zones
  38057. *
  38058. * @declare Highcharts.SeriesZonesOptionsObject
  38059. * @type {Array<*>}
  38060. * @since 4.1.0
  38061. * @product highcharts highstock
  38062. * @apioption plotOptions.series.zones
  38063. */
  38064. /**
  38065. * Styled mode only. A custom class name for the zone.
  38066. *
  38067. * @sample highcharts/css/color-zones/
  38068. * Zones styled by class name
  38069. *
  38070. * @type {string}
  38071. * @since 5.0.0
  38072. * @apioption plotOptions.series.zones.className
  38073. */
  38074. /**
  38075. * Defines the color of the series.
  38076. *
  38077. * @see [series color](#plotOptions.series.color)
  38078. *
  38079. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38080. * @since 4.1.0
  38081. * @product highcharts highstock
  38082. * @apioption plotOptions.series.zones.color
  38083. */
  38084. /**
  38085. * A name for the dash style to use for the graph.
  38086. *
  38087. * @see [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  38088. *
  38089. * @sample {highcharts|highstock} highcharts/series/color-zones-dashstyle-dot/
  38090. * Dashed line indicates prognosis
  38091. *
  38092. * @type {Highcharts.DashStyleValue}
  38093. * @since 4.1.0
  38094. * @product highcharts highstock
  38095. * @apioption plotOptions.series.zones.dashStyle
  38096. */
  38097. /**
  38098. * Defines the fill color for the series (in area type series)
  38099. *
  38100. * @see [fillColor](#plotOptions.area.fillColor)
  38101. *
  38102. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38103. * @since 4.1.0
  38104. * @product highcharts highstock
  38105. * @apioption plotOptions.series.zones.fillColor
  38106. */
  38107. /**
  38108. * The value up to where the zone extends, if undefined the zones
  38109. * stretches to the last value in the series.
  38110. *
  38111. * @type {number}
  38112. * @since 4.1.0
  38113. * @product highcharts highstock
  38114. * @apioption plotOptions.series.zones.value
  38115. */
  38116. /**
  38117. * When using dual or multiple color axes, this number defines which
  38118. * colorAxis the particular series is connected to. It refers to
  38119. * either the
  38120. * {@link #colorAxis.id|axis id}
  38121. * or the index of the axis in the colorAxis array, with 0 being the
  38122. * first. Set this option to false to prevent a series from connecting
  38123. * to the default color axis.
  38124. *
  38125. * Since v7.2.0 the option can also be an axis id or an axis index
  38126. * instead of a boolean flag.
  38127. *
  38128. * @sample highcharts/coloraxis/coloraxis-with-pie/
  38129. * Color axis with pie series
  38130. * @sample highcharts/coloraxis/multiple-coloraxis/
  38131. * Multiple color axis
  38132. *
  38133. * @type {number|string|boolean}
  38134. * @default 0
  38135. * @product highcharts highstock highmaps
  38136. * @apioption plotOptions.series.colorAxis
  38137. */
  38138. /**
  38139. * Determines what data value should be used to calculate point color
  38140. * if `colorAxis` is used. Requires to set `min` and `max` if some
  38141. * custom point property is used or if approximation for data grouping
  38142. * is set to `'sum'`.
  38143. *
  38144. * @sample highcharts/coloraxis/custom-color-key/
  38145. * Custom color key
  38146. * @sample highcharts/coloraxis/changed-default-color-key/
  38147. * Changed default color key
  38148. *
  38149. * @type {string}
  38150. * @default y
  38151. * @since 7.2.0
  38152. * @product highcharts highstock highmaps
  38153. * @apioption plotOptions.series.colorKey
  38154. */
  38155. /**
  38156. * Determines whether the series should look for the nearest point
  38157. * in both dimensions or just the x-dimension when hovering the series.
  38158. * Defaults to `'xy'` for scatter series and `'x'` for most other
  38159. * series. If the data has duplicate x-values, it is recommended to
  38160. * set this to `'xy'` to allow hovering over all points.
  38161. *
  38162. * Applies only to series types using nearest neighbor search (not
  38163. * direct hover) for tooltip.
  38164. *
  38165. * @sample {highcharts} highcharts/series/findnearestpointby/
  38166. * Different hover behaviors
  38167. * @sample {highstock} highcharts/series/findnearestpointby/
  38168. * Different hover behaviors
  38169. * @sample {highmaps} highcharts/series/findnearestpointby/
  38170. * Different hover behaviors
  38171. *
  38172. * @since 5.0.10
  38173. * @validvalue ["x", "xy"]
  38174. *
  38175. * @private
  38176. */
  38177. findNearestPointBy: 'x'
  38178. };
  38179. return Series;
  38180. }());
  38181. extend(Series.prototype, {
  38182. axisTypes: ['xAxis', 'yAxis'],
  38183. coll: 'series',
  38184. colorCounter: 0,
  38185. cropShoulder: 1,
  38186. directTouch: false,
  38187. drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
  38188. isCartesian: true,
  38189. kdAxisArray: ['clientX', 'plotY'],
  38190. // each point's x and y values are stored in this.xData and this.yData:
  38191. parallelArrays: ['x', 'y'],
  38192. pointClass: Point,
  38193. requireSorting: true,
  38194. // requires the data to be sorted:
  38195. sorted: true
  38196. });
  38197. /* *
  38198. *
  38199. * Registry
  38200. *
  38201. * */
  38202. SeriesRegistry.series = Series;
  38203. /* *
  38204. *
  38205. * Default Export
  38206. *
  38207. * */
  38208. /* *
  38209. *
  38210. * API Declarations
  38211. *
  38212. * */
  38213. /**
  38214. * This is a placeholder type of the possible series options for
  38215. * [Highcharts](../highcharts/series), [Highcharts Stock](../highstock/series),
  38216. * [Highmaps](../highmaps/series), and [Gantt](../gantt/series).
  38217. *
  38218. * In TypeScript is this dynamically generated to reference all possible types
  38219. * of series options.
  38220. *
  38221. * @ignore-declaration
  38222. * @typedef {Highcharts.SeriesOptions|Highcharts.Dictionary<*>} Highcharts.SeriesOptionsType
  38223. */
  38224. /**
  38225. * Options for `dataSorting`.
  38226. *
  38227. * @interface Highcharts.DataSortingOptionsObject
  38228. * @since 8.0.0
  38229. */ /**
  38230. * Enable or disable data sorting for the series.
  38231. * @name Highcharts.DataSortingOptionsObject#enabled
  38232. * @type {boolean|undefined}
  38233. */ /**
  38234. * Whether to allow matching points by name in an update.
  38235. * @name Highcharts.DataSortingOptionsObject#matchByName
  38236. * @type {boolean|undefined}
  38237. */ /**
  38238. * Determines what data value should be used to sort by.
  38239. * @name Highcharts.DataSortingOptionsObject#sortKey
  38240. * @type {string|undefined}
  38241. */
  38242. /**
  38243. * Function callback when a series has been animated.
  38244. *
  38245. * @callback Highcharts.SeriesAfterAnimateCallbackFunction
  38246. *
  38247. * @param {Highcharts.Series} this
  38248. * The series where the event occured.
  38249. *
  38250. * @param {Highcharts.SeriesAfterAnimateEventObject} event
  38251. * Event arguments.
  38252. */
  38253. /**
  38254. * Event information regarding completed animation of a series.
  38255. *
  38256. * @interface Highcharts.SeriesAfterAnimateEventObject
  38257. */ /**
  38258. * Animated series.
  38259. * @name Highcharts.SeriesAfterAnimateEventObject#target
  38260. * @type {Highcharts.Series}
  38261. */ /**
  38262. * Event type.
  38263. * @name Highcharts.SeriesAfterAnimateEventObject#type
  38264. * @type {"afterAnimate"}
  38265. */
  38266. /**
  38267. * Function callback when the checkbox next to the series' name in the legend is
  38268. * clicked.
  38269. *
  38270. * @callback Highcharts.SeriesCheckboxClickCallbackFunction
  38271. *
  38272. * @param {Highcharts.Series} this
  38273. * The series where the event occured.
  38274. *
  38275. * @param {Highcharts.SeriesCheckboxClickEventObject} event
  38276. * Event arguments.
  38277. */
  38278. /**
  38279. * Event information regarding check of a series box.
  38280. *
  38281. * @interface Highcharts.SeriesCheckboxClickEventObject
  38282. */ /**
  38283. * Whether the box has been checked.
  38284. * @name Highcharts.SeriesCheckboxClickEventObject#checked
  38285. * @type {boolean}
  38286. */ /**
  38287. * Related series.
  38288. * @name Highcharts.SeriesCheckboxClickEventObject#item
  38289. * @type {Highcharts.Series}
  38290. */ /**
  38291. * Related series.
  38292. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38293. * @type {Highcharts.Series}
  38294. */ /**
  38295. * Event type.
  38296. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38297. * @type {"checkboxClick"}
  38298. */
  38299. /**
  38300. * Function callback when a series is clicked. Return false to cancel toogle
  38301. * actions.
  38302. *
  38303. * @callback Highcharts.SeriesClickCallbackFunction
  38304. *
  38305. * @param {Highcharts.Series} this
  38306. * The series where the event occured.
  38307. *
  38308. * @param {Highcharts.SeriesClickEventObject} event
  38309. * Event arguments.
  38310. */
  38311. /**
  38312. * Common information for a click event on a series.
  38313. *
  38314. * @interface Highcharts.SeriesClickEventObject
  38315. * @extends global.Event
  38316. */ /**
  38317. * Nearest point on the graph.
  38318. * @name Highcharts.SeriesClickEventObject#point
  38319. * @type {Highcharts.Point}
  38320. */
  38321. /**
  38322. * Gets fired when the series is hidden after chart generation time, either by
  38323. * clicking the legend item or by calling `.hide()`.
  38324. *
  38325. * @callback Highcharts.SeriesHideCallbackFunction
  38326. *
  38327. * @param {Highcharts.Series} this
  38328. * The series where the event occured.
  38329. *
  38330. * @param {global.Event} event
  38331. * The event that occured.
  38332. */
  38333. /**
  38334. * The SVG value used for the `stroke-linecap` and `stroke-linejoin` of a line
  38335. * graph.
  38336. *
  38337. * @typedef {"butt"|"round"|"square"|string} Highcharts.SeriesLinecapValue
  38338. */
  38339. /**
  38340. * Gets fired when the legend item belonging to the series is clicked. The
  38341. * default action is to toggle the visibility of the series. This can be
  38342. * prevented by returning `false` or calling `event.preventDefault()`.
  38343. *
  38344. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  38345. *
  38346. * @param {Highcharts.Series} this
  38347. * The series where the event occured.
  38348. *
  38349. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  38350. * The event that occured.
  38351. */
  38352. /**
  38353. * Information about the event.
  38354. *
  38355. * @interface Highcharts.SeriesLegendItemClickEventObject
  38356. */ /**
  38357. * Related browser event.
  38358. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  38359. * @type {global.PointerEvent}
  38360. */ /**
  38361. * Prevent the default action of toggle the visibility of the series.
  38362. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  38363. * @type {Function}
  38364. */ /**
  38365. * Related series.
  38366. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38367. * @type {Highcharts.Series}
  38368. */ /**
  38369. * Event type.
  38370. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38371. * @type {"checkboxClick"}
  38372. */
  38373. /**
  38374. * Gets fired when the mouse leaves the graph.
  38375. *
  38376. * @callback Highcharts.SeriesMouseOutCallbackFunction
  38377. *
  38378. * @param {Highcharts.Series} this
  38379. * Series where the event occured.
  38380. *
  38381. * @param {global.PointerEvent} event
  38382. * Event that occured.
  38383. */
  38384. /**
  38385. * Gets fired when the mouse enters the graph.
  38386. *
  38387. * @callback Highcharts.SeriesMouseOverCallbackFunction
  38388. *
  38389. * @param {Highcharts.Series} this
  38390. * Series where the event occured.
  38391. *
  38392. * @param {global.PointerEvent} event
  38393. * Event that occured.
  38394. */
  38395. /**
  38396. * Translation and scale for the plot area of a series.
  38397. *
  38398. * @interface Highcharts.SeriesPlotBoxObject
  38399. */ /**
  38400. * @name Highcharts.SeriesPlotBoxObject#scaleX
  38401. * @type {number}
  38402. */ /**
  38403. * @name Highcharts.SeriesPlotBoxObject#scaleY
  38404. * @type {number}
  38405. */ /**
  38406. * @name Highcharts.SeriesPlotBoxObject#translateX
  38407. * @type {number}
  38408. */ /**
  38409. * @name Highcharts.SeriesPlotBoxObject#translateY
  38410. * @type {number}
  38411. */
  38412. /**
  38413. * Gets fired when the series is shown after chart generation time, either by
  38414. * clicking the legend item or by calling `.show()`.
  38415. *
  38416. * @callback Highcharts.SeriesShowCallbackFunction
  38417. *
  38418. * @param {Highcharts.Series} this
  38419. * Series where the event occured.
  38420. *
  38421. * @param {global.Event} event
  38422. * Event that occured.
  38423. */
  38424. /**
  38425. * Possible key values for the series state options.
  38426. *
  38427. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.SeriesStateValue
  38428. */
  38429. ''; // detach doclets above
  38430. /* *
  38431. *
  38432. * API Options
  38433. *
  38434. * */
  38435. /**
  38436. * Series options for specific data and the data itself. In TypeScript you
  38437. * have to cast the series options to specific series types, to get all
  38438. * possible options for a series.
  38439. *
  38440. * @example
  38441. * // TypeScript example
  38442. * Highcharts.chart('container', {
  38443. * series: [{
  38444. * color: '#06C',
  38445. * data: [[0, 1], [2, 3]]
  38446. * } as Highcharts.SeriesLineOptions ]
  38447. * });
  38448. *
  38449. * @type {Array<*>}
  38450. * @apioption series
  38451. */
  38452. /**
  38453. * An id for the series. This can be used after render time to get a pointer
  38454. * to the series object through `chart.get()`.
  38455. *
  38456. * @sample {highcharts} highcharts/plotoptions/series-id/
  38457. * Get series by id
  38458. *
  38459. * @type {string}
  38460. * @since 1.2.0
  38461. * @apioption series.id
  38462. */
  38463. /**
  38464. * The index of the series in the chart, affecting the internal index in the
  38465. * `chart.series` array, the visible Z index as well as the order in the
  38466. * legend.
  38467. *
  38468. * @type {number}
  38469. * @since 2.3.0
  38470. * @apioption series.index
  38471. */
  38472. /**
  38473. * The sequential index of the series in the legend.
  38474. *
  38475. * @see [legend.reversed](#legend.reversed),
  38476. * [yAxis.reversedStacks](#yAxis.reversedStacks)
  38477. *
  38478. * @sample {highcharts|highstock} highcharts/series/legendindex/
  38479. * Legend in opposite order
  38480. *
  38481. * @type {number}
  38482. * @apioption series.legendIndex
  38483. */
  38484. /**
  38485. * The name of the series as shown in the legend, tooltip etc.
  38486. *
  38487. * @sample {highcharts} highcharts/series/name/
  38488. * Series name
  38489. * @sample {highmaps} maps/demo/category-map/
  38490. * Series name
  38491. *
  38492. * @type {string}
  38493. * @apioption series.name
  38494. */
  38495. /**
  38496. * This option allows grouping series in a stacked chart. The stack option
  38497. * can be a string or anything else, as long as the grouped series' stack
  38498. * options match each other after conversion into a string.
  38499. *
  38500. * @sample {highcharts} highcharts/series/stack/
  38501. * Stacked and grouped columns
  38502. *
  38503. * @type {number|string}
  38504. * @since 2.1
  38505. * @product highcharts highstock
  38506. * @apioption series.stack
  38507. */
  38508. /**
  38509. * The type of series, for example `line` or `column`. By default, the
  38510. * series type is inherited from [chart.type](#chart.type), so unless the
  38511. * chart is a combination of series types, there is no need to set it on the
  38512. * series level.
  38513. *
  38514. * @sample {highcharts} highcharts/series/type/
  38515. * Line and column in the same chart
  38516. * @sample highcharts/series/type-dynamic/
  38517. * Dynamic types with button selector
  38518. * @sample {highmaps} maps/demo/mapline-mappoint/
  38519. * Multiple types in the same map
  38520. *
  38521. * @type {string}
  38522. * @apioption series.type
  38523. */
  38524. /**
  38525. * When using dual or multiple x axes, this number defines which xAxis the
  38526. * particular series is connected to. It refers to either the
  38527. * {@link #xAxis.id|axis id}
  38528. * or the index of the axis in the xAxis array, with 0 being the first.
  38529. *
  38530. * @type {number|string}
  38531. * @default 0
  38532. * @product highcharts highstock
  38533. * @apioption series.xAxis
  38534. */
  38535. /**
  38536. * When using dual or multiple y axes, this number defines which yAxis the
  38537. * particular series is connected to. It refers to either the
  38538. * {@link #yAxis.id|axis id}
  38539. * or the index of the axis in the yAxis array, with 0 being the first.
  38540. *
  38541. * @sample {highcharts} highcharts/series/yaxis/
  38542. * Apply the column series to the secondary Y axis
  38543. *
  38544. * @type {number|string}
  38545. * @default 0
  38546. * @product highcharts highstock
  38547. * @apioption series.yAxis
  38548. */
  38549. /**
  38550. * Define the visual z index of the series.
  38551. *
  38552. * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
  38553. * With no z index, the series defined last are on top
  38554. * @sample {highcharts} highcharts/plotoptions/series-zindex/
  38555. * With a z index, the series with the highest z index is on top
  38556. * @sample {highstock} highcharts/plotoptions/series-zindex-default/
  38557. * With no z index, the series defined last are on top
  38558. * @sample {highstock} highcharts/plotoptions/series-zindex/
  38559. * With a z index, the series with the highest z index is on top
  38560. *
  38561. * @type {number}
  38562. * @product highcharts highstock
  38563. * @apioption series.zIndex
  38564. */
  38565. ''; // include precedent doclets in transpilat
  38566. return Series;
  38567. });
  38568. _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/Globals.js'], _modules['Core/Utilities.js']], function (A, Axis, Chart, Series, H, U) {
  38569. /* *
  38570. *
  38571. * (c) 2010-2021 Torstein Honsi
  38572. *
  38573. * License: www.highcharts.com/license
  38574. *
  38575. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38576. *
  38577. * Highcharts feature to make the Y axis stay fixed when scrolling the chart
  38578. * horizontally on mobile devices. Supports left and right side axes.
  38579. */
  38580. /*
  38581. WIP on vertical scrollable plot area (#9378). To do:
  38582. - Bottom axis positioning
  38583. - Test with Gantt
  38584. - Look for size optimizing the code
  38585. - API and demos
  38586. */
  38587. var stop = A.stop;
  38588. var addEvent = U.addEvent,
  38589. createElement = U.createElement,
  38590. merge = U.merge,
  38591. pick = U.pick;
  38592. /**
  38593. * Options for a scrollable plot area. This feature provides a minimum size for
  38594. * the plot area of the chart. If the size gets smaller than this, typically
  38595. * on mobile devices, a native browser scrollbar is presented. This scrollbar
  38596. * provides smooth scrolling for the contents of the plot area, whereas the
  38597. * title, legend and unaffected axes are fixed.
  38598. *
  38599. * Since v7.1.2, a scrollable plot area can be defined for either horizontal or
  38600. * vertical scrolling, depending on whether the `minWidth` or `minHeight`
  38601. * option is set.
  38602. *
  38603. * @sample highcharts/chart/scrollable-plotarea
  38604. * Scrollable plot area
  38605. * @sample highcharts/chart/scrollable-plotarea-vertical
  38606. * Vertically scrollable plot area
  38607. * @sample {gantt} highcharts/chart/scrollable-plotarea-vertical
  38608. * Gantt chart with vertically scrollable plot area
  38609. *
  38610. * @since 6.1.0
  38611. * @product highcharts gantt
  38612. * @apioption chart.scrollablePlotArea
  38613. */
  38614. /**
  38615. * The minimum height for the plot area. If it gets smaller than this, the plot
  38616. * area will become scrollable.
  38617. *
  38618. * @type {number}
  38619. * @apioption chart.scrollablePlotArea.minHeight
  38620. */
  38621. /**
  38622. * The minimum width for the plot area. If it gets smaller than this, the plot
  38623. * area will become scrollable.
  38624. *
  38625. * @type {number}
  38626. * @apioption chart.scrollablePlotArea.minWidth
  38627. */
  38628. /**
  38629. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  38630. * 1, where 0 aligns the plot area to the left and 1 aligns it to the right.
  38631. * Typically we would use 1 if the chart has right aligned Y axes.
  38632. *
  38633. * @type {number}
  38634. * @apioption chart.scrollablePlotArea.scrollPositionX
  38635. */
  38636. /**
  38637. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  38638. * 1, where 0 aligns the plot area to the top and 1 aligns it to the bottom.
  38639. *
  38640. * @type {number}
  38641. * @apioption chart.scrollablePlotArea.scrollPositionY
  38642. */
  38643. /**
  38644. * The opacity of mask applied on one of the sides of the plot
  38645. * area.
  38646. *
  38647. * @sample {highcharts} highcharts/chart/scrollable-plotarea-opacity
  38648. * Disabled opacity for the mask
  38649. *
  38650. * @type {number}
  38651. * @default 0.85
  38652. * @since 7.1.1
  38653. * @apioption chart.scrollablePlotArea.opacity
  38654. */
  38655. ''; // detach API doclets
  38656. /* eslint-disable no-invalid-this, valid-jsdoc */
  38657. addEvent(Chart, 'afterSetChartSize', function (e) {
  38658. var scrollablePlotArea = this.options.chart.scrollablePlotArea,
  38659. scrollableMinWidth = scrollablePlotArea && scrollablePlotArea.minWidth,
  38660. scrollableMinHeight = scrollablePlotArea && scrollablePlotArea.minHeight,
  38661. scrollablePixelsX,
  38662. scrollablePixelsY,
  38663. corrections;
  38664. if (!this.renderer.forExport) {
  38665. // The amount of pixels to scroll, the difference between chart
  38666. // width and scrollable width
  38667. if (scrollableMinWidth) {
  38668. this.scrollablePixelsX = scrollablePixelsX = Math.max(0, scrollableMinWidth - this.chartWidth);
  38669. if (scrollablePixelsX) {
  38670. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38671. this.plotBox.width = this.plotWidth += scrollablePixelsX;
  38672. if (this.inverted) {
  38673. this.clipBox.height += scrollablePixelsX;
  38674. }
  38675. else {
  38676. this.clipBox.width += scrollablePixelsX;
  38677. }
  38678. corrections = {
  38679. // Corrections for right side
  38680. 1: { name: 'right', value: scrollablePixelsX }
  38681. };
  38682. }
  38683. // Currently we can only do either X or Y
  38684. }
  38685. else if (scrollableMinHeight) {
  38686. this.scrollablePixelsY = scrollablePixelsY = Math.max(0, scrollableMinHeight - this.chartHeight);
  38687. if (scrollablePixelsY) {
  38688. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38689. this.plotBox.height = this.plotHeight += scrollablePixelsY;
  38690. if (this.inverted) {
  38691. this.clipBox.width += scrollablePixelsY;
  38692. }
  38693. else {
  38694. this.clipBox.height += scrollablePixelsY;
  38695. }
  38696. corrections = {
  38697. 2: { name: 'bottom', value: scrollablePixelsY }
  38698. };
  38699. }
  38700. }
  38701. if (corrections && !e.skipAxes) {
  38702. this.axes.forEach(function (axis) {
  38703. // For right and bottom axes, only fix the plot line length
  38704. if (corrections[axis.side]) {
  38705. // Get the plot lines right in getPlotLinePath,
  38706. // temporarily set it to the adjusted plot width.
  38707. axis.getPlotLinePath = function () {
  38708. var marginName = corrections[axis.side].name,
  38709. correctionValue = corrections[axis.side].value,
  38710. // axis.right or axis.bottom
  38711. margin = this[marginName],
  38712. path;
  38713. // Temporarily adjust
  38714. this[marginName] = margin - correctionValue;
  38715. path = H.Axis.prototype.getPlotLinePath.apply(this, arguments);
  38716. // Reset
  38717. this[marginName] = margin;
  38718. return path;
  38719. };
  38720. }
  38721. else {
  38722. // Apply the corrected plotWidth
  38723. axis.setAxisSize();
  38724. axis.setAxisTranslation();
  38725. }
  38726. });
  38727. }
  38728. }
  38729. });
  38730. addEvent(Chart, 'render', function () {
  38731. if (this.scrollablePixelsX || this.scrollablePixelsY) {
  38732. if (this.setUpScrolling) {
  38733. this.setUpScrolling();
  38734. }
  38735. this.applyFixed();
  38736. }
  38737. else if (this.fixedDiv) { // Has been in scrollable mode
  38738. this.applyFixed();
  38739. }
  38740. });
  38741. /**
  38742. * @private
  38743. * @function Highcharts.Chart#setUpScrolling
  38744. * @return {void}
  38745. */
  38746. Chart.prototype.setUpScrolling = function () {
  38747. var _this = this;
  38748. var css = {
  38749. WebkitOverflowScrolling: 'touch',
  38750. overflowX: 'hidden',
  38751. overflowY: 'hidden'
  38752. };
  38753. if (this.scrollablePixelsX) {
  38754. css.overflowX = 'auto';
  38755. }
  38756. if (this.scrollablePixelsY) {
  38757. css.overflowY = 'auto';
  38758. }
  38759. // Insert a container with position relative
  38760. // that scrolling and fixed container renders to (#10555)
  38761. this.scrollingParent = createElement('div', {
  38762. className: 'highcharts-scrolling-parent'
  38763. }, {
  38764. position: 'relative'
  38765. }, this.renderTo);
  38766. // Add the necessary divs to provide scrolling
  38767. this.scrollingContainer = createElement('div', {
  38768. 'className': 'highcharts-scrolling'
  38769. }, css, this.scrollingParent);
  38770. // On scroll, reset the chart position because it applies to the scrolled
  38771. // container
  38772. addEvent(this.scrollingContainer, 'scroll', function () {
  38773. if (_this.pointer) {
  38774. delete _this.pointer.chartPosition;
  38775. }
  38776. });
  38777. this.innerContainer = createElement('div', {
  38778. 'className': 'highcharts-inner-container'
  38779. }, null, this.scrollingContainer);
  38780. // Now move the container inside
  38781. this.innerContainer.appendChild(this.container);
  38782. // Don't run again
  38783. this.setUpScrolling = null;
  38784. };
  38785. /**
  38786. * These elements are moved over to the fixed renderer and stay fixed when the
  38787. * user scrolls the chart
  38788. * @private
  38789. */
  38790. Chart.prototype.moveFixedElements = function () {
  38791. var container = this.container,
  38792. fixedRenderer = this.fixedRenderer,
  38793. fixedSelectors = [
  38794. '.highcharts-contextbutton',
  38795. '.highcharts-credits',
  38796. '.highcharts-legend',
  38797. '.highcharts-legend-checkbox',
  38798. '.highcharts-navigator-series',
  38799. '.highcharts-navigator-xaxis',
  38800. '.highcharts-navigator-yaxis',
  38801. '.highcharts-navigator',
  38802. '.highcharts-reset-zoom',
  38803. '.highcharts-drillup-button',
  38804. '.highcharts-scrollbar',
  38805. '.highcharts-subtitle',
  38806. '.highcharts-title'
  38807. ],
  38808. axisClass;
  38809. if (this.scrollablePixelsX && !this.inverted) {
  38810. axisClass = '.highcharts-yaxis';
  38811. }
  38812. else if (this.scrollablePixelsX && this.inverted) {
  38813. axisClass = '.highcharts-xaxis';
  38814. }
  38815. else if (this.scrollablePixelsY && !this.inverted) {
  38816. axisClass = '.highcharts-xaxis';
  38817. }
  38818. else if (this.scrollablePixelsY && this.inverted) {
  38819. axisClass = '.highcharts-yaxis';
  38820. }
  38821. if (axisClass) {
  38822. fixedSelectors.push(axisClass + ":not(.highcharts-radial-axis)", axisClass + "-labels:not(.highcharts-radial-axis-labels)");
  38823. }
  38824. fixedSelectors.forEach(function (className) {
  38825. [].forEach.call(container.querySelectorAll(className), function (elem) {
  38826. (elem.namespaceURI === fixedRenderer.SVG_NS ?
  38827. fixedRenderer.box :
  38828. fixedRenderer.box.parentNode).appendChild(elem);
  38829. elem.style.pointerEvents = 'auto';
  38830. });
  38831. });
  38832. };
  38833. /**
  38834. * @private
  38835. * @function Highcharts.Chart#applyFixed
  38836. * @return {void}
  38837. */
  38838. Chart.prototype.applyFixed = function () {
  38839. var fixedRenderer,
  38840. scrollableWidth,
  38841. scrollableHeight,
  38842. firstTime = !this.fixedDiv,
  38843. chartOptions = this.options.chart,
  38844. scrollableOptions = chartOptions.scrollablePlotArea;
  38845. // First render
  38846. if (firstTime) {
  38847. this.fixedDiv = createElement('div', {
  38848. className: 'highcharts-fixed'
  38849. }, {
  38850. position: 'absolute',
  38851. overflow: 'hidden',
  38852. pointerEvents: 'none',
  38853. zIndex: (chartOptions.style && chartOptions.style.zIndex || 0) + 2,
  38854. top: 0
  38855. }, null, true);
  38856. if (this.scrollingContainer) {
  38857. this.scrollingContainer.parentNode.insertBefore(this.fixedDiv, this.scrollingContainer);
  38858. }
  38859. this.renderTo.style.overflow = 'visible';
  38860. this.fixedRenderer = fixedRenderer = new H.Renderer(this.fixedDiv, this.chartWidth, this.chartHeight, this.options.chart.style);
  38861. // Mask
  38862. this.scrollableMask = fixedRenderer
  38863. .path()
  38864. .attr({
  38865. fill: this.options.chart.backgroundColor || '#fff',
  38866. 'fill-opacity': pick(scrollableOptions.opacity, 0.85),
  38867. zIndex: -1
  38868. })
  38869. .addClass('highcharts-scrollable-mask')
  38870. .add();
  38871. addEvent(this, 'afterShowResetZoom', this.moveFixedElements);
  38872. addEvent(this, 'afterDrilldown', this.moveFixedElements);
  38873. addEvent(this, 'afterLayOutTitles', this.moveFixedElements);
  38874. }
  38875. else {
  38876. // Set the size of the fixed renderer to the visible width
  38877. this.fixedRenderer.setSize(this.chartWidth, this.chartHeight);
  38878. }
  38879. if (this.scrollableDirty || firstTime) {
  38880. this.scrollableDirty = false;
  38881. this.moveFixedElements();
  38882. }
  38883. // Increase the size of the scrollable renderer and background
  38884. scrollableWidth = this.chartWidth + (this.scrollablePixelsX || 0);
  38885. scrollableHeight = this.chartHeight + (this.scrollablePixelsY || 0);
  38886. stop(this.container);
  38887. this.container.style.width = scrollableWidth + 'px';
  38888. this.container.style.height = scrollableHeight + 'px';
  38889. this.renderer.boxWrapper.attr({
  38890. width: scrollableWidth,
  38891. height: scrollableHeight,
  38892. viewBox: [0, 0, scrollableWidth, scrollableHeight].join(' ')
  38893. });
  38894. this.chartBackground.attr({
  38895. width: scrollableWidth,
  38896. height: scrollableHeight
  38897. });
  38898. this.scrollingContainer.style.height = this.chartHeight + 'px';
  38899. // Set scroll position
  38900. if (firstTime) {
  38901. if (scrollableOptions.scrollPositionX) {
  38902. this.scrollingContainer.scrollLeft =
  38903. this.scrollablePixelsX *
  38904. scrollableOptions.scrollPositionX;
  38905. }
  38906. if (scrollableOptions.scrollPositionY) {
  38907. this.scrollingContainer.scrollTop =
  38908. this.scrollablePixelsY *
  38909. scrollableOptions.scrollPositionY;
  38910. }
  38911. }
  38912. // Mask behind the left and right side
  38913. var axisOffset = this.axisOffset,
  38914. maskTop = this.plotTop - axisOffset[0] - 1,
  38915. maskLeft = this.plotLeft - axisOffset[3] - 1,
  38916. maskBottom = this.plotTop + this.plotHeight + axisOffset[2] + 1,
  38917. maskRight = this.plotLeft + this.plotWidth + axisOffset[1] + 1,
  38918. maskPlotRight = this.plotLeft + this.plotWidth -
  38919. (this.scrollablePixelsX || 0),
  38920. maskPlotBottom = this.plotTop + this.plotHeight -
  38921. (this.scrollablePixelsY || 0),
  38922. d;
  38923. if (this.scrollablePixelsX) {
  38924. d = [
  38925. // Left side
  38926. ['M', 0, maskTop],
  38927. ['L', this.plotLeft - 1, maskTop],
  38928. ['L', this.plotLeft - 1, maskBottom],
  38929. ['L', 0, maskBottom],
  38930. ['Z'],
  38931. // Right side
  38932. ['M', maskPlotRight, maskTop],
  38933. ['L', this.chartWidth, maskTop],
  38934. ['L', this.chartWidth, maskBottom],
  38935. ['L', maskPlotRight, maskBottom],
  38936. ['Z']
  38937. ];
  38938. }
  38939. else if (this.scrollablePixelsY) {
  38940. d = [
  38941. // Top side
  38942. ['M', maskLeft, 0],
  38943. ['L', maskLeft, this.plotTop - 1],
  38944. ['L', maskRight, this.plotTop - 1],
  38945. ['L', maskRight, 0],
  38946. ['Z'],
  38947. // Bottom side
  38948. ['M', maskLeft, maskPlotBottom],
  38949. ['L', maskLeft, this.chartHeight],
  38950. ['L', maskRight, this.chartHeight],
  38951. ['L', maskRight, maskPlotBottom],
  38952. ['Z']
  38953. ];
  38954. }
  38955. else {
  38956. d = [['M', 0, 0]];
  38957. }
  38958. if (this.redrawTrigger !== 'adjustHeight') {
  38959. this.scrollableMask.attr({ d: d });
  38960. }
  38961. };
  38962. addEvent(Axis, 'afterInit', function () {
  38963. this.chart.scrollableDirty = true;
  38964. });
  38965. addEvent(Series, 'show', function () {
  38966. this.chart.scrollableDirty = true;
  38967. });
  38968. });
  38969. _registerModule(_modules, 'Core/Axis/StackingAxis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Utilities.js']], function (A, U) {
  38970. /* *
  38971. *
  38972. * (c) 2010-2021 Torstein Honsi
  38973. *
  38974. * License: www.highcharts.com/license
  38975. *
  38976. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38977. *
  38978. * */
  38979. var getDeferredAnimation = A.getDeferredAnimation;
  38980. var addEvent = U.addEvent,
  38981. destroyObjectProperties = U.destroyObjectProperties,
  38982. fireEvent = U.fireEvent,
  38983. isNumber = U.isNumber,
  38984. objectEach = U.objectEach,
  38985. pick = U.pick;
  38986. /* eslint-disable valid-jsdoc */
  38987. /**
  38988. * Adds stacking support to axes.
  38989. * @private
  38990. * @class
  38991. */
  38992. var StackingAxisAdditions = /** @class */ (function () {
  38993. /* *
  38994. *
  38995. * Constructors
  38996. *
  38997. * */
  38998. function StackingAxisAdditions(axis) {
  38999. this.oldStacks = {};
  39000. this.stacks = {};
  39001. this.stacksTouched = 0;
  39002. this.axis = axis;
  39003. }
  39004. /* *
  39005. *
  39006. * Functions
  39007. *
  39008. * */
  39009. /**
  39010. * Build the stacks from top down
  39011. * @private
  39012. */
  39013. StackingAxisAdditions.prototype.buildStacks = function () {
  39014. var stacking = this;
  39015. var axis = stacking.axis;
  39016. var axisSeries = axis.series;
  39017. var reversedStacks = axis.options.reversedStacks;
  39018. var len = axisSeries.length;
  39019. var actualSeries,
  39020. i;
  39021. if (!axis.isXAxis) {
  39022. stacking.usePercentage = false;
  39023. i = len;
  39024. while (i--) {
  39025. actualSeries = axisSeries[reversedStacks ? i : len - i - 1];
  39026. actualSeries.setStackedPoints();
  39027. actualSeries.setGroupedPoints();
  39028. }
  39029. // Loop up again to compute percent and stream stack
  39030. for (i = 0; i < len; i++) {
  39031. axisSeries[i].modifyStacks();
  39032. }
  39033. fireEvent(axis, 'afterBuildStacks');
  39034. }
  39035. };
  39036. /**
  39037. * @private
  39038. */
  39039. StackingAxisAdditions.prototype.cleanStacks = function () {
  39040. var stacking = this;
  39041. var axis = stacking.axis;
  39042. var stacks;
  39043. if (!axis.isXAxis) {
  39044. if (stacking.oldStacks) {
  39045. stacks = stacking.stacks = stacking.oldStacks;
  39046. }
  39047. // reset stacks
  39048. objectEach(stacks, function (type) {
  39049. objectEach(type, function (stack) {
  39050. stack.cumulative = stack.total;
  39051. });
  39052. });
  39053. }
  39054. };
  39055. /**
  39056. * Set all the stacks to initial states and destroy unused ones.
  39057. * @private
  39058. */
  39059. StackingAxisAdditions.prototype.resetStacks = function () {
  39060. var _this = this;
  39061. var _a = this,
  39062. axis = _a.axis,
  39063. stacks = _a.stacks;
  39064. if (!axis.isXAxis) {
  39065. objectEach(stacks, function (type) {
  39066. objectEach(type, function (stack, x) {
  39067. // Clean up memory after point deletion (#1044, #4320)
  39068. if (isNumber(stack.touched) &&
  39069. stack.touched < _this.stacksTouched) {
  39070. stack.destroy();
  39071. delete type[x];
  39072. // Reset stacks
  39073. }
  39074. else {
  39075. stack.total = null;
  39076. stack.cumulative = null;
  39077. }
  39078. });
  39079. });
  39080. }
  39081. };
  39082. /**
  39083. * @private
  39084. */
  39085. StackingAxisAdditions.prototype.renderStackTotals = function () {
  39086. var stacking = this;
  39087. var axis = stacking.axis;
  39088. var chart = axis.chart;
  39089. var renderer = chart.renderer;
  39090. var stacks = stacking.stacks;
  39091. var stackLabelsAnim = axis.options.stackLabels && axis.options.stackLabels.animation;
  39092. var animationConfig = getDeferredAnimation(chart,
  39093. stackLabelsAnim || false);
  39094. var stackTotalGroup = stacking.stackTotalGroup = (stacking.stackTotalGroup ||
  39095. renderer
  39096. .g('stack-labels')
  39097. .attr({
  39098. visibility: 'visible',
  39099. zIndex: 6,
  39100. opacity: 0
  39101. })
  39102. .add());
  39103. // plotLeft/Top will change when y axis gets wider so we need to
  39104. // translate the stackTotalGroup at every render call. See bug #506
  39105. // and #516
  39106. stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
  39107. // Render each stack total
  39108. objectEach(stacks, function (type) {
  39109. objectEach(type, function (stack) {
  39110. stack.render(stackTotalGroup);
  39111. });
  39112. });
  39113. stackTotalGroup.animate({
  39114. opacity: 1
  39115. }, animationConfig);
  39116. };
  39117. return StackingAxisAdditions;
  39118. }());
  39119. /**
  39120. * Axis with stacking support.
  39121. * @private
  39122. * @class
  39123. */
  39124. var StackingAxis = /** @class */ (function () {
  39125. function StackingAxis() {
  39126. }
  39127. /* *
  39128. *
  39129. * Static Functions
  39130. *
  39131. * */
  39132. /**
  39133. * Extends axis with stacking support.
  39134. * @private
  39135. */
  39136. StackingAxis.compose = function (AxisClass) {
  39137. var axisProto = AxisClass.prototype;
  39138. addEvent(AxisClass, 'init', StackingAxis.onInit);
  39139. addEvent(AxisClass, 'destroy', StackingAxis.onDestroy);
  39140. };
  39141. /**
  39142. * @private
  39143. */
  39144. StackingAxis.onDestroy = function () {
  39145. var stacking = this.stacking;
  39146. if (!stacking) {
  39147. return;
  39148. }
  39149. var stacks = stacking.stacks;
  39150. // Destroy each stack total
  39151. objectEach(stacks, function (stack, stackKey) {
  39152. destroyObjectProperties(stack);
  39153. stacks[stackKey] = null;
  39154. });
  39155. if (stacking &&
  39156. stacking.stackTotalGroup) {
  39157. stacking.stackTotalGroup.destroy();
  39158. }
  39159. };
  39160. /**
  39161. * @private
  39162. */
  39163. StackingAxis.onInit = function () {
  39164. var axis = this;
  39165. if (!axis.stacking) {
  39166. axis.stacking = new StackingAxisAdditions(axis);
  39167. }
  39168. };
  39169. return StackingAxis;
  39170. }());
  39171. return StackingAxis;
  39172. });
  39173. _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) {
  39174. /* *
  39175. *
  39176. * (c) 2010-2021 Torstein Honsi
  39177. *
  39178. * License: www.highcharts.com/license
  39179. *
  39180. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39181. *
  39182. * */
  39183. var format = F.format;
  39184. var correctFloat = U.correctFloat,
  39185. defined = U.defined,
  39186. destroyObjectProperties = U.destroyObjectProperties,
  39187. isArray = U.isArray,
  39188. isNumber = U.isNumber,
  39189. objectEach = U.objectEach,
  39190. pick = U.pick;
  39191. /**
  39192. * Stack of data points
  39193. *
  39194. * @product highcharts
  39195. *
  39196. * @interface Highcharts.StackItemObject
  39197. */ /**
  39198. * Alignment settings
  39199. * @name Highcharts.StackItemObject#alignOptions
  39200. * @type {Highcharts.AlignObject}
  39201. */ /**
  39202. * Related axis
  39203. * @name Highcharts.StackItemObject#axis
  39204. * @type {Highcharts.Axis}
  39205. */ /**
  39206. * Cumulative value of the stacked data points
  39207. * @name Highcharts.StackItemObject#cumulative
  39208. * @type {number}
  39209. */ /**
  39210. * True if on the negative side
  39211. * @name Highcharts.StackItemObject#isNegative
  39212. * @type {boolean}
  39213. */ /**
  39214. * Related SVG element
  39215. * @name Highcharts.StackItemObject#label
  39216. * @type {Highcharts.SVGElement}
  39217. */ /**
  39218. * Related stack options
  39219. * @name Highcharts.StackItemObject#options
  39220. * @type {Highcharts.YAxisStackLabelsOptions}
  39221. */ /**
  39222. * Total value of the stacked data points
  39223. * @name Highcharts.StackItemObject#total
  39224. * @type {number}
  39225. */ /**
  39226. * Shared x value of the stack
  39227. * @name Highcharts.StackItemObject#x
  39228. * @type {number}
  39229. */
  39230. ''; // detached doclets above
  39231. /* eslint-disable no-invalid-this, valid-jsdoc */
  39232. /**
  39233. * The class for stacks. Each stack, on a specific X value and either negative
  39234. * or positive, has its own stack item.
  39235. *
  39236. * @private
  39237. * @class
  39238. * @name Highcharts.StackItem
  39239. * @param {Highcharts.Axis} axis
  39240. * @param {Highcharts.YAxisStackLabelsOptions} options
  39241. * @param {boolean} isNegative
  39242. * @param {number} x
  39243. * @param {Highcharts.OptionsStackingValue} [stackOption]
  39244. */
  39245. var StackItem = /** @class */ (function () {
  39246. function StackItem(axis, options, isNegative, x, stackOption) {
  39247. var inverted = axis.chart.inverted;
  39248. this.axis = axis;
  39249. // Tells if the stack is negative
  39250. this.isNegative = isNegative;
  39251. // Save the options to be able to style the label
  39252. this.options = options = options || {};
  39253. // Save the x value to be able to position the label later
  39254. this.x = x;
  39255. // Initialize total value
  39256. this.total = null;
  39257. // This will keep each points' extremes stored by series.index and point
  39258. // index
  39259. this.points = {};
  39260. this.hasValidPoints = false;
  39261. // Save the stack option on the series configuration object,
  39262. // and whether to treat it as percent
  39263. this.stack = stackOption;
  39264. this.leftCliff = 0;
  39265. this.rightCliff = 0;
  39266. // The align options and text align varies on whether the stack is
  39267. // negative and if the chart is inverted or not.
  39268. // First test the user supplied value, then use the dynamic.
  39269. this.alignOptions = {
  39270. align: options.align ||
  39271. (inverted ? (isNegative ? 'left' : 'right') : 'center'),
  39272. verticalAlign: options.verticalAlign ||
  39273. (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
  39274. y: options.y,
  39275. x: options.x
  39276. };
  39277. this.textAlign = options.textAlign ||
  39278. (inverted ? (isNegative ? 'right' : 'left') : 'center');
  39279. }
  39280. /**
  39281. * @private
  39282. * @function Highcharts.StackItem#destroy
  39283. */
  39284. StackItem.prototype.destroy = function () {
  39285. destroyObjectProperties(this, this.axis);
  39286. };
  39287. /**
  39288. * Renders the stack total label and adds it to the stack label group.
  39289. *
  39290. * @private
  39291. * @function Highcharts.StackItem#render
  39292. * @param {Highcharts.SVGElement} group
  39293. */
  39294. StackItem.prototype.render = function (group) {
  39295. var chart = this.axis.chart,
  39296. options = this.options,
  39297. formatOption = options.format,
  39298. attr = {},
  39299. str = formatOption ? // format the text in the label
  39300. format(formatOption,
  39301. this,
  39302. chart) :
  39303. options.formatter.call(this);
  39304. // Change the text to reflect the new total and set visibility to hidden
  39305. // in case the serie is hidden
  39306. if (this.label) {
  39307. this.label.attr({ text: str, visibility: 'hidden' });
  39308. }
  39309. else {
  39310. // Create new label
  39311. this.label = chart.renderer
  39312. .label(str, null, null, options.shape, null, null, options.useHTML, false, 'stack-labels');
  39313. attr = {
  39314. r: options.borderRadius || 0,
  39315. text: str,
  39316. rotation: options.rotation,
  39317. padding: pick(options.padding, 5),
  39318. visibility: 'hidden' // hidden until setOffset is called
  39319. };
  39320. if (!chart.styledMode) {
  39321. attr.fill = options.backgroundColor;
  39322. attr.stroke = options.borderColor;
  39323. attr['stroke-width'] = options.borderWidth;
  39324. this.label.css(options.style);
  39325. }
  39326. this.label.attr(attr);
  39327. if (!this.label.added) {
  39328. this.label.add(group); // add to the labels-group
  39329. }
  39330. }
  39331. // Rank it higher than data labels (#8742)
  39332. this.label.labelrank = chart.plotSizeY;
  39333. };
  39334. /**
  39335. * Sets the offset that the stack has from the x value and repositions the
  39336. * label.
  39337. *
  39338. * @private
  39339. * @function Highcarts.StackItem#setOffset
  39340. * @param {number} xOffset
  39341. * @param {number} xWidth
  39342. * @param {number} [boxBottom]
  39343. * @param {number} [boxTop]
  39344. * @param {number} [defaultX]
  39345. */
  39346. StackItem.prototype.setOffset = function (xOffset, xWidth, boxBottom, boxTop, defaultX) {
  39347. var stackItem = this,
  39348. axis = stackItem.axis,
  39349. chart = axis.chart,
  39350. // stack value translated mapped to chart coordinates
  39351. y = axis.translate(axis.stacking.usePercentage ?
  39352. 100 :
  39353. (boxTop ?
  39354. boxTop :
  39355. stackItem.total), 0, 0, 0, 1),
  39356. yZero = axis.translate(boxBottom ? boxBottom : 0), // stack origin
  39357. // stack height:
  39358. h = defined(y) && Math.abs(y - yZero),
  39359. // x position:
  39360. x = pick(defaultX,
  39361. chart.xAxis[0].translate(stackItem.x)) +
  39362. xOffset,
  39363. stackBox = defined(y) && stackItem.getStackBox(chart,
  39364. stackItem,
  39365. x,
  39366. y,
  39367. xWidth,
  39368. h,
  39369. axis),
  39370. label = stackItem.label,
  39371. isNegative = stackItem.isNegative,
  39372. isJustify = pick(stackItem.options.overflow, 'justify') === 'justify',
  39373. textAlign = stackItem.textAlign,
  39374. visible;
  39375. if (label && stackBox) {
  39376. var bBox = label.getBBox(),
  39377. padding = label.padding,
  39378. boxOffsetX = void 0,
  39379. boxOffsetY = void 0;
  39380. if (textAlign === 'left') {
  39381. boxOffsetX = chart.inverted ? -padding : padding;
  39382. }
  39383. else if (textAlign === 'right') {
  39384. boxOffsetX = bBox.width;
  39385. }
  39386. else {
  39387. if (chart.inverted && textAlign === 'center') {
  39388. boxOffsetX = bBox.width / 2;
  39389. }
  39390. else {
  39391. boxOffsetX = chart.inverted ?
  39392. (isNegative ? bBox.width + padding : -padding) : bBox.width / 2;
  39393. }
  39394. }
  39395. boxOffsetY = chart.inverted ?
  39396. bBox.height / 2 : (isNegative ? -padding : bBox.height);
  39397. // Reset alignOptions property after justify #12337
  39398. stackItem.alignOptions.x = pick(stackItem.options.x, 0);
  39399. stackItem.alignOptions.y = pick(stackItem.options.y, 0);
  39400. // Set the stackBox position
  39401. stackBox.x -= boxOffsetX;
  39402. stackBox.y -= boxOffsetY;
  39403. // Align the label to the box
  39404. label.align(stackItem.alignOptions, null, stackBox);
  39405. // Check if label is inside the plotArea #12294
  39406. if (chart.isInsidePlot(label.alignAttr.x + boxOffsetX - stackItem.alignOptions.x, label.alignAttr.y + boxOffsetY - stackItem.alignOptions.y)) {
  39407. label.show();
  39408. }
  39409. else {
  39410. // Move label away to avoid the overlapping issues
  39411. label.alignAttr.y = -9999;
  39412. isJustify = false;
  39413. }
  39414. if (isJustify) {
  39415. // Justify stackLabel into the stackBox
  39416. Series.prototype.justifyDataLabel.call(this.axis, label, stackItem.alignOptions, label.alignAttr, bBox, stackBox);
  39417. }
  39418. label.attr({
  39419. x: label.alignAttr.x,
  39420. y: label.alignAttr.y
  39421. });
  39422. if (pick(!isJustify && stackItem.options.crop, true)) {
  39423. visible =
  39424. isNumber(label.x) &&
  39425. isNumber(label.y) &&
  39426. chart.isInsidePlot(label.x - padding + label.width, label.y) &&
  39427. chart.isInsidePlot(label.x + padding, label.y);
  39428. if (!visible) {
  39429. label.hide();
  39430. }
  39431. }
  39432. }
  39433. };
  39434. /**
  39435. * @private
  39436. * @function Highcharts.StackItem#getStackBox
  39437. *
  39438. * @param {Highcharts.Chart} chart
  39439. *
  39440. * @param {Highcharts.StackItem} stackItem
  39441. *
  39442. * @param {number} x
  39443. *
  39444. * @param {number} y
  39445. *
  39446. * @param {number} xWidth
  39447. *
  39448. * @param {number} h
  39449. *
  39450. * @param {Highcharts.Axis} axis
  39451. *
  39452. * @return {Highcharts.BBoxObject}
  39453. */
  39454. StackItem.prototype.getStackBox = function (chart, stackItem, x, y, xWidth, h, axis) {
  39455. var reversed = stackItem.axis.reversed,
  39456. inverted = chart.inverted,
  39457. axisPos = axis.height + axis.pos -
  39458. (inverted ? chart.plotLeft : chart.plotTop),
  39459. neg = (stackItem.isNegative && !reversed) ||
  39460. (!stackItem.isNegative && reversed); // #4056
  39461. return {
  39462. x: inverted ? (neg ? y - axis.right : y - h + axis.pos - chart.plotLeft) :
  39463. x + chart.xAxis[0].transB - chart.plotLeft,
  39464. y: inverted ?
  39465. axis.height - x - xWidth :
  39466. (neg ?
  39467. (axisPos - y - h) :
  39468. axisPos - y),
  39469. width: inverted ? h : xWidth,
  39470. height: inverted ? xWidth : h
  39471. };
  39472. };
  39473. return StackItem;
  39474. }());
  39475. /**
  39476. * Generate stacks for each series and calculate stacks total values
  39477. *
  39478. * @private
  39479. * @function Highcharts.Chart#getStacks
  39480. */
  39481. Chart.prototype.getStacks = function () {
  39482. var chart = this,
  39483. inverted = chart.inverted;
  39484. // reset stacks for each yAxis
  39485. chart.yAxis.forEach(function (axis) {
  39486. if (axis.stacking && axis.stacking.stacks && axis.hasVisibleSeries) {
  39487. axis.stacking.oldStacks = axis.stacking.stacks;
  39488. }
  39489. });
  39490. chart.series.forEach(function (series) {
  39491. var xAxisOptions = series.xAxis && series.xAxis.options || {};
  39492. if (series.options.stacking &&
  39493. (series.visible === true ||
  39494. chart.options.chart.ignoreHiddenSeries === false)) {
  39495. series.stackKey = [
  39496. series.type,
  39497. pick(series.options.stack, ''),
  39498. inverted ? xAxisOptions.top : xAxisOptions.left,
  39499. inverted ? xAxisOptions.height : xAxisOptions.width
  39500. ].join(',');
  39501. }
  39502. });
  39503. };
  39504. // Stacking methods defined on the Axis prototype
  39505. StackingAxis.compose(Axis);
  39506. // Stacking methods defined for Series prototype
  39507. /**
  39508. * Set grouped points in a stack-like object. When `centerInCategory` is true,
  39509. * and `stacking` is not enabled, we need a pseudo (horizontal) stack in order
  39510. * to handle grouping of points within the same category.
  39511. *
  39512. * @private
  39513. * @function Highcharts.Series#setStackedPoints
  39514. * @return {void}
  39515. */
  39516. Series.prototype.setGroupedPoints = function () {
  39517. var stacking = this.yAxis.stacking;
  39518. if (this.options.centerInCategory &&
  39519. (this.is('column') || this.is('columnrange')) &&
  39520. // With stacking enabled, we already have stacks that we can compute
  39521. // from
  39522. !this.options.stacking &&
  39523. // With only one series, we don't need to consider centerInCategory
  39524. this.chart.series.length > 1) {
  39525. Series.prototype.setStackedPoints.call(this, 'group');
  39526. // After updating, if we now have proper stacks, we must delete the group
  39527. // pseudo stacks (#14986)
  39528. }
  39529. else if (stacking) {
  39530. objectEach(stacking.stacks, function (type, key) {
  39531. if (key.slice(-5) === 'group') {
  39532. objectEach(type, function (stack) { return stack.destroy(); });
  39533. delete stacking.stacks[key];
  39534. }
  39535. });
  39536. }
  39537. };
  39538. /**
  39539. * Adds series' points value to corresponding stack
  39540. *
  39541. * @private
  39542. * @function Highcharts.Series#setStackedPoints
  39543. */
  39544. Series.prototype.setStackedPoints = function (stackingParam) {
  39545. var stacking = stackingParam || this.options.stacking;
  39546. if (!stacking || (this.visible !== true &&
  39547. this.chart.options.chart.ignoreHiddenSeries !== false)) {
  39548. return;
  39549. }
  39550. 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;
  39551. yAxis.stacking.stacksTouched += 1;
  39552. // loop over the non-null y values and read them into a local array
  39553. for (i = 0; i < yDataLength; i++) {
  39554. x = xData[i];
  39555. y = yData[i];
  39556. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index);
  39557. pointKey = stackIndicator.key;
  39558. // Read stacked values into a stack based on the x value,
  39559. // the sign of y and the stack key. Stacking is also handled for null
  39560. // values (#739)
  39561. isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
  39562. key = isNegative ? negKey : stackKey;
  39563. // Create empty object for this stack if it doesn't exist yet
  39564. if (!stacks[key]) {
  39565. stacks[key] =
  39566. {};
  39567. }
  39568. // Initialize StackItem for this x
  39569. if (!stacks[key][x]) {
  39570. if (oldStacks[key] &&
  39571. oldStacks[key][x]) {
  39572. stacks[key][x] = oldStacks[key][x];
  39573. stacks[key][x].total = null;
  39574. }
  39575. else {
  39576. stacks[key][x] = new StackItem(yAxis, yAxis.options.stackLabels, isNegative, x, stackOption);
  39577. }
  39578. }
  39579. // If the StackItem doesn't exist, create it first
  39580. stack = stacks[key][x];
  39581. if (y !== null) {
  39582. stack.points[pointKey] = stack.points[series.index] =
  39583. [pick(stack.cumulative, stackThreshold)];
  39584. // Record the base of the stack
  39585. if (!defined(stack.cumulative)) {
  39586. stack.base = pointKey;
  39587. }
  39588. stack.touched = yAxis.stacking.stacksTouched;
  39589. // In area charts, if there are multiple points on the same X value,
  39590. // let the area fill the full span of those points
  39591. if (stackIndicator.index > 0 && series.singleStacks === false) {
  39592. stack.points[pointKey][0] =
  39593. stack.points[series.index + ',' + x + ',0'][0];
  39594. }
  39595. // When updating to null, reset the point stack (#7493)
  39596. }
  39597. else {
  39598. stack.points[pointKey] = stack.points[series.index] =
  39599. null;
  39600. }
  39601. // Add value to the stack total
  39602. if (stacking === 'percent') {
  39603. // Percent stacked column, totals are the same for the positive and
  39604. // negative stacks
  39605. other = isNegative ? stackKey : negKey;
  39606. if (negStacks && stacks[other] && stacks[other][x]) {
  39607. other = stacks[other][x];
  39608. stack.total = other.total =
  39609. Math.max(other.total, stack.total) +
  39610. Math.abs(y) ||
  39611. 0;
  39612. // Percent stacked areas
  39613. }
  39614. else {
  39615. stack.total =
  39616. correctFloat(stack.total + (Math.abs(y) || 0));
  39617. }
  39618. }
  39619. else if (stacking === 'group') {
  39620. if (isArray(y)) {
  39621. y = y[0];
  39622. }
  39623. // In this stack, the total is the number of valid points
  39624. if (y !== null) {
  39625. stack.total = (stack.total || 0) + 1;
  39626. }
  39627. }
  39628. else {
  39629. stack.total = correctFloat(stack.total + (y || 0));
  39630. }
  39631. if (stacking === 'group') {
  39632. // This point's index within the stack, pushed to stack.points[1]
  39633. stack.cumulative = (stack.total || 1) - 1;
  39634. }
  39635. else {
  39636. stack.cumulative =
  39637. pick(stack.cumulative, stackThreshold) + (y || 0);
  39638. }
  39639. if (y !== null) {
  39640. stack.points[pointKey].push(stack.cumulative);
  39641. stackedYData[i] = stack.cumulative;
  39642. stack.hasValidPoints = true;
  39643. }
  39644. }
  39645. if (stacking === 'percent') {
  39646. yAxis.stacking.usePercentage = true;
  39647. }
  39648. if (stacking !== 'group') {
  39649. this.stackedYData = stackedYData; // To be used in getExtremes
  39650. }
  39651. // Reset old stacks
  39652. yAxis.stacking.oldStacks = {};
  39653. };
  39654. /**
  39655. * Iterate over all stacks and compute the absolute values to percent
  39656. *
  39657. * @private
  39658. * @function Highcharts.Series#modifyStacks
  39659. */
  39660. Series.prototype.modifyStacks = function () {
  39661. var series = this,
  39662. yAxis = series.yAxis,
  39663. stackKey = series.stackKey,
  39664. stacks = yAxis.stacking.stacks,
  39665. processedXData = series.processedXData,
  39666. stackIndicator,
  39667. stacking = series.options.stacking;
  39668. if (series[stacking + 'Stacker']) { // Modifier function exists
  39669. [stackKey, '-' + stackKey].forEach(function (key) {
  39670. var i = processedXData.length,
  39671. x,
  39672. stack,
  39673. pointExtremes;
  39674. while (i--) {
  39675. x = processedXData[i];
  39676. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index, key);
  39677. stack = stacks[key] && stacks[key][x];
  39678. pointExtremes =
  39679. stack && stack.points[stackIndicator.key];
  39680. if (pointExtremes) {
  39681. series[stacking + 'Stacker'](pointExtremes, stack, i);
  39682. }
  39683. }
  39684. });
  39685. }
  39686. };
  39687. /**
  39688. * Modifier function for percent stacks. Blows up the stack to 100%.
  39689. *
  39690. * @private
  39691. * @function Highcharts.Series#percentStacker
  39692. */
  39693. Series.prototype.percentStacker = function (pointExtremes, stack, i) {
  39694. var totalFactor = stack.total ? 100 / stack.total : 0;
  39695. // Y bottom value
  39696. pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
  39697. // Y value
  39698. pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
  39699. this.stackedYData[i] = pointExtremes[1];
  39700. };
  39701. /**
  39702. * Get stack indicator, according to it's x-value, to determine points with the
  39703. * same x-value
  39704. *
  39705. * @private
  39706. * @function Highcharts.Series#getStackIndicator
  39707. * @param {Highcharts.StackItemIndicatorObject|undefined} stackIndicator
  39708. * @param {number} x
  39709. * @param {number} index
  39710. * @param {string} [key]
  39711. * @return {Highcharts.StackItemIndicatorObject}
  39712. */
  39713. Series.prototype.getStackIndicator = function (stackIndicator, x, index, key) {
  39714. // Update stack indicator, when:
  39715. // first point in a stack || x changed || stack type (negative vs positive)
  39716. // changed:
  39717. if (!defined(stackIndicator) ||
  39718. stackIndicator.x !== x ||
  39719. (key && stackIndicator.key !== key)) {
  39720. stackIndicator = {
  39721. x: x,
  39722. index: 0,
  39723. key: key
  39724. };
  39725. }
  39726. else {
  39727. (stackIndicator).index++;
  39728. }
  39729. stackIndicator.key =
  39730. [index, x, stackIndicator.index].join(',');
  39731. return stackIndicator;
  39732. };
  39733. H.StackItem = StackItem;
  39734. return H.StackItem;
  39735. });
  39736. _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) {
  39737. /* *
  39738. *
  39739. * (c) 2010-2021 Torstein Honsi
  39740. *
  39741. * License: www.highcharts.com/license
  39742. *
  39743. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39744. *
  39745. * */
  39746. var __extends = (this && this.__extends) || (function () {
  39747. var extendStatics = function (d,
  39748. b) {
  39749. extendStatics = Object.setPrototypeOf ||
  39750. ({ __proto__: [] } instanceof Array && function (d,
  39751. b) { d.__proto__ = b; }) ||
  39752. function (d,
  39753. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39754. return extendStatics(d, b);
  39755. };
  39756. return function (d, b) {
  39757. extendStatics(d, b);
  39758. function __() { this.constructor = d; }
  39759. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39760. };
  39761. })();
  39762. var defined = U.defined,
  39763. merge = U.merge;
  39764. /* *
  39765. *
  39766. * Class
  39767. *
  39768. * */
  39769. /**
  39770. * The line series is the base type and is therefor the series base prototype.
  39771. *
  39772. * @private
  39773. */
  39774. var LineSeries = /** @class */ (function (_super) {
  39775. __extends(LineSeries, _super);
  39776. function LineSeries() {
  39777. /* *
  39778. *
  39779. * Static Functions
  39780. *
  39781. * */
  39782. var _this = _super !== null && _super.apply(this,
  39783. arguments) || this;
  39784. /* *
  39785. *
  39786. * Properties
  39787. *
  39788. * */
  39789. _this.data = void 0;
  39790. _this.options = void 0;
  39791. _this.points = void 0;
  39792. return _this;
  39793. }
  39794. /* *
  39795. *
  39796. * Functions
  39797. *
  39798. * */
  39799. /**
  39800. * Draw the graph. Called internally when rendering line-like series
  39801. * types. The first time it generates the `series.graph` item and
  39802. * optionally other series-wide items like `series.area` for area
  39803. * charts. On subsequent calls these items are updated with new
  39804. * positions and attributes.
  39805. *
  39806. * @function Highcharts.Series#drawGraph
  39807. */
  39808. LineSeries.prototype.drawGraph = function () {
  39809. var series = this,
  39810. options = this.options,
  39811. graphPath = (this.gappedPath || this.getGraphPath).call(this),
  39812. styledMode = this.chart.styledMode,
  39813. props = [[
  39814. 'graph',
  39815. 'highcharts-graph'
  39816. ]];
  39817. // Presentational properties
  39818. if (!styledMode) {
  39819. props[0].push((options.lineColor ||
  39820. this.color ||
  39821. palette.neutralColor20 // when colorByPoint = true
  39822. ), options.dashStyle);
  39823. }
  39824. props = series.getZonesGraphs(props);
  39825. // Draw the graph
  39826. props.forEach(function (prop, i) {
  39827. var graphKey = prop[0],
  39828. graph = series[graphKey],
  39829. verb = graph ? 'animate' : 'attr',
  39830. attribs;
  39831. if (graph) {
  39832. graph.endX = series.preventGraphAnimation ?
  39833. null :
  39834. graphPath.xMap;
  39835. graph.animate({ d: graphPath });
  39836. }
  39837. else if (graphPath.length) { // #1487
  39838. /**
  39839. * SVG element of area-based charts. Can be used for styling
  39840. * purposes. If zones are configured, this element will be
  39841. * hidden and replaced by multiple zone areas, accessible
  39842. * via `series['zone-area-x']` (where x is a number,
  39843. * starting with 0).
  39844. *
  39845. * @name Highcharts.Series#area
  39846. * @type {Highcharts.SVGElement|undefined}
  39847. */
  39848. /**
  39849. * SVG element of line-based charts. Can be used for styling
  39850. * purposes. If zones are configured, this element will be
  39851. * hidden and replaced by multiple zone lines, accessible
  39852. * via `series['zone-graph-x']` (where x is a number,
  39853. * starting with 0).
  39854. *
  39855. * @name Highcharts.Series#graph
  39856. * @type {Highcharts.SVGElement|undefined}
  39857. */
  39858. series[graphKey] = graph = series.chart.renderer
  39859. .path(graphPath)
  39860. .addClass(prop[1])
  39861. .attr({ zIndex: 1 }) // #1069
  39862. .add(series.group);
  39863. }
  39864. if (graph && !styledMode) {
  39865. attribs = {
  39866. 'stroke': prop[2],
  39867. 'stroke-width': options.lineWidth,
  39868. // Polygon series use filled graph
  39869. 'fill': (series.fillGraph && series.color) || 'none'
  39870. };
  39871. if (prop[3]) {
  39872. attribs.dashstyle = prop[3];
  39873. }
  39874. else if (options.linecap !== 'square') {
  39875. attribs['stroke-linecap'] =
  39876. attribs['stroke-linejoin'] = 'round';
  39877. }
  39878. graph[verb](attribs)
  39879. // Add shadow to normal series (0) or to first
  39880. // zone (1) #3932
  39881. .shadow((i < 2) && options.shadow);
  39882. }
  39883. // Helpers for animation
  39884. if (graph) {
  39885. graph.startX = graphPath.xMap;
  39886. graph.isArea = graphPath.isArea; // For arearange animation
  39887. }
  39888. });
  39889. };
  39890. // eslint-disable-next-line valid-jsdoc
  39891. /**
  39892. * Get the graph path.
  39893. *
  39894. * @private
  39895. */
  39896. LineSeries.prototype.getGraphPath = function (points, nullsAsZeroes, connectCliffs) {
  39897. var series = this,
  39898. options = series.options,
  39899. step = options.step,
  39900. reversed,
  39901. graphPath = [],
  39902. xMap = [],
  39903. gap;
  39904. points = points || series.points;
  39905. // Bottom of a stack is reversed
  39906. reversed = points.reversed;
  39907. if (reversed) {
  39908. points.reverse();
  39909. }
  39910. // Reverse the steps (#5004)
  39911. step = {
  39912. right: 1,
  39913. center: 2
  39914. }[step] || (step && 3);
  39915. if (step && reversed) {
  39916. step = 4 - step;
  39917. }
  39918. // Remove invalid points, especially in spline (#5015)
  39919. points = this.getValidPoints(points, false, !(options.connectNulls && !nullsAsZeroes && !connectCliffs));
  39920. // Build the line
  39921. points.forEach(function (point, i) {
  39922. var plotX = point.plotX,
  39923. plotY = point.plotY,
  39924. lastPoint = points[i - 1],
  39925. // the path to this point from the previous
  39926. pathToPoint;
  39927. if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) &&
  39928. !connectCliffs) {
  39929. gap = true; // ... and continue
  39930. }
  39931. // Line series, nullsAsZeroes is not handled
  39932. if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
  39933. gap = !options.connectNulls;
  39934. // Area series, nullsAsZeroes is set
  39935. }
  39936. else if (point.isNull && !nullsAsZeroes) {
  39937. gap = true;
  39938. }
  39939. else {
  39940. if (i === 0 || gap) {
  39941. pathToPoint = [[
  39942. 'M',
  39943. point.plotX,
  39944. point.plotY
  39945. ]];
  39946. // Generate the spline as defined in the SplineSeries object
  39947. }
  39948. else if (series.getPointSpline) {
  39949. pathToPoint = [series.getPointSpline(points, point, i)];
  39950. }
  39951. else if (step) {
  39952. if (step === 1) { // right
  39953. pathToPoint = [[
  39954. 'L',
  39955. lastPoint.plotX,
  39956. plotY
  39957. ]];
  39958. }
  39959. else if (step === 2) { // center
  39960. pathToPoint = [[
  39961. 'L',
  39962. (lastPoint.plotX + plotX) / 2,
  39963. lastPoint.plotY
  39964. ], [
  39965. 'L',
  39966. (lastPoint.plotX + plotX) / 2,
  39967. plotY
  39968. ]];
  39969. }
  39970. else {
  39971. pathToPoint = [[
  39972. 'L',
  39973. plotX,
  39974. lastPoint.plotY
  39975. ]];
  39976. }
  39977. pathToPoint.push([
  39978. 'L',
  39979. plotX,
  39980. plotY
  39981. ]);
  39982. }
  39983. else {
  39984. // normal line to next point
  39985. pathToPoint = [[
  39986. 'L',
  39987. plotX,
  39988. plotY
  39989. ]];
  39990. }
  39991. // Prepare for animation. When step is enabled, there are
  39992. // two path nodes for each x value.
  39993. xMap.push(point.x);
  39994. if (step) {
  39995. xMap.push(point.x);
  39996. if (step === 2) { // step = center (#8073)
  39997. xMap.push(point.x);
  39998. }
  39999. }
  40000. graphPath.push.apply(graphPath, pathToPoint);
  40001. gap = false;
  40002. }
  40003. });
  40004. graphPath.xMap = xMap;
  40005. series.graphPath = graphPath;
  40006. return graphPath;
  40007. };
  40008. // eslint-disable-next-line valid-jsdoc
  40009. /**
  40010. * Get zones properties for building graphs. Extendable by series with
  40011. * multiple lines within one series.
  40012. *
  40013. * @private
  40014. */
  40015. LineSeries.prototype.getZonesGraphs = function (props) {
  40016. // Add the zone properties if any
  40017. this.zones.forEach(function (zone, i) {
  40018. var propset = [
  40019. 'zone-graph-' + i,
  40020. 'highcharts-graph highcharts-zone-graph-' + i + ' ' +
  40021. (zone.className || '')
  40022. ];
  40023. if (!this.chart.styledMode) {
  40024. propset.push((zone.color || this.color), (zone.dashStyle || this.options.dashStyle));
  40025. }
  40026. props.push(propset);
  40027. }, this);
  40028. return props;
  40029. };
  40030. /**
  40031. * General options for all series types.
  40032. *
  40033. * @optionparent plotOptions.series
  40034. */
  40035. LineSeries.defaultOptions = merge(Series.defaultOptions, {
  40036. // nothing here yet
  40037. });
  40038. return LineSeries;
  40039. }(Series));
  40040. SeriesRegistry.registerSeriesType('line', LineSeries);
  40041. /* *
  40042. *
  40043. * Default Export
  40044. *
  40045. * */
  40046. /* *
  40047. *
  40048. * API Options
  40049. *
  40050. * */
  40051. /**
  40052. * A line series displays information as a series of data points connected by
  40053. * straight line segments.
  40054. *
  40055. * @sample {highcharts} highcharts/demo/line-basic/
  40056. * Line chart
  40057. * @sample {highstock} stock/demo/basic-line/
  40058. * Line chart
  40059. *
  40060. * @extends plotOptions.series
  40061. * @product highcharts highstock
  40062. * @apioption plotOptions.line
  40063. */
  40064. /**
  40065. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  40066. * of a line graph. Round means that lines are rounded in the ends and
  40067. * bends.
  40068. *
  40069. * @type {Highcharts.SeriesLinecapValue}
  40070. * @default round
  40071. * @since 3.0.7
  40072. * @apioption plotOptions.line.linecap
  40073. */
  40074. /**
  40075. * A `line` series. If the [type](#series.line.type) option is not
  40076. * specified, it is inherited from [chart.type](#chart.type).
  40077. *
  40078. * @extends series,plotOptions.line
  40079. * @excluding dataParser,dataURL
  40080. * @product highcharts highstock
  40081. * @apioption series.line
  40082. */
  40083. /**
  40084. * An array of data points for the series. For the `line` series type,
  40085. * points can be given in the following ways:
  40086. *
  40087. * 1. An array of numerical values. In this case, the numerical values will be
  40088. * interpreted as `y` options. The `x` values will be automatically
  40089. * calculated, either starting at 0 and incremented by 1, or from
  40090. * `pointStart` and `pointInterval` given in the series options. If the axis
  40091. * has categories, these will be used. Example:
  40092. * ```js
  40093. * data: [0, 5, 3, 5]
  40094. * ```
  40095. *
  40096. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40097. * `x,y`. If the first value is a string, it is applied as the name of the
  40098. * point, and the `x` value is inferred.
  40099. * ```js
  40100. * data: [
  40101. * [0, 1],
  40102. * [1, 2],
  40103. * [2, 8]
  40104. * ]
  40105. * ```
  40106. *
  40107. * 3. An array of objects with named values. The following snippet shows only a
  40108. * few settings, see the complete options set below. If the total number of
  40109. * data points exceeds the series'
  40110. * [turboThreshold](#series.line.turboThreshold),
  40111. * this option is not available.
  40112. * ```js
  40113. * data: [{
  40114. * x: 1,
  40115. * y: 9,
  40116. * name: "Point2",
  40117. * color: "#00FF00"
  40118. * }, {
  40119. * x: 1,
  40120. * y: 6,
  40121. * name: "Point1",
  40122. * color: "#FF00FF"
  40123. * }]
  40124. * ```
  40125. *
  40126. * **Note:** In TypeScript you have to extend `PointOptionsObject` with an
  40127. * additional declaration to allow custom data types:
  40128. * ```ts
  40129. * declare module `highcharts` {
  40130. * interface PointOptionsObject {
  40131. * custom: Record<string, (boolean|number|string)>;
  40132. * }
  40133. * }
  40134. * ```
  40135. *
  40136. * @sample {highcharts} highcharts/chart/reflow-true/
  40137. * Numerical values
  40138. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40139. * Arrays of numeric x and y
  40140. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40141. * Arrays of datetime x and y
  40142. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40143. * Arrays of point.name and y
  40144. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40145. * Config objects
  40146. *
  40147. * @declare Highcharts.PointOptionsObject
  40148. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40149. * @apioption series.line.data
  40150. */
  40151. /**
  40152. * An additional, individual class name for the data point's graphic
  40153. * representation.
  40154. *
  40155. * @type {string}
  40156. * @since 5.0.0
  40157. * @product highcharts gantt
  40158. * @apioption series.line.data.className
  40159. */
  40160. /**
  40161. * Individual color for the point. By default the color is pulled from
  40162. * the global `colors` array.
  40163. *
  40164. * In styled mode, the `color` option doesn't take effect. Instead, use
  40165. * `colorIndex`.
  40166. *
  40167. * @sample {highcharts} highcharts/point/color/
  40168. * Mark the highest point
  40169. *
  40170. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40171. * @product highcharts highstock gantt
  40172. * @apioption series.line.data.color
  40173. */
  40174. /**
  40175. * A specific color index to use for the point, so its graphic representations
  40176. * are given the class name `highcharts-color-{n}`. In styled mode this will
  40177. * change the color of the graphic. In non-styled mode, the color by is set by
  40178. * the `fill` attribute, so the change in class name won't have a visual effect
  40179. * by default.
  40180. *
  40181. * @type {number}
  40182. * @since 5.0.0
  40183. * @product highcharts gantt
  40184. * @apioption series.line.data.colorIndex
  40185. */
  40186. /**
  40187. * A reserved subspace to store options and values for customized functionality.
  40188. * Here you can add additional data for your own event callbacks and formatter
  40189. * callbacks.
  40190. *
  40191. * @sample {highcharts} highcharts/point/custom/
  40192. * Point and series with custom data
  40193. *
  40194. * @type {Highcharts.Dictionary<*>}
  40195. * @apioption series.line.data.custom
  40196. */
  40197. /**
  40198. * Individual data label for each point. The options are the same as
  40199. * the ones for [plotOptions.series.dataLabels](
  40200. * #plotOptions.series.dataLabels).
  40201. *
  40202. * @sample highcharts/point/datalabels/
  40203. * Show a label for the last value
  40204. *
  40205. * @declare Highcharts.DataLabelsOptions
  40206. * @extends plotOptions.line.dataLabels
  40207. * @product highcharts highstock gantt
  40208. * @apioption series.line.data.dataLabels
  40209. */
  40210. /**
  40211. * A description of the point to add to the screen reader information
  40212. * about the point.
  40213. *
  40214. * @type {string}
  40215. * @since 5.0.0
  40216. * @requires modules/accessibility
  40217. * @apioption series.line.data.description
  40218. */
  40219. /**
  40220. * An id for the point. This can be used after render time to get a
  40221. * pointer to the point object through `chart.get()`.
  40222. *
  40223. * @sample {highcharts} highcharts/point/id/
  40224. * Remove an id'd point
  40225. *
  40226. * @type {string}
  40227. * @since 1.2.0
  40228. * @product highcharts highstock gantt
  40229. * @apioption series.line.data.id
  40230. */
  40231. /**
  40232. * The rank for this point's data label in case of collision. If two
  40233. * data labels are about to overlap, only the one with the highest `labelrank`
  40234. * will be drawn.
  40235. *
  40236. * @type {number}
  40237. * @apioption series.line.data.labelrank
  40238. */
  40239. /**
  40240. * The name of the point as shown in the legend, tooltip, dataLabels, etc.
  40241. *
  40242. * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
  40243. *
  40244. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40245. * Point names
  40246. *
  40247. * @type {string}
  40248. * @apioption series.line.data.name
  40249. */
  40250. /**
  40251. * Whether the data point is selected initially.
  40252. *
  40253. * @type {boolean}
  40254. * @default false
  40255. * @product highcharts highstock gantt
  40256. * @apioption series.line.data.selected
  40257. */
  40258. /**
  40259. * The x value of the point. For datetime axes, the X value is the timestamp
  40260. * in milliseconds since 1970.
  40261. *
  40262. * @type {number}
  40263. * @product highcharts highstock
  40264. * @apioption series.line.data.x
  40265. */
  40266. /**
  40267. * The y value of the point.
  40268. *
  40269. * @type {number|null}
  40270. * @product highcharts highstock
  40271. * @apioption series.line.data.y
  40272. */
  40273. /**
  40274. * The individual point events.
  40275. *
  40276. * @extends plotOptions.series.point.events
  40277. * @product highcharts highstock gantt
  40278. * @apioption series.line.data.events
  40279. */
  40280. /**
  40281. * Options for the point markers of line-like series.
  40282. *
  40283. * @declare Highcharts.PointMarkerOptionsObject
  40284. * @extends plotOptions.series.marker
  40285. * @product highcharts highstock
  40286. * @apioption series.line.data.marker
  40287. */
  40288. ''; // include precedent doclets in transpilat
  40289. return LineSeries;
  40290. });
  40291. _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) {
  40292. /* *
  40293. *
  40294. * (c) 2010-2021 Torstein Honsi
  40295. *
  40296. * License: www.highcharts.com/license
  40297. *
  40298. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40299. *
  40300. * */
  40301. var __extends = (this && this.__extends) || (function () {
  40302. var extendStatics = function (d,
  40303. b) {
  40304. extendStatics = Object.setPrototypeOf ||
  40305. ({ __proto__: [] } instanceof Array && function (d,
  40306. b) { d.__proto__ = b; }) ||
  40307. function (d,
  40308. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40309. return extendStatics(d, b);
  40310. };
  40311. return function (d, b) {
  40312. extendStatics(d, b);
  40313. function __() { this.constructor = d; }
  40314. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40315. };
  40316. })();
  40317. var color = Color.parse;
  40318. var LineSeries = SeriesRegistry.seriesTypes.line;
  40319. var extend = U.extend,
  40320. merge = U.merge,
  40321. objectEach = U.objectEach,
  40322. pick = U.pick;
  40323. /* *
  40324. *
  40325. * Class
  40326. *
  40327. * */
  40328. /**
  40329. * Area series type.
  40330. *
  40331. * @private
  40332. * @class
  40333. * @name AreaSeries
  40334. *
  40335. * @augments LineSeries
  40336. */
  40337. var AreaSeries = /** @class */ (function (_super) {
  40338. __extends(AreaSeries, _super);
  40339. function AreaSeries() {
  40340. /* *
  40341. *
  40342. * Static Properties
  40343. *
  40344. * */
  40345. var _this = _super !== null && _super.apply(this,
  40346. arguments) || this;
  40347. _this.data = void 0;
  40348. _this.options = void 0;
  40349. _this.points = void 0;
  40350. return _this;
  40351. /* eslint-enable valid-jsdoc */
  40352. }
  40353. /* *
  40354. *
  40355. * Functions
  40356. *
  40357. * */
  40358. /* eslint-disable valid-jsdoc */
  40359. /**
  40360. * Draw the graph and the underlying area. This method calls the Series
  40361. * base function and adds the area. The areaPath is calculated in the
  40362. * getSegmentPath method called from Series.prototype.drawGraph.
  40363. * @private
  40364. */
  40365. AreaSeries.prototype.drawGraph = function () {
  40366. // Define or reset areaPath
  40367. this.areaPath = [];
  40368. // Call the base method
  40369. _super.prototype.drawGraph.apply(this);
  40370. // Define local variables
  40371. var series = this,
  40372. areaPath = this.areaPath,
  40373. options = this.options,
  40374. zones = this.zones,
  40375. props = [[
  40376. 'area',
  40377. 'highcharts-area',
  40378. this.color,
  40379. options.fillColor
  40380. ]]; // area name, main color, fill color
  40381. zones.forEach(function (zone,
  40382. i) {
  40383. props.push([
  40384. 'zone-area-' + i,
  40385. 'highcharts-area highcharts-zone-area-' + i + ' ' +
  40386. zone.className,
  40387. zone.color || series.color,
  40388. zone.fillColor || options.fillColor
  40389. ]);
  40390. });
  40391. props.forEach(function (prop) {
  40392. var areaKey = prop[0],
  40393. area = series[areaKey],
  40394. verb = area ? 'animate' : 'attr',
  40395. attribs = {};
  40396. // Create or update the area
  40397. if (area) { // update
  40398. area.endX = series.preventGraphAnimation ?
  40399. null :
  40400. areaPath.xMap;
  40401. area.animate({ d: areaPath });
  40402. }
  40403. else { // create
  40404. attribs.zIndex = 0; // #1069
  40405. area = series[areaKey] = series.chart.renderer
  40406. .path(areaPath)
  40407. .addClass(prop[1])
  40408. .add(series.group);
  40409. area.isArea = true;
  40410. }
  40411. if (!series.chart.styledMode) {
  40412. attribs.fill = pick(prop[3], color(prop[2])
  40413. .setOpacity(pick(options.fillOpacity, 0.75))
  40414. .get());
  40415. }
  40416. area[verb](attribs);
  40417. area.startX = areaPath.xMap;
  40418. area.shiftUnit = options.step ? 2 : 1;
  40419. });
  40420. };
  40421. /**
  40422. * @private
  40423. */
  40424. AreaSeries.prototype.getGraphPath = function (points) {
  40425. 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
  40426. yAxis.getThreshold(options.threshold)), isNull, yBottom, connectNulls = pick(// #10574
  40427. options.connectNulls, stacking === 'percent'),
  40428. // To display null points in underlying stacked series, this
  40429. // series graph must be broken, and the area also fall down to
  40430. // fill the gap left by the null point. #2069
  40431. addDummyPoints = function (i, otherI, side) {
  40432. var point = points[i], stackedValues = stacking &&
  40433. stacks[point.x].points[seriesIndex], nullVal = point[side + 'Null'] || 0, cliffVal = point[side + 'Cliff'] || 0, top, bottom, isNull = true;
  40434. if (cliffVal || nullVal) {
  40435. top = (nullVal ?
  40436. stackedValues[0] :
  40437. stackedValues[1]) + cliffVal;
  40438. bottom = stackedValues[0] + cliffVal;
  40439. isNull = !!nullVal;
  40440. }
  40441. else if (!stacking &&
  40442. points[otherI] &&
  40443. points[otherI].isNull) {
  40444. top = bottom = threshold;
  40445. }
  40446. // Add to the top and bottom line of the area
  40447. if (typeof top !== 'undefined') {
  40448. graphPoints.push({
  40449. plotX: plotX,
  40450. plotY: top === null ?
  40451. translatedThreshold :
  40452. yAxis.getThreshold(top),
  40453. isNull: isNull,
  40454. isCliff: true
  40455. });
  40456. bottomPoints.push({
  40457. plotX: plotX,
  40458. plotY: bottom === null ?
  40459. translatedThreshold :
  40460. yAxis.getThreshold(bottom),
  40461. doCurve: false // #1041, gaps in areaspline areas
  40462. });
  40463. }
  40464. };
  40465. // Find what points to use
  40466. points = points || this.points;
  40467. // Fill in missing points
  40468. if (stacking) {
  40469. points = this.getStackPoints(points);
  40470. }
  40471. for (i = 0; i < points.length; i++) {
  40472. // Reset after series.update of stacking property (#12033)
  40473. if (!stacking) {
  40474. points[i].leftCliff = points[i].rightCliff =
  40475. points[i].leftNull = points[i].rightNull = void 0;
  40476. }
  40477. isNull = points[i].isNull;
  40478. plotX = pick(points[i].rectPlotX, points[i].plotX);
  40479. yBottom = stacking ? pick(points[i].yBottom, translatedThreshold) : translatedThreshold;
  40480. if (!isNull || connectNulls) {
  40481. if (!connectNulls) {
  40482. addDummyPoints(i, i - 1, 'left');
  40483. }
  40484. // Skip null point when stacking is false and connectNulls
  40485. // true
  40486. if (!(isNull && !stacking && connectNulls)) {
  40487. graphPoints.push(points[i]);
  40488. bottomPoints.push({
  40489. x: i,
  40490. plotX: plotX,
  40491. plotY: yBottom
  40492. });
  40493. }
  40494. if (!connectNulls) {
  40495. addDummyPoints(i, i + 1, 'right');
  40496. }
  40497. }
  40498. }
  40499. topPath = getGraphPath.call(this, graphPoints, true, true);
  40500. bottomPoints.reversed = true;
  40501. bottomPath = getGraphPath.call(this, bottomPoints, true, true);
  40502. var firstBottomPoint = bottomPath[0];
  40503. if (firstBottomPoint && firstBottomPoint[0] === 'M') {
  40504. bottomPath[0] = ['L', firstBottomPoint[1], firstBottomPoint[2]];
  40505. }
  40506. areaPath = topPath.concat(bottomPath);
  40507. if (areaPath.length) {
  40508. areaPath.push(['Z']);
  40509. }
  40510. // TODO: don't set leftCliff and rightCliff when connectNulls?
  40511. graphPath = getGraphPath
  40512. .call(this, graphPoints, false, connectNulls);
  40513. areaPath.xMap = topPath.xMap;
  40514. this.areaPath = areaPath;
  40515. return graphPath;
  40516. };
  40517. /**
  40518. * Return an array of stacked points, where null and missing points are
  40519. * replaced by dummy points in order for gaps to be drawn correctly in
  40520. * stacks.
  40521. * @private
  40522. */
  40523. AreaSeries.prototype.getStackPoints = function (points) {
  40524. var series = this,
  40525. segment = [],
  40526. keys = [],
  40527. xAxis = this.xAxis,
  40528. yAxis = this.yAxis,
  40529. stack = yAxis.stacking.stacks[this.stackKey],
  40530. pointMap = {},
  40531. yAxisSeries = yAxis.series,
  40532. seriesLength = yAxisSeries.length,
  40533. upOrDown = yAxis.options.reversedStacks ? 1 : -1,
  40534. seriesIndex = yAxisSeries.indexOf(series);
  40535. points = points || this.points;
  40536. if (this.options.stacking) {
  40537. for (var i = 0; i < points.length; i++) {
  40538. // Reset after point update (#7326)
  40539. points[i].leftNull = points[i].rightNull = void 0;
  40540. // Create a map where we can quickly look up the points by
  40541. // their X values.
  40542. pointMap[points[i].x] = points[i];
  40543. }
  40544. // Sort the keys (#1651)
  40545. objectEach(stack, function (stackX, x) {
  40546. // nulled after switching between
  40547. // grouping and not (#1651, #2336)
  40548. if (stackX.total !== null) {
  40549. keys.push(x);
  40550. }
  40551. });
  40552. keys.sort(function (a, b) {
  40553. return a - b;
  40554. });
  40555. var visibleSeries_1 = yAxisSeries.map(function (s) { return s.visible; });
  40556. keys.forEach(function (x, idx) {
  40557. var y = 0,
  40558. stackPoint,
  40559. stackedValues;
  40560. if (pointMap[x] && !pointMap[x].isNull) {
  40561. segment.push(pointMap[x]);
  40562. // Find left and right cliff. -1 goes left, 1 goes
  40563. // right.
  40564. [-1, 1].forEach(function (direction) {
  40565. var nullName = direction === 1 ?
  40566. 'rightNull' :
  40567. 'leftNull',
  40568. cliffName = direction === 1 ?
  40569. 'rightCliff' :
  40570. 'leftCliff',
  40571. cliff = 0,
  40572. otherStack = stack[keys[idx + direction]];
  40573. // If there is a stack next to this one,
  40574. // to the left or to the right...
  40575. if (otherStack) {
  40576. var i = seriesIndex;
  40577. // Can go either up or down,
  40578. // depending on reversedStacks
  40579. while (i >= 0 && i < seriesLength) {
  40580. var si = yAxisSeries[i].index;
  40581. stackPoint = otherStack.points[si];
  40582. if (!stackPoint) {
  40583. // If the next point in this series
  40584. // is missing, mark the point
  40585. // with point.leftNull or
  40586. // point.rightNull = true.
  40587. if (si === series.index) {
  40588. pointMap[x][nullName] = true;
  40589. // If there are missing points in
  40590. // the next stack in any of the
  40591. // series below this one, we need
  40592. // to substract the missing values
  40593. // and add a hiatus to the left or
  40594. // right.
  40595. }
  40596. else if (visibleSeries_1[i]) {
  40597. stackedValues =
  40598. stack[x].points[si];
  40599. if (stackedValues) {
  40600. cliff -= stackedValues[1] - stackedValues[0];
  40601. }
  40602. }
  40603. }
  40604. // When reversedStacks is true, loop up,
  40605. // else loop down
  40606. i += upOrDown;
  40607. }
  40608. }
  40609. pointMap[x][cliffName] = cliff;
  40610. });
  40611. // There is no point for this X value in this series, so we
  40612. // insert a dummy point in order for the areas to be drawn
  40613. // correctly.
  40614. }
  40615. else {
  40616. // Loop down the stack to find the series below this
  40617. // one that has a value (#1991)
  40618. var i = seriesIndex;
  40619. while (i >= 0 && i < seriesLength) {
  40620. var si = yAxisSeries[i].index;
  40621. stackPoint = stack[x].points[si];
  40622. if (stackPoint) {
  40623. y = stackPoint[1];
  40624. break;
  40625. }
  40626. // When reversedStacks is true, loop up, else loop
  40627. // down
  40628. i += upOrDown;
  40629. }
  40630. y = pick(y, 0);
  40631. y = yAxis.translate(// #6272
  40632. y, 0, 1, 0, 1);
  40633. segment.push({
  40634. isNull: true,
  40635. plotX: xAxis.translate(// #6272
  40636. x, 0, 0, 0, 1),
  40637. x: x,
  40638. plotY: y,
  40639. yBottom: y
  40640. });
  40641. }
  40642. });
  40643. }
  40644. return segment;
  40645. };
  40646. /**
  40647. * The area series type.
  40648. *
  40649. * @sample {highcharts} highcharts/demo/area-basic/
  40650. * Area chart
  40651. * @sample {highstock} stock/demo/area/
  40652. * Area chart
  40653. *
  40654. * @extends plotOptions.line
  40655. * @excluding useOhlcData
  40656. * @product highcharts highstock
  40657. * @optionparent plotOptions.area
  40658. */
  40659. AreaSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  40660. /**
  40661. * @see [fillColor](#plotOptions.area.fillColor)
  40662. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  40663. *
  40664. * @apioption plotOptions.area.color
  40665. */
  40666. /**
  40667. * Fill color or gradient for the area. When `null`, the series' `color`
  40668. * is used with the series' `fillOpacity`.
  40669. *
  40670. * In styled mode, the fill color can be set with the `.highcharts-area`
  40671. * class name.
  40672. *
  40673. * @see [color](#plotOptions.area.color)
  40674. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  40675. *
  40676. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-default/
  40677. * Null by default
  40678. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-gradient/
  40679. * Gradient
  40680. *
  40681. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40682. * @product highcharts highstock
  40683. * @apioption plotOptions.area.fillColor
  40684. */
  40685. /**
  40686. * Fill opacity for the area. When you set an explicit `fillColor`,
  40687. * the `fillOpacity` is not applied. Instead, you should define the
  40688. * opacity in the `fillColor` with an rgba color definition. The
  40689. * `fillOpacity` setting, also the default setting, overrides the alpha
  40690. * component of the `color` setting.
  40691. *
  40692. * In styled mode, the fill opacity can be set with the
  40693. * `.highcharts-area` class name.
  40694. *
  40695. * @see [color](#plotOptions.area.color)
  40696. * @see [fillColor](#plotOptions.area.fillColor)
  40697. *
  40698. * @sample {highcharts} highcharts/plotoptions/area-fillopacity/
  40699. * Automatic fill color and fill opacity of 0.1
  40700. *
  40701. * @type {number}
  40702. * @default {highcharts} 0.75
  40703. * @default {highstock} 0.75
  40704. * @product highcharts highstock
  40705. * @apioption plotOptions.area.fillOpacity
  40706. */
  40707. /**
  40708. * A separate color for the graph line. By default the line takes the
  40709. * `color` of the series, but the lineColor setting allows setting a
  40710. * separate color for the line without altering the `fillColor`.
  40711. *
  40712. * In styled mode, the line stroke can be set with the
  40713. * `.highcharts-graph` class name.
  40714. *
  40715. * @sample {highcharts} highcharts/plotoptions/area-linecolor/
  40716. * Dark gray line
  40717. *
  40718. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40719. * @product highcharts highstock
  40720. * @apioption plotOptions.area.lineColor
  40721. */
  40722. /**
  40723. * A separate color for the negative part of the area.
  40724. *
  40725. * In styled mode, a negative color is set with the
  40726. * `.highcharts-negative` class name.
  40727. *
  40728. * @see [negativeColor](#plotOptions.area.negativeColor)
  40729. *
  40730. * @sample {highcharts} highcharts/css/series-negative-color/
  40731. * Negative color in styled mode
  40732. *
  40733. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40734. * @since 3.0
  40735. * @product highcharts
  40736. * @apioption plotOptions.area.negativeFillColor
  40737. */
  40738. /**
  40739. * Whether the whole area or just the line should respond to mouseover
  40740. * tooltips and other mouse or touch events.
  40741. *
  40742. * @sample {highcharts|highstock} highcharts/plotoptions/area-trackbyarea/
  40743. * Display the tooltip when the area is hovered
  40744. *
  40745. * @type {boolean}
  40746. * @default false
  40747. * @since 1.1.6
  40748. * @product highcharts highstock
  40749. * @apioption plotOptions.area.trackByArea
  40750. */
  40751. /**
  40752. * The Y axis value to serve as the base for the area, for
  40753. * distinguishing between values above and below a threshold. The area
  40754. * between the graph and the threshold is filled.
  40755. *
  40756. * * If a number is given, the Y axis will scale to the threshold.
  40757. * * If `null`, the scaling behaves like a line series with fill between
  40758. * the graph and the Y axis minimum.
  40759. * * If `Infinity` or `-Infinity`, the area between the graph and the
  40760. * corresponding Y axis extreme is filled (since v6.1.0).
  40761. *
  40762. * @sample {highcharts} highcharts/plotoptions/area-threshold/
  40763. * A threshold of 100
  40764. * @sample {highcharts} highcharts/plotoptions/area-threshold-infinity/
  40765. * A threshold of Infinity
  40766. *
  40767. * @type {number|null}
  40768. * @since 2.0
  40769. * @product highcharts highstock
  40770. */
  40771. threshold: 0
  40772. });
  40773. return AreaSeries;
  40774. }(LineSeries));
  40775. extend(AreaSeries.prototype, {
  40776. singleStacks: false,
  40777. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  40778. });
  40779. SeriesRegistry.registerSeriesType('area', AreaSeries);
  40780. /* *
  40781. *
  40782. * Default Export
  40783. *
  40784. * */
  40785. /* *
  40786. *
  40787. * API Options
  40788. *
  40789. * */
  40790. /**
  40791. * A `area` series. If the [type](#series.area.type) option is not
  40792. * specified, it is inherited from [chart.type](#chart.type).
  40793. *
  40794. * @extends series,plotOptions.area
  40795. * @excluding dataParser, dataURL, useOhlcData
  40796. * @product highcharts highstock
  40797. * @apioption series.area
  40798. */
  40799. /**
  40800. * @see [fillColor](#series.area.fillColor)
  40801. * @see [fillOpacity](#series.area.fillOpacity)
  40802. *
  40803. * @apioption series.area.color
  40804. */
  40805. /**
  40806. * An array of data points for the series. For the `area` series type,
  40807. * points can be given in the following ways:
  40808. *
  40809. * 1. An array of numerical values. In this case, the numerical values will be
  40810. * interpreted as `y` options. The `x` values will be automatically
  40811. * calculated, either starting at 0 and incremented by 1, or from
  40812. * `pointStart` * and `pointInterval` given in the series options. If the
  40813. * axis has categories, these will be used. Example:
  40814. * ```js
  40815. * data: [0, 5, 3, 5]
  40816. * ```
  40817. *
  40818. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40819. * `x,y`. If the first value is a string, it is applied as the name of the
  40820. * point, and the `x` value is inferred.
  40821. * ```js
  40822. * data: [
  40823. * [0, 9],
  40824. * [1, 7],
  40825. * [2, 6]
  40826. * ]
  40827. * ```
  40828. *
  40829. * 3. An array of objects with named values. The following snippet shows only a
  40830. * few settings, see the complete options set below. If the total number of
  40831. * data points exceeds the series'
  40832. * [turboThreshold](#series.area.turboThreshold), this option is not
  40833. * available.
  40834. * ```js
  40835. * data: [{
  40836. * x: 1,
  40837. * y: 9,
  40838. * name: "Point2",
  40839. * color: "#00FF00"
  40840. * }, {
  40841. * x: 1,
  40842. * y: 6,
  40843. * name: "Point1",
  40844. * color: "#FF00FF"
  40845. * }]
  40846. * ```
  40847. *
  40848. * @sample {highcharts} highcharts/chart/reflow-true/
  40849. * Numerical values
  40850. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40851. * Arrays of numeric x and y
  40852. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40853. * Arrays of datetime x and y
  40854. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40855. * Arrays of point.name and y
  40856. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40857. * Config objects
  40858. *
  40859. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40860. * @extends series.line.data
  40861. * @product highcharts highstock
  40862. * @apioption series.area.data
  40863. */
  40864. /**
  40865. * @see [color](#series.area.color)
  40866. * @see [fillOpacity](#series.area.fillOpacity)
  40867. *
  40868. * @apioption series.area.fillColor
  40869. */
  40870. /**
  40871. * @see [color](#series.area.color)
  40872. * @see [fillColor](#series.area.fillColor)
  40873. *
  40874. * @default {highcharts} 0.75
  40875. * @default {highstock} 0.75
  40876. * @apioption series.area.fillOpacity
  40877. */
  40878. ''; // adds doclets above to transpilat
  40879. return AreaSeries;
  40880. });
  40881. _registerModule(_modules, 'Series/Spline/SplineSeries.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  40882. /* *
  40883. *
  40884. * (c) 2010-2021 Torstein Honsi
  40885. *
  40886. * License: www.highcharts.com/license
  40887. *
  40888. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40889. *
  40890. * */
  40891. var __extends = (this && this.__extends) || (function () {
  40892. var extendStatics = function (d,
  40893. b) {
  40894. extendStatics = Object.setPrototypeOf ||
  40895. ({ __proto__: [] } instanceof Array && function (d,
  40896. b) { d.__proto__ = b; }) ||
  40897. function (d,
  40898. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40899. return extendStatics(d, b);
  40900. };
  40901. return function (d, b) {
  40902. extendStatics(d, b);
  40903. function __() { this.constructor = d; }
  40904. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40905. };
  40906. })();
  40907. var LineSeries = SeriesRegistry.seriesTypes.line;
  40908. var merge = U.merge,
  40909. pick = U.pick;
  40910. /**
  40911. * Spline series type.
  40912. *
  40913. * @private
  40914. */
  40915. var SplineSeries = /** @class */ (function (_super) {
  40916. __extends(SplineSeries, _super);
  40917. function SplineSeries() {
  40918. /* *
  40919. *
  40920. * Static Properties
  40921. *
  40922. * */
  40923. var _this = _super !== null && _super.apply(this,
  40924. arguments) || this;
  40925. /* *
  40926. *
  40927. * Properties
  40928. *
  40929. * */
  40930. _this.data = void 0;
  40931. _this.options = void 0;
  40932. _this.points = void 0;
  40933. return _this;
  40934. /* eslint-enable valid-jsdoc */
  40935. }
  40936. /* *
  40937. *
  40938. * Functions
  40939. *
  40940. * */
  40941. /* eslint-disable valid-jsdoc */
  40942. /**
  40943. * Get the spline segment from a given point's previous neighbour to the
  40944. * given point.
  40945. *
  40946. * @private
  40947. * @function Highcharts.seriesTypes.spline#getPointSpline
  40948. *
  40949. * @param {Array<Highcharts.Point>}
  40950. *
  40951. * @param {Highcharts.Point} point
  40952. *
  40953. * @param {number} i
  40954. *
  40955. * @return {Highcharts.SVGPathArray}
  40956. */
  40957. SplineSeries.prototype.getPointSpline = function (points, point, i) {
  40958. var
  40959. // 1 means control points midway between points, 2 means 1/3
  40960. // from the point, 3 is 1/4 etc
  40961. smoothing = 1.5,
  40962. denom = smoothing + 1,
  40963. plotX = point.plotX || 0,
  40964. plotY = point.plotY || 0,
  40965. lastPoint = points[i - 1],
  40966. nextPoint = points[i + 1],
  40967. leftContX,
  40968. leftContY,
  40969. rightContX,
  40970. rightContY,
  40971. ret;
  40972. /**
  40973. * @private
  40974. */
  40975. function doCurve(otherPoint) {
  40976. return otherPoint &&
  40977. !otherPoint.isNull &&
  40978. otherPoint.doCurve !== false &&
  40979. // #6387, area splines next to null:
  40980. !point.isCliff;
  40981. }
  40982. // Find control points
  40983. if (doCurve(lastPoint) && doCurve(nextPoint)) {
  40984. var lastX = lastPoint.plotX || 0,
  40985. lastY = lastPoint.plotY || 0,
  40986. nextX = nextPoint.plotX || 0,
  40987. nextY = nextPoint.plotY || 0,
  40988. correction = 0;
  40989. leftContX = (smoothing * plotX + lastX) / denom;
  40990. leftContY = (smoothing * plotY + lastY) / denom;
  40991. rightContX = (smoothing * plotX + nextX) / denom;
  40992. rightContY = (smoothing * plotY + nextY) / denom;
  40993. // Have the two control points make a straight line through main
  40994. // point
  40995. if (rightContX !== leftContX) { // #5016, division by zero
  40996. correction = (((rightContY - leftContY) *
  40997. (rightContX - plotX)) /
  40998. (rightContX - leftContX) + plotY - rightContY);
  40999. }
  41000. leftContY += correction;
  41001. rightContY += correction;
  41002. // to prevent false extremes, check that control points are
  41003. // between neighbouring points' y values
  41004. if (leftContY > lastY && leftContY > plotY) {
  41005. leftContY = Math.max(lastY, plotY);
  41006. // mirror of left control point
  41007. rightContY = 2 * plotY - leftContY;
  41008. }
  41009. else if (leftContY < lastY && leftContY < plotY) {
  41010. leftContY = Math.min(lastY, plotY);
  41011. rightContY = 2 * plotY - leftContY;
  41012. }
  41013. if (rightContY > nextY && rightContY > plotY) {
  41014. rightContY = Math.max(nextY, plotY);
  41015. leftContY = 2 * plotY - rightContY;
  41016. }
  41017. else if (rightContY < nextY && rightContY < plotY) {
  41018. rightContY = Math.min(nextY, plotY);
  41019. leftContY = 2 * plotY - rightContY;
  41020. }
  41021. // record for drawing in next point
  41022. point.rightContX = rightContX;
  41023. point.rightContY = rightContY;
  41024. }
  41025. // Visualize control points for debugging
  41026. /*
  41027. if (leftContX) {
  41028. this.chart.renderer.circle(
  41029. leftContX + this.chart.plotLeft,
  41030. leftContY + this.chart.plotTop,
  41031. 2
  41032. )
  41033. .attr({
  41034. stroke: 'red',
  41035. 'stroke-width': 2,
  41036. fill: 'none',
  41037. zIndex: 9
  41038. })
  41039. .add();
  41040. this.chart.renderer.path(['M', leftContX + this.chart.plotLeft,
  41041. leftContY + this.chart.plotTop,
  41042. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41043. .attr({
  41044. stroke: 'red',
  41045. 'stroke-width': 2,
  41046. zIndex: 9
  41047. })
  41048. .add();
  41049. }
  41050. if (rightContX) {
  41051. this.chart.renderer.circle(
  41052. rightContX + this.chart.plotLeft,
  41053. rightContY + this.chart.plotTop,
  41054. 2
  41055. )
  41056. .attr({
  41057. stroke: 'green',
  41058. 'stroke-width': 2,
  41059. fill: 'none',
  41060. zIndex: 9
  41061. })
  41062. .add();
  41063. this.chart.renderer.path(['M', rightContX + this.chart.plotLeft,
  41064. rightContY + this.chart.plotTop,
  41065. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41066. .attr({
  41067. stroke: 'green',
  41068. 'stroke-width': 2,
  41069. zIndex: 9
  41070. })
  41071. .add();
  41072. }
  41073. // */
  41074. ret = [
  41075. 'C',
  41076. pick(lastPoint.rightContX, lastPoint.plotX, 0),
  41077. pick(lastPoint.rightContY, lastPoint.plotY, 0),
  41078. pick(leftContX, plotX, 0),
  41079. pick(leftContY, plotY, 0),
  41080. plotX,
  41081. plotY
  41082. ];
  41083. // reset for updating series later
  41084. lastPoint.rightContX = lastPoint.rightContY = void 0;
  41085. return ret;
  41086. };
  41087. /**
  41088. * A spline series is a special type of line series, where the segments
  41089. * between the data points are smoothed.
  41090. *
  41091. * @sample {highcharts} highcharts/demo/spline-irregular-time/
  41092. * Spline chart
  41093. * @sample {highstock} stock/demo/spline/
  41094. * Spline chart
  41095. *
  41096. * @extends plotOptions.series
  41097. * @excluding step, boostThreshold, boostBlending
  41098. * @product highcharts highstock
  41099. * @optionparent plotOptions.spline
  41100. */
  41101. SplineSeries.defaultOptions = merge(LineSeries.defaultOptions);
  41102. return SplineSeries;
  41103. }(LineSeries));
  41104. SeriesRegistry.registerSeriesType('spline', SplineSeries);
  41105. /* *
  41106. *
  41107. * Default Export
  41108. *
  41109. * */
  41110. /* *
  41111. *
  41112. * API Options
  41113. *
  41114. * */
  41115. /**
  41116. * A `spline` series. If the [type](#series.spline.type) option is
  41117. * not specified, it is inherited from [chart.type](#chart.type).
  41118. *
  41119. * @extends series,plotOptions.spline
  41120. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41121. * @product highcharts highstock
  41122. * @apioption series.spline
  41123. */
  41124. /**
  41125. * An array of data points for the series. For the `spline` series type,
  41126. * points can be given in the following ways:
  41127. *
  41128. * 1. An array of numerical values. In this case, the numerical values will be
  41129. * interpreted as `y` options. The `x` values will be automatically
  41130. * calculated, either starting at 0 and incremented by 1, or from
  41131. * `pointStart` and `pointInterval` given in the series options. If the axis
  41132. * has categories, these will be used. Example:
  41133. * ```js
  41134. * data: [0, 5, 3, 5]
  41135. * ```
  41136. *
  41137. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41138. * `x,y`. If the first value is a string, it is applied as the name of the
  41139. * point, and the `x` value is inferred.
  41140. * ```js
  41141. * data: [
  41142. * [0, 9],
  41143. * [1, 2],
  41144. * [2, 8]
  41145. * ]
  41146. * ```
  41147. *
  41148. * 3. An array of objects with named values. The following snippet shows only a
  41149. * few settings, see the complete options set below. If the total number of
  41150. * data points exceeds the series'
  41151. * [turboThreshold](#series.spline.turboThreshold),
  41152. * this option is not available.
  41153. * ```js
  41154. * data: [{
  41155. * x: 1,
  41156. * y: 9,
  41157. * name: "Point2",
  41158. * color: "#00FF00"
  41159. * }, {
  41160. * x: 1,
  41161. * y: 0,
  41162. * name: "Point1",
  41163. * color: "#FF00FF"
  41164. * }]
  41165. * ```
  41166. *
  41167. * @sample {highcharts} highcharts/chart/reflow-true/
  41168. * Numerical values
  41169. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41170. * Arrays of numeric x and y
  41171. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41172. * Arrays of datetime x and y
  41173. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41174. * Arrays of point.name and y
  41175. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41176. * Config objects
  41177. *
  41178. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41179. * @extends series.line.data
  41180. * @product highcharts highstock
  41181. * @apioption series.spline.data
  41182. */
  41183. ''; // adds doclets above intro transpilat
  41184. return SplineSeries;
  41185. });
  41186. _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) {
  41187. /* *
  41188. *
  41189. * (c) 2010-2021 Torstein Honsi
  41190. *
  41191. * License: www.highcharts.com/license
  41192. *
  41193. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41194. *
  41195. * */
  41196. var __extends = (this && this.__extends) || (function () {
  41197. var extendStatics = function (d,
  41198. b) {
  41199. extendStatics = Object.setPrototypeOf ||
  41200. ({ __proto__: [] } instanceof Array && function (d,
  41201. b) { d.__proto__ = b; }) ||
  41202. function (d,
  41203. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41204. return extendStatics(d, b);
  41205. };
  41206. return function (d, b) {
  41207. extendStatics(d, b);
  41208. function __() { this.constructor = d; }
  41209. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41210. };
  41211. })();
  41212. var areaProto = AreaSeries.prototype;
  41213. var extend = U.extend,
  41214. merge = U.merge;
  41215. /* *
  41216. *
  41217. * Class
  41218. *
  41219. * */
  41220. /**
  41221. * AreaSpline series type.
  41222. *
  41223. * @private
  41224. * @class
  41225. * @name Highcharts.seriesTypes.areaspline
  41226. *
  41227. * @augments Highcharts.Series
  41228. */
  41229. var AreaSplineSeries = /** @class */ (function (_super) {
  41230. __extends(AreaSplineSeries, _super);
  41231. function AreaSplineSeries() {
  41232. /* *
  41233. *
  41234. * Static properties
  41235. *
  41236. * */
  41237. var _this = _super !== null && _super.apply(this,
  41238. arguments) || this;
  41239. /* *
  41240. *
  41241. * Properties
  41242. *
  41243. * */
  41244. _this.data = void 0;
  41245. _this.points = void 0;
  41246. _this.options = void 0;
  41247. return _this;
  41248. }
  41249. /**
  41250. * The area spline series is an area series where the graph between the
  41251. * points is smoothed into a spline.
  41252. *
  41253. * @sample {highcharts} highcharts/demo/areaspline/
  41254. * Area spline chart
  41255. * @sample {highstock} stock/demo/areaspline/
  41256. * Area spline chart
  41257. *
  41258. * @extends plotOptions.area
  41259. * @excluding step, boostThreshold, boostBlending
  41260. * @product highcharts highstock
  41261. * @apioption plotOptions.areaspline
  41262. */
  41263. /**
  41264. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41265. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41266. *
  41267. * @apioption plotOptions.areaspline.color
  41268. */
  41269. /**
  41270. * @see [color](#plotOptions.areaspline.color)
  41271. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41272. *
  41273. * @apioption plotOptions.areaspline.fillColor
  41274. */
  41275. /**
  41276. * @see [color](#plotOptions.areaspline.color)
  41277. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41278. *
  41279. * @default {highcharts} 0.75
  41280. * @default {highstock} 0.75
  41281. * @apioption plotOptions.areaspline.fillOpacity
  41282. */
  41283. AreaSplineSeries.defaultOptions = merge(SplineSeries.defaultOptions, AreaSeries.defaultOptions);
  41284. return AreaSplineSeries;
  41285. }(SplineSeries));
  41286. extend(AreaSplineSeries.prototype, {
  41287. getGraphPath: areaProto.getGraphPath,
  41288. getStackPoints: areaProto.getStackPoints,
  41289. drawGraph: areaProto.drawGraph,
  41290. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  41291. });
  41292. SeriesRegistry.registerSeriesType('areaspline', AreaSplineSeries);
  41293. /* *
  41294. *
  41295. * Default export
  41296. *
  41297. * */
  41298. /**
  41299. * A `areaspline` series. If the [type](#series.areaspline.type) option
  41300. * is not specified, it is inherited from [chart.type](#chart.type).
  41301. *
  41302. *
  41303. * @extends series,plotOptions.areaspline
  41304. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41305. * @product highcharts highstock
  41306. * @apioption series.areaspline
  41307. */
  41308. /**
  41309. * @see [fillColor](#series.areaspline.fillColor)
  41310. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41311. *
  41312. * @apioption series.areaspline.color
  41313. */
  41314. /**
  41315. * An array of data points for the series. For the `areaspline` series
  41316. * type, points can be given in the following ways:
  41317. *
  41318. * 1. An array of numerical values. In this case, the numerical values will be
  41319. * interpreted as `y` options. The `x` values will be automatically
  41320. * calculated, either starting at 0 and incremented by 1, or from
  41321. * `pointStart` and `pointInterval` given in the series options. If the axis
  41322. * has categories, these will be used. Example:
  41323. * ```js
  41324. * data: [0, 5, 3, 5]
  41325. * ```
  41326. *
  41327. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41328. * `x,y`. If the first value is a string, it is applied as the name of the
  41329. * point, and the `x` value is inferred.
  41330. * ```js
  41331. * data: [
  41332. * [0, 10],
  41333. * [1, 9],
  41334. * [2, 3]
  41335. * ]
  41336. * ```
  41337. *
  41338. * 3. An array of objects with named values. The following snippet shows only a
  41339. * few settings, see the complete options set below. If the total number of
  41340. * data points exceeds the series'
  41341. * [turboThreshold](#series.areaspline.turboThreshold), this option is not
  41342. * available.
  41343. * ```js
  41344. * data: [{
  41345. * x: 1,
  41346. * y: 4,
  41347. * name: "Point2",
  41348. * color: "#00FF00"
  41349. * }, {
  41350. * x: 1,
  41351. * y: 4,
  41352. * name: "Point1",
  41353. * color: "#FF00FF"
  41354. * }]
  41355. * ```
  41356. *
  41357. * @sample {highcharts} highcharts/chart/reflow-true/
  41358. * Numerical values
  41359. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41360. * Arrays of numeric x and y
  41361. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41362. * Arrays of datetime x and y
  41363. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41364. * Arrays of point.name and y
  41365. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41366. * Config objects
  41367. *
  41368. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41369. * @extends series.line.data
  41370. * @product highcharts highstock
  41371. * @apioption series.areaspline.data
  41372. */
  41373. /**
  41374. * @see [color](#series.areaspline.color)
  41375. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41376. *
  41377. * @apioption series.areaspline.fillColor
  41378. */
  41379. /**
  41380. * @see [color](#series.areaspline.color)
  41381. * @see [fillColor](#series.areaspline.fillColor)
  41382. *
  41383. * @default {highcharts} 0.75
  41384. * @default {highstock} 0.75
  41385. * @apioption series.areaspline.fillOpacity
  41386. */
  41387. ''; // adds doclets above into transpilat
  41388. return AreaSplineSeries;
  41389. });
  41390. _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) {
  41391. /* *
  41392. *
  41393. * (c) 2010-2021 Torstein Honsi
  41394. *
  41395. * License: www.highcharts.com/license
  41396. *
  41397. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41398. *
  41399. * */
  41400. var __extends = (this && this.__extends) || (function () {
  41401. var extendStatics = function (d,
  41402. b) {
  41403. extendStatics = Object.setPrototypeOf ||
  41404. ({ __proto__: [] } instanceof Array && function (d,
  41405. b) { d.__proto__ = b; }) ||
  41406. function (d,
  41407. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41408. return extendStatics(d, b);
  41409. };
  41410. return function (d, b) {
  41411. extendStatics(d, b);
  41412. function __() { this.constructor = d; }
  41413. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41414. };
  41415. })();
  41416. var animObject = A.animObject;
  41417. var color = Color.parse;
  41418. var hasTouch = H.hasTouch,
  41419. noop = H.noop;
  41420. var clamp = U.clamp,
  41421. css = U.css,
  41422. defined = U.defined,
  41423. extend = U.extend,
  41424. fireEvent = U.fireEvent,
  41425. isArray = U.isArray,
  41426. isNumber = U.isNumber,
  41427. merge = U.merge,
  41428. pick = U.pick,
  41429. objectEach = U.objectEach;
  41430. /**
  41431. * The column series type.
  41432. *
  41433. * @private
  41434. * @class
  41435. * @name Highcharts.seriesTypes.column
  41436. *
  41437. * @augments Highcharts.Series
  41438. */
  41439. var ColumnSeries = /** @class */ (function (_super) {
  41440. __extends(ColumnSeries, _super);
  41441. function ColumnSeries() {
  41442. /* *
  41443. *
  41444. * Static Properties
  41445. *
  41446. * */
  41447. var _this = _super !== null && _super.apply(this,
  41448. arguments) || this;
  41449. /* *
  41450. *
  41451. * Properties
  41452. *
  41453. * */
  41454. _this.borderWidth = void 0;
  41455. _this.data = void 0;
  41456. _this.group = void 0;
  41457. _this.options = void 0;
  41458. _this.points = void 0;
  41459. return _this;
  41460. /* eslint-enable valid-jsdoc */
  41461. }
  41462. /* *
  41463. *
  41464. * Functions
  41465. *
  41466. * */
  41467. /* eslint-disable valid-jsdoc */
  41468. /**
  41469. * Animate the column heights one by one from zero.
  41470. *
  41471. * @private
  41472. * @function Highcharts.seriesTypes.column#animate
  41473. *
  41474. * @param {boolean} init
  41475. * Whether to initialize the animation or run it
  41476. */
  41477. ColumnSeries.prototype.animate = function (init) {
  41478. var series = this,
  41479. yAxis = this.yAxis,
  41480. options = series.options,
  41481. inverted = this.chart.inverted,
  41482. attr = {},
  41483. translateProp = inverted ? 'translateX' : 'translateY',
  41484. translateStart,
  41485. translatedThreshold;
  41486. if (init) {
  41487. attr.scaleY = 0.001;
  41488. translatedThreshold = clamp(yAxis.toPixels(options.threshold), yAxis.pos, yAxis.pos + yAxis.len);
  41489. if (inverted) {
  41490. attr.translateX = translatedThreshold - yAxis.len;
  41491. }
  41492. else {
  41493. attr.translateY = translatedThreshold;
  41494. }
  41495. // apply finnal clipping (used in Highcharts Stock) (#7083)
  41496. // animation is done by scaleY, so cliping is for panes
  41497. if (series.clipBox) {
  41498. series.setClip();
  41499. }
  41500. series.group.attr(attr);
  41501. }
  41502. else { // run the animation
  41503. translateStart = Number(series.group.attr(translateProp));
  41504. series.group.animate({ scaleY: 1 }, extend(animObject(series.options.animation), {
  41505. // Do the scale synchronously to ensure smooth
  41506. // updating (#5030, #7228)
  41507. step: function (val, fx) {
  41508. if (series.group) {
  41509. attr[translateProp] = translateStart +
  41510. fx.pos * (yAxis.pos - translateStart);
  41511. series.group.attr(attr);
  41512. }
  41513. }
  41514. }));
  41515. }
  41516. };
  41517. /**
  41518. * Initialize the series. Extends the basic Series.init method by
  41519. * marking other series of the same type as dirty.
  41520. *
  41521. * @private
  41522. * @function Highcharts.seriesTypes.column#init
  41523. */
  41524. ColumnSeries.prototype.init = function (chart, options) {
  41525. _super.prototype.init.apply(this, arguments);
  41526. var series = this;
  41527. chart = series.chart;
  41528. // if the series is added dynamically, force redraw of other
  41529. // series affected by a new column
  41530. if (chart.hasRendered) {
  41531. chart.series.forEach(function (otherSeries) {
  41532. if (otherSeries.type === series.type) {
  41533. otherSeries.isDirty = true;
  41534. }
  41535. });
  41536. }
  41537. };
  41538. /**
  41539. * Return the width and x offset of the columns adjusted for grouping,
  41540. * groupPadding, pointPadding, pointWidth etc.
  41541. *
  41542. * @private
  41543. * @function Highcharts.seriesTypes.column#getColumnMetrics
  41544. * @return {Highcharts.ColumnMetricsObject}
  41545. */
  41546. ColumnSeries.prototype.getColumnMetrics = function () {
  41547. var series = this,
  41548. options = series.options,
  41549. xAxis = series.xAxis,
  41550. yAxis = series.yAxis,
  41551. reversedStacks = xAxis.options.reversedStacks,
  41552. // Keep backward compatibility: reversed xAxis had reversed
  41553. // stacks
  41554. reverseStacks = (xAxis.reversed && !reversedStacks) ||
  41555. (!xAxis.reversed && reversedStacks),
  41556. stackKey,
  41557. stackGroups = {},
  41558. columnCount = 0;
  41559. // Get the total number of column type series. This is called on
  41560. // every series. Consider moving this logic to a chart.orderStacks()
  41561. // function and call it on init, addSeries and removeSeries
  41562. if (options.grouping === false) {
  41563. columnCount = 1;
  41564. }
  41565. else {
  41566. series.chart.series.forEach(function (otherSeries) {
  41567. var otherYAxis = otherSeries.yAxis,
  41568. otherOptions = otherSeries.options,
  41569. columnIndex;
  41570. if (otherSeries.type === series.type &&
  41571. (otherSeries.visible ||
  41572. !series.chart.options.chart.ignoreHiddenSeries) &&
  41573. yAxis.len === otherYAxis.len &&
  41574. yAxis.pos === otherYAxis.pos) { // #642, #2086
  41575. if (otherOptions.stacking && otherOptions.stacking !== 'group') {
  41576. stackKey = otherSeries.stackKey;
  41577. if (typeof stackGroups[stackKey] ===
  41578. 'undefined') {
  41579. stackGroups[stackKey] = columnCount++;
  41580. }
  41581. columnIndex = stackGroups[stackKey];
  41582. }
  41583. else if (otherOptions.grouping !== false) { // #1162
  41584. columnIndex = columnCount++;
  41585. }
  41586. otherSeries.columnIndex = columnIndex;
  41587. }
  41588. });
  41589. }
  41590. var categoryWidth = Math.min(Math.abs(xAxis.transA) * ((xAxis.ordinal && xAxis.ordinal.slope) ||
  41591. options.pointRange ||
  41592. xAxis.closestPointRange ||
  41593. xAxis.tickInterval ||
  41594. 1), // #2610
  41595. xAxis.len // #1535
  41596. ),
  41597. groupPadding = categoryWidth * options.groupPadding,
  41598. groupWidth = categoryWidth - 2 * groupPadding,
  41599. pointOffsetWidth = groupWidth / (columnCount || 1),
  41600. pointWidth = Math.min(options.maxPointWidth || xAxis.len,
  41601. pick(options.pointWidth,
  41602. pointOffsetWidth * (1 - 2 * options.pointPadding))),
  41603. pointPadding = (pointOffsetWidth - pointWidth) / 2,
  41604. // #1251, #3737
  41605. colIndex = (series.columnIndex || 0) + (reverseStacks ? 1 : 0),
  41606. pointXOffset = pointPadding +
  41607. (groupPadding +
  41608. colIndex * pointOffsetWidth -
  41609. (categoryWidth / 2)) * (reverseStacks ? -1 : 1);
  41610. // Save it for reading in linked series (Error bars particularly)
  41611. series.columnMetrics = {
  41612. width: pointWidth,
  41613. offset: pointXOffset,
  41614. paddedWidth: pointOffsetWidth,
  41615. columnCount: columnCount
  41616. };
  41617. return series.columnMetrics;
  41618. };
  41619. /**
  41620. * Make the columns crisp. The edges are rounded to the nearest full
  41621. * pixel.
  41622. *
  41623. * @private
  41624. * @function Highcharts.seriesTypes.column#crispCol
  41625. */
  41626. ColumnSeries.prototype.crispCol = function (x, y, w, h) {
  41627. var chart = this.chart,
  41628. borderWidth = this.borderWidth,
  41629. xCrisp = -(borderWidth % 2 ? 0.5 : 0),
  41630. yCrisp = borderWidth % 2 ? 0.5 : 1,
  41631. right,
  41632. bottom,
  41633. fromTop;
  41634. if (chart.inverted && chart.renderer.isVML) {
  41635. yCrisp += 1;
  41636. }
  41637. // Horizontal. We need to first compute the exact right edge, then
  41638. // round it and compute the width from there.
  41639. if (this.options.crisp) {
  41640. right = Math.round(x + w) + xCrisp;
  41641. x = Math.round(x) + xCrisp;
  41642. w = right - x;
  41643. }
  41644. // Vertical
  41645. bottom = Math.round(y + h) + yCrisp;
  41646. fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
  41647. y = Math.round(y) + yCrisp;
  41648. h = bottom - y;
  41649. // Top edges are exceptions
  41650. if (fromTop && h) { // #5146
  41651. y -= 1;
  41652. h += 1;
  41653. }
  41654. return {
  41655. x: x,
  41656. y: y,
  41657. width: w,
  41658. height: h
  41659. };
  41660. };
  41661. /**
  41662. * Adjust for missing columns, according to the `centerInCategory`
  41663. * option. Missing columns are either single points or stacks where the
  41664. * point or points are either missing or null.
  41665. *
  41666. * @private
  41667. * @function Highcharts.seriesTypes.column#adjustForMissingColumns
  41668. * @param {number} x
  41669. * The x coordinate of the column, left side
  41670. *
  41671. * @param {number} pointWidth
  41672. * The pointWidth, already computed upstream
  41673. *
  41674. * @param {Highcharts.ColumnPoint} point
  41675. * The point instance
  41676. *
  41677. * @param {Highcharts.ColumnMetricsObject} metrics
  41678. * The series-wide column metrics
  41679. *
  41680. * @return {number}
  41681. * The adjusted x position, or the original if not adjusted
  41682. */
  41683. ColumnSeries.prototype.adjustForMissingColumns = function (x, pointWidth, point, metrics) {
  41684. var _this = this;
  41685. var stacking = this.options.stacking;
  41686. if (!point.isNull && metrics.columnCount > 1) {
  41687. var indexInCategory_1 = 0;
  41688. var totalInCategory_1 = 0;
  41689. // Loop over all the stacks on the Y axis. When stacking is
  41690. // enabled, these are real point stacks. When stacking is not
  41691. // enabled, but `centerInCategory` is true, there is one stack
  41692. // handling the grouping of points in each category. This is
  41693. // done in the `setGroupedPoints` function.
  41694. objectEach(this.yAxis.stacking && this.yAxis.stacking.stacks, function (stack) {
  41695. if (typeof point.x === 'number') {
  41696. var stackItem = stack[point.x.toString()];
  41697. if (stackItem) {
  41698. var pointValues = stackItem.points[_this.index],
  41699. total = stackItem.total;
  41700. // If true `stacking` is enabled, count the
  41701. // total number of non-null stacks in the
  41702. // category, and note which index this point is
  41703. // within those stacks.
  41704. if (stacking) {
  41705. if (pointValues) {
  41706. indexInCategory_1 = totalInCategory_1;
  41707. }
  41708. if (stackItem.hasValidPoints) {
  41709. totalInCategory_1++;
  41710. }
  41711. // If `stacking` is not enabled, look for the
  41712. // index and total of the `group` stack.
  41713. }
  41714. else if (isArray(pointValues)) {
  41715. indexInCategory_1 = pointValues[1];
  41716. totalInCategory_1 = total || 0;
  41717. }
  41718. }
  41719. }
  41720. });
  41721. // Compute the adjusted x position
  41722. var boxWidth = (totalInCategory_1 - 1) * metrics.paddedWidth +
  41723. pointWidth;
  41724. x = (point.plotX || 0) + boxWidth / 2 - pointWidth -
  41725. indexInCategory_1 * metrics.paddedWidth;
  41726. }
  41727. return x;
  41728. };
  41729. /**
  41730. * Translate each point to the plot area coordinate system and find
  41731. * shape positions
  41732. *
  41733. * @private
  41734. * @function Highcharts.seriesTypes.column#translate
  41735. */
  41736. ColumnSeries.prototype.translate = function () {
  41737. var series = this,
  41738. chart = series.chart,
  41739. options = series.options,
  41740. dense = series.dense =
  41741. series.closestPointRange * series.xAxis.transA < 2,
  41742. borderWidth = series.borderWidth = pick(options.borderWidth,
  41743. dense ? 0 : 1 // #3635
  41744. ),
  41745. xAxis = series.xAxis,
  41746. yAxis = series.yAxis,
  41747. threshold = options.threshold,
  41748. translatedThreshold = series.translatedThreshold =
  41749. yAxis.getThreshold(threshold),
  41750. minPointLength = pick(options.minPointLength, 5),
  41751. metrics = series.getColumnMetrics(),
  41752. seriesPointWidth = metrics.width,
  41753. // postprocessed for border width
  41754. seriesBarW = series.barW =
  41755. Math.max(seriesPointWidth, 1 + 2 * borderWidth),
  41756. seriesXOffset = series.pointXOffset = metrics.offset,
  41757. dataMin = series.dataMin,
  41758. dataMax = series.dataMax;
  41759. if (chart.inverted) {
  41760. translatedThreshold -= 0.5; // #3355
  41761. }
  41762. // When the pointPadding is 0, we want the columns to be packed
  41763. // tightly, so we allow individual columns to have individual sizes.
  41764. // When pointPadding is greater, we strive for equal-width columns
  41765. // (#2694).
  41766. if (options.pointPadding) {
  41767. seriesBarW = Math.ceil(seriesBarW);
  41768. }
  41769. Series.prototype.translate.apply(series);
  41770. // Record the new values
  41771. series.points.forEach(function (point) {
  41772. var yBottom = pick(point.yBottom,
  41773. translatedThreshold),
  41774. safeDistance = 999 + Math.abs(yBottom),
  41775. pointWidth = seriesPointWidth,
  41776. plotX = point.plotX || 0,
  41777. // Don't draw too far outside plot area (#1303, #2241,
  41778. // #4264)
  41779. plotY = clamp(point.plotY, -safeDistance,
  41780. yAxis.len + safeDistance),
  41781. barX = plotX + seriesXOffset,
  41782. barW = seriesBarW,
  41783. barY = Math.min(plotY,
  41784. yBottom),
  41785. up,
  41786. barH = Math.max(plotY,
  41787. yBottom) - barY;
  41788. // Handle options.minPointLength
  41789. if (minPointLength && Math.abs(barH) < minPointLength) {
  41790. barH = minPointLength;
  41791. up = (!yAxis.reversed && !point.negative) ||
  41792. (yAxis.reversed && point.negative);
  41793. // Reverse zeros if there's no positive value in the series
  41794. // in visible range (#7046)
  41795. if (isNumber(threshold) &&
  41796. isNumber(dataMax) &&
  41797. point.y === threshold &&
  41798. dataMax <= threshold &&
  41799. // and if there's room for it (#7311)
  41800. (yAxis.min || 0) < threshold &&
  41801. // if all points are the same value (i.e zero) not draw
  41802. // as negative points (#10646), but only if there's room
  41803. // for it (#14876)
  41804. (dataMin !== dataMax || (yAxis.max || 0) <= threshold)) {
  41805. up = !up;
  41806. }
  41807. // If stacked...
  41808. barY = (Math.abs(barY - translatedThreshold) > minPointLength ?
  41809. // ...keep position
  41810. yBottom - minPointLength :
  41811. // #1485, #4051
  41812. translatedThreshold -
  41813. (up ? minPointLength : 0));
  41814. }
  41815. // Handle point.options.pointWidth
  41816. // @todo Handle grouping/stacking too. Calculate offset properly
  41817. if (defined(point.options.pointWidth)) {
  41818. pointWidth = barW =
  41819. Math.ceil(point.options.pointWidth);
  41820. barX -= Math.round((pointWidth - seriesPointWidth) / 2);
  41821. }
  41822. // Adjust for null or missing points
  41823. if (options.centerInCategory) {
  41824. barX = series.adjustForMissingColumns(barX, pointWidth, point, metrics);
  41825. }
  41826. // Cache for access in polar
  41827. point.barX = barX;
  41828. point.pointWidth = pointWidth;
  41829. // Fix the tooltip on center of grouped columns (#1216, #424,
  41830. // #3648)
  41831. point.tooltipPos = chart.inverted ?
  41832. [
  41833. clamp(yAxis.len + yAxis.pos - chart.plotLeft - plotY, yAxis.pos - chart.plotLeft, yAxis.len + yAxis.pos - chart.plotLeft),
  41834. xAxis.len + xAxis.pos - chart.plotTop - barX - barW / 2,
  41835. barH
  41836. ] :
  41837. [
  41838. xAxis.left - chart.plotLeft + barX + barW / 2,
  41839. clamp(plotY + yAxis.pos -
  41840. chart.plotTop, yAxis.pos - chart.plotTop, yAxis.len + yAxis.pos - chart.plotTop),
  41841. barH
  41842. ];
  41843. // Register shape type and arguments to be used in drawPoints
  41844. // Allow shapeType defined on pointClass level
  41845. point.shapeType = series.pointClass.prototype.shapeType || 'rect';
  41846. point.shapeArgs = series.crispCol.apply(series, point.isNull ?
  41847. // #3169, drilldown from null must have a position to work
  41848. // from #6585, dataLabel should be placed on xAxis, not
  41849. // floating in the middle of the chart
  41850. [barX, translatedThreshold, barW, 0] :
  41851. [barX, barY, barW, barH]);
  41852. });
  41853. };
  41854. /**
  41855. * Columns have no graph
  41856. *
  41857. * @private
  41858. * @function Highcharts.seriesTypes.column#drawGraph
  41859. */
  41860. ColumnSeries.prototype.drawGraph = function () {
  41861. this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
  41862. };
  41863. /**
  41864. * Get presentational attributes
  41865. *
  41866. * @private
  41867. * @function Highcharts.seriesTypes.column#pointAttribs
  41868. */
  41869. ColumnSeries.prototype.pointAttribs = function (point, state) {
  41870. var options = this.options, stateOptions, ret, p2o = this.pointAttrToOptions || {}, strokeOption = p2o.stroke || 'borderColor', strokeWidthOption = p2o['stroke-width'] || 'borderWidth', fill = (point && point.color) || this.color,
  41871. // set to fill when borderColor null:
  41872. stroke = ((point && point[strokeOption]) ||
  41873. options[strokeOption] ||
  41874. fill), strokeWidth = (point && point[strokeWidthOption]) ||
  41875. options[strokeWidthOption] ||
  41876. this[strokeWidthOption] || 0, dashstyle = (point && point.options.dashStyle) || options.dashStyle, opacity = pick(point && point.opacity, options.opacity, 1), zone, brightness;
  41877. // Handle zone colors
  41878. if (point && this.zones.length) {
  41879. zone = point.getZone();
  41880. // When zones are present, don't use point.color (#4267).
  41881. // Changed order (#6527), added support for colorAxis (#10670)
  41882. fill = (point.options.color ||
  41883. (zone && (zone.color || point.nonZonedColor)) ||
  41884. this.color);
  41885. if (zone) {
  41886. stroke = zone.borderColor || stroke;
  41887. dashstyle = zone.dashStyle || dashstyle;
  41888. strokeWidth = zone.borderWidth || strokeWidth;
  41889. }
  41890. }
  41891. // Select or hover states
  41892. if (state && point) {
  41893. stateOptions = merge(options.states[state],
  41894. // #6401
  41895. point.options.states &&
  41896. point.options.states[state] ||
  41897. {});
  41898. brightness = stateOptions.brightness;
  41899. fill =
  41900. stateOptions.color || (typeof brightness !== 'undefined' &&
  41901. color(fill)
  41902. .brighten(stateOptions.brightness)
  41903. .get()) || fill;
  41904. stroke = stateOptions[strokeOption] || stroke;
  41905. strokeWidth =
  41906. stateOptions[strokeWidthOption] || strokeWidth;
  41907. dashstyle = stateOptions.dashStyle || dashstyle;
  41908. opacity = pick(stateOptions.opacity, opacity);
  41909. }
  41910. ret = {
  41911. fill: fill,
  41912. stroke: stroke,
  41913. 'stroke-width': strokeWidth,
  41914. opacity: opacity
  41915. };
  41916. if (dashstyle) {
  41917. ret.dashstyle = dashstyle;
  41918. }
  41919. return ret;
  41920. };
  41921. /**
  41922. * Draw the columns. For bars, the series.group is rotated, so the same
  41923. * coordinates apply for columns and bars. This method is inherited by
  41924. * scatter series.
  41925. *
  41926. * @private
  41927. * @function Highcharts.seriesTypes.column#drawPoints
  41928. */
  41929. ColumnSeries.prototype.drawPoints = function () {
  41930. var series = this,
  41931. chart = this.chart,
  41932. options = series.options,
  41933. renderer = chart.renderer,
  41934. animationLimit = options.animationLimit || 250,
  41935. shapeArgs;
  41936. // draw the columns
  41937. series.points.forEach(function (point) {
  41938. var plotY = point.plotY,
  41939. graphic = point.graphic,
  41940. hasGraphic = !!graphic,
  41941. verb = graphic && chart.pointCount < animationLimit ?
  41942. 'animate' : 'attr';
  41943. if (isNumber(plotY) && point.y !== null) {
  41944. shapeArgs = point.shapeArgs;
  41945. // When updating a series between 2d and 3d or cartesian and
  41946. // polar, the shape type changes.
  41947. if (graphic && point.hasNewShapeType()) {
  41948. graphic = graphic.destroy();
  41949. }
  41950. // Set starting position for point sliding animation.
  41951. if (series.enabledDataSorting) {
  41952. point.startXPos = series.xAxis.reversed ?
  41953. -(shapeArgs ? (shapeArgs.width || 0) : 0) :
  41954. series.xAxis.width;
  41955. }
  41956. if (!graphic) {
  41957. point.graphic = graphic =
  41958. renderer[point.shapeType](shapeArgs)
  41959. .add(point.group || series.group);
  41960. if (graphic &&
  41961. series.enabledDataSorting &&
  41962. chart.hasRendered &&
  41963. chart.pointCount < animationLimit) {
  41964. graphic.attr({
  41965. x: point.startXPos
  41966. });
  41967. hasGraphic = true;
  41968. verb = 'animate';
  41969. }
  41970. }
  41971. if (graphic && hasGraphic) { // update
  41972. graphic[verb](merge(shapeArgs));
  41973. }
  41974. // Border radius is not stylable (#6900)
  41975. if (options.borderRadius) {
  41976. graphic[verb]({
  41977. r: options.borderRadius
  41978. });
  41979. }
  41980. // Presentational
  41981. if (!chart.styledMode) {
  41982. graphic[verb](series.pointAttribs(point, (point.selected && 'select')))
  41983. .shadow(point.allowShadow !== false && options.shadow, null, options.stacking && !options.borderRadius);
  41984. }
  41985. if (graphic) {
  41986. graphic.addClass(point.getClassName(), true);
  41987. graphic.attr({
  41988. visibility: point.visible ? 'inherit' : 'hidden'
  41989. });
  41990. }
  41991. }
  41992. else if (graphic) {
  41993. point.graphic = graphic.destroy(); // #1269
  41994. }
  41995. });
  41996. };
  41997. /**
  41998. * Draw the tracker for a point.
  41999. * @private
  42000. */
  42001. ColumnSeries.prototype.drawTracker = function () {
  42002. var series = this,
  42003. chart = series.chart,
  42004. pointer = chart.pointer,
  42005. onMouseOver = function (e) {
  42006. var point = pointer.getPointFromEvent(e);
  42007. // undefined on graph in scatterchart
  42008. if (typeof point !== 'undefined') {
  42009. pointer.isDirectTouch = true;
  42010. point.onMouseOver(e);
  42011. }
  42012. }, dataLabels;
  42013. // Add reference to the point
  42014. series.points.forEach(function (point) {
  42015. dataLabels = (isArray(point.dataLabels) ?
  42016. point.dataLabels :
  42017. (point.dataLabel ? [point.dataLabel] : []));
  42018. if (point.graphic) {
  42019. point.graphic.element.point = point;
  42020. }
  42021. dataLabels.forEach(function (dataLabel) {
  42022. if (dataLabel.div) {
  42023. dataLabel.div.point = point;
  42024. }
  42025. else {
  42026. dataLabel.element.point = point;
  42027. }
  42028. });
  42029. });
  42030. // Add the event listeners, we need to do this only once
  42031. if (!series._hasTracking) {
  42032. series.trackerGroups.forEach(function (key) {
  42033. if (series[key]) {
  42034. // we don't always have dataLabelsGroup
  42035. series[key]
  42036. .addClass('highcharts-tracker')
  42037. .on('mouseover', onMouseOver)
  42038. .on('mouseout', function (e) {
  42039. pointer.onTrackerMouseOut(e);
  42040. });
  42041. if (hasTouch) {
  42042. series[key].on('touchstart', onMouseOver);
  42043. }
  42044. if (!chart.styledMode && series.options.cursor) {
  42045. series[key]
  42046. .css(css)
  42047. .css({ cursor: series.options.cursor });
  42048. }
  42049. }
  42050. });
  42051. series._hasTracking = true;
  42052. }
  42053. fireEvent(this, 'afterDrawTracker');
  42054. };
  42055. /**
  42056. * Remove this series from the chart
  42057. *
  42058. * @private
  42059. * @function Highcharts.seriesTypes.column#remove
  42060. */
  42061. ColumnSeries.prototype.remove = function () {
  42062. var series = this,
  42063. chart = series.chart;
  42064. // column and bar series affects other series of the same type
  42065. // as they are either stacked or grouped
  42066. if (chart.hasRendered) {
  42067. chart.series.forEach(function (otherSeries) {
  42068. if (otherSeries.type === series.type) {
  42069. otherSeries.isDirty = true;
  42070. }
  42071. });
  42072. }
  42073. Series.prototype.remove.apply(series, arguments);
  42074. };
  42075. /**
  42076. * Column series display one column per value along an X axis.
  42077. *
  42078. * @sample {highcharts} highcharts/demo/column-basic/
  42079. * Column chart
  42080. * @sample {highstock} stock/demo/column/
  42081. * Column chart
  42082. *
  42083. * @extends plotOptions.line
  42084. * @excluding connectEnds, connectNulls, gapSize, gapUnit, linecap,
  42085. * lineWidth, marker, step, useOhlcData
  42086. * @product highcharts highstock
  42087. * @optionparent plotOptions.column
  42088. */
  42089. ColumnSeries.defaultOptions = merge(Series.defaultOptions, {
  42090. /**
  42091. * The corner radius of the border surrounding each column or bar.
  42092. *
  42093. * @sample {highcharts} highcharts/plotoptions/column-borderradius/
  42094. * Rounded columns
  42095. *
  42096. * @product highcharts highstock gantt
  42097. *
  42098. * @private
  42099. */
  42100. borderRadius: 0,
  42101. /**
  42102. * When using automatic point colors pulled from the global
  42103. * [colors](colors) or series-specific
  42104. * [plotOptions.column.colors](series.colors) collections, this option
  42105. * determines whether the chart should receive one color per series or
  42106. * one color per point.
  42107. *
  42108. * In styled mode, the `colors` or `series.colors` arrays are not
  42109. * supported, and instead this option gives the points individual color
  42110. * class names on the form `highcharts-color-{n}`.
  42111. *
  42112. * @see [series colors](#plotOptions.column.colors)
  42113. *
  42114. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-false/
  42115. * False by default
  42116. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-true/
  42117. * True
  42118. *
  42119. * @type {boolean}
  42120. * @default false
  42121. * @since 2.0
  42122. * @product highcharts highstock gantt
  42123. * @apioption plotOptions.column.colorByPoint
  42124. */
  42125. /**
  42126. * A series specific or series type specific color set to apply instead
  42127. * of the global [colors](#colors) when [colorByPoint](
  42128. * #plotOptions.column.colorByPoint) is true.
  42129. *
  42130. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  42131. * @since 3.0
  42132. * @product highcharts highstock gantt
  42133. * @apioption plotOptions.column.colors
  42134. */
  42135. /**
  42136. * When `true`, the columns will center in the category, ignoring null
  42137. * or missing points. When `false`, space will be reserved for null or
  42138. * missing points.
  42139. *
  42140. * @sample {highcharts} highcharts/series-column/centerincategory/
  42141. * Center in category
  42142. *
  42143. * @since 8.0.1
  42144. * @product highcharts highstock gantt
  42145. *
  42146. * @private
  42147. */
  42148. centerInCategory: false,
  42149. /**
  42150. * Padding between each value groups, in x axis units.
  42151. *
  42152. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-default/
  42153. * 0.2 by default
  42154. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-none/
  42155. * No group padding - all columns are evenly spaced
  42156. *
  42157. * @product highcharts highstock gantt
  42158. *
  42159. * @private
  42160. */
  42161. groupPadding: 0.2,
  42162. /**
  42163. * Whether to group non-stacked columns or to let them render
  42164. * independent of each other. Non-grouped columns will be laid out
  42165. * individually and overlap each other.
  42166. *
  42167. * @sample {highcharts} highcharts/plotoptions/column-grouping-false/
  42168. * Grouping disabled
  42169. * @sample {highstock} highcharts/plotoptions/column-grouping-false/
  42170. * Grouping disabled
  42171. *
  42172. * @type {boolean}
  42173. * @default true
  42174. * @since 2.3.0
  42175. * @product highcharts highstock gantt
  42176. * @apioption plotOptions.column.grouping
  42177. */
  42178. /**
  42179. * @ignore-option
  42180. * @private
  42181. */
  42182. marker: null,
  42183. /**
  42184. * The maximum allowed pixel width for a column, translated to the
  42185. * height of a bar in a bar chart. This prevents the columns from
  42186. * becoming too wide when there is a small number of points in the
  42187. * chart.
  42188. *
  42189. * @see [pointWidth](#plotOptions.column.pointWidth)
  42190. *
  42191. * @sample {highcharts} highcharts/plotoptions/column-maxpointwidth-20/
  42192. * Limited to 50
  42193. * @sample {highstock} highcharts/plotoptions/column-maxpointwidth-20/
  42194. * Limited to 50
  42195. *
  42196. * @type {number}
  42197. * @since 4.1.8
  42198. * @product highcharts highstock gantt
  42199. * @apioption plotOptions.column.maxPointWidth
  42200. */
  42201. /**
  42202. * Padding between each column or bar, in x axis units.
  42203. *
  42204. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-default/
  42205. * 0.1 by default
  42206. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-025/
  42207. * 0.25
  42208. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-none/
  42209. * 0 for tightly packed columns
  42210. *
  42211. * @product highcharts highstock gantt
  42212. *
  42213. * @private
  42214. */
  42215. pointPadding: 0.1,
  42216. /**
  42217. * A pixel value specifying a fixed width for each column or bar point.
  42218. * When set to `undefined`, the width is calculated from the
  42219. * `pointPadding` and `groupPadding`. The width effects the dimension
  42220. * that is not based on the point value. For column series it is the
  42221. * hoizontal length and for bar series it is the vertical length.
  42222. *
  42223. * @see [maxPointWidth](#plotOptions.column.maxPointWidth)
  42224. *
  42225. * @sample {highcharts} highcharts/plotoptions/column-pointwidth-20/
  42226. * 20px wide columns regardless of chart width or the amount of
  42227. * data points
  42228. *
  42229. * @type {number}
  42230. * @since 1.2.5
  42231. * @product highcharts highstock gantt
  42232. * @apioption plotOptions.column.pointWidth
  42233. */
  42234. /**
  42235. * A pixel value specifying a fixed width for the column or bar.
  42236. * Overrides pointWidth on the series.
  42237. *
  42238. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42239. *
  42240. * @type {number}
  42241. * @default undefined
  42242. * @since 7.0.0
  42243. * @product highcharts highstock gantt
  42244. * @apioption series.column.data.pointWidth
  42245. */
  42246. /**
  42247. * The minimal height for a column or width for a bar. By default,
  42248. * 0 values are not shown. To visualize a 0 (or close to zero) point,
  42249. * set the minimal point length to a pixel value like 3\. In stacked
  42250. * column charts, minPointLength might not be respected for tightly
  42251. * packed values.
  42252. *
  42253. * @sample {highcharts} highcharts/plotoptions/column-minpointlength/
  42254. * Zero base value
  42255. * @sample {highcharts} highcharts/plotoptions/column-minpointlength-pos-and-neg/
  42256. * Positive and negative close to zero values
  42257. *
  42258. * @product highcharts highstock gantt
  42259. *
  42260. * @private
  42261. */
  42262. minPointLength: 0,
  42263. /**
  42264. * When the series contains less points than the crop threshold, all
  42265. * points are drawn, event if the points fall outside the visible plot
  42266. * area at the current zoom. The advantage of drawing all points
  42267. * (including markers and columns), is that animation is performed on
  42268. * updates. On the other hand, when the series contains more points than
  42269. * the crop threshold, the series data is cropped to only contain points
  42270. * that fall within the plot area. The advantage of cropping away
  42271. * invisible points is to increase performance on large series.
  42272. *
  42273. * @product highcharts highstock gantt
  42274. *
  42275. * @private
  42276. */
  42277. cropThreshold: 50,
  42278. /**
  42279. * The X axis range that each point is valid for. This determines the
  42280. * width of the column. On a categorized axis, the range will be 1
  42281. * by default (one category unit). On linear and datetime axes, the
  42282. * range will be computed as the distance between the two closest data
  42283. * points.
  42284. *
  42285. * The default `null` means it is computed automatically, but this
  42286. * option can be used to override the automatic value.
  42287. *
  42288. * This option is set by default to 1 if data sorting is enabled.
  42289. *
  42290. * @sample {highcharts} highcharts/plotoptions/column-pointrange/
  42291. * Set the point range to one day on a data set with one week
  42292. * between the points
  42293. *
  42294. * @type {number|null}
  42295. * @since 2.3
  42296. * @product highcharts highstock gantt
  42297. *
  42298. * @private
  42299. */
  42300. pointRange: null,
  42301. states: {
  42302. /**
  42303. * Options for the hovered point. These settings override the normal
  42304. * state options when a point is moused over or touched.
  42305. *
  42306. * @extends plotOptions.series.states.hover
  42307. * @excluding halo, lineWidth, lineWidthPlus, marker
  42308. * @product highcharts highstock gantt
  42309. */
  42310. hover: {
  42311. /** @ignore-option */
  42312. halo: false,
  42313. /**
  42314. * A specific border color for the hovered point. Defaults to
  42315. * inherit the normal state border color.
  42316. *
  42317. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42318. * @product highcharts gantt
  42319. * @apioption plotOptions.column.states.hover.borderColor
  42320. */
  42321. /**
  42322. * A specific color for the hovered point.
  42323. *
  42324. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42325. * @product highcharts gantt
  42326. * @apioption plotOptions.column.states.hover.color
  42327. */
  42328. /**
  42329. * How much to brighten the point on interaction. Requires the
  42330. * main color to be defined in hex or rgb(a) format.
  42331. *
  42332. * In styled mode, the hover brightening is by default replaced
  42333. * with a fill-opacity set in the `.highcharts-point:hover`
  42334. * rule.
  42335. *
  42336. * @sample {highcharts} highcharts/plotoptions/column-states-hover-brightness/
  42337. * Brighten by 0.5
  42338. *
  42339. * @product highcharts highstock gantt
  42340. */
  42341. brightness: 0.1
  42342. },
  42343. /**
  42344. * Options for the selected point. These settings override the
  42345. * normal state options when a point is selected.
  42346. *
  42347. * @extends plotOptions.series.states.select
  42348. * @excluding halo, lineWidth, lineWidthPlus, marker
  42349. * @product highcharts highstock gantt
  42350. */
  42351. select: {
  42352. /**
  42353. * A specific color for the selected point.
  42354. *
  42355. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42356. * @default #cccccc
  42357. * @product highcharts highstock gantt
  42358. */
  42359. color: palette.neutralColor20,
  42360. /**
  42361. * A specific border color for the selected point.
  42362. *
  42363. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42364. * @default #000000
  42365. * @product highcharts highstock gantt
  42366. */
  42367. borderColor: palette.neutralColor100
  42368. }
  42369. },
  42370. dataLabels: {
  42371. align: void 0,
  42372. verticalAlign: void 0,
  42373. /**
  42374. * The y position offset of the label relative to the point in
  42375. * pixels.
  42376. *
  42377. * @type {number}
  42378. */
  42379. y: void 0
  42380. },
  42381. // false doesn't work well: https://jsfiddle.net/highcharts/hz8fopan/14/
  42382. /**
  42383. * @ignore-option
  42384. * @private
  42385. */
  42386. startFromThreshold: true,
  42387. stickyTracking: false,
  42388. tooltip: {
  42389. distance: 6
  42390. },
  42391. /**
  42392. * The Y axis value to serve as the base for the columns, for
  42393. * distinguishing between values above and below a threshold. If `null`,
  42394. * the columns extend from the padding Y axis minimum.
  42395. *
  42396. * @type {number|null}
  42397. * @since 2.0
  42398. * @product highcharts
  42399. *
  42400. * @private
  42401. */
  42402. threshold: 0,
  42403. /**
  42404. * The width of the border surrounding each column or bar. Defaults to
  42405. * `1` when there is room for a border, but to `0` when the columns are
  42406. * so dense that a border would cover the next column.
  42407. *
  42408. * In styled mode, the stroke width can be set with the
  42409. * `.highcharts-point` rule.
  42410. *
  42411. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42412. * 2px black border
  42413. *
  42414. * @type {number}
  42415. * @default undefined
  42416. * @product highcharts highstock gantt
  42417. * @apioption plotOptions.column.borderWidth
  42418. */
  42419. /**
  42420. * The color of the border surrounding each column or bar.
  42421. *
  42422. * In styled mode, the border stroke can be set with the
  42423. * `.highcharts-point` rule.
  42424. *
  42425. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42426. * Dark gray border
  42427. *
  42428. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42429. * @default #ffffff
  42430. * @product highcharts highstock gantt
  42431. *
  42432. * @private
  42433. */
  42434. borderColor: palette.backgroundColor
  42435. });
  42436. return ColumnSeries;
  42437. }(Series));
  42438. extend(ColumnSeries.prototype, {
  42439. cropShoulder: 0,
  42440. // When tooltip is not shared, this series (and derivatives) requires
  42441. // direct touch/hover. KD-tree does not apply.
  42442. directTouch: true,
  42443. /**
  42444. * Use a solid rectangle like the area series types
  42445. *
  42446. * @private
  42447. * @function Highcharts.seriesTypes.column#drawLegendSymbol
  42448. *
  42449. * @param {Highcharts.Legend} legend
  42450. * The legend object
  42451. *
  42452. * @param {Highcharts.Series|Highcharts.Point} item
  42453. * The series (this) or point
  42454. */
  42455. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  42456. getSymbol: noop,
  42457. // use separate negative stacks, unlike area stacks where a negative
  42458. // point is substracted from previous (#1910)
  42459. negStacks: true,
  42460. trackerGroups: ['group', 'dataLabelsGroup']
  42461. });
  42462. SeriesRegistry.registerSeriesType('column', ColumnSeries);
  42463. /* *
  42464. *
  42465. * Export
  42466. *
  42467. * */
  42468. /* *
  42469. *
  42470. * API Declarations
  42471. *
  42472. * */
  42473. /**
  42474. * Adjusted width and x offset of the columns for grouping.
  42475. *
  42476. * @private
  42477. * @interface Highcharts.ColumnMetricsObject
  42478. */ /**
  42479. * Width of the columns.
  42480. * @name Highcharts.ColumnMetricsObject#width
  42481. * @type {number}
  42482. */ /**
  42483. * Offset of the columns.
  42484. * @name Highcharts.ColumnMetricsObject#offset
  42485. * @type {number}
  42486. */
  42487. ''; // detach doclets above
  42488. /* *
  42489. *
  42490. * API Options
  42491. *
  42492. * */
  42493. /**
  42494. * A `column` series. If the [type](#series.column.type) option is
  42495. * not specified, it is inherited from [chart.type](#chart.type).
  42496. *
  42497. * @extends series,plotOptions.column
  42498. * @excluding connectNulls, dataParser, dataURL, gapSize, gapUnit, linecap,
  42499. * lineWidth, marker, connectEnds, step
  42500. * @product highcharts highstock
  42501. * @apioption series.column
  42502. */
  42503. /**
  42504. * An array of data points for the series. For the `column` series type,
  42505. * points can be given in the following ways:
  42506. *
  42507. * 1. An array of numerical values. In this case, the numerical values will be
  42508. * interpreted as `y` options. The `x` values will be automatically
  42509. * calculated, either starting at 0 and incremented by 1, or from
  42510. * `pointStart` and `pointInterval` given in the series options. If the axis
  42511. * has categories, these will be used. Example:
  42512. * ```js
  42513. * data: [0, 5, 3, 5]
  42514. * ```
  42515. *
  42516. * 2. An array of arrays with 2 values. In this case, the values correspond to
  42517. * `x,y`. If the first value is a string, it is applied as the name of the
  42518. * point, and the `x` value is inferred.
  42519. * ```js
  42520. * data: [
  42521. * [0, 6],
  42522. * [1, 2],
  42523. * [2, 6]
  42524. * ]
  42525. * ```
  42526. *
  42527. * 3. An array of objects with named values. The following snippet shows only a
  42528. * few settings, see the complete options set below. If the total number of
  42529. * data points exceeds the series'
  42530. * [turboThreshold](#series.column.turboThreshold), this option is not
  42531. * available.
  42532. * ```js
  42533. * data: [{
  42534. * x: 1,
  42535. * y: 9,
  42536. * name: "Point2",
  42537. * color: "#00FF00"
  42538. * }, {
  42539. * x: 1,
  42540. * y: 6,
  42541. * name: "Point1",
  42542. * color: "#FF00FF"
  42543. * }]
  42544. * ```
  42545. *
  42546. * @sample {highcharts} highcharts/chart/reflow-true/
  42547. * Numerical values
  42548. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  42549. * Arrays of numeric x and y
  42550. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  42551. * Arrays of datetime x and y
  42552. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  42553. * Arrays of point.name and y
  42554. * @sample {highcharts} highcharts/series/data-array-of-objects/
  42555. * Config objects
  42556. *
  42557. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  42558. * @extends series.line.data
  42559. * @excluding marker
  42560. * @product highcharts highstock
  42561. * @apioption series.column.data
  42562. */
  42563. /**
  42564. * The color of the border surrounding the column or bar.
  42565. *
  42566. * In styled mode, the border stroke can be set with the `.highcharts-point`
  42567. * rule.
  42568. *
  42569. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42570. * Dark gray border
  42571. *
  42572. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42573. * @product highcharts highstock
  42574. * @apioption series.column.data.borderColor
  42575. */
  42576. /**
  42577. * The width of the border surrounding the column or bar.
  42578. *
  42579. * In styled mode, the stroke width can be set with the `.highcharts-point`
  42580. * rule.
  42581. *
  42582. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42583. * 2px black border
  42584. *
  42585. * @type {number}
  42586. * @product highcharts highstock
  42587. * @apioption series.column.data.borderWidth
  42588. */
  42589. /**
  42590. * A name for the dash style to use for the column or bar. Overrides
  42591. * dashStyle on the series.
  42592. *
  42593. * In styled mode, the stroke dash-array can be set with the same classes as
  42594. * listed under [data.color](#series.column.data.color).
  42595. *
  42596. * @see [series.pointWidth](#plotOptions.column.dashStyle)
  42597. *
  42598. * @type {Highcharts.DashStyleValue}
  42599. * @apioption series.column.data.dashStyle
  42600. */
  42601. /**
  42602. * A pixel value specifying a fixed width for the column or bar. Overrides
  42603. * pointWidth on the series. The width effects the dimension that is not based
  42604. * on the point value.
  42605. *
  42606. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42607. *
  42608. * @type {number}
  42609. * @apioption series.column.data.pointWidth
  42610. */
  42611. /**
  42612. * @excluding halo, lineWidth, lineWidthPlus, marker
  42613. * @product highcharts highstock
  42614. * @apioption series.column.states.hover
  42615. */
  42616. /**
  42617. * @excluding halo, lineWidth, lineWidthPlus, marker
  42618. * @product highcharts highstock
  42619. * @apioption series.column.states.select
  42620. */
  42621. ''; // includes above doclets in transpilat
  42622. return ColumnSeries;
  42623. });
  42624. _registerModule(_modules, 'Series/Bar/BarSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColumnSeries, SeriesRegistry, U) {
  42625. /* *
  42626. *
  42627. * (c) 2010-2021 Torstein Honsi
  42628. *
  42629. * License: www.highcharts.com/license
  42630. *
  42631. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42632. *
  42633. * */
  42634. var __extends = (this && this.__extends) || (function () {
  42635. var extendStatics = function (d,
  42636. b) {
  42637. extendStatics = Object.setPrototypeOf ||
  42638. ({ __proto__: [] } instanceof Array && function (d,
  42639. b) { d.__proto__ = b; }) ||
  42640. function (d,
  42641. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42642. return extendStatics(d, b);
  42643. };
  42644. return function (d, b) {
  42645. extendStatics(d, b);
  42646. function __() { this.constructor = d; }
  42647. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42648. };
  42649. })();
  42650. var extend = U.extend,
  42651. merge = U.merge;
  42652. /* *
  42653. *
  42654. * Class
  42655. *
  42656. * */
  42657. /**
  42658. * Bar series type.
  42659. *
  42660. * @private
  42661. * @class
  42662. * @name Highcharts.seriesTypes.bar
  42663. *
  42664. * @augments Highcharts.Series
  42665. */
  42666. var BarSeries = /** @class */ (function (_super) {
  42667. __extends(BarSeries, _super);
  42668. function BarSeries() {
  42669. /* *
  42670. *
  42671. * Static Properties
  42672. *
  42673. * */
  42674. var _this = _super !== null && _super.apply(this,
  42675. arguments) || this;
  42676. /* *
  42677. *
  42678. * Properties
  42679. *
  42680. * */
  42681. _this.data = void 0;
  42682. _this.options = void 0;
  42683. _this.points = void 0;
  42684. return _this;
  42685. }
  42686. /**
  42687. * A bar series is a special type of column series where the columns are
  42688. * horizontal.
  42689. *
  42690. * @sample highcharts/demo/bar-basic/
  42691. * Bar chart
  42692. *
  42693. * @extends plotOptions.column
  42694. * @product highcharts
  42695. * @optionparent plotOptions.bar
  42696. */
  42697. BarSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  42698. // nothing here yet
  42699. });
  42700. return BarSeries;
  42701. }(ColumnSeries));
  42702. extend(BarSeries.prototype, {
  42703. inverted: true
  42704. });
  42705. SeriesRegistry.registerSeriesType('bar', BarSeries);
  42706. /* *
  42707. *
  42708. * Default Export
  42709. *
  42710. * */
  42711. /* *
  42712. *
  42713. * API Options
  42714. *
  42715. * */
  42716. /**
  42717. * A `bar` series. If the [type](#series.bar.type) option is not specified,
  42718. * it is inherited from [chart.type](#chart.type).
  42719. *
  42720. * @extends series,plotOptions.bar
  42721. * @excluding connectNulls, dashStyle, dataParser, dataURL, gapSize, gapUnit,
  42722. * linecap, lineWidth, marker, connectEnds, step
  42723. * @product highcharts
  42724. * @apioption series.bar
  42725. */
  42726. /**
  42727. * An array of data points for the series. For the `bar` series type,
  42728. * points can be given in the following ways:
  42729. *
  42730. * 1. An array of numerical values. In this case, the numerical values will be
  42731. * interpreted as `y` options. The `x` values will be automatically
  42732. * calculated, either starting at 0 and incremented by 1, or from
  42733. * `pointStart` and `pointInterval` given in the series options. If the axis
  42734. * has categories, these will be used. Example:
  42735. * ```js
  42736. * data: [0, 5, 3, 5]
  42737. * ```
  42738. *
  42739. * 2. An array of arrays with 2 values. In this case, the values correspond to
  42740. * `x,y`. If the first value is a string, it is applied as the name of the
  42741. * point, and the `x` value is inferred.
  42742. * ```js
  42743. * data: [
  42744. * [0, 5],
  42745. * [1, 10],
  42746. * [2, 3]
  42747. * ]
  42748. * ```
  42749. *
  42750. * 3. An array of objects with named values. The following snippet shows only a
  42751. * few settings, see the complete options set below. If the total number of
  42752. * data points exceeds the series'
  42753. * [turboThreshold](#series.bar.turboThreshold), this option is not
  42754. * available.
  42755. * ```js
  42756. * data: [{
  42757. * x: 1,
  42758. * y: 1,
  42759. * name: "Point2",
  42760. * color: "#00FF00"
  42761. * }, {
  42762. * x: 1,
  42763. * y: 10,
  42764. * name: "Point1",
  42765. * color: "#FF00FF"
  42766. * }]
  42767. * ```
  42768. *
  42769. * @sample {highcharts} highcharts/chart/reflow-true/
  42770. * Numerical values
  42771. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  42772. * Arrays of numeric x and y
  42773. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  42774. * Arrays of datetime x and y
  42775. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  42776. * Arrays of point.name and y
  42777. * @sample {highcharts} highcharts/series/data-array-of-objects/
  42778. * Config objects
  42779. *
  42780. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  42781. * @extends series.column.data
  42782. * @product highcharts
  42783. * @apioption series.bar.data
  42784. */
  42785. /**
  42786. * @excluding halo,lineWidth,lineWidthPlus,marker
  42787. * @product highcharts highstock
  42788. * @apioption series.bar.states.hover
  42789. */
  42790. /**
  42791. * @excluding halo,lineWidth,lineWidthPlus,marker
  42792. * @product highcharts highstock
  42793. * @apioption series.bar.states.select
  42794. */
  42795. ''; // gets doclets above into transpilat
  42796. return BarSeries;
  42797. });
  42798. _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) {
  42799. /* *
  42800. *
  42801. * (c) 2010-2021 Torstein Honsi
  42802. *
  42803. * License: www.highcharts.com/license
  42804. *
  42805. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42806. *
  42807. * */
  42808. var __extends = (this && this.__extends) || (function () {
  42809. var extendStatics = function (d,
  42810. b) {
  42811. extendStatics = Object.setPrototypeOf ||
  42812. ({ __proto__: [] } instanceof Array && function (d,
  42813. b) { d.__proto__ = b; }) ||
  42814. function (d,
  42815. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42816. return extendStatics(d, b);
  42817. };
  42818. return function (d, b) {
  42819. extendStatics(d, b);
  42820. function __() { this.constructor = d; }
  42821. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42822. };
  42823. })();
  42824. var addEvent = U.addEvent,
  42825. extend = U.extend,
  42826. merge = U.merge;
  42827. /* *
  42828. *
  42829. * Class
  42830. *
  42831. * */
  42832. /**
  42833. * Scatter series type.
  42834. *
  42835. * @private
  42836. */
  42837. var ScatterSeries = /** @class */ (function (_super) {
  42838. __extends(ScatterSeries, _super);
  42839. function ScatterSeries() {
  42840. var _this = _super !== null && _super.apply(this,
  42841. arguments) || this;
  42842. /* *
  42843. *
  42844. * Properties
  42845. *
  42846. * */
  42847. _this.data = void 0;
  42848. _this.options = void 0;
  42849. _this.points = void 0;
  42850. return _this;
  42851. /* eslint-enable valid-jsdoc */
  42852. }
  42853. /* *
  42854. *
  42855. * Functions
  42856. *
  42857. * */
  42858. /* eslint-disable valid-jsdoc */
  42859. /**
  42860. * Optionally add the jitter effect.
  42861. * @private
  42862. */
  42863. ScatterSeries.prototype.applyJitter = function () {
  42864. var series = this,
  42865. jitter = this.options.jitter,
  42866. len = this.points.length;
  42867. /**
  42868. * Return a repeatable, pseudo-random number based on an integer
  42869. * seed.
  42870. * @private
  42871. */
  42872. function unrandom(seed) {
  42873. var rand = Math.sin(seed) * 10000;
  42874. return rand - Math.floor(rand);
  42875. }
  42876. if (jitter) {
  42877. this.points.forEach(function (point, i) {
  42878. ['x', 'y'].forEach(function (dim, j) {
  42879. var axis,
  42880. plotProp = 'plot' + dim.toUpperCase(),
  42881. min,
  42882. max,
  42883. translatedJitter;
  42884. if (jitter[dim] && !point.isNull) {
  42885. axis = series[dim + 'Axis'];
  42886. translatedJitter =
  42887. jitter[dim] * axis.transA;
  42888. if (axis && !axis.isLog) {
  42889. // Identify the outer bounds of the jitter range
  42890. min = Math.max(0, point[plotProp] - translatedJitter);
  42891. max = Math.min(axis.len, point[plotProp] + translatedJitter);
  42892. // Find a random position within this range
  42893. point[plotProp] = min +
  42894. (max - min) * unrandom(i + j * len);
  42895. // Update clientX for the tooltip k-d-tree
  42896. if (dim === 'x') {
  42897. point.clientX = point.plotX;
  42898. }
  42899. }
  42900. }
  42901. });
  42902. });
  42903. }
  42904. };
  42905. /**
  42906. * @private
  42907. * @function Highcharts.seriesTypes.scatter#drawGraph
  42908. */
  42909. ScatterSeries.prototype.drawGraph = function () {
  42910. if (this.options.lineWidth ||
  42911. // In case we have a graph from before and we update the line
  42912. // width to 0 (#13816)
  42913. (this.options.lineWidth === 0 &&
  42914. this.graph &&
  42915. this.graph.strokeWidth())) {
  42916. _super.prototype.drawGraph.call(this);
  42917. }
  42918. };
  42919. /**
  42920. * A scatter plot uses cartesian coordinates to display values for two
  42921. * variables for a set of data.
  42922. *
  42923. * @sample {highcharts} highcharts/demo/scatter/
  42924. * Scatter plot
  42925. *
  42926. * @extends plotOptions.line
  42927. * @excluding cropThreshold, pointPlacement, shadow, useOhlcData
  42928. * @product highcharts highstock
  42929. * @optionparent plotOptions.scatter
  42930. */
  42931. ScatterSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  42932. /**
  42933. * The width of the line connecting the data points.
  42934. *
  42935. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-none/
  42936. * 0 by default
  42937. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-1/
  42938. * 1px
  42939. *
  42940. * @product highcharts highstock
  42941. */
  42942. lineWidth: 0,
  42943. findNearestPointBy: 'xy',
  42944. /**
  42945. * Apply a jitter effect for the rendered markers. When plotting
  42946. * discrete values, a little random noise may help telling the points
  42947. * apart. The jitter setting applies a random displacement of up to `n`
  42948. * axis units in either direction. So for example on a horizontal X
  42949. * axis, setting the `jitter.x` to 0.24 will render the point in a
  42950. * random position between 0.24 units to the left and 0.24 units to the
  42951. * right of the true axis position. On a category axis, setting it to
  42952. * 0.5 will fill up the bin and make the data appear continuous.
  42953. *
  42954. * When rendered on top of a box plot or a column series, a jitter value
  42955. * of 0.24 will correspond to the underlying series' default
  42956. * [groupPadding](
  42957. * https://api.highcharts.com/highcharts/plotOptions.column.groupPadding)
  42958. * and [pointPadding](
  42959. * https://api.highcharts.com/highcharts/plotOptions.column.pointPadding)
  42960. * settings.
  42961. *
  42962. * @sample {highcharts} highcharts/series-scatter/jitter
  42963. * Jitter on a scatter plot
  42964. *
  42965. * @sample {highcharts} highcharts/series-scatter/jitter-boxplot
  42966. * Jittered scatter plot on top of a box plot
  42967. *
  42968. * @product highcharts highstock
  42969. * @since 7.0.2
  42970. */
  42971. jitter: {
  42972. /**
  42973. * The maximal X offset for the random jitter effect.
  42974. */
  42975. x: 0,
  42976. /**
  42977. * The maximal Y offset for the random jitter effect.
  42978. */
  42979. y: 0
  42980. },
  42981. marker: {
  42982. enabled: true // Overrides auto-enabling in line series (#3647)
  42983. },
  42984. /**
  42985. * Sticky tracking of mouse events. When true, the `mouseOut` event
  42986. * on a series isn't triggered until the mouse moves over another
  42987. * series, or out of the plot area. When false, the `mouseOut` event on
  42988. * a series is triggered when the mouse leaves the area around the
  42989. * series' graph or markers. This also implies the tooltip. When
  42990. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  42991. * will be hidden when moving the mouse between series.
  42992. *
  42993. * @type {boolean}
  42994. * @default false
  42995. * @product highcharts highstock
  42996. * @apioption plotOptions.scatter.stickyTracking
  42997. */
  42998. /**
  42999. * A configuration object for the tooltip rendering of each single
  43000. * series. Properties are inherited from [tooltip](#tooltip).
  43001. * Overridable properties are `headerFormat`, `pointFormat`,
  43002. * `yDecimals`, `xDateFormat`, `yPrefix` and `ySuffix`. Unlike other
  43003. * series, in a scatter plot the series.name by default shows in the
  43004. * headerFormat and point.x and point.y in the pointFormat.
  43005. *
  43006. * @product highcharts highstock
  43007. */
  43008. tooltip: {
  43009. headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  43010. '<span style="font-size: 10px"> {series.name}</span><br/>',
  43011. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
  43012. }
  43013. });
  43014. return ScatterSeries;
  43015. }(LineSeries));
  43016. extend(ScatterSeries.prototype, {
  43017. drawTracker: ColumnSeries.prototype.drawTracker,
  43018. sorted: false,
  43019. requireSorting: false,
  43020. noSharedTooltip: true,
  43021. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  43022. takeOrdinalPosition: false // #2342
  43023. });
  43024. /* *
  43025. *
  43026. * Events
  43027. *
  43028. * */
  43029. /* eslint-disable no-invalid-this */
  43030. addEvent(ScatterSeries, 'afterTranslate', function () {
  43031. this.applyJitter();
  43032. });
  43033. SeriesRegistry.registerSeriesType('scatter', ScatterSeries);
  43034. /* *
  43035. *
  43036. * Default Export
  43037. *
  43038. * */
  43039. /* *
  43040. *
  43041. * API Options
  43042. *
  43043. * */
  43044. /**
  43045. * A `scatter` series. If the [type](#series.scatter.type) option is
  43046. * not specified, it is inherited from [chart.type](#chart.type).
  43047. *
  43048. * @extends series,plotOptions.scatter
  43049. * @excluding cropThreshold, dataParser, dataURL, useOhlcData
  43050. * @product highcharts highstock
  43051. * @apioption series.scatter
  43052. */
  43053. /**
  43054. * An array of data points for the series. For the `scatter` series
  43055. * type, points can be given in the following ways:
  43056. *
  43057. * 1. An array of numerical values. In this case, the numerical values will be
  43058. * interpreted as `y` options. The `x` values will be automatically
  43059. * calculated, either starting at 0 and incremented by 1, or from
  43060. * `pointStart` and `pointInterval` given in the series options. If the axis
  43061. * has categories, these will be used. Example:
  43062. * ```js
  43063. * data: [0, 5, 3, 5]
  43064. * ```
  43065. *
  43066. * 2. An array of arrays with 2 values. In this case, the values correspond to
  43067. * `x,y`. If the first value is a string, it is applied as the name of the
  43068. * point, and the `x` value is inferred.
  43069. * ```js
  43070. * data: [
  43071. * [0, 0],
  43072. * [1, 8],
  43073. * [2, 9]
  43074. * ]
  43075. * ```
  43076. *
  43077. * 3. An array of objects with named values. The following snippet shows only a
  43078. * few settings, see the complete options set below. If the total number of
  43079. * data points exceeds the series'
  43080. * [turboThreshold](#series.scatter.turboThreshold), this option is not
  43081. * available.
  43082. * ```js
  43083. * data: [{
  43084. * x: 1,
  43085. * y: 2,
  43086. * name: "Point2",
  43087. * color: "#00FF00"
  43088. * }, {
  43089. * x: 1,
  43090. * y: 4,
  43091. * name: "Point1",
  43092. * color: "#FF00FF"
  43093. * }]
  43094. * ```
  43095. *
  43096. * @sample {highcharts} highcharts/chart/reflow-true/
  43097. * Numerical values
  43098. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  43099. * Arrays of numeric x and y
  43100. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  43101. * Arrays of datetime x and y
  43102. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  43103. * Arrays of point.name and y
  43104. * @sample {highcharts} highcharts/series/data-array-of-objects/
  43105. * Config objects
  43106. *
  43107. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  43108. * @extends series.line.data
  43109. * @product highcharts highstock
  43110. * @apioption series.scatter.data
  43111. */
  43112. ''; // adds doclets above to transpilat
  43113. return ScatterSeries;
  43114. });
  43115. _registerModule(_modules, 'Mixins/CenteredSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (H, Series, U) {
  43116. /* *
  43117. *
  43118. * (c) 2010-2021 Torstein Honsi
  43119. *
  43120. * License: www.highcharts.com/license
  43121. *
  43122. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43123. *
  43124. * */
  43125. /**
  43126. * @private
  43127. * @interface Highcharts.RadianAngles
  43128. */ /**
  43129. * @name Highcharts.RadianAngles#end
  43130. * @type {number}
  43131. */ /**
  43132. * @name Highcharts.RadianAngles#start
  43133. * @type {number}
  43134. */
  43135. var isNumber = U.isNumber,
  43136. pick = U.pick,
  43137. relativeLength = U.relativeLength;
  43138. var deg2rad = H.deg2rad;
  43139. /* eslint-disable valid-jsdoc */
  43140. /**
  43141. * @private
  43142. * @mixin Highcharts.CenteredSeriesMixin
  43143. */
  43144. var centeredSeriesMixin = H.CenteredSeriesMixin = {
  43145. /**
  43146. * Get the center of the pie based on the size and center options relative
  43147. * to the plot area. Borrowed by the polar and gauge series types.
  43148. *
  43149. * @private
  43150. * @function Highcharts.CenteredSeriesMixin.getCenter
  43151. *
  43152. * @return {Array<number>}
  43153. */
  43154. getCenter: function () {
  43155. var options = this.options,
  43156. chart = this.chart,
  43157. slicingRoom = 2 * (options.slicedOffset || 0),
  43158. handleSlicingRoom,
  43159. plotWidth = chart.plotWidth - 2 * slicingRoom,
  43160. plotHeight = chart.plotHeight - 2 * slicingRoom,
  43161. centerOption = options.center,
  43162. smallestSize = Math.min(plotWidth,
  43163. plotHeight),
  43164. size = options.size,
  43165. innerSize = options.innerSize || 0,
  43166. positions,
  43167. i,
  43168. value;
  43169. if (typeof size === 'string') {
  43170. size = parseFloat(size);
  43171. }
  43172. if (typeof innerSize === 'string') {
  43173. innerSize = parseFloat(innerSize);
  43174. }
  43175. positions = [
  43176. pick(centerOption[0], '50%'),
  43177. pick(centerOption[1], '50%'),
  43178. // Prevent from negative values
  43179. pick(size && size < 0 ? void 0 : options.size, '100%'),
  43180. pick(innerSize && innerSize < 0 ? void 0 : options.innerSize || 0, '0%')
  43181. ];
  43182. // No need for inner size in angular (gauges) series but still required
  43183. // for pie series
  43184. if (chart.angular && !(this instanceof Series)) {
  43185. positions[3] = 0;
  43186. }
  43187. for (i = 0; i < 4; ++i) {
  43188. value = positions[i];
  43189. handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
  43190. // i == 0: centerX, relative to width
  43191. // i == 1: centerY, relative to height
  43192. // i == 2: size, relative to smallestSize
  43193. // i == 3: innerSize, relative to size
  43194. positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) + (handleSlicingRoom ? slicingRoom : 0);
  43195. }
  43196. // innerSize cannot be larger than size (#3632)
  43197. if (positions[3] > positions[2]) {
  43198. positions[3] = positions[2];
  43199. }
  43200. return positions;
  43201. },
  43202. /**
  43203. * getStartAndEndRadians - Calculates start and end angles in radians.
  43204. * Used in series types such as pie and sunburst.
  43205. *
  43206. * @private
  43207. * @function Highcharts.CenteredSeriesMixin.getStartAndEndRadians
  43208. *
  43209. * @param {number} [start]
  43210. * Start angle in degrees.
  43211. *
  43212. * @param {number} [end]
  43213. * Start angle in degrees.
  43214. *
  43215. * @return {Highcharts.RadianAngles}
  43216. * Returns an object containing start and end angles as radians.
  43217. */
  43218. getStartAndEndRadians: function (start, end) {
  43219. var startAngle = isNumber(start) ? start : 0, // must be a number
  43220. endAngle = ((isNumber(end) && // must be a number
  43221. end > startAngle && // must be larger than the start angle
  43222. // difference must be less than 360 degrees
  43223. (end - startAngle) < 360) ?
  43224. end :
  43225. startAngle + 360),
  43226. correction = -90;
  43227. return {
  43228. start: deg2rad * (startAngle + correction),
  43229. end: deg2rad * (endAngle + correction)
  43230. };
  43231. }
  43232. };
  43233. return centeredSeriesMixin;
  43234. });
  43235. _registerModule(_modules, 'Series/Pie/PiePoint.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (A, Point, U) {
  43236. /* *
  43237. *
  43238. * (c) 2010-2021 Torstein Honsi
  43239. *
  43240. * License: www.highcharts.com/license
  43241. *
  43242. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43243. *
  43244. * */
  43245. var __extends = (this && this.__extends) || (function () {
  43246. var extendStatics = function (d,
  43247. b) {
  43248. extendStatics = Object.setPrototypeOf ||
  43249. ({ __proto__: [] } instanceof Array && function (d,
  43250. b) { d.__proto__ = b; }) ||
  43251. function (d,
  43252. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43253. return extendStatics(d, b);
  43254. };
  43255. return function (d, b) {
  43256. extendStatics(d, b);
  43257. function __() { this.constructor = d; }
  43258. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43259. };
  43260. })();
  43261. var setAnimation = A.setAnimation;
  43262. var addEvent = U.addEvent,
  43263. defined = U.defined,
  43264. extend = U.extend,
  43265. isNumber = U.isNumber,
  43266. pick = U.pick,
  43267. relativeLength = U.relativeLength;
  43268. /* *
  43269. *
  43270. * Class
  43271. *
  43272. * */
  43273. var PiePoint = /** @class */ (function (_super) {
  43274. __extends(PiePoint, _super);
  43275. function PiePoint() {
  43276. /* *
  43277. *
  43278. * Properties
  43279. *
  43280. * */
  43281. var _this = _super !== null && _super.apply(this,
  43282. arguments) || this;
  43283. _this.labelDistance = void 0;
  43284. _this.options = void 0;
  43285. _this.series = void 0;
  43286. return _this;
  43287. }
  43288. /* *
  43289. *
  43290. * Functions
  43291. *
  43292. * */
  43293. /* eslint-disable valid-jsdoc */
  43294. /**
  43295. * Extendable method for getting the path of the connector between the
  43296. * data label and the pie slice.
  43297. * @private
  43298. */
  43299. PiePoint.prototype.getConnectorPath = function () {
  43300. var labelPosition = this.labelPosition,
  43301. options = this.series.options.dataLabels,
  43302. connectorShape = options.connectorShape,
  43303. predefinedShapes = this.connectorShapes;
  43304. // find out whether to use the predefined shape
  43305. if (predefinedShapes[connectorShape]) {
  43306. connectorShape = predefinedShapes[connectorShape];
  43307. }
  43308. return connectorShape.call(this, {
  43309. // pass simplified label position object for user's convenience
  43310. x: labelPosition.final.x,
  43311. y: labelPosition.final.y,
  43312. alignment: labelPosition.alignment
  43313. }, labelPosition.connectorPosition, options);
  43314. };
  43315. /**
  43316. * @private
  43317. */
  43318. PiePoint.prototype.getTranslate = function () {
  43319. return this.sliced ? this.slicedTranslation : {
  43320. translateX: 0,
  43321. translateY: 0
  43322. };
  43323. };
  43324. /**
  43325. * @private
  43326. */
  43327. PiePoint.prototype.haloPath = function (size) {
  43328. var shapeArgs = this.shapeArgs;
  43329. return this.sliced || !this.visible ?
  43330. [] :
  43331. this.series.chart.renderer.symbols.arc(shapeArgs.x, shapeArgs.y, shapeArgs.r + size, shapeArgs.r + size, {
  43332. // Substract 1px to ensure the background is not bleeding
  43333. // through between the halo and the slice (#7495).
  43334. innerR: shapeArgs.r - 1,
  43335. start: shapeArgs.start,
  43336. end: shapeArgs.end
  43337. });
  43338. };
  43339. /**
  43340. * Initialize the pie slice.
  43341. * @private
  43342. */
  43343. PiePoint.prototype.init = function () {
  43344. Point.prototype.init.apply(this, arguments);
  43345. var point = this,
  43346. toggleSlice;
  43347. point.name = pick(point.name, 'Slice');
  43348. // add event listener for select
  43349. toggleSlice = function (e) {
  43350. point.slice(e.type === 'select');
  43351. };
  43352. addEvent(point, 'select', toggleSlice);
  43353. addEvent(point, 'unselect', toggleSlice);
  43354. return point;
  43355. };
  43356. /**
  43357. * Negative points are not valid (#1530, #3623, #5322)
  43358. * @private
  43359. */
  43360. PiePoint.prototype.isValid = function () {
  43361. return isNumber(this.y) && this.y >= 0;
  43362. };
  43363. /**
  43364. * Toggle the visibility of the pie slice.
  43365. * @private
  43366. *
  43367. * @param {boolean} vis
  43368. * Whether to show the slice or not. If undefined, the visibility is
  43369. * toggled.
  43370. */
  43371. PiePoint.prototype.setVisible = function (vis, redraw) {
  43372. var point = this,
  43373. series = point.series,
  43374. chart = series.chart,
  43375. ignoreHiddenPoint = series.options.ignoreHiddenPoint;
  43376. redraw = pick(redraw, ignoreHiddenPoint);
  43377. if (vis !== point.visible) {
  43378. // If called without an argument, toggle visibility
  43379. point.visible = point.options.visible = vis =
  43380. typeof vis === 'undefined' ? !point.visible : vis;
  43381. // update userOptions.data
  43382. series.options.data[series.data.indexOf(point)] =
  43383. point.options;
  43384. // Show and hide associated elements. This is performed
  43385. // regardless of redraw or not, because chart.redraw only
  43386. // handles full series.
  43387. ['graphic', 'dataLabel', 'connector', 'shadowGroup'].forEach(function (key) {
  43388. if (point[key]) {
  43389. point[key][vis ? 'show' : 'hide'](vis);
  43390. }
  43391. });
  43392. if (point.legendItem) {
  43393. chart.legend.colorizeItem(point, vis);
  43394. }
  43395. // #4170, hide halo after hiding point
  43396. if (!vis && point.state === 'hover') {
  43397. point.setState('');
  43398. }
  43399. // Handle ignore hidden slices
  43400. if (ignoreHiddenPoint) {
  43401. series.isDirty = true;
  43402. }
  43403. if (redraw) {
  43404. chart.redraw();
  43405. }
  43406. }
  43407. };
  43408. /**
  43409. * Set or toggle whether the slice is cut out from the pie.
  43410. * @private
  43411. *
  43412. * @param {boolean} sliced
  43413. * When undefined, the slice state is toggled.
  43414. *
  43415. * @param {boolean} redraw
  43416. * Whether to redraw the chart. True by default.
  43417. *
  43418. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>}
  43419. * Animation options.
  43420. */
  43421. PiePoint.prototype.slice = function (sliced, redraw, animation) {
  43422. var point = this,
  43423. series = point.series,
  43424. chart = series.chart;
  43425. setAnimation(animation, chart);
  43426. // redraw is true by default
  43427. redraw = pick(redraw, true);
  43428. /**
  43429. * Pie series only. Whether to display a slice offset from the
  43430. * center.
  43431. * @name Highcharts.Point#sliced
  43432. * @type {boolean|undefined}
  43433. */
  43434. // if called without an argument, toggle
  43435. point.sliced = point.options.sliced = sliced =
  43436. defined(sliced) ? sliced : !point.sliced;
  43437. // update userOptions.data
  43438. series.options.data[series.data.indexOf(point)] =
  43439. point.options;
  43440. if (point.graphic) {
  43441. point.graphic.animate(this.getTranslate());
  43442. }
  43443. if (point.shadowGroup) {
  43444. point.shadowGroup.animate(this.getTranslate());
  43445. }
  43446. };
  43447. return PiePoint;
  43448. }(Point));
  43449. extend(PiePoint.prototype, {
  43450. connectorShapes: {
  43451. // only one available before v7.0.0
  43452. fixedOffset: function (labelPosition, connectorPosition, options) {
  43453. var breakAt = connectorPosition.breakAt,
  43454. touchingSliceAt = connectorPosition.touchingSliceAt,
  43455. lineSegment = options.softConnector ? [
  43456. 'C',
  43457. // 1st control point (of the curve)
  43458. labelPosition.x +
  43459. // 5 gives the connector a little horizontal bend
  43460. (labelPosition.alignment === 'left' ? -5 : 5),
  43461. labelPosition.y,
  43462. 2 * breakAt.x - touchingSliceAt.x,
  43463. 2 * breakAt.y - touchingSliceAt.y,
  43464. breakAt.x,
  43465. breakAt.y //
  43466. ] : [
  43467. 'L',
  43468. breakAt.x,
  43469. breakAt.y
  43470. ];
  43471. // assemble the path
  43472. return ([
  43473. ['M', labelPosition.x, labelPosition.y],
  43474. lineSegment,
  43475. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43476. ]);
  43477. },
  43478. straight: function (labelPosition, connectorPosition) {
  43479. var touchingSliceAt = connectorPosition.touchingSliceAt;
  43480. // direct line to the slice
  43481. return [
  43482. ['M', labelPosition.x, labelPosition.y],
  43483. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43484. ];
  43485. },
  43486. crookedLine: function (labelPosition, connectorPosition, options) {
  43487. var touchingSliceAt = connectorPosition.touchingSliceAt,
  43488. series = this.series,
  43489. pieCenterX = series.center[0],
  43490. plotWidth = series.chart.plotWidth,
  43491. plotLeft = series.chart.plotLeft,
  43492. alignment = labelPosition.alignment,
  43493. radius = this.shapeArgs.r,
  43494. crookDistance = relativeLength(// % to fraction
  43495. options.crookDistance, 1),
  43496. crookX = alignment === 'left' ?
  43497. pieCenterX + radius + (plotWidth + plotLeft -
  43498. pieCenterX - radius) * (1 - crookDistance) :
  43499. plotLeft + (pieCenterX - radius) * crookDistance,
  43500. segmentWithCrook = [
  43501. 'L',
  43502. crookX,
  43503. labelPosition.y
  43504. ],
  43505. useCrook = true;
  43506. // crookedLine formula doesn't make sense if the path overlaps
  43507. // the label - use straight line instead in that case
  43508. if (alignment === 'left' ?
  43509. (crookX > labelPosition.x || crookX < touchingSliceAt.x) :
  43510. (crookX < labelPosition.x || crookX > touchingSliceAt.x)) {
  43511. useCrook = false;
  43512. }
  43513. // assemble the path
  43514. var path = [
  43515. ['M',
  43516. labelPosition.x,
  43517. labelPosition.y]
  43518. ];
  43519. if (useCrook) {
  43520. path.push(segmentWithCrook);
  43521. }
  43522. path.push(['L', touchingSliceAt.x, touchingSliceAt.y]);
  43523. return path;
  43524. }
  43525. }
  43526. });
  43527. /* *
  43528. *
  43529. * Default Export
  43530. *
  43531. * */
  43532. return PiePoint;
  43533. });
  43534. _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/SVGRenderer.js'], _modules['Core/Utilities.js']], function (CenteredSeriesMixin, ColumnSeries, H, LegendSymbolMixin, palette, PiePoint, Series, SeriesRegistry, SVGRenderer, U) {
  43535. /* *
  43536. *
  43537. * (c) 2010-2021 Torstein Honsi
  43538. *
  43539. * License: www.highcharts.com/license
  43540. *
  43541. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43542. *
  43543. * */
  43544. var __extends = (this && this.__extends) || (function () {
  43545. var extendStatics = function (d,
  43546. b) {
  43547. extendStatics = Object.setPrototypeOf ||
  43548. ({ __proto__: [] } instanceof Array && function (d,
  43549. b) { d.__proto__ = b; }) ||
  43550. function (d,
  43551. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43552. return extendStatics(d, b);
  43553. };
  43554. return function (d, b) {
  43555. extendStatics(d, b);
  43556. function __() { this.constructor = d; }
  43557. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43558. };
  43559. })();
  43560. var getStartAndEndRadians = CenteredSeriesMixin.getStartAndEndRadians;
  43561. var noop = H.noop;
  43562. var clamp = U.clamp,
  43563. extend = U.extend,
  43564. fireEvent = U.fireEvent,
  43565. merge = U.merge,
  43566. pick = U.pick,
  43567. relativeLength = U.relativeLength;
  43568. /* *
  43569. *
  43570. * Class
  43571. *
  43572. * */
  43573. /**
  43574. * Pie series type.
  43575. *
  43576. * @private
  43577. * @class
  43578. * @name Highcharts.seriesTypes.pie
  43579. *
  43580. * @augments Highcharts.Series
  43581. */
  43582. var PieSeries = /** @class */ (function (_super) {
  43583. __extends(PieSeries, _super);
  43584. function PieSeries() {
  43585. /* *
  43586. *
  43587. * Static Properties
  43588. *
  43589. * */
  43590. var _this = _super !== null && _super.apply(this,
  43591. arguments) || this;
  43592. /* *
  43593. *
  43594. * Properties
  43595. *
  43596. * */
  43597. _this.center = void 0;
  43598. _this.data = void 0;
  43599. _this.maxLabelDistance = void 0;
  43600. _this.options = void 0;
  43601. _this.points = void 0;
  43602. return _this;
  43603. /* eslint-enable valid-jsdoc */
  43604. }
  43605. /* *
  43606. *
  43607. * Functions
  43608. *
  43609. * */
  43610. /* eslint-disable valid-jsdoc */
  43611. /**
  43612. * Animates the pies in.
  43613. * @private
  43614. */
  43615. PieSeries.prototype.animate = function (init) {
  43616. var series = this,
  43617. points = series.points,
  43618. startAngleRad = series.startAngleRad;
  43619. if (!init) {
  43620. points.forEach(function (point) {
  43621. var graphic = point.graphic,
  43622. args = point.shapeArgs;
  43623. if (graphic && args) {
  43624. // start values
  43625. graphic.attr({
  43626. // animate from inner radius (#779)
  43627. r: pick(point.startR, (series.center && series.center[3] / 2)),
  43628. start: startAngleRad,
  43629. end: startAngleRad
  43630. });
  43631. // animate
  43632. graphic.animate({
  43633. r: args.r,
  43634. start: args.start,
  43635. end: args.end
  43636. }, series.options.animation);
  43637. }
  43638. });
  43639. }
  43640. };
  43641. /**
  43642. * Called internally to draw auxiliary graph in pie-like series in
  43643. * situtation when the default graph is not sufficient enough to present
  43644. * the data well. Auxiliary graph is saved in the same object as
  43645. * regular graph.
  43646. * @private
  43647. */
  43648. PieSeries.prototype.drawEmpty = function () {
  43649. var centerX,
  43650. centerY,
  43651. start = this.startAngleRad,
  43652. end = this.endAngleRad,
  43653. options = this.options;
  43654. // Draw auxiliary graph if there're no visible points.
  43655. if (this.total === 0 && this.center) {
  43656. centerX = this.center[0];
  43657. centerY = this.center[1];
  43658. if (!this.graph) {
  43659. this.graph = this.chart.renderer
  43660. .arc(centerX, centerY, this.center[1] / 2, 0, start, end)
  43661. .addClass('highcharts-empty-series')
  43662. .add(this.group);
  43663. }
  43664. this.graph.attr({
  43665. d: SVGRenderer.prototype.symbols.arc(centerX, centerY, this.center[2] / 2, 0, {
  43666. start: start,
  43667. end: end,
  43668. innerR: this.center[3] / 2
  43669. })
  43670. });
  43671. if (!this.chart.styledMode) {
  43672. this.graph.attr({
  43673. 'stroke-width': options.borderWidth,
  43674. fill: options.fillColor || 'none',
  43675. stroke: options.color || palette.neutralColor20
  43676. });
  43677. }
  43678. }
  43679. else if (this.graph) { // Destroy the graph object.
  43680. this.graph = this.graph.destroy();
  43681. }
  43682. };
  43683. /**
  43684. * Slices in pie chart are initialized in DOM, but it's shapes and
  43685. * animations are normally run in `drawPoints()`.
  43686. * @private
  43687. */
  43688. PieSeries.prototype.drawPoints = function () {
  43689. var renderer = this.chart.renderer;
  43690. this.points.forEach(function (point) {
  43691. // When updating a series between 2d and 3d or cartesian and
  43692. // polar, the shape type changes.
  43693. if (point.graphic && point.hasNewShapeType()) {
  43694. point.graphic = point.graphic.destroy();
  43695. }
  43696. if (!point.graphic) {
  43697. point.graphic = renderer[point.shapeType](point.shapeArgs)
  43698. .add(point.series.group);
  43699. point.delayedRendering = true;
  43700. }
  43701. });
  43702. };
  43703. /**
  43704. * Extend the generatePoints method by adding total and percentage
  43705. * properties to each point
  43706. * @private
  43707. */
  43708. PieSeries.prototype.generatePoints = function () {
  43709. _super.prototype.generatePoints.call(this);
  43710. this.updateTotals();
  43711. };
  43712. /**
  43713. * Utility for getting the x value from a given y, used for
  43714. * anticollision logic in data labels. Added point for using specific
  43715. * points' label distance.
  43716. * @private
  43717. */
  43718. PieSeries.prototype.getX = function (y, left, point) {
  43719. var center = this.center,
  43720. // Variable pie has individual radius
  43721. radius = this.radii ?
  43722. this.radii[point.index] || 0 :
  43723. center[2] / 2,
  43724. angle,
  43725. x;
  43726. angle = Math.asin(clamp((y - center[1]) / (radius + point.labelDistance), -1, 1));
  43727. x = center[0] +
  43728. (left ? -1 : 1) *
  43729. (Math.cos(angle) * (radius + point.labelDistance)) +
  43730. (point.labelDistance > 0 ?
  43731. (left ? -1 : 1) * this.options.dataLabels.padding :
  43732. 0);
  43733. return x;
  43734. };
  43735. /**
  43736. * Define hasData function for non-cartesian series. Returns true if the
  43737. * series has points at all.
  43738. * @private
  43739. */
  43740. PieSeries.prototype.hasData = function () {
  43741. return !!this.processedXData.length; // != 0
  43742. };
  43743. /**
  43744. * Draw the data points
  43745. * @private
  43746. */
  43747. PieSeries.prototype.redrawPoints = function () {
  43748. var series = this,
  43749. chart = series.chart,
  43750. renderer = chart.renderer,
  43751. groupTranslation,
  43752. graphic,
  43753. pointAttr,
  43754. shapeArgs,
  43755. shadow = series.options.shadow;
  43756. this.drawEmpty();
  43757. if (shadow && !series.shadowGroup && !chart.styledMode) {
  43758. series.shadowGroup = renderer
  43759. .g('shadow')
  43760. .attr({ zIndex: -1 })
  43761. .add(series.group);
  43762. }
  43763. // draw the slices
  43764. series.points.forEach(function (point) {
  43765. var animateTo = {};
  43766. graphic = point.graphic;
  43767. if (!point.isNull && graphic) {
  43768. var shadowGroup = void 0;
  43769. shapeArgs = point.shapeArgs;
  43770. // If the point is sliced, use special translation, else use
  43771. // plot area translation
  43772. groupTranslation = point.getTranslate();
  43773. if (!chart.styledMode) {
  43774. // Put the shadow behind all points
  43775. shadowGroup = point.shadowGroup;
  43776. if (shadow && !shadowGroup) {
  43777. shadowGroup = point.shadowGroup = renderer
  43778. .g('shadow')
  43779. .add(series.shadowGroup);
  43780. }
  43781. if (shadowGroup) {
  43782. shadowGroup.attr(groupTranslation);
  43783. }
  43784. pointAttr = series.pointAttribs(point, (point.selected && 'select'));
  43785. }
  43786. // Draw the slice
  43787. if (!point.delayedRendering) {
  43788. graphic
  43789. .setRadialReference(series.center);
  43790. if (!chart.styledMode) {
  43791. merge(true, animateTo, pointAttr);
  43792. }
  43793. merge(true, animateTo, shapeArgs, groupTranslation);
  43794. graphic.animate(animateTo);
  43795. }
  43796. else {
  43797. graphic
  43798. .setRadialReference(series.center)
  43799. .attr(shapeArgs)
  43800. .attr(groupTranslation);
  43801. if (!chart.styledMode) {
  43802. graphic
  43803. .attr(pointAttr)
  43804. .attr({ 'stroke-linejoin': 'round' })
  43805. .shadow(shadow, shadowGroup);
  43806. }
  43807. point.delayedRendering = false;
  43808. }
  43809. graphic.attr({
  43810. visibility: point.visible ? 'inherit' : 'hidden'
  43811. });
  43812. graphic.addClass(point.getClassName(), true);
  43813. }
  43814. else if (graphic) {
  43815. point.graphic = graphic.destroy();
  43816. }
  43817. });
  43818. };
  43819. /**
  43820. * Utility for sorting data labels.
  43821. * @private
  43822. */
  43823. PieSeries.prototype.sortByAngle = function (points, sign) {
  43824. points.sort(function (a, b) {
  43825. return ((typeof a.angle !== 'undefined') &&
  43826. (b.angle - a.angle) * sign);
  43827. });
  43828. };
  43829. /**
  43830. * Do translation for pie slices
  43831. * @private
  43832. */
  43833. PieSeries.prototype.translate = function (positions) {
  43834. this.generatePoints();
  43835. var series = this,
  43836. cumulative = 0,
  43837. precision = 1000, // issue #172
  43838. options = series.options,
  43839. slicedOffset = options.slicedOffset,
  43840. connectorOffset = slicedOffset + (options.borderWidth || 0),
  43841. finalConnectorOffset,
  43842. start,
  43843. end,
  43844. angle,
  43845. radians = getStartAndEndRadians(options.startAngle,
  43846. options.endAngle),
  43847. startAngleRad = series.startAngleRad = radians.start,
  43848. endAngleRad = series.endAngleRad = radians.end,
  43849. circ = endAngleRad - startAngleRad, // 2 * Math.PI,
  43850. points = series.points,
  43851. // the x component of the radius vector for a given point
  43852. radiusX,
  43853. radiusY,
  43854. labelDistance = options.dataLabels.distance,
  43855. ignoreHiddenPoint = options.ignoreHiddenPoint,
  43856. i,
  43857. len = points.length,
  43858. point;
  43859. // Get positions - either an integer or a percentage string must be
  43860. // given. If positions are passed as a parameter, we're in a
  43861. // recursive loop for adjusting space for data labels.
  43862. if (!positions) {
  43863. series.center = positions = series.getCenter();
  43864. }
  43865. // Calculate the geometry for each point
  43866. for (i = 0; i < len; i++) {
  43867. point = points[i];
  43868. // set start and end angle
  43869. start = startAngleRad + (cumulative * circ);
  43870. if (point.isValid() &&
  43871. (!ignoreHiddenPoint || point.visible)) {
  43872. cumulative += point.percentage / 100;
  43873. }
  43874. end = startAngleRad + (cumulative * circ);
  43875. // set the shape
  43876. var shapeArgs = {
  43877. x: positions[0],
  43878. y: positions[1],
  43879. r: positions[2] / 2,
  43880. innerR: positions[3] / 2,
  43881. start: Math.round(start * precision) / precision,
  43882. end: Math.round(end * precision) / precision
  43883. };
  43884. point.shapeType = 'arc';
  43885. point.shapeArgs = shapeArgs;
  43886. // Used for distance calculation for specific point.
  43887. point.labelDistance = pick((point.options.dataLabels &&
  43888. point.options.dataLabels.distance), labelDistance);
  43889. // Compute point.labelDistance if it's defined as percentage
  43890. // of slice radius (#8854)
  43891. point.labelDistance = relativeLength(point.labelDistance, shapeArgs.r);
  43892. // Saved for later dataLabels distance calculation.
  43893. series.maxLabelDistance = Math.max(series.maxLabelDistance || 0, point.labelDistance);
  43894. // The angle must stay within -90 and 270 (#2645)
  43895. angle = (end + start) / 2;
  43896. if (angle > 1.5 * Math.PI) {
  43897. angle -= 2 * Math.PI;
  43898. }
  43899. else if (angle < -Math.PI / 2) {
  43900. angle += 2 * Math.PI;
  43901. }
  43902. // Center for the sliced out slice
  43903. point.slicedTranslation = {
  43904. translateX: Math.round(Math.cos(angle) * slicedOffset),
  43905. translateY: Math.round(Math.sin(angle) * slicedOffset)
  43906. };
  43907. // set the anchor point for tooltips
  43908. radiusX = Math.cos(angle) * positions[2] / 2;
  43909. radiusY = Math.sin(angle) * positions[2] / 2;
  43910. point.tooltipPos = [
  43911. positions[0] + radiusX * 0.7,
  43912. positions[1] + radiusY * 0.7
  43913. ];
  43914. point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ?
  43915. 1 :
  43916. 0;
  43917. point.angle = angle;
  43918. // Set the anchor point for data labels. Use point.labelDistance
  43919. // instead of labelDistance // #1174
  43920. // finalConnectorOffset - not override connectorOffset value.
  43921. finalConnectorOffset = Math.min(connectorOffset, point.labelDistance / 5); // #1678
  43922. point.labelPosition = {
  43923. natural: {
  43924. // initial position of the data label - it's utilized for
  43925. // finding the final position for the label
  43926. x: positions[0] + radiusX + Math.cos(angle) *
  43927. point.labelDistance,
  43928. y: positions[1] + radiusY + Math.sin(angle) *
  43929. point.labelDistance
  43930. },
  43931. 'final': {
  43932. // used for generating connector path -
  43933. // initialized later in drawDataLabels function
  43934. // x: undefined,
  43935. // y: undefined
  43936. },
  43937. // left - pie on the left side of the data label
  43938. // right - pie on the right side of the data label
  43939. // center - data label overlaps the pie
  43940. alignment: point.labelDistance < 0 ?
  43941. 'center' : point.half ? 'right' : 'left',
  43942. connectorPosition: {
  43943. breakAt: {
  43944. x: positions[0] + radiusX + Math.cos(angle) *
  43945. finalConnectorOffset,
  43946. y: positions[1] + radiusY + Math.sin(angle) *
  43947. finalConnectorOffset
  43948. },
  43949. touchingSliceAt: {
  43950. x: positions[0] + radiusX,
  43951. y: positions[1] + radiusY
  43952. }
  43953. }
  43954. };
  43955. }
  43956. fireEvent(series, 'afterTranslate');
  43957. };
  43958. /**
  43959. * Recompute total chart sum and update percentages of points.
  43960. * @private
  43961. */
  43962. PieSeries.prototype.updateTotals = function () {
  43963. var i,
  43964. total = 0,
  43965. points = this.points,
  43966. len = points.length,
  43967. point,
  43968. ignoreHiddenPoint = this.options.ignoreHiddenPoint;
  43969. // Get the total sum
  43970. for (i = 0; i < len; i++) {
  43971. point = points[i];
  43972. if (point.isValid() &&
  43973. (!ignoreHiddenPoint || point.visible)) {
  43974. total += point.y;
  43975. }
  43976. }
  43977. this.total = total;
  43978. // Set each point's properties
  43979. for (i = 0; i < len; i++) {
  43980. point = points[i];
  43981. point.percentage =
  43982. (total > 0 && (point.visible || !ignoreHiddenPoint)) ?
  43983. point.y / total * 100 :
  43984. 0;
  43985. point.total = total;
  43986. }
  43987. };
  43988. /**
  43989. * A pie chart is a circular graphic which is divided into slices to
  43990. * illustrate numerical proportion.
  43991. *
  43992. * @sample highcharts/demo/pie-basic/
  43993. * Pie chart
  43994. *
  43995. * @extends plotOptions.line
  43996. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  43997. * cropThreshold, dashStyle, dataSorting, dragDrop,
  43998. * findNearestPointBy, getExtremesFromAll, label, lineWidth,
  43999. * marker, negativeColor, pointInterval, pointIntervalUnit,
  44000. * pointPlacement, pointStart, softThreshold, stacking, step,
  44001. * threshold, turboThreshold, zoneAxis, zones, dataSorting,
  44002. * boostBlending
  44003. * @product highcharts
  44004. * @optionparent plotOptions.pie
  44005. */
  44006. PieSeries.defaultOptions = merge(Series.defaultOptions, {
  44007. /**
  44008. * @excluding legendItemClick
  44009. * @apioption plotOptions.pie.events
  44010. */
  44011. /**
  44012. * Fires when the checkbox next to the point name in the legend is
  44013. * clicked. One parameter, event, is passed to the function. The state
  44014. * of the checkbox is found by event.checked. The checked item is found
  44015. * by event.item. Return false to prevent the default action which is to
  44016. * toggle the select state of the series.
  44017. *
  44018. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  44019. * Alert checkbox status
  44020. *
  44021. * @type {Function}
  44022. * @since 1.2.0
  44023. * @product highcharts
  44024. * @context Highcharts.Point
  44025. * @apioption plotOptions.pie.events.checkboxClick
  44026. */
  44027. /**
  44028. * Fires when the legend item belonging to the pie point (slice) is
  44029. * clicked. The `this` keyword refers to the point itself. One
  44030. * parameter, `event`, is passed to the function, containing common
  44031. * event information. The default action is to toggle the visibility of
  44032. * the point. This can be prevented by calling `event.preventDefault()`.
  44033. *
  44034. * @sample {highcharts} highcharts/plotoptions/pie-point-events-legenditemclick/
  44035. * Confirm toggle visibility
  44036. *
  44037. * @type {Highcharts.PointLegendItemClickCallbackFunction}
  44038. * @since 1.2.0
  44039. * @product highcharts
  44040. * @apioption plotOptions.pie.point.events.legendItemClick
  44041. */
  44042. /**
  44043. * The center of the pie chart relative to the plot area. Can be
  44044. * percentages or pixel values. The default behaviour (as of 3.0) is to
  44045. * center the pie so that all slices and data labels are within the plot
  44046. * area. As a consequence, the pie may actually jump around in a chart
  44047. * with dynamic values, as the data labels move. In that case, the
  44048. * center should be explicitly set, for example to `["50%", "50%"]`.
  44049. *
  44050. * @sample {highcharts} highcharts/plotoptions/pie-center/
  44051. * Centered at 100, 100
  44052. *
  44053. * @type {Array<(number|string|null),(number|string|null)>}
  44054. * @default [null, null]
  44055. * @product highcharts
  44056. *
  44057. * @private
  44058. */
  44059. center: [null, null],
  44060. /**
  44061. * The color of the pie series. A pie series is represented as an empty
  44062. * circle if the total sum of its values is 0. Use this property to
  44063. * define the color of its border.
  44064. *
  44065. * In styled mode, the color can be defined by the
  44066. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  44067. * color can be set with the `.highcharts-series`,
  44068. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  44069. * `.highcharts-series-{n}` class, or individual classes given by the
  44070. * `className` option.
  44071. *
  44072. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44073. * Empty pie series
  44074. *
  44075. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44076. * @default ${palette.neutralColor20}
  44077. * @apioption plotOptions.pie.color
  44078. */
  44079. /**
  44080. * @product highcharts
  44081. *
  44082. * @private
  44083. */
  44084. clip: false,
  44085. /**
  44086. * @ignore-option
  44087. *
  44088. * @private
  44089. */
  44090. colorByPoint: true,
  44091. /**
  44092. * A series specific or series type specific color set to use instead
  44093. * of the global [colors](#colors).
  44094. *
  44095. * @sample {highcharts} highcharts/demo/pie-monochrome/
  44096. * Set default colors for all pies
  44097. *
  44098. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  44099. * @since 3.0
  44100. * @product highcharts
  44101. * @apioption plotOptions.pie.colors
  44102. */
  44103. /**
  44104. * @declare Highcharts.SeriesPieDataLabelsOptionsObject
  44105. * @extends plotOptions.series.dataLabels
  44106. * @excluding align, allowOverlap, inside, staggerLines, step
  44107. * @private
  44108. */
  44109. dataLabels: {
  44110. /**
  44111. * Alignment method for data labels. Possible values are:
  44112. *
  44113. * - `toPlotEdges`: Each label touches the nearest vertical edge of
  44114. * the plot area.
  44115. *
  44116. * - `connectors`: Connectors have the same x position and the
  44117. * widest label of each half (left & right) touches the nearest
  44118. * vertical edge of the plot area.
  44119. *
  44120. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-connectors/
  44121. * alignTo: connectors
  44122. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-plotedges/
  44123. * alignTo: plotEdges
  44124. *
  44125. * @type {string}
  44126. * @since 7.0.0
  44127. * @product highcharts
  44128. * @apioption plotOptions.pie.dataLabels.alignTo
  44129. */
  44130. allowOverlap: true,
  44131. /**
  44132. * The color of the line connecting the data label to the pie slice.
  44133. * The default color is the same as the point's color.
  44134. *
  44135. * In styled mode, the connector stroke is given in the
  44136. * `.highcharts-data-label-connector` class.
  44137. *
  44138. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorcolor/
  44139. * Blue connectors
  44140. * @sample {highcharts} highcharts/css/pie-point/
  44141. * Styled connectors
  44142. *
  44143. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44144. * @since 2.1
  44145. * @product highcharts
  44146. * @apioption plotOptions.pie.dataLabels.connectorColor
  44147. */
  44148. /**
  44149. * The distance from the data label to the connector. Note that
  44150. * data labels also have a default `padding`, so in order for the
  44151. * connector to touch the text, the `padding` must also be 0.
  44152. *
  44153. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorpadding/
  44154. * No padding
  44155. *
  44156. * @since 2.1
  44157. * @product highcharts
  44158. */
  44159. connectorPadding: 5,
  44160. /**
  44161. * Specifies the method that is used to generate the connector path.
  44162. * Highcharts provides 3 built-in connector shapes: `'fixedOffset'`
  44163. * (default), `'straight'` and `'crookedLine'`. Using
  44164. * `'crookedLine'` has the most sense (in most of the cases) when
  44165. * `'alignTo'` is set.
  44166. *
  44167. * Users can provide their own method by passing a function instead
  44168. * of a String. 3 arguments are passed to the callback:
  44169. *
  44170. * - Object that holds the information about the coordinates of the
  44171. * label (`x` & `y` properties) and how the label is located in
  44172. * relation to the pie (`alignment` property). `alignment` can by
  44173. * one of the following:
  44174. * `'left'` (pie on the left side of the data label),
  44175. * `'right'` (pie on the right side of the data label) or
  44176. * `'center'` (data label overlaps the pie).
  44177. *
  44178. * - Object that holds the information about the position of the
  44179. * connector. Its `touchingSliceAt` porperty tells the position
  44180. * of the place where the connector touches the slice.
  44181. *
  44182. * - Data label options
  44183. *
  44184. * The function has to return an SVG path definition in array form
  44185. * (see the example).
  44186. *
  44187. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-string/
  44188. * connectorShape is a String
  44189. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-function/
  44190. * connectorShape is a function
  44191. *
  44192. * @type {string|Function}
  44193. * @since 7.0.0
  44194. * @product highcharts
  44195. */
  44196. connectorShape: 'fixedOffset',
  44197. /**
  44198. * The width of the line connecting the data label to the pie slice.
  44199. *
  44200. * In styled mode, the connector stroke width is given in the
  44201. * `.highcharts-data-label-connector` class.
  44202. *
  44203. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorwidth-disabled/
  44204. * Disable the connector
  44205. * @sample {highcharts} highcharts/css/pie-point/
  44206. * Styled connectors
  44207. *
  44208. * @type {number}
  44209. * @default 1
  44210. * @since 2.1
  44211. * @product highcharts
  44212. * @apioption plotOptions.pie.dataLabels.connectorWidth
  44213. */
  44214. /**
  44215. * Works only if `connectorShape` is `'crookedLine'`. It defines how
  44216. * far from the vertical plot edge the coonnector path should be
  44217. * crooked.
  44218. *
  44219. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-crookdistance/
  44220. * crookDistance set to 90%
  44221. *
  44222. * @since 7.0.0
  44223. * @product highcharts
  44224. */
  44225. crookDistance: '70%',
  44226. /**
  44227. * The distance of the data label from the pie's edge. Negative
  44228. * numbers put the data label on top of the pie slices. Can also be
  44229. * defined as a percentage of pie's radius. Connectors are only
  44230. * shown for data labels outside the pie.
  44231. *
  44232. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-distance/
  44233. * Data labels on top of the pie
  44234. *
  44235. * @type {number|string}
  44236. * @since 2.1
  44237. * @product highcharts
  44238. */
  44239. distance: 30,
  44240. enabled: true,
  44241. /**
  44242. * A
  44243. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  44244. * for the data label. Available variables are the same as for
  44245. * `formatter`.
  44246. *
  44247. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  44248. * Add a unit
  44249. *
  44250. * @type {string}
  44251. * @default undefined
  44252. * @since 3.0
  44253. * @apioption plotOptions.pie.dataLabels.format
  44254. */
  44255. // eslint-disable-next-line valid-jsdoc
  44256. /**
  44257. * Callback JavaScript function to format the data label. Note that
  44258. * if a `format` is defined, the format takes precedence and the
  44259. * formatter is ignored.
  44260. *
  44261. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  44262. * @default function () { return this.point.isNull ? void 0 : this.point.name; }
  44263. */
  44264. formatter: function () {
  44265. return this.point.isNull ? void 0 : this.point.name;
  44266. },
  44267. /**
  44268. * Whether to render the connector as a soft arc or a line with
  44269. * sharp break. Works only if `connectorShape` equals to
  44270. * `fixedOffset`.
  44271. *
  44272. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-true/
  44273. * Soft
  44274. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-false/
  44275. * Non soft
  44276. *
  44277. * @since 2.1.7
  44278. * @product highcharts
  44279. */
  44280. softConnector: true,
  44281. /**
  44282. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow
  44283. * Long labels truncated with an ellipsis
  44284. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap
  44285. * Long labels are wrapped
  44286. *
  44287. * @type {Highcharts.CSSObject}
  44288. * @apioption plotOptions.pie.dataLabels.style
  44289. */
  44290. x: 0
  44291. },
  44292. /**
  44293. * If the total sum of the pie's values is 0, the series is represented
  44294. * as an empty circle . The `fillColor` option defines the color of that
  44295. * circle. Use [pie.borderWidth](#plotOptions.pie.borderWidth) to set
  44296. * the border thickness.
  44297. *
  44298. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44299. * Empty pie series
  44300. *
  44301. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44302. * @private
  44303. */
  44304. fillColor: void 0,
  44305. /**
  44306. * The end angle of the pie in degrees where 0 is top and 90 is right.
  44307. * Defaults to `startAngle` plus 360.
  44308. *
  44309. * @sample {highcharts} highcharts/demo/pie-semi-circle/
  44310. * Semi-circle donut
  44311. *
  44312. * @type {number}
  44313. * @since 1.3.6
  44314. * @product highcharts
  44315. * @apioption plotOptions.pie.endAngle
  44316. */
  44317. /**
  44318. * Equivalent to [chart.ignoreHiddenSeries](#chart.ignoreHiddenSeries),
  44319. * this option tells whether the series shall be redrawn as if the
  44320. * hidden point were `null`.
  44321. *
  44322. * The default value changed from `false` to `true` with Highcharts
  44323. * 3.0.
  44324. *
  44325. * @sample {highcharts} highcharts/plotoptions/pie-ignorehiddenpoint/
  44326. * True, the hiddden point is ignored
  44327. *
  44328. * @since 2.3.0
  44329. * @product highcharts
  44330. *
  44331. * @private
  44332. */
  44333. ignoreHiddenPoint: true,
  44334. /**
  44335. * @ignore-option
  44336. *
  44337. * @private
  44338. */
  44339. inactiveOtherPoints: true,
  44340. /**
  44341. * The size of the inner diameter for the pie. A size greater than 0
  44342. * renders a donut chart. Can be a percentage or pixel value.
  44343. * Percentages are relative to the pie size. Pixel values are given as
  44344. * integers.
  44345. *
  44346. *
  44347. * Note: in Highcharts < 4.1.2, the percentage was relative to the plot
  44348. * area, not the pie size.
  44349. *
  44350. * @sample {highcharts} highcharts/plotoptions/pie-innersize-80px/
  44351. * 80px inner size
  44352. * @sample {highcharts} highcharts/plotoptions/pie-innersize-50percent/
  44353. * 50% of the plot area
  44354. * @sample {highcharts} highcharts/demo/3d-pie-donut/
  44355. * 3D donut
  44356. *
  44357. * @type {number|string}
  44358. * @default 0
  44359. * @since 2.0
  44360. * @product highcharts
  44361. * @apioption plotOptions.pie.innerSize
  44362. */
  44363. /**
  44364. * @ignore-option
  44365. *
  44366. * @private
  44367. */
  44368. legendType: 'point',
  44369. /**
  44370. * @ignore-option
  44371. *
  44372. * @private
  44373. */
  44374. marker: null,
  44375. /**
  44376. * The minimum size for a pie in response to auto margins. The pie will
  44377. * try to shrink to make room for data labels in side the plot area,
  44378. * but only to this size.
  44379. *
  44380. * @type {number|string}
  44381. * @default 80
  44382. * @since 3.0
  44383. * @product highcharts
  44384. * @apioption plotOptions.pie.minSize
  44385. */
  44386. /**
  44387. * The diameter of the pie relative to the plot area. Can be a
  44388. * percentage or pixel value. Pixel values are given as integers. The
  44389. * default behaviour (as of 3.0) is to scale to the plot area and give
  44390. * room for data labels within the plot area.
  44391. * [slicedOffset](#plotOptions.pie.slicedOffset) is also included in the
  44392. * default size calculation. As a consequence, the size of the pie may
  44393. * vary when points are updated and data labels more around. In that
  44394. * case it is best to set a fixed value, for example `"75%"`.
  44395. *
  44396. * @sample {highcharts} highcharts/plotoptions/pie-size/
  44397. * Smaller pie
  44398. *
  44399. * @type {number|string|null}
  44400. * @product highcharts
  44401. *
  44402. * @private
  44403. */
  44404. size: null,
  44405. /**
  44406. * Whether to display this particular series or series type in the
  44407. * legend. Since 2.1, pies are not shown in the legend by default.
  44408. *
  44409. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  44410. * One series in the legend, one hidden
  44411. *
  44412. * @product highcharts
  44413. *
  44414. * @private
  44415. */
  44416. showInLegend: false,
  44417. /**
  44418. * If a point is sliced, moved out from the center, how many pixels
  44419. * should it be moved?.
  44420. *
  44421. * @sample {highcharts} highcharts/plotoptions/pie-slicedoffset-20/
  44422. * 20px offset
  44423. *
  44424. * @product highcharts
  44425. *
  44426. * @private
  44427. */
  44428. slicedOffset: 10,
  44429. /**
  44430. * The start angle of the pie slices in degrees where 0 is top and 90
  44431. * right.
  44432. *
  44433. * @sample {highcharts} highcharts/plotoptions/pie-startangle-90/
  44434. * Start from right
  44435. *
  44436. * @type {number}
  44437. * @default 0
  44438. * @since 2.3.4
  44439. * @product highcharts
  44440. * @apioption plotOptions.pie.startAngle
  44441. */
  44442. /**
  44443. * Sticky tracking of mouse events. When true, the `mouseOut` event
  44444. * on a series isn't triggered until the mouse moves over another
  44445. * series, or out of the plot area. When false, the `mouseOut` event on
  44446. * a series is triggered when the mouse leaves the area around the
  44447. * series' graph or markers. This also implies the tooltip. When
  44448. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  44449. * will be hidden when moving the mouse between series.
  44450. *
  44451. * @product highcharts
  44452. *
  44453. * @private
  44454. */
  44455. stickyTracking: false,
  44456. tooltip: {
  44457. followPointer: true
  44458. },
  44459. /**
  44460. * The color of the border surrounding each slice. When `null`, the
  44461. * border takes the same color as the slice fill. This can be used
  44462. * together with a `borderWidth` to fill drawing gaps created by
  44463. * antialiazing artefacts in borderless pies.
  44464. *
  44465. * In styled mode, the border stroke is given in the `.highcharts-point`
  44466. * class.
  44467. *
  44468. * @sample {highcharts} highcharts/plotoptions/pie-bordercolor-black/
  44469. * Black border
  44470. *
  44471. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44472. * @default #ffffff
  44473. * @product highcharts
  44474. *
  44475. * @private
  44476. */
  44477. borderColor: palette.backgroundColor,
  44478. /**
  44479. * The width of the border surrounding each slice.
  44480. *
  44481. * When setting the border width to 0, there may be small gaps between
  44482. * the slices due to SVG antialiasing artefacts. To work around this,
  44483. * keep the border width at 0.5 or 1, but set the `borderColor` to
  44484. * `null` instead.
  44485. *
  44486. * In styled mode, the border stroke width is given in the
  44487. * `.highcharts-point` class.
  44488. *
  44489. * @sample {highcharts} highcharts/plotoptions/pie-borderwidth/
  44490. * 3px border
  44491. *
  44492. * @product highcharts
  44493. *
  44494. * @private
  44495. */
  44496. borderWidth: 1,
  44497. /**
  44498. * @ignore-options
  44499. * @private
  44500. */
  44501. lineWidth: void 0,
  44502. states: {
  44503. /**
  44504. * @extends plotOptions.series.states.hover
  44505. * @excluding marker, lineWidth, lineWidthPlus
  44506. * @product highcharts
  44507. */
  44508. hover: {
  44509. /**
  44510. * How much to brighten the point on interaction. Requires the
  44511. * main color to be defined in hex or rgb(a) format.
  44512. *
  44513. * In styled mode, the hover brightness is by default replaced
  44514. * by a fill-opacity given in the `.highcharts-point-hover`
  44515. * class.
  44516. *
  44517. * @sample {highcharts} highcharts/plotoptions/pie-states-hover-brightness/
  44518. * Brightened by 0.5
  44519. *
  44520. * @product highcharts
  44521. */
  44522. brightness: 0.1
  44523. }
  44524. }
  44525. });
  44526. return PieSeries;
  44527. }(Series));
  44528. extend(PieSeries.prototype, {
  44529. axisTypes: [],
  44530. directTouch: true,
  44531. drawGraph: void 0,
  44532. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  44533. drawTracker: ColumnSeries.prototype.drawTracker,
  44534. getCenter: CenteredSeriesMixin.getCenter,
  44535. getSymbol: noop,
  44536. isCartesian: false,
  44537. noSharedTooltip: true,
  44538. pointAttribs: ColumnSeries.prototype.pointAttribs,
  44539. pointClass: PiePoint,
  44540. requireSorting: false,
  44541. searchPoint: noop,
  44542. trackerGroups: ['group', 'dataLabelsGroup']
  44543. });
  44544. SeriesRegistry.registerSeriesType('pie', PieSeries);
  44545. /* *
  44546. *
  44547. * Default Export
  44548. *
  44549. * */
  44550. /* *
  44551. *
  44552. * API Options
  44553. *
  44554. * */
  44555. /**
  44556. * A `pie` series. If the [type](#series.pie.type) option is not specified,
  44557. * it is inherited from [chart.type](#chart.type).
  44558. *
  44559. * @extends series,plotOptions.pie
  44560. * @excluding cropThreshold, dataParser, dataURL, stack, xAxis, yAxis,
  44561. * dataSorting, step, boostThreshold, boostBlending
  44562. * @product highcharts
  44563. * @apioption series.pie
  44564. */
  44565. /**
  44566. * An array of data points for the series. For the `pie` series type,
  44567. * points can be given in the following ways:
  44568. *
  44569. * 1. An array of numerical values. In this case, the numerical values will be
  44570. * interpreted as `y` options. Example:
  44571. * ```js
  44572. * data: [0, 5, 3, 5]
  44573. * ```
  44574. *
  44575. * 2. An array of objects with named values. The following snippet shows only a
  44576. * few settings, see the complete options set below. If the total number of
  44577. * data points exceeds the series'
  44578. * [turboThreshold](#series.pie.turboThreshold),
  44579. * this option is not available.
  44580. * ```js
  44581. * data: [{
  44582. * y: 1,
  44583. * name: "Point2",
  44584. * color: "#00FF00"
  44585. * }, {
  44586. * y: 7,
  44587. * name: "Point1",
  44588. * color: "#FF00FF"
  44589. * }]
  44590. * ```
  44591. *
  44592. * @sample {highcharts} highcharts/chart/reflow-true/
  44593. * Numerical values
  44594. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  44595. * Arrays of numeric x and y
  44596. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  44597. * Arrays of datetime x and y
  44598. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  44599. * Arrays of point.name and y
  44600. * @sample {highcharts} highcharts/series/data-array-of-objects/
  44601. * Config objects
  44602. *
  44603. * @type {Array<number|Array<string,(number|null)>|null|*>}
  44604. * @extends series.line.data
  44605. * @excluding marker, x
  44606. * @product highcharts
  44607. * @apioption series.pie.data
  44608. */
  44609. /**
  44610. * @type {Highcharts.SeriesPieDataLabelsOptionsObject}
  44611. * @product highcharts
  44612. * @apioption series.pie.data.dataLabels
  44613. */
  44614. /**
  44615. * The sequential index of the data point in the legend.
  44616. *
  44617. * @type {number}
  44618. * @product highcharts
  44619. * @apioption series.pie.data.legendIndex
  44620. */
  44621. /**
  44622. * Whether to display a slice offset from the center.
  44623. *
  44624. * @sample {highcharts} highcharts/point/sliced/
  44625. * One sliced point
  44626. *
  44627. * @type {boolean}
  44628. * @product highcharts
  44629. * @apioption series.pie.data.sliced
  44630. */
  44631. /**
  44632. * @extends plotOptions.pie.dataLabels
  44633. * @excluding align, allowOverlap, inside, staggerLines, step
  44634. * @product highcharts
  44635. * @apioption series.pie.dataLabels
  44636. */
  44637. /**
  44638. * @excluding legendItemClick
  44639. * @product highcharts
  44640. * @apioption series.pie.events
  44641. */
  44642. ''; // placeholder for transpiled doclets above
  44643. return PieSeries;
  44644. });
  44645. _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) {
  44646. /* *
  44647. *
  44648. * (c) 2010-2021 Torstein Honsi
  44649. *
  44650. * License: www.highcharts.com/license
  44651. *
  44652. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  44653. *
  44654. * */
  44655. var getDeferredAnimation = A.getDeferredAnimation;
  44656. var format = F.format;
  44657. var noop = H.noop;
  44658. var seriesTypes = SeriesRegistry.seriesTypes;
  44659. var arrayMax = U.arrayMax,
  44660. clamp = U.clamp,
  44661. defined = U.defined,
  44662. extend = U.extend,
  44663. fireEvent = U.fireEvent,
  44664. isArray = U.isArray,
  44665. merge = U.merge,
  44666. objectEach = U.objectEach,
  44667. pick = U.pick,
  44668. relativeLength = U.relativeLength,
  44669. splat = U.splat,
  44670. stableSort = U.stableSort;
  44671. /**
  44672. * Callback JavaScript function to format the data label as a string. Note that
  44673. * if a `format` is defined, the format takes precedence and the formatter is
  44674. * ignored.
  44675. *
  44676. * @callback Highcharts.DataLabelsFormatterCallbackFunction
  44677. *
  44678. * @param {Highcharts.PointLabelObject} this
  44679. * Data label context to format
  44680. *
  44681. * @param {Highcharts.DataLabelsOptions} options
  44682. * [API options](/highcharts/plotOptions.series.dataLabels) of the data label
  44683. *
  44684. * @return {number|string|null|undefined}
  44685. * Formatted data label text
  44686. */
  44687. /**
  44688. * Values for handling data labels that flow outside the plot area.
  44689. *
  44690. * @typedef {"allow"|"justify"} Highcharts.DataLabelsOverflowValue
  44691. */
  44692. ''; // detach doclets above
  44693. /* eslint-disable valid-jsdoc */
  44694. /**
  44695. * General distribution algorithm for distributing labels of differing size
  44696. * along a confined length in two dimensions. The algorithm takes an array of
  44697. * objects containing a size, a target and a rank. It will place the labels as
  44698. * close as possible to their targets, skipping the lowest ranked labels if
  44699. * necessary.
  44700. *
  44701. * @private
  44702. * @function Highcharts.distribute
  44703. * @param {Highcharts.DataLabelsBoxArray} boxes
  44704. * @param {number} len
  44705. * @param {number} [maxDistance]
  44706. * @return {void}
  44707. */
  44708. H.distribute = function (boxes, len, maxDistance) {
  44709. var i,
  44710. overlapping = true,
  44711. origBoxes = boxes, // Original array will be altered with added .pos
  44712. restBoxes = [], // The outranked overshoot
  44713. box,
  44714. target,
  44715. total = 0,
  44716. reducedLen = origBoxes.reducedLen || len;
  44717. /**
  44718. * @private
  44719. */
  44720. function sortByTarget(a, b) {
  44721. return a.target - b.target;
  44722. }
  44723. // If the total size exceeds the len, remove those boxes with the lowest
  44724. // rank
  44725. i = boxes.length;
  44726. while (i--) {
  44727. total += boxes[i].size;
  44728. }
  44729. // Sort by rank, then slice away overshoot
  44730. if (total > reducedLen) {
  44731. stableSort(boxes, function (a, b) {
  44732. return (b.rank || 0) - (a.rank || 0);
  44733. });
  44734. i = 0;
  44735. total = 0;
  44736. while (total <= reducedLen) {
  44737. total += boxes[i].size;
  44738. i++;
  44739. }
  44740. restBoxes = boxes.splice(i - 1, boxes.length);
  44741. }
  44742. // Order by target
  44743. stableSort(boxes, sortByTarget);
  44744. // So far we have been mutating the original array. Now
  44745. // create a copy with target arrays
  44746. boxes = boxes.map(function (box) {
  44747. return {
  44748. size: box.size,
  44749. targets: [box.target],
  44750. align: pick(box.align, 0.5)
  44751. };
  44752. });
  44753. while (overlapping) {
  44754. // Initial positions: target centered in box
  44755. i = boxes.length;
  44756. while (i--) {
  44757. box = boxes[i];
  44758. // Composite box, average of targets
  44759. target = (Math.min.apply(0, box.targets) +
  44760. Math.max.apply(0, box.targets)) / 2;
  44761. box.pos = clamp(target - box.size * box.align, 0, len - box.size);
  44762. }
  44763. // Detect overlap and join boxes
  44764. i = boxes.length;
  44765. overlapping = false;
  44766. while (i--) {
  44767. // Overlap
  44768. if (i > 0 &&
  44769. boxes[i - 1].pos + boxes[i - 1].size >
  44770. boxes[i].pos) {
  44771. // Add this size to the previous box
  44772. boxes[i - 1].size += boxes[i].size;
  44773. boxes[i - 1].targets = boxes[i - 1]
  44774. .targets
  44775. .concat(boxes[i].targets);
  44776. boxes[i - 1].align = 0.5;
  44777. // Overlapping right, push left
  44778. if (boxes[i - 1].pos + boxes[i - 1].size > len) {
  44779. boxes[i - 1].pos = len - boxes[i - 1].size;
  44780. }
  44781. boxes.splice(i, 1); // Remove this item
  44782. overlapping = true;
  44783. }
  44784. }
  44785. }
  44786. // Add the rest (hidden boxes)
  44787. origBoxes.push.apply(origBoxes, restBoxes);
  44788. // Now the composite boxes are placed, we need to put the original boxes
  44789. // within them
  44790. i = 0;
  44791. boxes.some(function (box) {
  44792. var posInCompositeBox = 0;
  44793. if (box.targets.some(function () {
  44794. origBoxes[i].pos = box.pos + posInCompositeBox;
  44795. // If the distance between the position and the target exceeds
  44796. // maxDistance, abort the loop and decrease the length in increments
  44797. // of 10% to recursively reduce the number of visible boxes by
  44798. // rank. Once all boxes are within the maxDistance, we're good.
  44799. if (typeof maxDistance !== 'undefined' &&
  44800. Math.abs(origBoxes[i].pos - origBoxes[i].target) > maxDistance) {
  44801. // Reset the positions that are already set
  44802. origBoxes.slice(0, i + 1).forEach(function (box) {
  44803. delete box.pos;
  44804. });
  44805. // Try with a smaller length
  44806. origBoxes.reducedLen =
  44807. (origBoxes.reducedLen || len) - (len * 0.1);
  44808. // Recurse
  44809. if (origBoxes.reducedLen > len * 0.1) {
  44810. H.distribute(origBoxes, len, maxDistance);
  44811. }
  44812. // Exceeded maxDistance => abort
  44813. return true;
  44814. }
  44815. posInCompositeBox += origBoxes[i].size;
  44816. i++;
  44817. })) {
  44818. // Exceeded maxDistance => abort
  44819. return true;
  44820. }
  44821. });
  44822. // Add the rest (hidden) boxes and sort by target
  44823. stableSort(origBoxes, sortByTarget);
  44824. };
  44825. /**
  44826. * Draw the data labels
  44827. *
  44828. * @private
  44829. * @function Highcharts.Series#drawDataLabels
  44830. * @return {void}
  44831. * @fires Highcharts.Series#event:afterDrawDataLabels
  44832. */
  44833. Series.prototype.drawDataLabels = function () {
  44834. var series = this,
  44835. chart = series.chart,
  44836. seriesOptions = series.options,
  44837. seriesDlOptions = seriesOptions.dataLabels,
  44838. points = series.points,
  44839. pointOptions,
  44840. hasRendered = series.hasRendered || 0,
  44841. dataLabelsGroup,
  44842. dataLabelAnim = seriesDlOptions.animation,
  44843. animationConfig = seriesDlOptions.defer ?
  44844. getDeferredAnimation(chart,
  44845. dataLabelAnim,
  44846. series) :
  44847. { defer: 0,
  44848. duration: 0 },
  44849. renderer = chart.renderer;
  44850. /**
  44851. * Handle the dataLabels.filter option.
  44852. * @private
  44853. */
  44854. function applyFilter(point, options) {
  44855. var filter = options.filter,
  44856. op,
  44857. prop,
  44858. val;
  44859. if (filter) {
  44860. op = filter.operator;
  44861. prop = point[filter.property];
  44862. val = filter.value;
  44863. if ((op === '>' && prop > val) ||
  44864. (op === '<' && prop < val) ||
  44865. (op === '>=' && prop >= val) ||
  44866. (op === '<=' && prop <= val) ||
  44867. (op === '==' && prop == val) || // eslint-disable-line eqeqeq
  44868. (op === '===' && prop === val)) {
  44869. return true;
  44870. }
  44871. return false;
  44872. }
  44873. return true;
  44874. }
  44875. /**
  44876. * Merge two objects that can be arrays. If one of them is an array, the
  44877. * other is merged into each element. If both are arrays, each element is
  44878. * merged by index. If neither are arrays, we use normal merge.
  44879. * @private
  44880. */
  44881. function mergeArrays(one, two) {
  44882. var res = [],
  44883. i;
  44884. if (isArray(one) && !isArray(two)) {
  44885. res = one.map(function (el) {
  44886. return merge(el, two);
  44887. });
  44888. }
  44889. else if (isArray(two) && !isArray(one)) {
  44890. res = two.map(function (el) {
  44891. return merge(one, el);
  44892. });
  44893. }
  44894. else if (!isArray(one) && !isArray(two)) {
  44895. res = merge(one, two);
  44896. }
  44897. else {
  44898. i = Math.max(one.length, two.length);
  44899. while (i--) {
  44900. res[i] = merge(one[i], two[i]);
  44901. }
  44902. }
  44903. return res;
  44904. }
  44905. // Merge in plotOptions.dataLabels for series
  44906. seriesDlOptions = mergeArrays(mergeArrays(chart.options.plotOptions &&
  44907. chart.options.plotOptions.series &&
  44908. chart.options.plotOptions.series.dataLabels, chart.options.plotOptions &&
  44909. chart.options.plotOptions[series.type] &&
  44910. chart.options.plotOptions[series.type].dataLabels), seriesDlOptions);
  44911. fireEvent(this, 'drawDataLabels');
  44912. if (isArray(seriesDlOptions) ||
  44913. seriesDlOptions.enabled ||
  44914. series._hasPointLabels) {
  44915. // Create a separate group for the data labels to avoid rotation
  44916. dataLabelsGroup = series.plotGroup('dataLabelsGroup', 'data-labels', !hasRendered ? 'hidden' : 'inherit', // #5133, #10220
  44917. seriesDlOptions.zIndex || 6);
  44918. dataLabelsGroup.attr({ opacity: +hasRendered }); // #3300
  44919. if (!hasRendered) {
  44920. var group = series.dataLabelsGroup;
  44921. if (group) {
  44922. if (series.visible) { // #2597, #3023, #3024
  44923. dataLabelsGroup.show(true);
  44924. }
  44925. group[seriesOptions.animation ? 'animate' : 'attr']({ opacity: 1 }, animationConfig);
  44926. }
  44927. }
  44928. // Make the labels for each point
  44929. points.forEach(function (point) {
  44930. // Merge in series options for the point.
  44931. // @note dataLabelAttribs (like pointAttribs) would eradicate
  44932. // the need for dlOptions, and simplify the section below.
  44933. pointOptions = splat(mergeArrays(seriesDlOptions, point.dlOptions || // dlOptions is used in treemaps
  44934. (point.options && point.options.dataLabels)));
  44935. // Handle each individual data label for this point
  44936. pointOptions.forEach(function (labelOptions, i) {
  44937. // Options for one datalabel
  44938. var labelEnabled = (labelOptions.enabled &&
  44939. // #2282, #4641, #7112, #10049
  44940. (!point.isNull || point.dataLabelOnNull) &&
  44941. applyFilter(point,
  44942. labelOptions)),
  44943. labelConfig,
  44944. formatString,
  44945. labelText,
  44946. style,
  44947. rotation,
  44948. attr,
  44949. dataLabel = point.dataLabels ? point.dataLabels[i] :
  44950. point.dataLabel,
  44951. connector = point.connectors ? point.connectors[i] :
  44952. point.connector,
  44953. labelDistance = pick(labelOptions.distance,
  44954. point.labelDistance),
  44955. isNew = !dataLabel;
  44956. if (labelEnabled) {
  44957. // Create individual options structure that can be extended
  44958. // without affecting others
  44959. labelConfig = point.getLabelConfig();
  44960. formatString = pick(labelOptions[point.formatPrefix + 'Format'], labelOptions.format);
  44961. labelText = defined(formatString) ?
  44962. format(formatString, labelConfig, chart) :
  44963. (labelOptions[point.formatPrefix + 'Formatter'] ||
  44964. labelOptions.formatter).call(labelConfig, labelOptions);
  44965. style = labelOptions.style;
  44966. rotation = labelOptions.rotation;
  44967. if (!chart.styledMode) {
  44968. // Determine the color
  44969. style.color = pick(labelOptions.color, style.color, series.color, palette.neutralColor100);
  44970. // Get automated contrast color
  44971. if (style.color === 'contrast') {
  44972. point.contrastColor = renderer.getContrast((point.color || series.color));
  44973. style.color = (!defined(labelDistance) &&
  44974. labelOptions.inside) ||
  44975. labelDistance < 0 ||
  44976. !!seriesOptions.stacking ?
  44977. point.contrastColor :
  44978. palette.neutralColor100;
  44979. }
  44980. else {
  44981. delete point.contrastColor;
  44982. }
  44983. if (seriesOptions.cursor) {
  44984. style.cursor = seriesOptions.cursor;
  44985. }
  44986. }
  44987. attr = {
  44988. r: labelOptions.borderRadius || 0,
  44989. rotation: rotation,
  44990. padding: labelOptions.padding,
  44991. zIndex: 1
  44992. };
  44993. if (!chart.styledMode) {
  44994. attr.fill = labelOptions.backgroundColor;
  44995. attr.stroke = labelOptions.borderColor;
  44996. attr['stroke-width'] = labelOptions.borderWidth;
  44997. }
  44998. // Remove unused attributes (#947)
  44999. objectEach(attr, function (val, name) {
  45000. if (typeof val === 'undefined') {
  45001. delete attr[name];
  45002. }
  45003. });
  45004. }
  45005. // If the point is outside the plot area, destroy it. #678, #820
  45006. if (dataLabel && (!labelEnabled || !defined(labelText))) {
  45007. point.dataLabel =
  45008. point.dataLabel && point.dataLabel.destroy();
  45009. if (point.dataLabels) {
  45010. // Remove point.dataLabels if this was the last one
  45011. if (point.dataLabels.length === 1) {
  45012. delete point.dataLabels;
  45013. }
  45014. else {
  45015. delete point.dataLabels[i];
  45016. }
  45017. }
  45018. if (!i) {
  45019. delete point.dataLabel;
  45020. }
  45021. if (connector) {
  45022. point.connector = point.connector.destroy();
  45023. if (point.connectors) {
  45024. // Remove point.connectors if this was the last one
  45025. if (point.connectors.length === 1) {
  45026. delete point.connectors;
  45027. }
  45028. else {
  45029. delete point.connectors[i];
  45030. }
  45031. }
  45032. }
  45033. // Individual labels are disabled if the are explicitly disabled
  45034. // in the point options, or if they fall outside the plot area.
  45035. }
  45036. else if (labelEnabled && defined(labelText)) {
  45037. if (!dataLabel) {
  45038. // Create new label element
  45039. point.dataLabels = point.dataLabels || [];
  45040. dataLabel = point.dataLabels[i] = rotation ?
  45041. // Labels don't rotate, use text element
  45042. renderer.text(labelText, 0, -9999, labelOptions.useHTML)
  45043. .addClass('highcharts-data-label') :
  45044. // We can use label
  45045. renderer.label(labelText, 0, -9999, labelOptions.shape, null, null, labelOptions.useHTML, null, 'data-label');
  45046. // Store for backwards compatibility
  45047. if (!i) {
  45048. point.dataLabel = dataLabel;
  45049. }
  45050. dataLabel.addClass(' highcharts-data-label-color-' + point.colorIndex +
  45051. ' ' + (labelOptions.className || '') +
  45052. ( // #3398
  45053. labelOptions.useHTML ?
  45054. ' highcharts-tracker' :
  45055. ''));
  45056. }
  45057. else {
  45058. // Use old element and just update text
  45059. attr.text = labelText;
  45060. }
  45061. // Store data label options for later access
  45062. dataLabel.options = labelOptions;
  45063. dataLabel.attr(attr);
  45064. if (!chart.styledMode) {
  45065. // Styles must be applied before add in order to read
  45066. // text bounding box
  45067. dataLabel.css(style).shadow(labelOptions.shadow);
  45068. }
  45069. if (!dataLabel.added) {
  45070. dataLabel.add(dataLabelsGroup);
  45071. }
  45072. if (labelOptions.textPath && !labelOptions.useHTML) {
  45073. dataLabel.setTextPath((point.getDataLabelPath &&
  45074. point.getDataLabelPath(dataLabel)) || point.graphic, labelOptions.textPath);
  45075. if (point.dataLabelPath &&
  45076. !labelOptions.textPath.enabled) {
  45077. // clean the DOM
  45078. point.dataLabelPath = point.dataLabelPath.destroy();
  45079. }
  45080. }
  45081. // Now the data label is created and placed at 0,0, so we
  45082. // need to align it
  45083. series.alignDataLabel(point, dataLabel, labelOptions, null, isNew);
  45084. }
  45085. });
  45086. });
  45087. }
  45088. fireEvent(this, 'afterDrawDataLabels');
  45089. };
  45090. /**
  45091. * Align each individual data label.
  45092. *
  45093. * @private
  45094. * @function Highcharts.Series#alignDataLabel
  45095. * @param {Highcharts.Point} point
  45096. * @param {Highcharts.SVGElement} dataLabel
  45097. * @param {Highcharts.DataLabelsOptions} options
  45098. * @param {Highcharts.BBoxObject} alignTo
  45099. * @param {boolean} [isNew]
  45100. * @return {void}
  45101. */
  45102. Series.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  45103. var series = this,
  45104. chart = this.chart,
  45105. inverted = this.isCartesian && chart.inverted,
  45106. enabledDataSorting = this.enabledDataSorting,
  45107. plotX = pick(point.dlBox && point.dlBox.centerX,
  45108. point.plotX, -9999),
  45109. plotY = pick(point.plotY, -9999),
  45110. bBox = dataLabel.getBBox(),
  45111. baseline,
  45112. rotation = options.rotation,
  45113. normRotation,
  45114. negRotation,
  45115. align = options.align,
  45116. rotCorr, // rotation correction
  45117. isInsidePlot = chart.isInsidePlot(plotX,
  45118. Math.round(plotY), {
  45119. inverted: inverted,
  45120. paneCoordinates: true,
  45121. series: series
  45122. }),
  45123. // Math.round for rounding errors (#2683), alignTo to allow column
  45124. // labels (#2700)
  45125. alignAttr, // the final position;
  45126. justify = pick(options.overflow, (enabledDataSorting ? 'none' : 'justify')) === 'justify', visible = this.visible &&
  45127. point.visible !== false &&
  45128. (point.series.forceDL ||
  45129. (enabledDataSorting && !justify) ||
  45130. isInsidePlot ||
  45131. (
  45132. // If the data label is inside the align box, it is enough
  45133. // that parts of the align box is inside the plot area
  45134. // (#12370). When stacking, it is always inside regardless
  45135. // of the option (#15148).
  45136. pick(options.inside, !!this.options.stacking) &&
  45137. alignTo &&
  45138. chart.isInsidePlot(plotX, inverted ?
  45139. alignTo.x + 1 :
  45140. alignTo.y + alignTo.height - 1, {
  45141. inverted: inverted,
  45142. paneCoordinates: true,
  45143. series: series
  45144. }))), setStartPos = function (alignOptions) {
  45145. if (enabledDataSorting && series.xAxis && !justify) {
  45146. series.setDataLabelStartPos(point, dataLabel, isNew, isInsidePlot, alignOptions);
  45147. }
  45148. };
  45149. if (visible) {
  45150. baseline = chart.renderer.fontMetrics(chart.styledMode ? void 0 : options.style.fontSize, dataLabel).b;
  45151. // The alignment box is a singular point
  45152. alignTo = extend({
  45153. x: inverted ? this.yAxis.len - plotY : plotX,
  45154. y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
  45155. width: 0,
  45156. height: 0
  45157. }, alignTo);
  45158. // Add the text size for alignment calculation
  45159. extend(options, {
  45160. width: bBox.width,
  45161. height: bBox.height
  45162. });
  45163. // Allow a hook for changing alignment in the last moment, then do the
  45164. // alignment
  45165. if (rotation) {
  45166. justify = false; // Not supported for rotated text
  45167. rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
  45168. alignAttr = {
  45169. x: (alignTo.x +
  45170. (options.x || 0) +
  45171. alignTo.width / 2 +
  45172. rotCorr.x),
  45173. y: (alignTo.y +
  45174. (options.y || 0) +
  45175. { top: 0, middle: 0.5, bottom: 1 }[options.verticalAlign] *
  45176. alignTo.height)
  45177. };
  45178. setStartPos(alignAttr); // data sorting
  45179. dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
  45180. .attr({
  45181. align: align
  45182. });
  45183. // Compensate for the rotated label sticking out on the sides
  45184. normRotation = (rotation + 720) % 360;
  45185. negRotation = normRotation > 180 && normRotation < 360;
  45186. if (align === 'left') {
  45187. alignAttr.y -= negRotation ? bBox.height : 0;
  45188. }
  45189. else if (align === 'center') {
  45190. alignAttr.x -= bBox.width / 2;
  45191. alignAttr.y -= bBox.height / 2;
  45192. }
  45193. else if (align === 'right') {
  45194. alignAttr.x -= bBox.width;
  45195. alignAttr.y -= negRotation ? 0 : bBox.height;
  45196. }
  45197. dataLabel.placed = true;
  45198. dataLabel.alignAttr = alignAttr;
  45199. }
  45200. else {
  45201. setStartPos(alignTo); // data sorting
  45202. dataLabel.align(options, void 0, alignTo);
  45203. alignAttr = dataLabel.alignAttr;
  45204. }
  45205. // Handle justify or crop
  45206. if (justify && alignTo.height >= 0) { // #8830
  45207. this.justifyDataLabel(dataLabel, options, alignAttr, bBox, alignTo, isNew);
  45208. // Now check that the data label is within the plot area
  45209. }
  45210. else if (pick(options.crop, true)) {
  45211. visible =
  45212. chart.isInsidePlot(alignAttr.x, alignAttr.y, {
  45213. paneCoordinates: true,
  45214. series: series
  45215. }) &&
  45216. chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height, {
  45217. paneCoordinates: true,
  45218. series: series
  45219. });
  45220. }
  45221. // When we're using a shape, make it possible with a connector or an
  45222. // arrow pointing to thie point
  45223. if (options.shape && !rotation) {
  45224. dataLabel[isNew ? 'attr' : 'animate']({
  45225. anchorX: inverted ?
  45226. chart.plotWidth - point.plotY :
  45227. point.plotX,
  45228. anchorY: inverted ?
  45229. chart.plotHeight - point.plotX :
  45230. point.plotY
  45231. });
  45232. }
  45233. }
  45234. // To use alignAttr property in hideOverlappingLabels
  45235. if (isNew && enabledDataSorting) {
  45236. dataLabel.placed = false;
  45237. }
  45238. // Show or hide based on the final aligned position
  45239. if (!visible && (!enabledDataSorting || justify)) {
  45240. dataLabel.hide(true);
  45241. dataLabel.placed = false; // don't animate back in
  45242. }
  45243. };
  45244. /**
  45245. * Set starting position for data label sorting animation.
  45246. *
  45247. * @private
  45248. * @function Highcharts.Series#setDataLabelStartPos
  45249. * @param {Highcharts.SVGElement} dataLabel
  45250. * @param {Highcharts.ColumnPoint} point
  45251. * @param {boolean | undefined} [isNew]
  45252. * @param {boolean} [isInside]
  45253. * @param {Highcharts.AlignObject} [alignOptions]
  45254. *
  45255. * @return {void}
  45256. */
  45257. Series.prototype.setDataLabelStartPos = function (point, dataLabel, isNew, isInside, alignOptions) {
  45258. var chart = this.chart,
  45259. inverted = chart.inverted,
  45260. xAxis = this.xAxis,
  45261. reversed = xAxis.reversed,
  45262. labelCenter = inverted ? dataLabel.height / 2 : dataLabel.width / 2,
  45263. pointWidth = point.pointWidth,
  45264. halfWidth = pointWidth ? pointWidth / 2 : 0,
  45265. startXPos,
  45266. startYPos;
  45267. startXPos = inverted ?
  45268. alignOptions.x :
  45269. (reversed ?
  45270. -labelCenter - halfWidth :
  45271. xAxis.width - labelCenter + halfWidth);
  45272. startYPos = inverted ?
  45273. (reversed ?
  45274. this.yAxis.height - labelCenter + halfWidth :
  45275. -labelCenter - halfWidth) : alignOptions.y;
  45276. dataLabel.startXPos = startXPos;
  45277. dataLabel.startYPos = startYPos;
  45278. // We need to handle visibility in case of sorting point outside plot area
  45279. if (!isInside) {
  45280. dataLabel
  45281. .attr({ opacity: 1 })
  45282. .animate({ opacity: 0 }, void 0, dataLabel.hide);
  45283. }
  45284. else if (dataLabel.visibility === 'hidden') {
  45285. dataLabel.show();
  45286. dataLabel
  45287. .attr({ opacity: 0 })
  45288. .animate({ opacity: 1 });
  45289. }
  45290. // Save start position on first render, but do not change position
  45291. if (!chart.hasRendered) {
  45292. return;
  45293. }
  45294. // Set start position
  45295. if (isNew) {
  45296. dataLabel.attr({ x: dataLabel.startXPos, y: dataLabel.startYPos });
  45297. }
  45298. dataLabel.placed = true;
  45299. };
  45300. /**
  45301. * If data labels fall partly outside the plot area, align them back in, in a
  45302. * way that doesn't hide the point.
  45303. *
  45304. * @private
  45305. * @function Highcharts.Series#justifyDataLabel
  45306. * @param {Highcharts.SVGElement} dataLabel
  45307. * @param {Highcharts.DataLabelsOptions} options
  45308. * @param {Highcharts.SVGAttributes} alignAttr
  45309. * @param {Highcharts.BBoxObject} bBox
  45310. * @param {Highcharts.BBoxObject} [alignTo]
  45311. * @param {boolean} [isNew]
  45312. * @return {boolean|undefined}
  45313. */
  45314. Series.prototype.justifyDataLabel = function (dataLabel, options, alignAttr, bBox, alignTo, isNew) {
  45315. var chart = this.chart,
  45316. align = options.align,
  45317. verticalAlign = options.verticalAlign,
  45318. off,
  45319. justified,
  45320. padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
  45321. var _a = options.x,
  45322. x = _a === void 0 ? 0 : _a,
  45323. _b = options.y,
  45324. y = _b === void 0 ? 0 : _b;
  45325. // Off left
  45326. off = (alignAttr.x || 0) + padding;
  45327. if (off < 0) {
  45328. if (align === 'right' && x >= 0) {
  45329. options.align = 'left';
  45330. options.inside = true;
  45331. }
  45332. else {
  45333. x -= off;
  45334. }
  45335. justified = true;
  45336. }
  45337. // Off right
  45338. off = (alignAttr.x || 0) + bBox.width - padding;
  45339. if (off > chart.plotWidth) {
  45340. if (align === 'left' && x <= 0) {
  45341. options.align = 'right';
  45342. options.inside = true;
  45343. }
  45344. else {
  45345. x += chart.plotWidth - off;
  45346. }
  45347. justified = true;
  45348. }
  45349. // Off top
  45350. off = alignAttr.y + padding;
  45351. if (off < 0) {
  45352. if (verticalAlign === 'bottom' && y >= 0) {
  45353. options.verticalAlign = 'top';
  45354. options.inside = true;
  45355. }
  45356. else {
  45357. y -= off;
  45358. }
  45359. justified = true;
  45360. }
  45361. // Off bottom
  45362. off = (alignAttr.y || 0) + bBox.height - padding;
  45363. if (off > chart.plotHeight) {
  45364. if (verticalAlign === 'top' && y <= 0) {
  45365. options.verticalAlign = 'bottom';
  45366. options.inside = true;
  45367. }
  45368. else {
  45369. y += chart.plotHeight - off;
  45370. }
  45371. justified = true;
  45372. }
  45373. if (justified) {
  45374. options.x = x;
  45375. options.y = y;
  45376. dataLabel.placed = !isNew;
  45377. dataLabel.align(options, void 0, alignTo);
  45378. }
  45379. return justified;
  45380. };
  45381. if (seriesTypes.pie) {
  45382. seriesTypes.pie.prototype.dataLabelPositioners = {
  45383. // Based on the value computed in Highcharts' distribute algorithm.
  45384. radialDistributionY: function (point) {
  45385. return point.top + point.distributeBox.pos;
  45386. },
  45387. // get the x - use the natural x position for labels near the
  45388. // top and bottom, to prevent the top and botton slice
  45389. // connectors from touching each other on either side
  45390. // Based on the value computed in Highcharts' distribute algorithm.
  45391. radialDistributionX: function (series, point, y, naturalY) {
  45392. return series.getX(y < point.top + 2 || y > point.bottom - 2 ?
  45393. naturalY :
  45394. y, point.half, point);
  45395. },
  45396. // dataLabels.distance determines the x position of the label
  45397. justify: function (point, radius, seriesCenter) {
  45398. return seriesCenter[0] + (point.half ? -1 : 1) *
  45399. (radius + point.labelDistance);
  45400. },
  45401. // Left edges of the left-half labels touch the left edge of the plot
  45402. // area. Right edges of the right-half labels touch the right edge of
  45403. // the plot area.
  45404. alignToPlotEdges: function (dataLabel, half, plotWidth, plotLeft) {
  45405. var dataLabelWidth = dataLabel.getBBox().width;
  45406. return half ? dataLabelWidth + plotLeft :
  45407. plotWidth - dataLabelWidth - plotLeft;
  45408. },
  45409. // Connectors of each side end in the same x position. Labels are
  45410. // aligned to them. Left edge of the widest left-half label touches the
  45411. // left edge of the plot area. Right edge of the widest right-half label
  45412. // touches the right edge of the plot area.
  45413. alignToConnectors: function (points, half, plotWidth, plotLeft) {
  45414. var maxDataLabelWidth = 0,
  45415. dataLabelWidth;
  45416. // find widest data label
  45417. points.forEach(function (point) {
  45418. dataLabelWidth = point.dataLabel.getBBox().width;
  45419. if (dataLabelWidth > maxDataLabelWidth) {
  45420. maxDataLabelWidth = dataLabelWidth;
  45421. }
  45422. });
  45423. return half ? maxDataLabelWidth + plotLeft :
  45424. plotWidth - maxDataLabelWidth - plotLeft;
  45425. }
  45426. };
  45427. /**
  45428. * Override the base drawDataLabels method by pie specific functionality
  45429. *
  45430. * @private
  45431. * @function Highcharts.seriesTypes.pie#drawDataLabels
  45432. * @return {void}
  45433. */
  45434. seriesTypes.pie.prototype.drawDataLabels = function () {
  45435. var series = this,
  45436. data = series.data,
  45437. point,
  45438. chart = series.chart,
  45439. options = series.options.dataLabels || {},
  45440. connectorPadding = options.connectorPadding,
  45441. connectorWidth,
  45442. plotWidth = chart.plotWidth,
  45443. plotHeight = chart.plotHeight,
  45444. plotLeft = chart.plotLeft,
  45445. maxWidth = Math.round(chart.chartWidth / 3),
  45446. connector,
  45447. seriesCenter = series.center,
  45448. radius = seriesCenter[2] / 2,
  45449. centerY = seriesCenter[1],
  45450. dataLabel,
  45451. dataLabelWidth,
  45452. // labelPos,
  45453. labelPosition,
  45454. labelHeight,
  45455. // divide the points into right and left halves for anti collision
  45456. halves = [
  45457. [],
  45458. [] // left
  45459. ],
  45460. x,
  45461. y,
  45462. visibility,
  45463. j,
  45464. overflow = [0, 0, 0, 0], // top, right, bottom, left
  45465. dataLabelPositioners = series.dataLabelPositioners,
  45466. pointDataLabelsOptions;
  45467. // get out if not enabled
  45468. if (!series.visible ||
  45469. (!options.enabled &&
  45470. !series._hasPointLabels)) {
  45471. return;
  45472. }
  45473. // Reset all labels that have been shortened
  45474. data.forEach(function (point) {
  45475. if (point.dataLabel && point.visible && point.dataLabel.shortened) {
  45476. point.dataLabel
  45477. .attr({
  45478. width: 'auto'
  45479. }).css({
  45480. width: 'auto',
  45481. textOverflow: 'clip'
  45482. });
  45483. point.dataLabel.shortened = false;
  45484. }
  45485. });
  45486. // run parent method
  45487. Series.prototype.drawDataLabels.apply(series);
  45488. data.forEach(function (point) {
  45489. if (point.dataLabel) {
  45490. if (point.visible) { // #407, #2510
  45491. // Arrange points for detection collision
  45492. halves[point.half].push(point);
  45493. // Reset positions (#4905)
  45494. point.dataLabel._pos = null;
  45495. // Avoid long labels squeezing the pie size too far down
  45496. if (!defined(options.style.width) &&
  45497. !defined(point.options.dataLabels &&
  45498. point.options.dataLabels.style &&
  45499. point.options.dataLabels.style.width)) {
  45500. if (point.dataLabel.getBBox().width > maxWidth) {
  45501. point.dataLabel.css({
  45502. // Use a fraction of the maxWidth to avoid
  45503. // wrapping close to the end of the string.
  45504. width: Math.round(maxWidth * 0.7) + 'px'
  45505. });
  45506. point.dataLabel.shortened = true;
  45507. }
  45508. }
  45509. }
  45510. else {
  45511. point.dataLabel = point.dataLabel.destroy();
  45512. // Workaround to make pies destroy multiple datalabels
  45513. // correctly. This logic needs rewriting to support multiple
  45514. // datalabels fully.
  45515. if (point.dataLabels && point.dataLabels.length === 1) {
  45516. delete point.dataLabels;
  45517. }
  45518. }
  45519. }
  45520. });
  45521. /* Loop over the points in each half, starting from the top and bottom
  45522. * of the pie to detect overlapping labels.
  45523. */
  45524. halves.forEach(function (points, i) {
  45525. var top,
  45526. bottom,
  45527. length = points.length,
  45528. positions = [],
  45529. naturalY,
  45530. sideOverflow,
  45531. size,
  45532. distributionLength;
  45533. if (!length) {
  45534. return;
  45535. }
  45536. // Sort by angle
  45537. series.sortByAngle(points, i - 0.5);
  45538. // Only do anti-collision when we have dataLabels outside the pie
  45539. // and have connectors. (#856)
  45540. if (series.maxLabelDistance > 0) {
  45541. top = Math.max(0, centerY - radius - series.maxLabelDistance);
  45542. bottom = Math.min(centerY + radius + series.maxLabelDistance, chart.plotHeight);
  45543. points.forEach(function (point) {
  45544. // check if specific points' label is outside the pie
  45545. if (point.labelDistance > 0 && point.dataLabel) {
  45546. // point.top depends on point.labelDistance value
  45547. // Used for calculation of y value in getX method
  45548. point.top = Math.max(0, centerY - radius - point.labelDistance);
  45549. point.bottom = Math.min(centerY + radius + point.labelDistance, chart.plotHeight);
  45550. size = point.dataLabel.getBBox().height || 21;
  45551. // point.positionsIndex is needed for getting index of
  45552. // parameter related to specific point inside positions
  45553. // array - not every point is in positions array.
  45554. point.distributeBox = {
  45555. target: point.labelPosition.natural.y -
  45556. point.top + size / 2,
  45557. size: size,
  45558. rank: point.y
  45559. };
  45560. positions.push(point.distributeBox);
  45561. }
  45562. });
  45563. distributionLength = bottom + size - top;
  45564. H.distribute(positions, distributionLength, distributionLength / 5);
  45565. }
  45566. // Now the used slots are sorted, fill them up sequentially
  45567. for (j = 0; j < length; j++) {
  45568. point = points[j];
  45569. // labelPos = point.labelPos;
  45570. labelPosition = point.labelPosition;
  45571. dataLabel = point.dataLabel;
  45572. visibility = point.visible === false ? 'hidden' : 'inherit';
  45573. naturalY = labelPosition.natural.y;
  45574. y = naturalY;
  45575. if (positions && defined(point.distributeBox)) {
  45576. if (typeof point.distributeBox.pos === 'undefined') {
  45577. visibility = 'hidden';
  45578. }
  45579. else {
  45580. labelHeight = point.distributeBox.size;
  45581. // Find label's y position
  45582. y = dataLabelPositioners
  45583. .radialDistributionY(point);
  45584. }
  45585. }
  45586. // It is needed to delete point.positionIndex for
  45587. // dynamically added points etc.
  45588. delete point.positionIndex; // @todo unused
  45589. // Find label's x position
  45590. // justify is undocumented in the API - preserve support for it
  45591. if (options.justify) {
  45592. x = dataLabelPositioners.justify(point, radius, seriesCenter);
  45593. }
  45594. else {
  45595. switch (options.alignTo) {
  45596. case 'connectors':
  45597. x = dataLabelPositioners.alignToConnectors(points, i, plotWidth, plotLeft);
  45598. break;
  45599. case 'plotEdges':
  45600. x = dataLabelPositioners.alignToPlotEdges(dataLabel, i, plotWidth, plotLeft);
  45601. break;
  45602. default:
  45603. x = dataLabelPositioners.radialDistributionX(series, point, y, naturalY);
  45604. }
  45605. }
  45606. // Record the placement and visibility
  45607. dataLabel._attr = {
  45608. visibility: visibility,
  45609. align: labelPosition.alignment
  45610. };
  45611. pointDataLabelsOptions = point.options.dataLabels || {};
  45612. dataLabel._pos = {
  45613. x: (x +
  45614. pick(pointDataLabelsOptions.x, options.x) + // (#12985)
  45615. ({
  45616. left: connectorPadding,
  45617. right: -connectorPadding
  45618. }[labelPosition.alignment] || 0)),
  45619. // 10 is for the baseline (label vs text)
  45620. y: (y +
  45621. pick(pointDataLabelsOptions.y, options.y) - // (#12985)
  45622. 10)
  45623. };
  45624. // labelPos.x = x;
  45625. // labelPos.y = y;
  45626. labelPosition.final.x = x;
  45627. labelPosition.final.y = y;
  45628. // Detect overflowing data labels
  45629. if (pick(options.crop, true)) {
  45630. dataLabelWidth = dataLabel.getBBox().width;
  45631. sideOverflow = null;
  45632. // Overflow left
  45633. if (x - dataLabelWidth < connectorPadding &&
  45634. i === 1 // left half
  45635. ) {
  45636. sideOverflow = Math.round(dataLabelWidth - x + connectorPadding);
  45637. overflow[3] = Math.max(sideOverflow, overflow[3]);
  45638. // Overflow right
  45639. }
  45640. else if (x + dataLabelWidth > plotWidth - connectorPadding &&
  45641. i === 0 // right half
  45642. ) {
  45643. sideOverflow = Math.round(x + dataLabelWidth - plotWidth + connectorPadding);
  45644. overflow[1] = Math.max(sideOverflow, overflow[1]);
  45645. }
  45646. // Overflow top
  45647. if (y - labelHeight / 2 < 0) {
  45648. overflow[0] = Math.max(Math.round(-y + labelHeight / 2), overflow[0]);
  45649. // Overflow left
  45650. }
  45651. else if (y + labelHeight / 2 > plotHeight) {
  45652. overflow[2] = Math.max(Math.round(y + labelHeight / 2 - plotHeight), overflow[2]);
  45653. }
  45654. dataLabel.sideOverflow = sideOverflow;
  45655. }
  45656. } // for each point
  45657. }); // for each half
  45658. // Do not apply the final placement and draw the connectors until we
  45659. // have verified that labels are not spilling over.
  45660. if (arrayMax(overflow) === 0 ||
  45661. this.verifyDataLabelOverflow(overflow)) {
  45662. // Place the labels in the final position
  45663. this.placeDataLabels();
  45664. this.points.forEach(function (point) {
  45665. // #8864: every connector can have individual options
  45666. pointDataLabelsOptions =
  45667. merge(options, point.options.dataLabels);
  45668. connectorWidth =
  45669. pick(pointDataLabelsOptions.connectorWidth, 1);
  45670. // Draw the connector
  45671. if (connectorWidth) {
  45672. var isNew = void 0;
  45673. connector = point.connector;
  45674. dataLabel = point.dataLabel;
  45675. if (dataLabel &&
  45676. dataLabel._pos &&
  45677. point.visible &&
  45678. point.labelDistance > 0) {
  45679. visibility = dataLabel._attr.visibility;
  45680. isNew = !connector;
  45681. if (isNew) {
  45682. point.connector = connector = chart.renderer
  45683. .path()
  45684. .addClass('highcharts-data-label-connector ' +
  45685. ' highcharts-color-' + point.colorIndex +
  45686. (point.className ?
  45687. ' ' + point.className :
  45688. ''))
  45689. .add(series.dataLabelsGroup);
  45690. if (!chart.styledMode) {
  45691. connector.attr({
  45692. 'stroke-width': connectorWidth,
  45693. 'stroke': (pointDataLabelsOptions.connectorColor ||
  45694. point.color ||
  45695. palette.neutralColor60)
  45696. });
  45697. }
  45698. }
  45699. connector[isNew ? 'attr' : 'animate']({
  45700. d: point.getConnectorPath()
  45701. });
  45702. connector.attr('visibility', visibility);
  45703. }
  45704. else if (connector) {
  45705. point.connector = connector.destroy();
  45706. }
  45707. }
  45708. });
  45709. }
  45710. };
  45711. /**
  45712. * Extendable method for getting the path of the connector between the data
  45713. * label and the pie slice.
  45714. *
  45715. * @private
  45716. * @function Highcharts.seriesTypes.pie#connectorPath
  45717. *
  45718. * @param {*} labelPos
  45719. *
  45720. * @return {Highcharts.SVGPathArray}
  45721. */
  45722. // TODO: depracated - remove it
  45723. /*
  45724. seriesTypes.pie.prototype.connectorPath = function (labelPos) {
  45725. let x = labelPos.x,
  45726. y = labelPos.y;
  45727. return pick(this.options.dataLabels.softConnector, true) ? [
  45728. 'M',
  45729. // end of the string at the label
  45730. x + (labelPos[6] === 'left' ? 5 : -5), y,
  45731. 'C',
  45732. x, y, // first break, next to the label
  45733. 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
  45734. labelPos[2], labelPos[3], // second break
  45735. 'L',
  45736. labelPos[4], labelPos[5] // base
  45737. ] : [
  45738. 'M',
  45739. // end of the string at the label
  45740. x + (labelPos[6] === 'left' ? 5 : -5), y,
  45741. 'L',
  45742. labelPos[2], labelPos[3], // second break
  45743. 'L',
  45744. labelPos[4], labelPos[5] // base
  45745. ];
  45746. };
  45747. */
  45748. /**
  45749. * Perform the final placement of the data labels after we have verified
  45750. * that they fall within the plot area.
  45751. *
  45752. * @private
  45753. * @function Highcharts.seriesTypes.pie#placeDataLabels
  45754. * @return {void}
  45755. */
  45756. seriesTypes.pie.prototype.placeDataLabels = function () {
  45757. this.points.forEach(function (point) {
  45758. var dataLabel = point.dataLabel,
  45759. _pos;
  45760. if (dataLabel && point.visible) {
  45761. _pos = dataLabel._pos;
  45762. if (_pos) {
  45763. // Shorten data labels with ellipsis if they still overflow
  45764. // after the pie has reached minSize (#223).
  45765. if (dataLabel.sideOverflow) {
  45766. dataLabel._attr.width =
  45767. Math.max(dataLabel.getBBox().width -
  45768. dataLabel.sideOverflow, 0);
  45769. dataLabel.css({
  45770. width: dataLabel._attr.width + 'px',
  45771. textOverflow: ((this.options.dataLabels.style || {})
  45772. .textOverflow ||
  45773. 'ellipsis')
  45774. });
  45775. dataLabel.shortened = true;
  45776. }
  45777. dataLabel.attr(dataLabel._attr);
  45778. dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
  45779. dataLabel.moved = true;
  45780. }
  45781. else if (dataLabel) {
  45782. dataLabel.attr({ y: -9999 });
  45783. }
  45784. }
  45785. // Clear for update
  45786. delete point.distributeBox;
  45787. }, this);
  45788. };
  45789. seriesTypes.pie.prototype.alignDataLabel = noop;
  45790. /**
  45791. * Verify whether the data labels are allowed to draw, or we should run more
  45792. * translation and data label positioning to keep them inside the plot area.
  45793. * Returns true when data labels are ready to draw.
  45794. *
  45795. * @private
  45796. * @function Highcharts.seriesTypes.pie#verifyDataLabelOverflow
  45797. * @param {Array<number>} overflow
  45798. * @return {boolean}
  45799. */
  45800. seriesTypes.pie.prototype.verifyDataLabelOverflow = function (overflow) {
  45801. var center = this.center,
  45802. options = this.options,
  45803. centerOption = options.center,
  45804. minSize = options.minSize || 80,
  45805. newSize = minSize,
  45806. // If a size is set, return true and don't try to shrink the pie
  45807. // to fit the labels.
  45808. ret = options.size !== null;
  45809. if (!ret) {
  45810. // Handle horizontal size and center
  45811. if (centerOption[0] !== null) { // Fixed center
  45812. newSize = Math.max(center[2] -
  45813. Math.max(overflow[1], overflow[3]), minSize);
  45814. }
  45815. else { // Auto center
  45816. newSize = Math.max(
  45817. // horizontal overflow
  45818. center[2] - overflow[1] - overflow[3], minSize);
  45819. // horizontal center
  45820. center[0] += (overflow[3] - overflow[1]) / 2;
  45821. }
  45822. // Handle vertical size and center
  45823. if (centerOption[1] !== null) { // Fixed center
  45824. newSize = clamp(newSize, minSize, center[2] - Math.max(overflow[0], overflow[2]));
  45825. }
  45826. else { // Auto center
  45827. newSize = clamp(newSize, minSize,
  45828. // vertical overflow
  45829. center[2] - overflow[0] - overflow[2]);
  45830. // vertical center
  45831. center[1] += (overflow[0] - overflow[2]) / 2;
  45832. }
  45833. // If the size must be decreased, we need to run translate and
  45834. // drawDataLabels again
  45835. if (newSize < center[2]) {
  45836. center[2] = newSize;
  45837. center[3] = Math.min(// #3632
  45838. relativeLength(options.innerSize || 0, newSize), newSize);
  45839. this.translate(center);
  45840. if (this.drawDataLabels) {
  45841. this.drawDataLabels();
  45842. }
  45843. // Else, return true to indicate that the pie and its labels is
  45844. // within the plot area
  45845. }
  45846. else {
  45847. ret = true;
  45848. }
  45849. }
  45850. return ret;
  45851. };
  45852. }
  45853. if (seriesTypes.column) {
  45854. /**
  45855. * Override the basic data label alignment by adjusting for the position of
  45856. * the column.
  45857. *
  45858. * @private
  45859. * @function Highcharts.seriesTypes.column#alignDataLabel
  45860. * @param {Highcharts.Point} point
  45861. * @param {Highcharts.SVGElement} dataLabel
  45862. * @param {Highcharts.DataLabelsOptions} options
  45863. * @param {Highcharts.BBoxObject} alignTo
  45864. * @param {boolean} [isNew]
  45865. * @return {void}
  45866. */
  45867. seriesTypes.column.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  45868. var inverted = this.chart.inverted,
  45869. series = point.series,
  45870. // data label box for alignment
  45871. dlBox = point.dlBox || point.shapeArgs,
  45872. below = pick(point.below, // range series
  45873. point.plotY >
  45874. pick(this.translatedThreshold,
  45875. series.yAxis.len)),
  45876. // draw it inside the box?
  45877. inside = pick(options.inside, !!this.options.stacking),
  45878. overshoot;
  45879. // Align to the column itself, or the top of it
  45880. if (dlBox) { // Area range uses this method but not alignTo
  45881. alignTo = merge(dlBox);
  45882. if (alignTo.y < 0) {
  45883. alignTo.height += alignTo.y;
  45884. alignTo.y = 0;
  45885. }
  45886. // If parts of the box overshoots outside the plot area, modify the
  45887. // box to center the label inside
  45888. overshoot = alignTo.y + alignTo.height - series.yAxis.len;
  45889. if (overshoot > 0 && overshoot < alignTo.height) {
  45890. alignTo.height -= overshoot;
  45891. }
  45892. if (inverted) {
  45893. alignTo = {
  45894. x: series.yAxis.len - alignTo.y - alignTo.height,
  45895. y: series.xAxis.len - alignTo.x - alignTo.width,
  45896. width: alignTo.height,
  45897. height: alignTo.width
  45898. };
  45899. }
  45900. // Compute the alignment box
  45901. if (!inside) {
  45902. if (inverted) {
  45903. alignTo.x += below ? 0 : alignTo.width;
  45904. alignTo.width = 0;
  45905. }
  45906. else {
  45907. alignTo.y += below ? alignTo.height : 0;
  45908. alignTo.height = 0;
  45909. }
  45910. }
  45911. }
  45912. // When alignment is undefined (typically columns and bars), display the
  45913. // individual point below or above the point depending on the threshold
  45914. options.align = pick(options.align, !inverted || inside ? 'center' : below ? 'right' : 'left');
  45915. options.verticalAlign = pick(options.verticalAlign, inverted || inside ? 'middle' : below ? 'top' : 'bottom');
  45916. // Call the parent method
  45917. Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
  45918. // If label was justified and we have contrast, set it:
  45919. if (options.inside && point.contrastColor) {
  45920. dataLabel.css({
  45921. color: point.contrastColor
  45922. });
  45923. }
  45924. };
  45925. }
  45926. });
  45927. _registerModule(_modules, 'Extensions/OverlappingDataLabels.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  45928. /* *
  45929. *
  45930. * Highcharts module to hide overlapping data labels.
  45931. * This module is included in Highcharts.
  45932. *
  45933. * (c) 2009-2021 Torstein Honsi
  45934. *
  45935. * License: www.highcharts.com/license
  45936. *
  45937. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  45938. *
  45939. * */
  45940. var addEvent = U.addEvent,
  45941. fireEvent = U.fireEvent,
  45942. isArray = U.isArray,
  45943. isNumber = U.isNumber,
  45944. objectEach = U.objectEach,
  45945. pick = U.pick;
  45946. /**
  45947. * Internal type
  45948. * @private
  45949. */
  45950. /* eslint-disable no-invalid-this */
  45951. // Collect potensial overlapping data labels. Stack labels probably don't need
  45952. // to be considered because they are usually accompanied by data labels that lie
  45953. // inside the columns.
  45954. addEvent(Chart, 'render', function collectAndHide() {
  45955. var chart = this,
  45956. labels = [];
  45957. // Consider external label collectors
  45958. (this.labelCollectors || []).forEach(function (collector) {
  45959. labels = labels.concat(collector());
  45960. });
  45961. (this.yAxis || []).forEach(function (yAxis) {
  45962. if (yAxis.stacking &&
  45963. yAxis.options.stackLabels &&
  45964. !yAxis.options.stackLabels.allowOverlap) {
  45965. objectEach(yAxis.stacking.stacks, function (stack) {
  45966. objectEach(stack, function (stackItem) {
  45967. labels.push(stackItem.label);
  45968. });
  45969. });
  45970. }
  45971. });
  45972. (this.series || []).forEach(function (series) {
  45973. var dlOptions = series.options.dataLabels;
  45974. if (series.visible &&
  45975. !(dlOptions.enabled === false && !series._hasPointLabels)) { // #3866
  45976. var push = function (points) {
  45977. return points.forEach(function (point) {
  45978. if (point.visible) {
  45979. var dataLabels = (isArray(point.dataLabels) ?
  45980. point.dataLabels :
  45981. (point.dataLabel ? [point.dataLabel] : []));
  45982. dataLabels.forEach(function (label) {
  45983. var options = label.options;
  45984. label.labelrank = pick(options.labelrank, point.labelrank, point.shapeArgs && point.shapeArgs.height); // #4118
  45985. if (!options.allowOverlap) {
  45986. labels.push(label);
  45987. }
  45988. else { // #13449
  45989. label.oldOpacity = label.opacity;
  45990. label.newOpacity = 1;
  45991. hideOrShow(label, chart);
  45992. }
  45993. });
  45994. }
  45995. });
  45996. };
  45997. push(series.nodes || []);
  45998. push(series.points);
  45999. }
  46000. });
  46001. this.hideOverlappingLabels(labels);
  46002. });
  46003. /**
  46004. * Hide overlapping labels. Labels are moved and faded in and out on zoom to
  46005. * provide a smooth visual imression.
  46006. *
  46007. * @private
  46008. * @function Highcharts.Chart#hideOverlappingLabels
  46009. * @param {Array<Highcharts.SVGElement>} labels
  46010. * Rendered data labels
  46011. * @requires modules/overlapping-datalabels
  46012. */
  46013. Chart.prototype.hideOverlappingLabels = function (labels) {
  46014. var chart = this,
  46015. len = labels.length,
  46016. ren = chart.renderer,
  46017. label,
  46018. i,
  46019. j,
  46020. label1,
  46021. label2,
  46022. box1,
  46023. box2,
  46024. isLabelAffected = false,
  46025. isIntersectRect = function (box1,
  46026. box2) {
  46027. return !(box2.x >= box1.x + box1.width ||
  46028. box2.x + box2.width <= box1.x ||
  46029. box2.y >= box1.y + box1.height ||
  46030. box2.y + box2.height <= box1.y);
  46031. },
  46032. // Get the box with its position inside the chart, as opposed to getBBox
  46033. // that only reports the position relative to the parent.
  46034. getAbsoluteBox = function (label) {
  46035. var pos,
  46036. parent,
  46037. bBox,
  46038. // Substract the padding if no background or border (#4333)
  46039. padding = label.box ? 0 : (label.padding || 0),
  46040. lineHeightCorrection = 0,
  46041. xOffset = 0,
  46042. boxWidth,
  46043. alignValue;
  46044. if (label &&
  46045. (!label.alignAttr || label.placed)) {
  46046. pos = label.alignAttr || {
  46047. x: label.attr('x'),
  46048. y: label.attr('y')
  46049. };
  46050. parent = label.parentGroup;
  46051. // Get width and height if pure text nodes (stack labels)
  46052. if (!label.width) {
  46053. bBox = label.getBBox();
  46054. label.width = bBox.width;
  46055. label.height = bBox.height;
  46056. // Labels positions are computed from top left corner, so
  46057. // we need to substract the text height from text nodes too.
  46058. lineHeightCorrection = ren
  46059. .fontMetrics(null, label.element).h;
  46060. }
  46061. boxWidth = label.width - 2 * padding;
  46062. alignValue = {
  46063. left: '0',
  46064. center: '0.5',
  46065. right: '1'
  46066. }[label.alignValue];
  46067. if (alignValue) {
  46068. xOffset = +alignValue * boxWidth;
  46069. }
  46070. else if (isNumber(label.x) && Math.round(label.x) !== label.translateX) {
  46071. xOffset = label.x - label.translateX;
  46072. }
  46073. return {
  46074. x: pos.x + (parent.translateX || 0) + padding -
  46075. (xOffset || 0),
  46076. y: pos.y + (parent.translateY || 0) + padding -
  46077. lineHeightCorrection,
  46078. width: label.width - 2 * padding,
  46079. height: label.height - 2 * padding
  46080. };
  46081. }
  46082. };
  46083. for (i = 0; i < len; i++) {
  46084. label = labels[i];
  46085. if (label) {
  46086. // Mark with initial opacity
  46087. label.oldOpacity = label.opacity;
  46088. label.newOpacity = 1;
  46089. label.absoluteBox = getAbsoluteBox(label);
  46090. }
  46091. }
  46092. // Prevent a situation in a gradually rising slope, that each label will
  46093. // hide the previous one because the previous one always has lower rank.
  46094. labels.sort(function (a, b) {
  46095. return (b.labelrank || 0) - (a.labelrank || 0);
  46096. });
  46097. // Detect overlapping labels
  46098. for (i = 0; i < len; i++) {
  46099. label1 = labels[i];
  46100. box1 = label1 && label1.absoluteBox;
  46101. for (j = i + 1; j < len; ++j) {
  46102. label2 = labels[j];
  46103. box2 = label2 && label2.absoluteBox;
  46104. if (box1 &&
  46105. box2 &&
  46106. label1 !== label2 && // #6465, polar chart with connectEnds
  46107. label1.newOpacity !== 0 &&
  46108. label2.newOpacity !== 0) {
  46109. if (isIntersectRect(box1, box2)) {
  46110. (label1.labelrank < label2.labelrank ? label1 : label2)
  46111. .newOpacity = 0;
  46112. }
  46113. }
  46114. }
  46115. }
  46116. // Hide or show
  46117. labels.forEach(function (label) {
  46118. if (hideOrShow(label, chart)) {
  46119. isLabelAffected = true;
  46120. }
  46121. });
  46122. if (isLabelAffected) {
  46123. fireEvent(chart, 'afterHideAllOverlappingLabels');
  46124. }
  46125. };
  46126. /**
  46127. * Hide or show labels based on opacity.
  46128. *
  46129. * @private
  46130. * @function hideOrShow
  46131. * @param {Highcharts.SVGElement} label
  46132. * The label.
  46133. * @param {Highcharts.Chart} chart
  46134. * The chart that contains the label.
  46135. * @return {boolean}
  46136. */
  46137. function hideOrShow(label, chart) {
  46138. var complete,
  46139. newOpacity,
  46140. isLabelAffected = false;
  46141. if (label) {
  46142. newOpacity = label.newOpacity;
  46143. if (label.oldOpacity !== newOpacity) {
  46144. // Make sure the label is completely hidden to avoid catching
  46145. // clicks (#4362)
  46146. if (label.alignAttr && label.placed) { // data labels
  46147. label[newOpacity ? 'removeClass' : 'addClass']('highcharts-data-label-hidden');
  46148. complete = function () {
  46149. if (!chart.styledMode) {
  46150. label.css({ pointerEvents: newOpacity ? 'auto' : 'none' });
  46151. }
  46152. label.visibility = newOpacity ? 'inherit' : 'hidden';
  46153. };
  46154. isLabelAffected = true;
  46155. // Animate or set the opacity
  46156. label.alignAttr.opacity = newOpacity;
  46157. label[label.isOld ? 'animate' : 'attr'](label.alignAttr, null, complete);
  46158. fireEvent(chart, 'afterHideOverlappingLabel');
  46159. }
  46160. else { // other labels, tick labels
  46161. label.attr({
  46162. opacity: newOpacity
  46163. });
  46164. }
  46165. }
  46166. label.isOld = true;
  46167. }
  46168. return isLabelAffected;
  46169. }
  46170. });
  46171. _registerModule(_modules, 'Core/Responsive.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  46172. /* *
  46173. *
  46174. * (c) 2010-2021 Torstein Honsi
  46175. *
  46176. * License: www.highcharts.com/license
  46177. *
  46178. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46179. *
  46180. * */
  46181. var find = U.find,
  46182. isArray = U.isArray,
  46183. isObject = U.isObject,
  46184. merge = U.merge,
  46185. objectEach = U.objectEach,
  46186. pick = U.pick,
  46187. splat = U.splat,
  46188. uniqueKey = U.uniqueKey;
  46189. /**
  46190. * A callback function to gain complete control on when the responsive rule
  46191. * applies.
  46192. *
  46193. * @callback Highcharts.ResponsiveCallbackFunction
  46194. *
  46195. * @param {Highcharts.Chart} this
  46196. * Chart context.
  46197. *
  46198. * @return {boolean}
  46199. * Return `true` if it applies.
  46200. */
  46201. /**
  46202. * Allows setting a set of rules to apply for different screen or chart
  46203. * sizes. Each rule specifies additional chart options.
  46204. *
  46205. * @sample {highstock} stock/demo/responsive/
  46206. * Stock chart
  46207. * @sample highcharts/responsive/axis/
  46208. * Axis
  46209. * @sample highcharts/responsive/legend/
  46210. * Legend
  46211. * @sample highcharts/responsive/classname/
  46212. * Class name
  46213. *
  46214. * @since 5.0.0
  46215. * @apioption responsive
  46216. */
  46217. /**
  46218. * A set of rules for responsive settings. The rules are executed from
  46219. * the top down.
  46220. *
  46221. * @sample {highcharts} highcharts/responsive/axis/
  46222. * Axis changes
  46223. * @sample {highstock} highcharts/responsive/axis/
  46224. * Axis changes
  46225. * @sample {highmaps} highcharts/responsive/axis/
  46226. * Axis changes
  46227. *
  46228. * @type {Array<*>}
  46229. * @since 5.0.0
  46230. * @apioption responsive.rules
  46231. */
  46232. /**
  46233. * A full set of chart options to apply as overrides to the general
  46234. * chart options. The chart options are applied when the given rule
  46235. * is active.
  46236. *
  46237. * A special case is configuration objects that take arrays, for example
  46238. * [xAxis](#xAxis), [yAxis](#yAxis) or [series](#series). For these
  46239. * collections, an `id` option is used to map the new option set to
  46240. * an existing object. If an existing object of the same id is not found,
  46241. * the item of the same indexupdated. So for example, setting `chartOptions`
  46242. * with two series items without an `id`, will cause the existing chart's
  46243. * two series to be updated with respective options.
  46244. *
  46245. * @sample {highstock} stock/demo/responsive/
  46246. * Stock chart
  46247. * @sample highcharts/responsive/axis/
  46248. * Axis
  46249. * @sample highcharts/responsive/legend/
  46250. * Legend
  46251. * @sample highcharts/responsive/classname/
  46252. * Class name
  46253. *
  46254. * @type {Highcharts.Options}
  46255. * @since 5.0.0
  46256. * @apioption responsive.rules.chartOptions
  46257. */
  46258. /**
  46259. * Under which conditions the rule applies.
  46260. *
  46261. * @since 5.0.0
  46262. * @apioption responsive.rules.condition
  46263. */
  46264. /**
  46265. * A callback function to gain complete control on when the responsive
  46266. * rule applies. Return `true` if it applies. This opens for checking
  46267. * against other metrics than the chart size, for example the document
  46268. * size or other elements.
  46269. *
  46270. * @type {Highcharts.ResponsiveCallbackFunction}
  46271. * @since 5.0.0
  46272. * @context Highcharts.Chart
  46273. * @apioption responsive.rules.condition.callback
  46274. */
  46275. /**
  46276. * The responsive rule applies if the chart height is less than this.
  46277. *
  46278. * @type {number}
  46279. * @since 5.0.0
  46280. * @apioption responsive.rules.condition.maxHeight
  46281. */
  46282. /**
  46283. * The responsive rule applies if the chart width is less than this.
  46284. *
  46285. * @sample highcharts/responsive/axis/
  46286. * Max width is 500
  46287. *
  46288. * @type {number}
  46289. * @since 5.0.0
  46290. * @apioption responsive.rules.condition.maxWidth
  46291. */
  46292. /**
  46293. * The responsive rule applies if the chart height is greater than this.
  46294. *
  46295. * @type {number}
  46296. * @default 0
  46297. * @since 5.0.0
  46298. * @apioption responsive.rules.condition.minHeight
  46299. */
  46300. /**
  46301. * The responsive rule applies if the chart width is greater than this.
  46302. *
  46303. * @type {number}
  46304. * @default 0
  46305. * @since 5.0.0
  46306. * @apioption responsive.rules.condition.minWidth
  46307. */
  46308. /* eslint-disable no-invalid-this, valid-jsdoc */
  46309. /**
  46310. * Update the chart based on the current chart/document size and options for
  46311. * responsiveness.
  46312. *
  46313. * @private
  46314. * @function Highcharts.Chart#setResponsive
  46315. * @param {boolean} [redraw=true]
  46316. * @param {boolean} [reset=false]
  46317. * Reset by un-applying all rules. Chart.update resets all rules before applying
  46318. * updated options.
  46319. */
  46320. Chart.prototype.setResponsive = function (redraw, reset) {
  46321. var options = this.options.responsive,
  46322. ruleIds = [],
  46323. currentResponsive = this.currentResponsive,
  46324. currentRuleIds,
  46325. undoOptions;
  46326. if (!reset && options && options.rules) {
  46327. options.rules.forEach(function (rule) {
  46328. if (typeof rule._id === 'undefined') {
  46329. rule._id = uniqueKey();
  46330. }
  46331. this.matchResponsiveRule(rule, ruleIds /* , redraw */);
  46332. }, this);
  46333. }
  46334. // Merge matching rules
  46335. var mergedOptions = merge.apply(0,
  46336. ruleIds.map(function (ruleId) {
  46337. return find(options.rules,
  46338. function (rule) {
  46339. return rule._id === ruleId;
  46340. }).chartOptions;
  46341. }));
  46342. mergedOptions.isResponsiveOptions = true;
  46343. // Stringified key for the rules that currently apply.
  46344. ruleIds = (ruleIds.toString() || void 0);
  46345. currentRuleIds = currentResponsive && currentResponsive.ruleIds;
  46346. // Changes in what rules apply
  46347. if (ruleIds !== currentRuleIds) {
  46348. // Undo previous rules. Before we apply a new set of rules, we need to
  46349. // roll back completely to base options (#6291).
  46350. if (currentResponsive) {
  46351. this.update(currentResponsive.undoOptions, redraw, true);
  46352. }
  46353. if (ruleIds) {
  46354. // Get undo-options for matching rules
  46355. undoOptions = this.currentOptions(mergedOptions);
  46356. undoOptions.isResponsiveOptions = true;
  46357. this.currentResponsive = {
  46358. ruleIds: ruleIds,
  46359. mergedOptions: mergedOptions,
  46360. undoOptions: undoOptions
  46361. };
  46362. this.update(mergedOptions, redraw, true);
  46363. }
  46364. else {
  46365. this.currentResponsive = void 0;
  46366. }
  46367. }
  46368. };
  46369. /**
  46370. * Handle a single responsiveness rule.
  46371. *
  46372. * @private
  46373. * @function Highcharts.Chart#matchResponsiveRule
  46374. * @param {Highcharts.ResponsiveRulesOptions} rule
  46375. * @param {Array<string>} matches
  46376. */
  46377. Chart.prototype.matchResponsiveRule = function (rule, matches) {
  46378. var condition = rule.condition,
  46379. fn = condition.callback || function () {
  46380. return (this.chartWidth <= pick(condition.maxWidth,
  46381. Number.MAX_VALUE) &&
  46382. this.chartHeight <=
  46383. pick(condition.maxHeight,
  46384. Number.MAX_VALUE) &&
  46385. this.chartWidth >= pick(condition.minWidth, 0) &&
  46386. this.chartHeight >= pick(condition.minHeight, 0));
  46387. };
  46388. if (fn.call(this)) {
  46389. matches.push(rule._id);
  46390. }
  46391. };
  46392. /**
  46393. * Get the current values for a given set of options. Used before we update
  46394. * the chart with a new responsiveness rule.
  46395. *
  46396. * @todo Restore axis options (by id?). The matching of items in collections
  46397. * bears resemblance to the oneToOne matching in Chart.update. Probably we can
  46398. * refactor out that matching and reuse it in both functions.
  46399. *
  46400. * @private
  46401. * @function Highcharts.Chart#currentOptions
  46402. * @param {Highcharts.Options} options
  46403. * @return {Highcharts.Options}
  46404. */
  46405. Chart.prototype.currentOptions = function (options) {
  46406. var chart = this,
  46407. ret = {};
  46408. /**
  46409. * Recurse over a set of options and its current values,
  46410. * and store the current values in the ret object.
  46411. */
  46412. function getCurrent(options, curr, ret, depth) {
  46413. var i;
  46414. objectEach(options, function (val, key) {
  46415. if (!depth &&
  46416. chart.collectionsWithUpdate.indexOf(key) > -1 &&
  46417. curr[key]) {
  46418. val = splat(val);
  46419. ret[key] = [];
  46420. // Iterate over collections like series, xAxis or yAxis and map
  46421. // the items by index.
  46422. for (i = 0; i < Math.max(val.length, curr[key].length); i++) {
  46423. // Item exists in current data (#6347)
  46424. if (curr[key][i]) {
  46425. // If the item is missing from the new data, we need to
  46426. // save the whole config structure. Like when
  46427. // responsively updating from a dual axis layout to a
  46428. // single axis and back (#13544).
  46429. if (val[i] === void 0) {
  46430. ret[key][i] = curr[key][i];
  46431. // Otherwise, proceed
  46432. }
  46433. else {
  46434. ret[key][i] = {};
  46435. getCurrent(val[i], curr[key][i], ret[key][i], depth + 1);
  46436. }
  46437. }
  46438. }
  46439. }
  46440. else if (isObject(val)) {
  46441. ret[key] = isArray(val) ? [] : {};
  46442. getCurrent(val, curr[key] || {}, ret[key], depth + 1);
  46443. }
  46444. else if (typeof curr[key] === 'undefined') { // #10286
  46445. ret[key] = null;
  46446. }
  46447. else {
  46448. ret[key] = curr[key];
  46449. }
  46450. });
  46451. }
  46452. getCurrent(options, this.options, ret, 0);
  46453. return ret;
  46454. };
  46455. });
  46456. _registerModule(_modules, 'masters/highcharts.src.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Core/Options.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/Series/Series.js']], function (Highcharts, Utilities, Options, Fx, Animation, AST, FormatUtilities, SVGElement, Series) {
  46457. var G = Highcharts;
  46458. // Animation
  46459. G.animate = Animation.animate;
  46460. G.animObject = Animation.animObject;
  46461. G.getDeferredAnimation = Animation.getDeferredAnimation;
  46462. G.setAnimation = Animation.setAnimation;
  46463. G.stop = Animation.stop;
  46464. G.timers = Fx.timers;
  46465. // Classes
  46466. G.AST = AST;
  46467. G.Fx = Fx;
  46468. G.Series = Series;
  46469. G.SVGElement = SVGElement;
  46470. // Format Utilities
  46471. G.dateFormat = FormatUtilities.dateFormat;
  46472. G.format = FormatUtilities.format;
  46473. G.numberFormat = FormatUtilities.numberFormat;
  46474. // Options
  46475. G.defaultOptions = Options.defaultOptions;
  46476. G.getOptions = Options.getOptions;
  46477. G.time = Options.defaultTime;
  46478. G.setOptions = Options.setOptions;
  46479. // Utilities
  46480. G.addEvent = Utilities.addEvent;
  46481. G.arrayMax = Utilities.arrayMax;
  46482. G.arrayMin = Utilities.arrayMin;
  46483. G.attr = Utilities.attr;
  46484. G.clearTimeout = Utilities.clearTimeout;
  46485. G.correctFloat = Utilities.correctFloat;
  46486. G.createElement = Utilities.createElement;
  46487. G.css = Utilities.css;
  46488. G.defined = Utilities.defined;
  46489. G.destroyObjectProperties = Utilities.destroyObjectProperties;
  46490. G.discardElement = Utilities.discardElement;
  46491. G.erase = Utilities.erase;
  46492. G.error = Utilities.error;
  46493. G.extend = Utilities.extend;
  46494. G.extendClass = Utilities.extendClass;
  46495. G.find = Utilities.find;
  46496. G.fireEvent = Utilities.fireEvent;
  46497. G.getMagnitude = Utilities.getMagnitude;
  46498. G.getStyle = Utilities.getStyle;
  46499. G.inArray = Utilities.inArray;
  46500. G.isArray = Utilities.isArray;
  46501. G.isClass = Utilities.isClass;
  46502. G.isDOMElement = Utilities.isDOMElement;
  46503. G.isFunction = Utilities.isFunction;
  46504. G.isNumber = Utilities.isNumber;
  46505. G.isObject = Utilities.isObject;
  46506. G.isString = Utilities.isString;
  46507. G.keys = Utilities.keys;
  46508. G.merge = Utilities.merge;
  46509. G.normalizeTickInterval = Utilities.normalizeTickInterval;
  46510. G.objectEach = Utilities.objectEach;
  46511. G.offset = Utilities.offset;
  46512. G.pad = Utilities.pad;
  46513. G.pick = Utilities.pick;
  46514. G.pInt = Utilities.pInt;
  46515. G.relativeLength = Utilities.relativeLength;
  46516. G.removeEvent = Utilities.removeEvent;
  46517. G.splat = Utilities.splat;
  46518. G.stableSort = Utilities.stableSort;
  46519. G.syncTimeout = Utilities.syncTimeout;
  46520. G.timeUnits = Utilities.timeUnits;
  46521. G.uniqueKey = Utilities.uniqueKey;
  46522. G.useSerialIds = Utilities.useSerialIds;
  46523. G.wrap = Utilities.wrap;
  46524. return G;
  46525. });
  46526. _modules['masters/highcharts.src.js']._modules = _modules;
  46527. return _modules['masters/highcharts.src.js'];
  46528. }));