highcharts.src.js 1.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805
  1. /**
  2. * @license Highcharts JS v8.2.0 (2020-08-20)
  3. *
  4. * (c) 2009-2018 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-2020 Torstein Honsi
  36. *
  37. * License: www.highcharts.com/license
  38. *
  39. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40. *
  41. * */
  42. /* globals Image, window */
  43. /**
  44. * Reference to the global SVGElement class as a workaround for a name conflict
  45. * in the Highcharts namespace.
  46. *
  47. * @global
  48. * @typedef {global.SVGElement} GlobalSVGElement
  49. *
  50. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  51. */
  52. // glob is a temporary fix to allow our es-modules to work.
  53. var glob = ( // @todo UMD variable named `window`, and glob named `win`
  54. typeof win !== 'undefined' ?
  55. win :
  56. typeof window !== 'undefined' ?
  57. window :
  58. {}), doc = glob.document, SVG_NS = 'http://www.w3.org/2000/svg', userAgent = (glob.navigator && glob.navigator.userAgent) || '', svg = (doc &&
  59. doc.createElementNS &&
  60. !!doc.createElementNS(SVG_NS, 'svg').createSVGRect), isMS = /(edge|msie|trident)/i.test(userAgent) && !glob.opera, isFirefox = userAgent.indexOf('Firefox') !== -1, isChrome = userAgent.indexOf('Chrome') !== -1, hasBidiBug = (isFirefox &&
  61. parseInt(userAgent.split('Firefox/')[1], 10) < 4 // issue #38
  62. );
  63. var H = {
  64. product: 'Highcharts',
  65. version: '8.2.0',
  66. deg2rad: Math.PI * 2 / 360,
  67. doc: doc,
  68. hasBidiBug: hasBidiBug,
  69. hasTouch: !!glob.TouchEvent,
  70. isMS: isMS,
  71. isWebKit: userAgent.indexOf('AppleWebKit') !== -1,
  72. isFirefox: isFirefox,
  73. isChrome: isChrome,
  74. isSafari: !isChrome && userAgent.indexOf('Safari') !== -1,
  75. isTouchDevice: /(Mobile|Android|Windows Phone)/.test(userAgent),
  76. SVG_NS: SVG_NS,
  77. chartCount: 0,
  78. seriesTypes: {},
  79. symbolSizes: {},
  80. svg: svg,
  81. win: glob,
  82. marginNames: ['plotTop', 'marginRight', 'marginBottom', 'plotLeft'],
  83. noop: function () { },
  84. /**
  85. * Theme options that should get applied to the chart. In module mode it
  86. * might not be possible to change this property because of read-only
  87. * restrictions, instead use {@link Highcharts.setOptions}.
  88. *
  89. * @name Highcharts.theme
  90. * @type {Highcharts.Options}
  91. */
  92. /**
  93. * An array containing the current chart objects in the page. A chart's
  94. * position in the array is preserved throughout the page's lifetime. When
  95. * a chart is destroyed, the array item becomes `undefined`.
  96. *
  97. * @name Highcharts.charts
  98. * @type {Array<Highcharts.Chart|undefined>}
  99. */
  100. charts: [],
  101. /**
  102. * A hook for defining additional date format specifiers. New
  103. * specifiers are defined as key-value pairs by using the
  104. * specifier as key, and a function which takes the timestamp as
  105. * value. This function returns the formatted portion of the
  106. * date.
  107. *
  108. * @sample highcharts/global/dateformats/
  109. * Adding support for week number
  110. *
  111. * @name Highcharts.dateFormats
  112. * @type {Highcharts.Dictionary<Highcharts.TimeFormatCallbackFunction>}
  113. */
  114. dateFormats: {}
  115. };
  116. return H;
  117. });
  118. _registerModule(_modules, 'Core/Utilities.js', [_modules['Core/Globals.js']], function (H) {
  119. /* *
  120. *
  121. * (c) 2010-2020 Torstein Honsi
  122. *
  123. * License: www.highcharts.com/license
  124. *
  125. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  126. *
  127. * */
  128. /**
  129. * An animation configuration. Animation configurations can also be defined as
  130. * booleans, where `false` turns off animation and `true` defaults to a duration
  131. * of 500ms and defer of 0ms.
  132. *
  133. * @interface Highcharts.AnimationOptionsObject
  134. */ /**
  135. * A callback function to exectute when the animation finishes.
  136. * @name Highcharts.AnimationOptionsObject#complete
  137. * @type {Function|undefined}
  138. */ /**
  139. * The animation defer in milliseconds.
  140. * @name Highcharts.AnimationOptionsObject#defer
  141. * @type {number|undefined}
  142. */ /**
  143. * The animation duration in milliseconds.
  144. * @name Highcharts.AnimationOptionsObject#duration
  145. * @type {number|undefined}
  146. */ /**
  147. * The name of an easing function as defined on the `Math` object.
  148. * @name Highcharts.AnimationOptionsObject#easing
  149. * @type {string|Function|undefined}
  150. */ /**
  151. * A callback function to execute on each step of each attribute or CSS property
  152. * that's being animated. The first argument contains information about the
  153. * animation and progress.
  154. * @name Highcharts.AnimationOptionsObject#step
  155. * @type {Function|undefined}
  156. */
  157. /**
  158. * Creates a frame for the animated SVG element.
  159. *
  160. * @callback Highcharts.AnimationStepCallbackFunction
  161. *
  162. * @param {Highcharts.SVGElement} this
  163. * The SVG element to animate.
  164. *
  165. * @return {void}
  166. */
  167. /**
  168. * Interface description for a class.
  169. *
  170. * @interface Highcharts.Class<T>
  171. * @extends Function
  172. */ /**
  173. * Class costructor.
  174. * @function Highcharts.Class<T>#new
  175. * @param {...Array<*>} args
  176. * Constructor arguments.
  177. * @return {T}
  178. * Class instance.
  179. */
  180. /**
  181. * A style object with camel case property names to define visual appearance of
  182. * a SVG element or HTML element. The properties can be whatever styles are
  183. * supported on the given SVG or HTML element.
  184. *
  185. * @example
  186. * {
  187. * fontFamily: 'monospace',
  188. * fontSize: '1.2em'
  189. * }
  190. *
  191. * @interface Highcharts.CSSObject
  192. */ /**
  193. * @name Highcharts.CSSObject#[key:string]
  194. * @type {boolean|number|string|undefined}
  195. */ /**
  196. * Background style for the element.
  197. * @name Highcharts.CSSObject#background
  198. * @type {string|undefined}
  199. */ /**
  200. * Background color of the element.
  201. * @name Highcharts.CSSObject#backgroundColor
  202. * @type {Highcharts.ColorString|undefined}
  203. */ /**
  204. * Border style for the element.
  205. * @name Highcharts.CSSObject#border
  206. * @type {string|undefined}
  207. */ /**
  208. * Radius of the element border.
  209. * @name Highcharts.CSSObject#borderRadius
  210. * @type {number|undefined}
  211. */ /**
  212. * Color used in the element. The 'contrast' option is a Highcharts custom
  213. * property that results in black or white, depending on the background of the
  214. * element.
  215. * @name Highcharts.CSSObject#color
  216. * @type {'contrast'|Highcharts.ColorString|undefined}
  217. */ /**
  218. * Style of the mouse cursor when resting over the element.
  219. * @name Highcharts.CSSObject#cursor
  220. * @type {Highcharts.CursorValue|undefined}
  221. */ /**
  222. * Font family of the element text. Multiple values have to be in decreasing
  223. * preference order and separated by comma.
  224. * @name Highcharts.CSSObject#fontFamily
  225. * @type {string|undefined}
  226. */ /**
  227. * Font size of the element text.
  228. * @name Highcharts.CSSObject#fontSize
  229. * @type {string|undefined}
  230. */ /**
  231. * Font weight of the element text.
  232. * @name Highcharts.CSSObject#fontWeight
  233. * @type {string|undefined}
  234. */ /**
  235. * Height of the element.
  236. * @name Highcharts.CSSObject#height
  237. * @type {number|undefined}
  238. */ /**
  239. * Width of the element border.
  240. * @name Highcharts.CSSObject#lineWidth
  241. * @type {number|undefined}
  242. */ /**
  243. * Opacity of the element.
  244. * @name Highcharts.CSSObject#opacity
  245. * @type {number|undefined}
  246. */ /**
  247. * Space around the element content.
  248. * @name Highcharts.CSSObject#padding
  249. * @type {string|undefined}
  250. */ /**
  251. * Behaviour of the element when the mouse cursor rests over it.
  252. * @name Highcharts.CSSObject#pointerEvents
  253. * @type {string|undefined}
  254. */ /**
  255. * Positioning of the element.
  256. * @name Highcharts.CSSObject#position
  257. * @type {string|undefined}
  258. */ /**
  259. * Alignment of the element text.
  260. * @name Highcharts.CSSObject#textAlign
  261. * @type {string|undefined}
  262. */ /**
  263. * Additional decoration of the element text.
  264. * @name Highcharts.CSSObject#textDecoration
  265. * @type {string|undefined}
  266. */ /**
  267. * Outline style of the element text.
  268. * @name Highcharts.CSSObject#textOutline
  269. * @type {string|undefined}
  270. */ /**
  271. * Line break style of the element text. Highcharts SVG elements support
  272. * `ellipsis` when a `width` is set.
  273. * @name Highcharts.CSSObject#textOverflow
  274. * @type {string|undefined}
  275. */ /**
  276. * Top spacing of the element relative to the parent element.
  277. * @name Highcharts.CSSObject#top
  278. * @type {string|undefined}
  279. */ /**
  280. * Animated transition of selected element properties.
  281. * @name Highcharts.CSSObject#transition
  282. * @type {string|undefined}
  283. */ /**
  284. * Line break style of the element text.
  285. * @name Highcharts.CSSObject#whiteSpace
  286. * @type {string|undefined}
  287. */ /**
  288. * Width of the element.
  289. * @name Highcharts.CSSObject#width
  290. * @type {number|undefined}
  291. */
  292. /**
  293. * All possible cursor styles.
  294. *
  295. * @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
  296. */
  297. /**
  298. * All possible dash styles.
  299. *
  300. * @typedef {'Dash'|'DashDot'|'Dot'|'LongDash'|'LongDashDot'|'LongDashDotDot'|'ShortDash'|'ShortDashDot'|'ShortDashDotDot'|'ShortDot'|'Solid'} Highcharts.DashStyleValue
  301. */
  302. /**
  303. * Generic dictionary in TypeScript notation.
  304. * Use the native `Record<string, any>` instead.
  305. *
  306. * @deprecated
  307. * @interface Highcharts.Dictionary<T>
  308. */ /**
  309. * @name Highcharts.Dictionary<T>#[key:string]
  310. * @type {T}
  311. */
  312. /**
  313. * The function callback to execute when the event is fired. The `this` context
  314. * contains the instance, that fired the event.
  315. *
  316. * @callback Highcharts.EventCallbackFunction<T>
  317. *
  318. * @param {T} this
  319. *
  320. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  321. * Event arguments.
  322. *
  323. * @return {boolean|void}
  324. */
  325. /**
  326. * The event options for adding function callback.
  327. *
  328. * @interface Highcharts.EventOptionsObject
  329. */ /**
  330. * The order the event handler should be called. This opens for having one
  331. * handler be called before another, independent of in which order they were
  332. * added.
  333. * @name Highcharts.EventOptionsObject#order
  334. * @type {number}
  335. */
  336. /**
  337. * Formats data as a string. Usually the data is accessible throught the `this`
  338. * keyword.
  339. *
  340. * @callback Highcharts.FormatterCallbackFunction<T>
  341. *
  342. * @param {T} this
  343. * Context to format
  344. *
  345. * @return {string}
  346. * Formatted text
  347. */
  348. /**
  349. * An object of key-value pairs for HTML attributes.
  350. *
  351. * @typedef {Highcharts.Dictionary<boolean|number|string|Function>} Highcharts.HTMLAttributes
  352. */
  353. /**
  354. * An HTML DOM element. The type is a reference to the regular HTMLElement in
  355. * the global scope.
  356. *
  357. * @typedef {global.HTMLElement} Highcharts.HTMLDOMElement
  358. *
  359. * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
  360. */
  361. /**
  362. * The iterator callback.
  363. *
  364. * @callback Highcharts.ObjectEachCallbackFunction<T>
  365. *
  366. * @param {T} this
  367. * The context.
  368. *
  369. * @param {*} value
  370. * The property value.
  371. *
  372. * @param {string} key
  373. * The property key.
  374. *
  375. * @param {*} obj
  376. * The object that objectEach is being applied to.
  377. */
  378. /**
  379. * An object containing `left` and `top` properties for the position in the
  380. * page.
  381. *
  382. * @interface Highcharts.OffsetObject
  383. */ /**
  384. * Left distance to the page border.
  385. * @name Highcharts.OffsetObject#left
  386. * @type {number}
  387. */ /**
  388. * Top distance to the page border.
  389. * @name Highcharts.OffsetObject#top
  390. * @type {number}
  391. */
  392. /**
  393. * Describes a range.
  394. *
  395. * @interface Highcharts.RangeObject
  396. */ /**
  397. * Maximum number of the range.
  398. * @name Highcharts.RangeObject#max
  399. * @type {number}
  400. */ /**
  401. * Minimum number of the range.
  402. * @name Highcharts.RangeObject#min
  403. * @type {number}
  404. */
  405. /**
  406. * If a number is given, it defines the pixel length. If a percentage string is
  407. * given, like for example `'50%'`, the setting defines a length relative to a
  408. * base size, for example the size of a container.
  409. *
  410. * @typedef {number|string} Highcharts.RelativeSize
  411. */
  412. /**
  413. * Proceed function to call original (wrapped) function.
  414. *
  415. * @callback Highcharts.WrapProceedFunction
  416. *
  417. * @param {*} [arg1]
  418. * Optional argument. Without any arguments defaults to first argument of
  419. * the wrapping function.
  420. *
  421. * @param {*} [arg2]
  422. * Optional argument. Without any arguments defaults to second argument
  423. * of the wrapping function.
  424. *
  425. * @param {*} [arg3]
  426. * Optional argument. Without any arguments defaults to third argument of
  427. * the wrapping function.
  428. *
  429. * @return {*}
  430. * Return value of the original function.
  431. */
  432. /**
  433. * The Highcharts object is the placeholder for all other members, and various
  434. * utility functions. The most important member of the namespace would be the
  435. * chart constructor.
  436. *
  437. * @example
  438. * var chart = Highcharts.chart('container', { ... });
  439. *
  440. * @namespace Highcharts
  441. */
  442. H.timers = [];
  443. var charts = H.charts,
  444. doc = H.doc,
  445. win = H.win;
  446. /**
  447. * Provide error messages for debugging, with links to online explanation. This
  448. * function can be overridden to provide custom error handling.
  449. *
  450. * @sample highcharts/chart/highcharts-error/
  451. * Custom error handler
  452. *
  453. * @function Highcharts.error
  454. *
  455. * @param {number|string} code
  456. * The error code. See
  457. * [errors.xml](https://github.com/highcharts/highcharts/blob/master/errors/errors.xml)
  458. * for available codes. If it is a string, the error message is printed
  459. * directly in the console.
  460. *
  461. * @param {boolean} [stop=false]
  462. * Whether to throw an error or just log a warning in the console.
  463. *
  464. * @param {Highcharts.Chart} [chart]
  465. * Reference to the chart that causes the error. Used in 'debugger'
  466. * module to display errors directly on the chart.
  467. * Important note: This argument is undefined for errors that lack
  468. * access to the Chart instance.
  469. *
  470. * @param {Highcharts.Dictionary<string>} [params]
  471. * Additional parameters for the generated message.
  472. *
  473. * @return {void}
  474. */
  475. function error(code, stop, chart, params) {
  476. var severity = stop ? 'Highcharts error' : 'Highcharts warning';
  477. if (code === 32) {
  478. code = severity + ": Deprecated member";
  479. }
  480. var isCode = isNumber(code),
  481. message = isCode ?
  482. severity + " #" + code + ": www.highcharts.com/errors/" + code + "/" :
  483. code.toString(),
  484. defaultHandler = function () {
  485. if (stop) {
  486. throw new Error(message);
  487. }
  488. // else ...
  489. if (win.console &&
  490. error.messages.indexOf(message) === -1 // prevent console flooting
  491. ) {
  492. console.log(message); // eslint-disable-line no-console
  493. }
  494. };
  495. if (typeof params !== 'undefined') {
  496. var additionalMessages_1 = '';
  497. if (isCode) {
  498. message += '?';
  499. }
  500. objectEach(params, function (value, key) {
  501. additionalMessages_1 += "\n - " + key + ": " + value;
  502. if (isCode) {
  503. message += encodeURI(key) + '=' + encodeURI(value);
  504. }
  505. });
  506. message += additionalMessages_1;
  507. }
  508. if (chart) {
  509. fireEvent(chart, 'displayError', { code: code, message: message, params: params }, defaultHandler);
  510. }
  511. else {
  512. defaultHandler();
  513. }
  514. error.messages.push(message);
  515. }
  516. (function (error) {
  517. error.messages = [];
  518. })(error || (error = {}));
  519. H.error = error;
  520. /* eslint-disable no-invalid-this, valid-jsdoc */
  521. /**
  522. * An animator object used internally. One instance applies to one property
  523. * (attribute or style prop) on one element. Animation is always initiated
  524. * through {@link SVGElement#animate}.
  525. *
  526. * @example
  527. * var rect = renderer.rect(0, 0, 10, 10).add();
  528. * rect.animate({ width: 100 });
  529. *
  530. * @private
  531. * @class
  532. * @name Highcharts.Fx
  533. */
  534. var Fx = /** @class */ (function () {
  535. /* *
  536. *
  537. * Constructors
  538. *
  539. * */
  540. /**
  541. *
  542. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} elem
  543. * The element to animate.
  544. *
  545. * @param {Partial<Highcharts.AnimationOptionsObject>} options
  546. * Animation options.
  547. *
  548. * @param {string} prop
  549. * The single attribute or CSS property to animate.
  550. */
  551. function Fx(elem, options, prop) {
  552. this.options = options;
  553. this.elem = elem;
  554. this.prop = prop;
  555. }
  556. /* *
  557. *
  558. * Functions
  559. *
  560. * */
  561. /**
  562. * Set the current step of a path definition on SVGElement.
  563. *
  564. * @function Highcharts.Fx#dSetter
  565. *
  566. * @return {void}
  567. */
  568. Fx.prototype.dSetter = function () {
  569. var paths = this.paths,
  570. start = paths && paths[0],
  571. end = paths && paths[1],
  572. path = [],
  573. now = this.now || 0;
  574. // Land on the final path without adjustment points appended in the ends
  575. if (now === 1 || !start || !end) {
  576. path = this.toD || [];
  577. }
  578. else if (start.length === end.length && now < 1) {
  579. for (var i = 0; i < end.length; i++) {
  580. // Tween between the start segment and the end segment. Start
  581. // with a copy of the end segment and tween the appropriate
  582. // numerics
  583. var startSeg = start[i];
  584. var endSeg = end[i];
  585. var tweenSeg = [];
  586. for (var j = 0; j < endSeg.length; j++) {
  587. var startItem = startSeg[j];
  588. var endItem = endSeg[j];
  589. // Tween numbers
  590. if (typeof startItem === 'number' &&
  591. typeof endItem === 'number' &&
  592. // Arc boolean flags
  593. !(endSeg[0] === 'A' && (j === 4 || j === 5))) {
  594. tweenSeg[j] = startItem + now * (endItem - startItem);
  595. // Strings, take directly from the end segment
  596. }
  597. else {
  598. tweenSeg[j] = endItem;
  599. }
  600. }
  601. path.push(tweenSeg);
  602. }
  603. // If animation is finished or length not matching, land on right value
  604. }
  605. else {
  606. path = end;
  607. }
  608. this.elem.attr('d', path, void 0, true);
  609. };
  610. /**
  611. * Update the element with the current animation step.
  612. *
  613. * @function Highcharts.Fx#update
  614. *
  615. * @return {void}
  616. */
  617. Fx.prototype.update = function () {
  618. var elem = this.elem,
  619. prop = this.prop, // if destroyed, it is null
  620. now = this.now,
  621. step = this.options.step;
  622. // Animation setter defined from outside
  623. if (this[prop + 'Setter']) {
  624. this[prop + 'Setter']();
  625. // Other animations on SVGElement
  626. }
  627. else if (elem.attr) {
  628. if (elem.element) {
  629. elem.attr(prop, now, null, true);
  630. }
  631. // HTML styles, raw HTML content like container size
  632. }
  633. else {
  634. elem.style[prop] = now + this.unit;
  635. }
  636. if (step) {
  637. step.call(elem, now, this);
  638. }
  639. };
  640. /**
  641. * Run an animation.
  642. *
  643. * @function Highcharts.Fx#run
  644. *
  645. * @param {number} from
  646. * The current value, value to start from.
  647. *
  648. * @param {number} to
  649. * The end value, value to land on.
  650. *
  651. * @param {string} unit
  652. * The property unit, for example `px`.
  653. *
  654. * @return {void}
  655. */
  656. Fx.prototype.run = function (from, to, unit) {
  657. var self = this,
  658. options = self.options,
  659. timer = function (gotoEnd) {
  660. return timer.stopped ? false : self.step(gotoEnd);
  661. }, requestAnimationFrame = win.requestAnimationFrame ||
  662. function (step) {
  663. setTimeout(step, 13);
  664. }, step = function () {
  665. for (var i = 0; i < H.timers.length; i++) {
  666. if (!H.timers[i]()) {
  667. H.timers.splice(i--, 1);
  668. }
  669. }
  670. if (H.timers.length) {
  671. requestAnimationFrame(step);
  672. }
  673. };
  674. if (from === to && !this.elem['forceAnimate:' + this.prop]) {
  675. delete options.curAnim[this.prop];
  676. if (options.complete && Object.keys(options.curAnim).length === 0) {
  677. options.complete.call(this.elem);
  678. }
  679. }
  680. else { // #7166
  681. this.startTime = +new Date();
  682. this.start = from;
  683. this.end = to;
  684. this.unit = unit;
  685. this.now = this.start;
  686. this.pos = 0;
  687. timer.elem = this.elem;
  688. timer.prop = this.prop;
  689. if (timer() && H.timers.push(timer) === 1) {
  690. requestAnimationFrame(step);
  691. }
  692. }
  693. };
  694. /**
  695. * Run a single step in the animation.
  696. *
  697. * @function Highcharts.Fx#step
  698. *
  699. * @param {boolean} [gotoEnd]
  700. * Whether to go to the endpoint of the animation after abort.
  701. *
  702. * @return {boolean}
  703. * Returns `true` if animation continues.
  704. */
  705. Fx.prototype.step = function (gotoEnd) {
  706. var t = +new Date(),
  707. ret,
  708. done,
  709. options = this.options,
  710. elem = this.elem,
  711. complete = options.complete,
  712. duration = options.duration,
  713. curAnim = options.curAnim;
  714. if (elem.attr && !elem.element) { // #2616, element is destroyed
  715. ret = false;
  716. }
  717. else if (gotoEnd || t >= duration + this.startTime) {
  718. this.now = this.end;
  719. this.pos = 1;
  720. this.update();
  721. curAnim[this.prop] = true;
  722. done = true;
  723. objectEach(curAnim, function (val) {
  724. if (val !== true) {
  725. done = false;
  726. }
  727. });
  728. if (done && complete) {
  729. complete.call(elem);
  730. }
  731. ret = false;
  732. }
  733. else {
  734. this.pos = options.easing((t - this.startTime) / duration);
  735. this.now = this.start + ((this.end - this.start) * this.pos);
  736. this.update();
  737. ret = true;
  738. }
  739. return ret;
  740. };
  741. /**
  742. * Prepare start and end values so that the path can be animated one to one.
  743. *
  744. * @function Highcharts.Fx#initPath
  745. *
  746. * @param {Highcharts.SVGElement} elem
  747. * The SVGElement item.
  748. *
  749. * @param {Highcharts.SVGPathArray|undefined} fromD
  750. * Starting path definition.
  751. *
  752. * @param {Highcharts.SVGPathArray} toD
  753. * Ending path definition.
  754. *
  755. * @return {Array<Highcharts.SVGPathArray,Highcharts.SVGPathArray>}
  756. * An array containing start and end paths in array form so that
  757. * they can be animated in parallel.
  758. */
  759. Fx.prototype.initPath = function (elem, fromD, toD) {
  760. var shift,
  761. startX = elem.startX,
  762. endX = elem.endX,
  763. fullLength,
  764. i,
  765. start = fromD && fromD.slice(), // copy
  766. end = toD.slice(), // copy
  767. isArea = elem.isArea,
  768. positionFactor = isArea ? 2 : 1,
  769. reverse;
  770. if (!start) {
  771. return [end, end];
  772. }
  773. /**
  774. * If shifting points, prepend a dummy point to the end path.
  775. * @private
  776. * @param {Highcharts.SVGPathArray} arr - array
  777. * @param {Highcharts.SVGPathArray} other - array
  778. * @return {void}
  779. */
  780. function prepend(arr, other) {
  781. while (arr.length < fullLength) {
  782. // Move to, line to or curve to?
  783. var moveSegment = arr[0],
  784. otherSegment = other[fullLength - arr.length];
  785. if (otherSegment && moveSegment[0] === 'M') {
  786. if (otherSegment[0] === 'C') {
  787. arr[0] = [
  788. 'C',
  789. moveSegment[1],
  790. moveSegment[2],
  791. moveSegment[1],
  792. moveSegment[2],
  793. moveSegment[1],
  794. moveSegment[2]
  795. ];
  796. }
  797. else {
  798. arr[0] = ['L', moveSegment[1], moveSegment[2]];
  799. }
  800. }
  801. // Prepend a copy of the first point
  802. arr.unshift(moveSegment);
  803. // For areas, the bottom path goes back again to the left, so we
  804. // need to append a copy of the last point.
  805. if (isArea) {
  806. arr.push(arr[arr.length - 1]);
  807. }
  808. }
  809. }
  810. /**
  811. * Copy and append last point until the length matches the end length.
  812. * @private
  813. * @param {Highcharts.SVGPathArray} arr - array
  814. * @param {Highcharts.SVGPathArray} other - array
  815. * @return {void}
  816. */
  817. function append(arr, other) {
  818. while (arr.length < fullLength) {
  819. // Pull out the slice that is going to be appended or inserted.
  820. // In a line graph, the positionFactor is 1, and the last point
  821. // is sliced out. In an area graph, the positionFactor is 2,
  822. // causing the middle two points to be sliced out, since an area
  823. // path starts at left, follows the upper path then turns and
  824. // follows the bottom back.
  825. var segmentToAdd = arr[arr.length / positionFactor - 1].slice();
  826. // Disable the first control point of curve segments
  827. if (segmentToAdd[0] === 'C') {
  828. segmentToAdd[1] = segmentToAdd[5];
  829. segmentToAdd[2] = segmentToAdd[6];
  830. }
  831. if (!isArea) {
  832. arr.push(segmentToAdd);
  833. }
  834. else {
  835. var lowerSegmentToAdd = arr[arr.length / positionFactor].slice();
  836. arr.splice(arr.length / 2, 0, segmentToAdd, lowerSegmentToAdd);
  837. }
  838. }
  839. }
  840. // For sideways animation, find out how much we need to shift to get the
  841. // start path Xs to match the end path Xs.
  842. if (startX && endX) {
  843. for (i = 0; i < startX.length; i++) {
  844. // Moving left, new points coming in on right
  845. if (startX[i] === endX[0]) {
  846. shift = i;
  847. break;
  848. // Moving right
  849. }
  850. else if (startX[0] ===
  851. endX[endX.length - startX.length + i]) {
  852. shift = i;
  853. reverse = true;
  854. break;
  855. // Fixed from the right side, "scaling" left
  856. }
  857. else if (startX[startX.length - 1] ===
  858. endX[endX.length - startX.length + i]) {
  859. shift = startX.length - i;
  860. break;
  861. }
  862. }
  863. if (typeof shift === 'undefined') {
  864. start = [];
  865. }
  866. }
  867. if (start.length && isNumber(shift)) {
  868. // The common target length for the start and end array, where both
  869. // arrays are padded in opposite ends
  870. fullLength = end.length + shift * positionFactor;
  871. if (!reverse) {
  872. prepend(end, start);
  873. append(start, end);
  874. }
  875. else {
  876. prepend(start, end);
  877. append(end, start);
  878. }
  879. }
  880. return [start, end];
  881. };
  882. /**
  883. * Handle animation of the color attributes directly.
  884. *
  885. * @function Highcharts.Fx#fillSetter
  886. *
  887. * @return {void}
  888. */
  889. Fx.prototype.fillSetter = function () {
  890. Fx.prototype.strokeSetter.apply(this, arguments);
  891. };
  892. /**
  893. * Handle animation of the color attributes directly.
  894. *
  895. * @function Highcharts.Fx#strokeSetter
  896. *
  897. * @return {void}
  898. */
  899. Fx.prototype.strokeSetter = function () {
  900. this.elem.attr(this.prop, H.color(this.start).tweenTo(H.color(this.end), this.pos), null, true);
  901. };
  902. return Fx;
  903. }());
  904. H.Fx = Fx;
  905. /* eslint-disable valid-jsdoc */
  906. /**
  907. * Utility function to deep merge two or more objects and return a third object.
  908. * If the first argument is true, the contents of the second object is copied
  909. * into the first object. The merge function can also be used with a single
  910. * object argument to create a deep copy of an object.
  911. *
  912. * @function Highcharts.merge<T>
  913. *
  914. * @param {boolean} extend
  915. * Whether to extend the left-side object (a) or return a whole new
  916. * object.
  917. *
  918. * @param {T|undefined} a
  919. * The first object to extend. When only this is given, the function
  920. * returns a deep copy.
  921. *
  922. * @param {...Array<object|undefined>} [n]
  923. * An object to merge into the previous one.
  924. *
  925. * @return {T}
  926. * The merged object. If the first argument is true, the return is the
  927. * same as the second argument.
  928. */ /**
  929. * Utility function to deep merge two or more objects and return a third object.
  930. * The merge function can also be used with a single object argument to create a
  931. * deep copy of an object.
  932. *
  933. * @function Highcharts.merge<T>
  934. *
  935. * @param {T|undefined} a
  936. * The first object to extend. When only this is given, the function
  937. * returns a deep copy.
  938. *
  939. * @param {...Array<object|undefined>} [n]
  940. * An object to merge into the previous one.
  941. *
  942. * @return {T}
  943. * The merged object. If the first argument is true, the return is the
  944. * same as the second argument.
  945. */
  946. function merge() {
  947. /* eslint-enable valid-jsdoc */
  948. var i,
  949. args = arguments,
  950. len,
  951. ret = {},
  952. doCopy = function (copy,
  953. original) {
  954. // An object is replacing a primitive
  955. if (typeof copy !== 'object') {
  956. copy = {};
  957. }
  958. objectEach(original, function (value, key) {
  959. // Copy the contents of objects, but not arrays or DOM nodes
  960. if (isObject(value, true) &&
  961. !isClass(value) &&
  962. !isDOMElement(value)) {
  963. copy[key] = doCopy(copy[key] || {}, value);
  964. // Primitives and arrays are copied over directly
  965. }
  966. else {
  967. copy[key] = original[key];
  968. }
  969. });
  970. return copy;
  971. };
  972. // If first argument is true, copy into the existing object. Used in
  973. // setOptions.
  974. if (args[0] === true) {
  975. ret = args[1];
  976. args = Array.prototype.slice.call(args, 2);
  977. }
  978. // For each argument, extend the return
  979. len = args.length;
  980. for (i = 0; i < len; i++) {
  981. ret = doCopy(ret, args[i]);
  982. }
  983. return ret;
  984. }
  985. H.merge = merge;
  986. /**
  987. * Constrain a value to within a lower and upper threshold.
  988. *
  989. * @private
  990. * @param {number} value The initial value
  991. * @param {number} min The lower threshold
  992. * @param {number} max The upper threshold
  993. * @return {number} Returns a number value within min and max.
  994. */
  995. function clamp(value, min, max) {
  996. return value > min ? value < max ? value : max : min;
  997. }
  998. /**
  999. * Shortcut for parseInt
  1000. *
  1001. * @private
  1002. * @function Highcharts.pInt
  1003. *
  1004. * @param {*} s
  1005. * any
  1006. *
  1007. * @param {number} [mag]
  1008. * Magnitude
  1009. *
  1010. * @return {number}
  1011. * number
  1012. */
  1013. var pInt = H.pInt = function pInt(s,
  1014. mag) {
  1015. return parseInt(s,
  1016. mag || 10);
  1017. };
  1018. /**
  1019. * Utility function to check for string type.
  1020. *
  1021. * @function Highcharts.isString
  1022. *
  1023. * @param {*} s
  1024. * The item to check.
  1025. *
  1026. * @return {boolean}
  1027. * True if the argument is a string.
  1028. */
  1029. var isString = H.isString = function isString(s) {
  1030. return typeof s === 'string';
  1031. };
  1032. /**
  1033. * Utility function to check if an item is an array.
  1034. *
  1035. * @function Highcharts.isArray
  1036. *
  1037. * @param {*} obj
  1038. * The item to check.
  1039. *
  1040. * @return {boolean}
  1041. * True if the argument is an array.
  1042. */
  1043. var isArray = H.isArray = function isArray(obj) {
  1044. var str = Object.prototype.toString.call(obj);
  1045. return str === '[object Array]' || str === '[object Array Iterator]';
  1046. };
  1047. /**
  1048. * Utility function to check if an item is of type object.
  1049. *
  1050. * @function Highcharts.isObject
  1051. *
  1052. * @param {*} obj
  1053. * The item to check.
  1054. *
  1055. * @param {boolean} [strict=false]
  1056. * Also checks that the object is not an array.
  1057. *
  1058. * @return {boolean}
  1059. * True if the argument is an object.
  1060. */
  1061. function isObject(obj, strict) {
  1062. return (!!obj &&
  1063. typeof obj === 'object' &&
  1064. (!strict || !isArray(obj))); // eslint-disable-line @typescript-eslint/no-explicit-any
  1065. }
  1066. H.isObject = isObject;
  1067. /**
  1068. * Utility function to check if an Object is a HTML Element.
  1069. *
  1070. * @function Highcharts.isDOMElement
  1071. *
  1072. * @param {*} obj
  1073. * The item to check.
  1074. *
  1075. * @return {boolean}
  1076. * True if the argument is a HTML Element.
  1077. */
  1078. var isDOMElement = H.isDOMElement = function isDOMElement(obj) {
  1079. return isObject(obj) && typeof obj.nodeType === 'number';
  1080. };
  1081. /**
  1082. * Utility function to check if an Object is a class.
  1083. *
  1084. * @function Highcharts.isClass
  1085. *
  1086. * @param {object|undefined} obj
  1087. * The item to check.
  1088. *
  1089. * @return {boolean}
  1090. * True if the argument is a class.
  1091. */
  1092. var isClass = H.isClass = function isClass(obj) {
  1093. var c = obj && obj.constructor;
  1094. return !!(isObject(obj, true) &&
  1095. !isDOMElement(obj) &&
  1096. (c && c.name && c.name !== 'Object'));
  1097. };
  1098. /**
  1099. * Utility function to check if an item is a number and it is finite (not NaN,
  1100. * Infinity or -Infinity).
  1101. *
  1102. * @function Highcharts.isNumber
  1103. *
  1104. * @param {*} n
  1105. * The item to check.
  1106. *
  1107. * @return {boolean}
  1108. * True if the item is a finite number
  1109. */
  1110. var isNumber = H.isNumber = function isNumber(n) {
  1111. return typeof n === 'number' && !isNaN(n) && n < Infinity && n > -Infinity;
  1112. };
  1113. /**
  1114. * Remove the last occurence of an item from an array.
  1115. *
  1116. * @function Highcharts.erase
  1117. *
  1118. * @param {Array<*>} arr
  1119. * The array.
  1120. *
  1121. * @param {*} item
  1122. * The item to remove.
  1123. *
  1124. * @return {void}
  1125. */
  1126. var erase = H.erase = function erase(arr,
  1127. item) {
  1128. var i = arr.length;
  1129. while (i--) {
  1130. if (arr[i] === item) {
  1131. arr.splice(i, 1);
  1132. break;
  1133. }
  1134. }
  1135. };
  1136. /**
  1137. * Check if an object is null or undefined.
  1138. *
  1139. * @function Highcharts.defined
  1140. *
  1141. * @param {*} obj
  1142. * The object to check.
  1143. *
  1144. * @return {boolean}
  1145. * False if the object is null or undefined, otherwise true.
  1146. */
  1147. var defined = H.defined = function defined(obj) {
  1148. return typeof obj !== 'undefined' && obj !== null;
  1149. };
  1150. /**
  1151. * Set or get an attribute or an object of attributes. To use as a setter, pass
  1152. * a key and a value, or let the second argument be a collection of keys and
  1153. * values. To use as a getter, pass only a string as the second argument.
  1154. *
  1155. * @function Highcharts.attr
  1156. *
  1157. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} elem
  1158. * The DOM element to receive the attribute(s).
  1159. *
  1160. * @param {string|Highcharts.HTMLAttributes|Highcharts.SVGAttributes} [prop]
  1161. * The property or an object of key-value pairs.
  1162. *
  1163. * @param {number|string} [value]
  1164. * The value if a single property is set.
  1165. *
  1166. * @return {string|null|undefined}
  1167. * When used as a getter, return the value.
  1168. */
  1169. function attr(elem, prop, value) {
  1170. var ret;
  1171. // if the prop is a string
  1172. if (isString(prop)) {
  1173. // set the value
  1174. if (defined(value)) {
  1175. elem.setAttribute(prop, value);
  1176. // get the value
  1177. }
  1178. else if (elem && elem.getAttribute) {
  1179. ret = elem.getAttribute(prop);
  1180. // IE7 and below cannot get class through getAttribute (#7850)
  1181. if (!ret && prop === 'class') {
  1182. ret = elem.getAttribute(prop + 'Name');
  1183. }
  1184. }
  1185. // else if prop is defined, it is a hash of key/value pairs
  1186. }
  1187. else {
  1188. objectEach(prop, function (val, key) {
  1189. elem.setAttribute(key, val);
  1190. });
  1191. }
  1192. return ret;
  1193. }
  1194. H.attr = attr;
  1195. /**
  1196. * Check if an element is an array, and if not, make it into an array.
  1197. *
  1198. * @function Highcharts.splat
  1199. *
  1200. * @param {*} obj
  1201. * The object to splat.
  1202. *
  1203. * @return {Array}
  1204. * The produced or original array.
  1205. */
  1206. var splat = H.splat = function splat(obj) {
  1207. return isArray(obj) ? obj : [obj];
  1208. };
  1209. /**
  1210. * Set a timeout if the delay is given, otherwise perform the function
  1211. * synchronously.
  1212. *
  1213. * @function Highcharts.syncTimeout
  1214. *
  1215. * @param {Function} fn
  1216. * The function callback.
  1217. *
  1218. * @param {number} delay
  1219. * Delay in milliseconds.
  1220. *
  1221. * @param {*} [context]
  1222. * An optional context to send to the function callback.
  1223. *
  1224. * @return {number}
  1225. * An identifier for the timeout that can later be cleared with
  1226. * Highcharts.clearTimeout. Returns -1 if there is no timeout.
  1227. */
  1228. var syncTimeout = H.syncTimeout = function syncTimeout(fn,
  1229. delay,
  1230. context) {
  1231. if (delay > 0) {
  1232. return setTimeout(fn,
  1233. delay,
  1234. context);
  1235. }
  1236. fn.call(0, context);
  1237. return -1;
  1238. };
  1239. /**
  1240. * Internal clear timeout. The function checks that the `id` was not removed
  1241. * (e.g. by `chart.destroy()`). For the details see
  1242. * [issue #7901](https://github.com/highcharts/highcharts/issues/7901).
  1243. *
  1244. * @function Highcharts.clearTimeout
  1245. *
  1246. * @param {number} id
  1247. * Id of a timeout.
  1248. *
  1249. * @return {void}
  1250. */
  1251. var internalClearTimeout = H.clearTimeout = function (id) {
  1252. if (defined(id)) {
  1253. clearTimeout(id);
  1254. }
  1255. };
  1256. /* eslint-disable valid-jsdoc */
  1257. /**
  1258. * Utility function to extend an object with the members of another.
  1259. *
  1260. * @function Highcharts.extend<T>
  1261. *
  1262. * @param {T|undefined} a
  1263. * The object to be extended.
  1264. *
  1265. * @param {object} b
  1266. * The object to add to the first one.
  1267. *
  1268. * @return {T}
  1269. * Object a, the original object.
  1270. */
  1271. var extend = H.extend = function extend(a,
  1272. b) {
  1273. /* eslint-enable valid-jsdoc */
  1274. var n;
  1275. if (!a) {
  1276. a = {};
  1277. }
  1278. for (n in b) { // eslint-disable-line guard-for-in
  1279. a[n] = b[n];
  1280. }
  1281. return a;
  1282. };
  1283. /* eslint-disable valid-jsdoc */
  1284. /**
  1285. * Return the first value that is not null or undefined.
  1286. *
  1287. * @function Highcharts.pick<T>
  1288. *
  1289. * @param {...Array<T|null|undefined>} items
  1290. * Variable number of arguments to inspect.
  1291. *
  1292. * @return {T}
  1293. * The value of the first argument that is not null or undefined.
  1294. */
  1295. function pick() {
  1296. var args = arguments;
  1297. var length = args.length;
  1298. for (var i = 0; i < length; i++) {
  1299. var arg = args[i];
  1300. if (typeof arg !== 'undefined' && arg !== null) {
  1301. return arg;
  1302. }
  1303. }
  1304. }
  1305. H.pick = pick;
  1306. /**
  1307. * Set CSS on a given element.
  1308. *
  1309. * @function Highcharts.css
  1310. *
  1311. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
  1312. * An HTML DOM element.
  1313. *
  1314. * @param {Highcharts.CSSObject} styles
  1315. * Style object with camel case property names.
  1316. *
  1317. * @return {void}
  1318. */
  1319. var css = H.css = function css(el,
  1320. styles) {
  1321. if (H.isMS && !H.svg) { // #2686
  1322. if (styles && typeof styles.opacity !== 'undefined') {
  1323. styles.filter =
  1324. 'alpha(opacity=' + (styles.opacity * 100) + ')';
  1325. }
  1326. }
  1327. extend(el.style, styles);
  1328. };
  1329. /**
  1330. * Utility function to create an HTML element with attributes and styles.
  1331. *
  1332. * @function Highcharts.createElement
  1333. *
  1334. * @param {string} tag
  1335. * The HTML tag.
  1336. *
  1337. * @param {Highcharts.HTMLAttributes} [attribs]
  1338. * Attributes as an object of key-value pairs.
  1339. *
  1340. * @param {Highcharts.CSSObject} [styles]
  1341. * Styles as an object of key-value pairs.
  1342. *
  1343. * @param {Highcharts.HTMLDOMElement} [parent]
  1344. * The parent HTML object.
  1345. *
  1346. * @param {boolean} [nopad=false]
  1347. * If true, remove all padding, border and margin.
  1348. *
  1349. * @return {Highcharts.HTMLDOMElement}
  1350. * The created DOM element.
  1351. */
  1352. var createElement = H.createElement = function createElement(tag,
  1353. attribs,
  1354. styles,
  1355. parent,
  1356. nopad) {
  1357. var el = doc.createElement(tag);
  1358. if (attribs) {
  1359. extend(el, attribs);
  1360. }
  1361. if (nopad) {
  1362. css(el, { padding: '0', border: 'none', margin: '0' });
  1363. }
  1364. if (styles) {
  1365. css(el, styles);
  1366. }
  1367. if (parent) {
  1368. parent.appendChild(el);
  1369. }
  1370. return el;
  1371. };
  1372. // eslint-disable-next-line valid-jsdoc
  1373. /**
  1374. * Extend a prototyped class by new members.
  1375. *
  1376. * @function Highcharts.extendClass<T>
  1377. *
  1378. * @param {Highcharts.Class<T>} parent
  1379. * The parent prototype to inherit.
  1380. *
  1381. * @param {Highcharts.Dictionary<*>} members
  1382. * A collection of prototype members to add or override compared to the
  1383. * parent prototype.
  1384. *
  1385. * @return {Highcharts.Class<T>}
  1386. * A new prototype.
  1387. */
  1388. var extendClass = H.extendClass = function extendClass(parent,
  1389. members) {
  1390. var obj = (function () { });
  1391. obj.prototype = new parent(); // eslint-disable-line new-cap
  1392. extend(obj.prototype, members);
  1393. return obj;
  1394. };
  1395. /**
  1396. * Left-pad a string to a given length by adding a character repetetively.
  1397. *
  1398. * @function Highcharts.pad
  1399. *
  1400. * @param {number} number
  1401. * The input string or number.
  1402. *
  1403. * @param {number} [length]
  1404. * The desired string length.
  1405. *
  1406. * @param {string} [padder=0]
  1407. * The character to pad with.
  1408. *
  1409. * @return {string}
  1410. * The padded string.
  1411. */
  1412. var pad = H.pad = function pad(number, length, padder) {
  1413. return new Array((length || 2) +
  1414. 1 -
  1415. String(number)
  1416. .replace('-', '')
  1417. .length).join(padder || '0') + number;
  1418. };
  1419. /**
  1420. * Return a length based on either the integer value, or a percentage of a base.
  1421. *
  1422. * @function Highcharts.relativeLength
  1423. *
  1424. * @param {Highcharts.RelativeSize} value
  1425. * A percentage string or a number.
  1426. *
  1427. * @param {number} base
  1428. * The full length that represents 100%.
  1429. *
  1430. * @param {number} [offset=0]
  1431. * A pixel offset to apply for percentage values. Used internally in
  1432. * axis positioning.
  1433. *
  1434. * @return {number}
  1435. * The computed length.
  1436. */
  1437. var relativeLength = H.relativeLength = function relativeLength(value,
  1438. base,
  1439. offset) {
  1440. return (/%$/).test(value) ?
  1441. (base * parseFloat(value) / 100) + (offset || 0) :
  1442. parseFloat(value);
  1443. };
  1444. /**
  1445. * Wrap a method with extended functionality, preserving the original function.
  1446. *
  1447. * @function Highcharts.wrap
  1448. *
  1449. * @param {*} obj
  1450. * The context object that the method belongs to. In real cases, this is
  1451. * often a prototype.
  1452. *
  1453. * @param {string} method
  1454. * The name of the method to extend.
  1455. *
  1456. * @param {Highcharts.WrapProceedFunction} func
  1457. * A wrapper function callback. This function is called with the same
  1458. * arguments as the original function, except that the original function
  1459. * is unshifted and passed as the first argument.
  1460. */
  1461. var wrap = H.wrap = function wrap(obj,
  1462. method,
  1463. func) {
  1464. var proceed = obj[method];
  1465. obj[method] = function () {
  1466. var args = Array.prototype.slice.call(arguments),
  1467. outerArgs = arguments,
  1468. ctx = this,
  1469. ret;
  1470. ctx.proceed = function () {
  1471. proceed.apply(ctx, arguments.length ? arguments : outerArgs);
  1472. };
  1473. args.unshift(proceed);
  1474. ret = func.apply(this, args);
  1475. ctx.proceed = null;
  1476. return ret;
  1477. };
  1478. };
  1479. /**
  1480. * Format a string according to a subset of the rules of Python's String.format
  1481. * method.
  1482. *
  1483. * @example
  1484. * var s = Highcharts.format(
  1485. * 'The {color} fox was {len:.2f} feet long',
  1486. * { color: 'red', len: Math.PI }
  1487. * );
  1488. * // => The red fox was 3.14 feet long
  1489. *
  1490. * @function Highcharts.format
  1491. *
  1492. * @param {string} str
  1493. * The string to format.
  1494. *
  1495. * @param {Record<string, *>} ctx
  1496. * The context, a collection of key-value pairs where each key is
  1497. * replaced by its value.
  1498. *
  1499. * @param {Highcharts.Chart} [chart]
  1500. * A `Chart` instance used to get numberFormatter and time.
  1501. *
  1502. * @return {string}
  1503. * The formatted string.
  1504. */
  1505. var format = H.format = function (str,
  1506. ctx,
  1507. chart) {
  1508. var splitter = '{',
  1509. isInside = false,
  1510. segment,
  1511. valueAndFormat,
  1512. ret = [],
  1513. val,
  1514. index;
  1515. var floatRegex = /f$/;
  1516. var decRegex = /\.([0-9])/;
  1517. var lang = H.defaultOptions.lang;
  1518. var time = chart && chart.time || H.time;
  1519. var numberFormatter = chart && chart.numberFormatter || numberFormat;
  1520. while (str) {
  1521. index = str.indexOf(splitter);
  1522. if (index === -1) {
  1523. break;
  1524. }
  1525. segment = str.slice(0, index);
  1526. if (isInside) { // we're on the closing bracket looking back
  1527. valueAndFormat = segment.split(':');
  1528. val = getNestedProperty(valueAndFormat.shift() || '', ctx);
  1529. // Format the replacement
  1530. if (valueAndFormat.length && typeof val === 'number') {
  1531. segment = valueAndFormat.join(':');
  1532. if (floatRegex.test(segment)) { // float
  1533. var decimals = parseInt((segment.match(decRegex) || ['', '-1'])[1], 10);
  1534. if (val !== null) {
  1535. val = numberFormatter(val, decimals, lang.decimalPoint, segment.indexOf(',') > -1 ? lang.thousandsSep : '');
  1536. }
  1537. }
  1538. else {
  1539. val = time.dateFormat(segment, val);
  1540. }
  1541. }
  1542. // Push the result and advance the cursor
  1543. ret.push(val);
  1544. }
  1545. else {
  1546. ret.push(segment);
  1547. }
  1548. str = str.slice(index + 1); // the rest
  1549. isInside = !isInside; // toggle
  1550. splitter = isInside ? '}' : '{'; // now look for next matching bracket
  1551. }
  1552. ret.push(str);
  1553. return ret.join('');
  1554. };
  1555. /**
  1556. * Get the magnitude of a number.
  1557. *
  1558. * @function Highcharts.getMagnitude
  1559. *
  1560. * @param {number} num
  1561. * The number.
  1562. *
  1563. * @return {number}
  1564. * The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2 etc.
  1565. */
  1566. var getMagnitude = H.getMagnitude = function (num) {
  1567. return Math.pow(10,
  1568. Math.floor(Math.log(num) / Math.LN10));
  1569. };
  1570. /**
  1571. * Take an interval and normalize it to multiples of round numbers.
  1572. *
  1573. * @deprecated
  1574. * @function Highcharts.normalizeTickInterval
  1575. *
  1576. * @param {number} interval
  1577. * The raw, un-rounded interval.
  1578. *
  1579. * @param {Array<*>} [multiples]
  1580. * Allowed multiples.
  1581. *
  1582. * @param {number} [magnitude]
  1583. * The magnitude of the number.
  1584. *
  1585. * @param {boolean} [allowDecimals]
  1586. * Whether to allow decimals.
  1587. *
  1588. * @param {boolean} [hasTickAmount]
  1589. * If it has tickAmount, avoid landing on tick intervals lower than
  1590. * original.
  1591. *
  1592. * @return {number}
  1593. * The normalized interval.
  1594. *
  1595. * @todo
  1596. * Move this function to the Axis prototype. It is here only for historical
  1597. * reasons.
  1598. */
  1599. var normalizeTickInterval = H.normalizeTickInterval = function (interval,
  1600. multiples,
  1601. magnitude,
  1602. allowDecimals,
  1603. hasTickAmount) {
  1604. var normalized,
  1605. i,
  1606. retInterval = interval;
  1607. // round to a tenfold of 1, 2, 2.5 or 5
  1608. magnitude = pick(magnitude, 1);
  1609. normalized = interval / magnitude;
  1610. // multiples for a linear scale
  1611. if (!multiples) {
  1612. multiples = hasTickAmount ?
  1613. // Finer grained ticks when the tick amount is hard set, including
  1614. // when alignTicks is true on multiple axes (#4580).
  1615. [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
  1616. // Else, let ticks fall on rounder numbers
  1617. [1, 2, 2.5, 5, 10];
  1618. // the allowDecimals option
  1619. if (allowDecimals === false) {
  1620. if (magnitude === 1) {
  1621. multiples = multiples.filter(function (num) {
  1622. return num % 1 === 0;
  1623. });
  1624. }
  1625. else if (magnitude <= 0.1) {
  1626. multiples = [1 / magnitude];
  1627. }
  1628. }
  1629. }
  1630. // normalize the interval to the nearest multiple
  1631. for (i = 0; i < multiples.length; i++) {
  1632. retInterval = multiples[i];
  1633. // only allow tick amounts smaller than natural
  1634. if ((hasTickAmount &&
  1635. retInterval * magnitude >= interval) ||
  1636. (!hasTickAmount &&
  1637. (normalized <=
  1638. (multiples[i] +
  1639. (multiples[i + 1] || multiples[i])) / 2))) {
  1640. break;
  1641. }
  1642. }
  1643. // Multiply back to the correct magnitude. Correct floats to appropriate
  1644. // precision (#6085).
  1645. retInterval = correctFloat(retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10));
  1646. return retInterval;
  1647. };
  1648. /**
  1649. * Sort an object array and keep the order of equal items. The ECMAScript
  1650. * standard does not specify the behaviour when items are equal.
  1651. *
  1652. * @function Highcharts.stableSort
  1653. *
  1654. * @param {Array<*>} arr
  1655. * The array to sort.
  1656. *
  1657. * @param {Function} sortFunction
  1658. * The function to sort it with, like with regular Array.prototype.sort.
  1659. *
  1660. * @return {void}
  1661. */
  1662. var stableSort = H.stableSort = function stableSort(arr,
  1663. sortFunction) {
  1664. // @todo It seems like Chrome since v70 sorts in a stable way internally,
  1665. // plus all other browsers do it, so over time we may be able to remove this
  1666. // function
  1667. var length = arr.length,
  1668. sortValue,
  1669. i;
  1670. // Add index to each item
  1671. for (i = 0; i < length; i++) {
  1672. arr[i].safeI = i; // stable sort index
  1673. }
  1674. arr.sort(function (a, b) {
  1675. sortValue = sortFunction(a, b);
  1676. return sortValue === 0 ? a.safeI - b.safeI : sortValue;
  1677. });
  1678. // Remove index from items
  1679. for (i = 0; i < length; i++) {
  1680. delete arr[i].safeI; // stable sort index
  1681. }
  1682. };
  1683. /**
  1684. * Non-recursive method to find the lowest member of an array. `Math.min` raises
  1685. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1686. * than 150.000 points. This method is slightly slower, but safe.
  1687. *
  1688. * @function Highcharts.arrayMin
  1689. *
  1690. * @param {Array<*>} data
  1691. * An array of numbers.
  1692. *
  1693. * @return {number}
  1694. * The lowest number.
  1695. */
  1696. var arrayMin = H.arrayMin = function arrayMin(data) {
  1697. var i = data.length,
  1698. min = data[0];
  1699. while (i--) {
  1700. if (data[i] < min) {
  1701. min = data[i];
  1702. }
  1703. }
  1704. return min;
  1705. };
  1706. /**
  1707. * Non-recursive method to find the lowest member of an array. `Math.max` raises
  1708. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1709. * than 150.000 points. This method is slightly slower, but safe.
  1710. *
  1711. * @function Highcharts.arrayMax
  1712. *
  1713. * @param {Array<*>} data
  1714. * An array of numbers.
  1715. *
  1716. * @return {number}
  1717. * The highest number.
  1718. */
  1719. var arrayMax = H.arrayMax = function arrayMax(data) {
  1720. var i = data.length,
  1721. max = data[0];
  1722. while (i--) {
  1723. if (data[i] > max) {
  1724. max = data[i];
  1725. }
  1726. }
  1727. return max;
  1728. };
  1729. /**
  1730. * Utility method that destroys any SVGElement instances that are properties on
  1731. * the given object. It loops all properties and invokes destroy if there is a
  1732. * destroy method. The property is then delete.
  1733. *
  1734. * @function Highcharts.destroyObjectProperties
  1735. *
  1736. * @param {*} obj
  1737. * The object to destroy properties on.
  1738. *
  1739. * @param {*} [except]
  1740. * Exception, do not destroy this property, only delete it.
  1741. *
  1742. * @return {void}
  1743. */
  1744. var destroyObjectProperties = H.destroyObjectProperties =
  1745. function destroyObjectProperties(obj,
  1746. except) {
  1747. objectEach(obj,
  1748. function (val,
  1749. n) {
  1750. // If the object is non-null and destroy is defined
  1751. if (val && val !== except && val.destroy) {
  1752. // Invoke the destroy
  1753. val.destroy();
  1754. }
  1755. // Delete the property from the object.
  1756. delete obj[n];
  1757. });
  1758. };
  1759. /**
  1760. * Discard a HTML element by moving it to the bin and delete.
  1761. *
  1762. * @function Highcharts.discardElement
  1763. *
  1764. * @param {Highcharts.HTMLDOMElement} element
  1765. * The HTML node to discard.
  1766. *
  1767. * @return {void}
  1768. */
  1769. var discardElement = H.discardElement = function discardElement(element) {
  1770. var garbageBin = H.garbageBin;
  1771. // create a garbage bin element, not part of the DOM
  1772. if (!garbageBin) {
  1773. garbageBin = createElement('div');
  1774. }
  1775. // move the node and empty bin
  1776. if (element) {
  1777. garbageBin.appendChild(element);
  1778. }
  1779. garbageBin.innerHTML = '';
  1780. };
  1781. /**
  1782. * Fix JS round off float errors.
  1783. *
  1784. * @function Highcharts.correctFloat
  1785. *
  1786. * @param {number} num
  1787. * A float number to fix.
  1788. *
  1789. * @param {number} [prec=14]
  1790. * The precision.
  1791. *
  1792. * @return {number}
  1793. * The corrected float number.
  1794. */
  1795. var correctFloat = H.correctFloat = function correctFloat(num,
  1796. prec) {
  1797. return parseFloat(num.toPrecision(prec || 14));
  1798. };
  1799. /**
  1800. * Set the global animation to either a given value, or fall back to the given
  1801. * chart's animation option.
  1802. *
  1803. * @function Highcharts.setAnimation
  1804. *
  1805. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>|undefined} animation
  1806. * The animation object.
  1807. *
  1808. * @param {Highcharts.Chart} chart
  1809. * The chart instance.
  1810. *
  1811. * @return {void}
  1812. *
  1813. * @todo
  1814. * This function always relates to a chart, and sets a property on the renderer,
  1815. * so it should be moved to the SVGRenderer.
  1816. */
  1817. var setAnimation = H.setAnimation = function setAnimation(animation,
  1818. chart) {
  1819. chart.renderer.globalAnimation = pick(animation,
  1820. chart.options.chart.animation,
  1821. true);
  1822. };
  1823. /**
  1824. * Get the animation in object form, where a disabled animation is always
  1825. * returned as `{ duration: 0 }`.
  1826. *
  1827. * @function Highcharts.animObject
  1828. *
  1829. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=0]
  1830. * An animation setting. Can be an object with duration, complete and
  1831. * easing properties, or a boolean to enable or disable.
  1832. *
  1833. * @return {Highcharts.AnimationOptionsObject}
  1834. * An object with at least a duration property.
  1835. */
  1836. var animObject = H.animObject = function animObject(animation) {
  1837. return isObject(animation) ?
  1838. H.merge({ duration: 500,
  1839. defer: 0 },
  1840. animation) :
  1841. { duration: animation ? 500 : 0,
  1842. defer: 0 };
  1843. };
  1844. /**
  1845. * The time unit lookup
  1846. *
  1847. * @ignore
  1848. */
  1849. var timeUnits = H.timeUnits = {
  1850. millisecond: 1,
  1851. second: 1000,
  1852. minute: 60000,
  1853. hour: 3600000,
  1854. day: 24 * 3600000,
  1855. week: 7 * 24 * 3600000,
  1856. month: 28 * 24 * 3600000,
  1857. year: 364 * 24 * 3600000
  1858. };
  1859. /**
  1860. * Format a number and return a string based on input settings.
  1861. *
  1862. * @sample highcharts/members/highcharts-numberformat/
  1863. * Custom number format
  1864. *
  1865. * @function Highcharts.numberFormat
  1866. *
  1867. * @param {number} number
  1868. * The input number to format.
  1869. *
  1870. * @param {number} decimals
  1871. * The amount of decimals. A value of -1 preserves the amount in the
  1872. * input number.
  1873. *
  1874. * @param {string} [decimalPoint]
  1875. * The decimal point, defaults to the one given in the lang options, or
  1876. * a dot.
  1877. *
  1878. * @param {string} [thousandsSep]
  1879. * The thousands separator, defaults to the one given in the lang
  1880. * options, or a space character.
  1881. *
  1882. * @return {string}
  1883. * The formatted number.
  1884. */
  1885. var numberFormat = H.numberFormat = function numberFormat(number,
  1886. decimals,
  1887. decimalPoint,
  1888. thousandsSep) {
  1889. number = +number || 0;
  1890. decimals = +decimals;
  1891. var lang = H.defaultOptions.lang, origDec = (number.toString().split('.')[1] || '').split('e')[0].length, strinteger, thousands, ret, roundedNumber, exponent = number.toString().split('e'), fractionDigits;
  1892. if (decimals === -1) {
  1893. // Preserve decimals. Not huge numbers (#3793).
  1894. decimals = Math.min(origDec, 20);
  1895. }
  1896. else if (!isNumber(decimals)) {
  1897. decimals = 2;
  1898. }
  1899. else if (decimals && exponent[1] && exponent[1] < 0) {
  1900. // Expose decimals from exponential notation (#7042)
  1901. fractionDigits = decimals + +exponent[1];
  1902. if (fractionDigits >= 0) {
  1903. // remove too small part of the number while keeping the notation
  1904. exponent[0] = (+exponent[0]).toExponential(fractionDigits)
  1905. .split('e')[0];
  1906. decimals = fractionDigits;
  1907. }
  1908. else {
  1909. // fractionDigits < 0
  1910. exponent[0] = exponent[0].split('.')[0] || 0;
  1911. if (decimals < 20) {
  1912. // use number instead of exponential notation (#7405)
  1913. number = (exponent[0] * Math.pow(10, exponent[1]))
  1914. .toFixed(decimals);
  1915. }
  1916. else {
  1917. // or zero
  1918. number = 0;
  1919. }
  1920. exponent[1] = 0;
  1921. }
  1922. }
  1923. // Add another decimal to avoid rounding errors of float numbers. (#4573)
  1924. // Then use toFixed to handle rounding.
  1925. roundedNumber = (Math.abs(exponent[1] ? exponent[0] : number) +
  1926. Math.pow(10, -Math.max(decimals, origDec) - 1)).toFixed(decimals);
  1927. // A string containing the positive integer component of the number
  1928. strinteger = String(pInt(roundedNumber));
  1929. // Leftover after grouping into thousands. Can be 0, 1 or 2.
  1930. thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
  1931. // Language
  1932. decimalPoint = pick(decimalPoint, lang.decimalPoint);
  1933. thousandsSep = pick(thousandsSep, lang.thousandsSep);
  1934. // Start building the return
  1935. ret = number < 0 ? '-' : '';
  1936. // Add the leftover after grouping into thousands. For example, in the
  1937. // number 42 000 000, this line adds 42.
  1938. ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
  1939. // Add the remaining thousands groups, joined by the thousands separator
  1940. ret += strinteger
  1941. .substr(thousands)
  1942. .replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
  1943. // Add the decimal point and the decimal component
  1944. if (decimals) {
  1945. // Get the decimal component
  1946. ret += decimalPoint + roundedNumber.slice(-decimals);
  1947. }
  1948. if (exponent[1] && +ret !== 0) {
  1949. ret += 'e' + exponent[1];
  1950. }
  1951. return ret;
  1952. };
  1953. /**
  1954. * Easing definition
  1955. *
  1956. * @private
  1957. * @function Math.easeInOutSine
  1958. *
  1959. * @param {number} pos
  1960. * Current position, ranging from 0 to 1.
  1961. *
  1962. * @return {number}
  1963. * Ease result
  1964. */
  1965. Math.easeInOutSine = function (pos) {
  1966. return -0.5 * (Math.cos(Math.PI * pos) - 1);
  1967. };
  1968. /**
  1969. * Returns the value of a property path on a given object.
  1970. *
  1971. * @private
  1972. * @function getNestedProperty
  1973. *
  1974. * @param {string} path
  1975. * Path to the property, for example `custom.myValue`.
  1976. *
  1977. * @param {unknown} obj
  1978. * Instance containing the property on the specific path.
  1979. *
  1980. * @return {unknown}
  1981. * The unknown property value.
  1982. */
  1983. function getNestedProperty(path, obj) {
  1984. if (!path) {
  1985. return obj;
  1986. }
  1987. var pathElements = path.split('.').reverse();
  1988. var subProperty = obj;
  1989. if (pathElements.length === 1) {
  1990. return subProperty[path];
  1991. }
  1992. var pathElement = pathElements.pop();
  1993. while (typeof pathElement !== 'undefined' &&
  1994. typeof subProperty !== 'undefined' &&
  1995. subProperty !== null) {
  1996. subProperty = subProperty[pathElement];
  1997. pathElement = pathElements.pop();
  1998. }
  1999. return subProperty;
  2000. }
  2001. /**
  2002. * Get the computed CSS value for given element and property, only for numerical
  2003. * properties. For width and height, the dimension of the inner box (excluding
  2004. * padding) is returned. Used for fitting the chart within the container.
  2005. *
  2006. * @function Highcharts.getStyle
  2007. *
  2008. * @param {Highcharts.HTMLDOMElement} el
  2009. * An HTML element.
  2010. *
  2011. * @param {string} prop
  2012. * The property name.
  2013. *
  2014. * @param {boolean} [toInt=true]
  2015. * Parse to integer.
  2016. *
  2017. * @return {number|string}
  2018. * The numeric value.
  2019. */
  2020. var getStyle = H.getStyle = function (el,
  2021. prop,
  2022. toInt) {
  2023. var style;
  2024. // For width and height, return the actual inner pixel size (#4913)
  2025. if (prop === 'width') {
  2026. var offsetWidth = Math.min(el.offsetWidth,
  2027. el.scrollWidth);
  2028. // In flex boxes, we need to use getBoundingClientRect and floor it,
  2029. // because scrollWidth doesn't support subpixel precision (#6427) ...
  2030. var boundingClientRectWidth = el.getBoundingClientRect &&
  2031. el.getBoundingClientRect().width;
  2032. // ...unless if the containing div or its parents are transform-scaled
  2033. // down, in which case the boundingClientRect can't be used as it is
  2034. // also scaled down (#9871, #10498).
  2035. if (boundingClientRectWidth < offsetWidth &&
  2036. boundingClientRectWidth >= offsetWidth - 1) {
  2037. offsetWidth = Math.floor(boundingClientRectWidth);
  2038. }
  2039. return Math.max(0, // #8377
  2040. (offsetWidth -
  2041. H.getStyle(el, 'padding-left') -
  2042. H.getStyle(el, 'padding-right')));
  2043. }
  2044. if (prop === 'height') {
  2045. return Math.max(0, // #8377
  2046. Math.min(el.offsetHeight, el.scrollHeight) -
  2047. H.getStyle(el, 'padding-top') -
  2048. H.getStyle(el, 'padding-bottom'));
  2049. }
  2050. if (!win.getComputedStyle) {
  2051. // SVG not supported, forgot to load oldie.js?
  2052. error(27, true);
  2053. }
  2054. // Otherwise, get the computed style
  2055. style = win.getComputedStyle(el, undefined); // eslint-disable-line no-undefined
  2056. if (style) {
  2057. style = style.getPropertyValue(prop);
  2058. if (pick(toInt, prop !== 'opacity')) {
  2059. style = pInt(style);
  2060. }
  2061. }
  2062. return style;
  2063. };
  2064. /**
  2065. * Get the defer as a number value from series animation options.
  2066. *
  2067. * @function Highcharts.getDeferredAnimation
  2068. *
  2069. * @param {Highcharts.Chart} chart
  2070. * The chart instance.
  2071. *
  2072. * @return {number}
  2073. * The numeric value.
  2074. */
  2075. var getDeferredAnimation = H.getDeferredAnimation = function (chart,
  2076. animation,
  2077. series) {
  2078. var labelAnimation = animObject(animation);
  2079. var s = series ? [series] : chart.series;
  2080. var defer = 0;
  2081. var duration = 0;
  2082. s.forEach(function (series) {
  2083. var seriesAnim = animObject(series.options.animation);
  2084. defer = animation && defined(animation.defer) ?
  2085. labelAnimation.defer :
  2086. Math.max(defer, seriesAnim.duration + seriesAnim.defer);
  2087. duration = Math.min(labelAnimation.duration, seriesAnim.duration);
  2088. });
  2089. // Disable defer for exporting
  2090. if (chart.renderer.forExport) {
  2091. defer = 0;
  2092. }
  2093. var anim = {
  2094. defer: Math.max(0,
  2095. defer - duration),
  2096. duration: Math.min(defer,
  2097. duration)
  2098. };
  2099. return anim;
  2100. };
  2101. /**
  2102. * Search for an item in an array.
  2103. *
  2104. * @function Highcharts.inArray
  2105. *
  2106. * @deprecated
  2107. *
  2108. * @param {*} item
  2109. * The item to search for.
  2110. *
  2111. * @param {Array<*>} arr
  2112. * The array or node collection to search in.
  2113. *
  2114. * @param {number} [fromIndex=0]
  2115. * The index to start searching from.
  2116. *
  2117. * @return {number}
  2118. * The index within the array, or -1 if not found.
  2119. */
  2120. var inArray = H.inArray = function (item,
  2121. arr,
  2122. fromIndex) {
  2123. error(32,
  2124. false,
  2125. void 0, { 'Highcharts.inArray': 'use Array.indexOf' });
  2126. return arr.indexOf(item, fromIndex);
  2127. };
  2128. /* eslint-disable valid-jsdoc */
  2129. /**
  2130. * Return the value of the first element in the array that satisfies the
  2131. * provided testing function.
  2132. *
  2133. * @function Highcharts.find<T>
  2134. *
  2135. * @param {Array<T>} arr
  2136. * The array to test.
  2137. *
  2138. * @param {Function} callback
  2139. * The callback function. The function receives the item as the first
  2140. * argument. Return `true` if this item satisfies the condition.
  2141. *
  2142. * @return {T|undefined}
  2143. * The value of the element.
  2144. */
  2145. var find = H.find = Array.prototype.find ?
  2146. /* eslint-enable valid-jsdoc */
  2147. function (arr,
  2148. callback) {
  2149. return arr.find(callback);
  2150. } :
  2151. // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
  2152. function (arr, callback) {
  2153. var i,
  2154. length = arr.length;
  2155. for (i = 0; i < length; i++) {
  2156. if (callback(arr[i], i)) { // eslint-disable-line callback-return
  2157. return arr[i];
  2158. }
  2159. }
  2160. };
  2161. /**
  2162. * Returns an array of a given object's own properties.
  2163. *
  2164. * @function Highcharts.keys
  2165. * @deprecated
  2166. *
  2167. * @param {*} obj
  2168. * The object of which the properties are to be returned.
  2169. *
  2170. * @return {Array<string>}
  2171. * An array of strings that represents all the properties.
  2172. */
  2173. H.keys = function (obj) {
  2174. error(32, false, void 0, { 'Highcharts.keys': 'use Object.keys' });
  2175. return Object.keys(obj);
  2176. };
  2177. /**
  2178. * Get the element's offset position, corrected for `overflow: auto`.
  2179. *
  2180. * @function Highcharts.offset
  2181. *
  2182. * @param {global.Element} el
  2183. * The DOM element.
  2184. *
  2185. * @return {Highcharts.OffsetObject}
  2186. * An object containing `left` and `top` properties for the position in
  2187. * the page.
  2188. */
  2189. var offset = H.offset = function offset(el) {
  2190. var docElem = doc.documentElement,
  2191. box = (el.parentElement || el.parentNode) ?
  2192. el.getBoundingClientRect() :
  2193. { top: 0,
  2194. left: 0 };
  2195. return {
  2196. top: box.top + (win.pageYOffset || docElem.scrollTop) -
  2197. (docElem.clientTop || 0),
  2198. left: box.left + (win.pageXOffset || docElem.scrollLeft) -
  2199. (docElem.clientLeft || 0)
  2200. };
  2201. };
  2202. /**
  2203. * Stop running animation.
  2204. *
  2205. * @function Highcharts.stop
  2206. *
  2207. * @param {Highcharts.SVGElement} el
  2208. * The SVGElement to stop animation on.
  2209. *
  2210. * @param {string} [prop]
  2211. * The property to stop animating. If given, the stop method will stop a
  2212. * single property from animating, while others continue.
  2213. *
  2214. * @return {void}
  2215. *
  2216. * @todo
  2217. * A possible extension to this would be to stop a single property, when
  2218. * we want to continue animating others. Then assign the prop to the timer
  2219. * in the Fx.run method, and check for the prop here. This would be an
  2220. * improvement in all cases where we stop the animation from .attr. Instead of
  2221. * stopping everything, we can just stop the actual attributes we're setting.
  2222. */
  2223. var stop = H.stop = function (el,
  2224. prop) {
  2225. var i = H.timers.length;
  2226. // Remove timers related to this element (#4519)
  2227. while (i--) {
  2228. if (H.timers[i].elem === el && (!prop || prop === H.timers[i].prop)) {
  2229. H.timers[i].stopped = true; // #4667
  2230. }
  2231. }
  2232. };
  2233. /* eslint-disable valid-jsdoc */
  2234. /**
  2235. * Iterate over object key pairs in an object.
  2236. *
  2237. * @function Highcharts.objectEach<T>
  2238. *
  2239. * @param {*} obj
  2240. * The object to iterate over.
  2241. *
  2242. * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
  2243. * The iterator callback. It passes three arguments:
  2244. * * value - The property value.
  2245. * * key - The property key.
  2246. * * obj - The object that objectEach is being applied to.
  2247. *
  2248. * @param {T} [ctx]
  2249. * The context.
  2250. *
  2251. * @return {void}
  2252. */
  2253. var objectEach = H.objectEach = function objectEach(obj,
  2254. fn,
  2255. ctx) {
  2256. /* eslint-enable valid-jsdoc */
  2257. for (var key in obj) {
  2258. if (Object.hasOwnProperty.call(obj,
  2259. key)) {
  2260. fn.call(ctx || obj[key],
  2261. obj[key],
  2262. key,
  2263. obj);
  2264. }
  2265. }
  2266. };
  2267. /**
  2268. * Iterate over an array.
  2269. *
  2270. * @deprecated
  2271. * @function Highcharts.each
  2272. *
  2273. * @param {Array<*>} arr
  2274. * The array to iterate over.
  2275. *
  2276. * @param {Function} fn
  2277. * The iterator callback. It passes three arguments:
  2278. * - `item`: The array item.
  2279. * - `index`: The item's index in the array.
  2280. * - `arr`: The array that each is being applied to.
  2281. *
  2282. * @param {*} [ctx]
  2283. * The context.
  2284. *
  2285. * @return {void}
  2286. */
  2287. /**
  2288. * Filter an array by a callback.
  2289. *
  2290. * @deprecated
  2291. * @function Highcharts.grep
  2292. *
  2293. * @param {Array<*>} arr
  2294. * The array to filter.
  2295. *
  2296. * @param {Function} callback
  2297. * The callback function. The function receives the item as the first
  2298. * argument. Return `true` if the item is to be preserved.
  2299. *
  2300. * @return {Array<*>}
  2301. * A new, filtered array.
  2302. */
  2303. /**
  2304. * Map an array by a callback.
  2305. *
  2306. * @deprecated
  2307. * @function Highcharts.map
  2308. *
  2309. * @param {Array<*>} arr
  2310. * The array to map.
  2311. *
  2312. * @param {Function} fn
  2313. * The callback function. Return the new value for the new array.
  2314. *
  2315. * @return {Array<*>}
  2316. * A new array item with modified items.
  2317. */
  2318. /**
  2319. * Reduce an array to a single value.
  2320. *
  2321. * @deprecated
  2322. * @function Highcharts.reduce
  2323. *
  2324. * @param {Array<*>} arr
  2325. * The array to reduce.
  2326. *
  2327. * @param {Function} fn
  2328. * The callback function. Return the reduced value. Receives 4
  2329. * arguments: Accumulated/reduced value, current value, current array
  2330. * index, and the array.
  2331. *
  2332. * @param {*} initialValue
  2333. * The initial value of the accumulator.
  2334. *
  2335. * @return {*}
  2336. * The reduced value.
  2337. */
  2338. /**
  2339. * Test whether at least one element in the array passes the test implemented by
  2340. * the provided function.
  2341. *
  2342. * @deprecated
  2343. * @function Highcharts.some
  2344. *
  2345. * @param {Array<*>} arr
  2346. * The array to test
  2347. *
  2348. * @param {Function} fn
  2349. * The function to run on each item. Return truty to pass the test.
  2350. * Receives arguments `currentValue`, `index` and `array`.
  2351. *
  2352. * @param {*} ctx
  2353. * The context.
  2354. *
  2355. * @return {boolean}
  2356. */
  2357. objectEach({
  2358. map: 'map',
  2359. each: 'forEach',
  2360. grep: 'filter',
  2361. reduce: 'reduce',
  2362. some: 'some'
  2363. }, function (val, key) {
  2364. H[key] = function (arr) {
  2365. var _a;
  2366. error(32, false, void 0, (_a = {}, _a["Highcharts." + key] = "use Array." + val, _a));
  2367. return Array.prototype[val].apply(arr, [].slice.call(arguments, 1));
  2368. };
  2369. });
  2370. /* eslint-disable valid-jsdoc */
  2371. /**
  2372. * Add an event listener.
  2373. *
  2374. * @function Highcharts.addEvent<T>
  2375. *
  2376. * @param {Highcharts.Class<T>|T} el
  2377. * The element or object to add a listener to. It can be a
  2378. * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
  2379. *
  2380. * @param {string} type
  2381. * The event type.
  2382. *
  2383. * @param {Highcharts.EventCallbackFunction<T>|Function} fn
  2384. * The function callback to execute when the event is fired.
  2385. *
  2386. * @param {Highcharts.EventOptionsObject} [options]
  2387. * Options for adding the event.
  2388. *
  2389. * @return {Function}
  2390. * A callback function to remove the added event.
  2391. */
  2392. var addEvent = H.addEvent = function (el,
  2393. type,
  2394. fn,
  2395. options) {
  2396. if (options === void 0) { options = {}; }
  2397. /* eslint-enable valid-jsdoc */
  2398. var events,
  2399. addEventListener = (el.addEventListener || H.addEventListenerPolyfill);
  2400. // If we're setting events directly on the constructor, use a separate
  2401. // collection, `protoEvents` to distinguish it from the item events in
  2402. // `hcEvents`.
  2403. if (typeof el === 'function' && el.prototype) {
  2404. events = el.prototype.protoEvents = el.prototype.protoEvents || {};
  2405. }
  2406. else {
  2407. events = el.hcEvents = el.hcEvents || {};
  2408. }
  2409. // Allow click events added to points, otherwise they will be prevented by
  2410. // the TouchPointer.pinch function after a pinch zoom operation (#7091).
  2411. if (H.Point &&
  2412. el instanceof H.Point &&
  2413. el.series &&
  2414. el.series.chart) {
  2415. el.series.chart.runTrackerClick = true;
  2416. }
  2417. // Handle DOM events
  2418. if (addEventListener) {
  2419. addEventListener.call(el, type, fn, false);
  2420. }
  2421. if (!events[type]) {
  2422. events[type] = [];
  2423. }
  2424. var eventObject = {
  2425. fn: fn,
  2426. order: typeof options.order === 'number' ? options.order : Infinity
  2427. };
  2428. events[type].push(eventObject);
  2429. // Order the calls
  2430. events[type].sort(function (a, b) {
  2431. return a.order - b.order;
  2432. });
  2433. // Return a function that can be called to remove this event.
  2434. return function () {
  2435. removeEvent(el, type, fn);
  2436. };
  2437. };
  2438. /* eslint-disable valid-jsdoc */
  2439. /**
  2440. * Remove an event that was added with {@link Highcharts#addEvent}.
  2441. *
  2442. * @function Highcharts.removeEvent<T>
  2443. *
  2444. * @param {Highcharts.Class<T>|T} el
  2445. * The element to remove events on.
  2446. *
  2447. * @param {string} [type]
  2448. * The type of events to remove. If undefined, all events are removed
  2449. * from the element.
  2450. *
  2451. * @param {Highcharts.EventCallbackFunction<T>} [fn]
  2452. * The specific callback to remove. If undefined, all events that match
  2453. * the element and optionally the type are removed.
  2454. *
  2455. * @return {void}
  2456. */
  2457. var removeEvent = H.removeEvent = function removeEvent(el,
  2458. type,
  2459. fn) {
  2460. /* eslint-enable valid-jsdoc */
  2461. var events;
  2462. /**
  2463. * @private
  2464. * @param {string} type - event type
  2465. * @param {Highcharts.EventCallbackFunction<T>} fn - callback
  2466. * @return {void}
  2467. */
  2468. function removeOneEvent(type, fn) {
  2469. var removeEventListener = (el.removeEventListener || H.removeEventListenerPolyfill);
  2470. if (removeEventListener) {
  2471. removeEventListener.call(el, type, fn, false);
  2472. }
  2473. }
  2474. /**
  2475. * @private
  2476. * @param {any} eventCollection - collection
  2477. * @return {void}
  2478. */
  2479. function removeAllEvents(eventCollection) {
  2480. var types,
  2481. len;
  2482. if (!el.nodeName) {
  2483. return; // break on non-DOM events
  2484. }
  2485. if (type) {
  2486. types = {};
  2487. types[type] = true;
  2488. }
  2489. else {
  2490. types = eventCollection;
  2491. }
  2492. objectEach(types, function (_val, n) {
  2493. if (eventCollection[n]) {
  2494. len = eventCollection[n].length;
  2495. while (len--) {
  2496. removeOneEvent(n, eventCollection[n][len].fn);
  2497. }
  2498. }
  2499. });
  2500. }
  2501. ['protoEvents', 'hcEvents'].forEach(function (coll, i) {
  2502. var eventElem = i ? el : el.prototype;
  2503. var eventCollection = eventElem && eventElem[coll];
  2504. if (eventCollection) {
  2505. if (type) {
  2506. events = (eventCollection[type] || []);
  2507. if (fn) {
  2508. eventCollection[type] = events.filter(function (obj) {
  2509. return fn !== obj.fn;
  2510. });
  2511. removeOneEvent(type, fn);
  2512. }
  2513. else {
  2514. removeAllEvents(eventCollection);
  2515. eventCollection[type] = [];
  2516. }
  2517. }
  2518. else {
  2519. removeAllEvents(eventCollection);
  2520. eventElem[coll] = {};
  2521. }
  2522. }
  2523. });
  2524. };
  2525. /* eslint-disable valid-jsdoc */
  2526. /**
  2527. * Fire an event that was registered with {@link Highcharts#addEvent}.
  2528. *
  2529. * @function Highcharts.fireEvent<T>
  2530. *
  2531. * @param {T} el
  2532. * The object to fire the event on. It can be a {@link HTMLDOMElement},
  2533. * an {@link SVGElement} or any other object.
  2534. *
  2535. * @param {string} type
  2536. * The type of event.
  2537. *
  2538. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  2539. * Custom event arguments that are passed on as an argument to the event
  2540. * handler.
  2541. *
  2542. * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
  2543. * The default function to execute if the other listeners haven't
  2544. * returned false.
  2545. *
  2546. * @return {void}
  2547. */
  2548. var fireEvent = H.fireEvent = function (el,
  2549. type,
  2550. eventArguments,
  2551. defaultFunction) {
  2552. /* eslint-enable valid-jsdoc */
  2553. var e,
  2554. i;
  2555. eventArguments = eventArguments || {};
  2556. if (doc.createEvent &&
  2557. (el.dispatchEvent || el.fireEvent)) {
  2558. e = doc.createEvent('Events');
  2559. e.initEvent(type, true, true);
  2560. extend(e, eventArguments);
  2561. if (el.dispatchEvent) {
  2562. el.dispatchEvent(e);
  2563. }
  2564. else {
  2565. el.fireEvent(type, e);
  2566. }
  2567. }
  2568. else {
  2569. if (!eventArguments.target) {
  2570. // We're running a custom event
  2571. extend(eventArguments, {
  2572. // Attach a simple preventDefault function to skip
  2573. // default handler if called. The built-in
  2574. // defaultPrevented property is not overwritable (#5112)
  2575. preventDefault: function () {
  2576. eventArguments.defaultPrevented = true;
  2577. },
  2578. // Setting target to native events fails with clicking
  2579. // the zoom-out button in Chrome.
  2580. target: el,
  2581. // If the type is not set, we're running a custom event
  2582. // (#2297). If it is set, we're running a browser event,
  2583. // and setting it will cause en error in IE8 (#2465).
  2584. type: type
  2585. });
  2586. }
  2587. var fireInOrder = function (protoEvents,
  2588. hcEvents) {
  2589. if (protoEvents === void 0) { protoEvents = []; }
  2590. if (hcEvents === void 0) { hcEvents = []; }
  2591. var iA = 0;
  2592. var iB = 0;
  2593. var length = protoEvents.length + hcEvents.length;
  2594. for (i = 0; i < length; i++) {
  2595. var obj = (!protoEvents[iA] ?
  2596. hcEvents[iB++] :
  2597. !hcEvents[iB] ?
  2598. protoEvents[iA++] :
  2599. protoEvents[iA].order <= hcEvents[iB].order ?
  2600. protoEvents[iA++] :
  2601. hcEvents[iB++]);
  2602. // If the event handler return false, prevent the default
  2603. // handler from executing
  2604. if (obj.fn.call(el, eventArguments) === false) {
  2605. eventArguments.preventDefault();
  2606. }
  2607. }
  2608. };
  2609. fireInOrder(el.protoEvents && el.protoEvents[type], el.hcEvents && el.hcEvents[type]);
  2610. }
  2611. // Run the default if not prevented
  2612. if (defaultFunction && !eventArguments.defaultPrevented) {
  2613. defaultFunction.call(el, eventArguments);
  2614. }
  2615. };
  2616. /**
  2617. * The global animate method, which uses Fx to create individual animators.
  2618. *
  2619. * @function Highcharts.animate
  2620. *
  2621. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} el
  2622. * The element to animate.
  2623. *
  2624. * @param {Highcharts.CSSObject|Highcharts.SVGAttributes} params
  2625. * An object containing key-value pairs of the properties to animate.
  2626. * Supports numeric as pixel-based CSS properties for HTML objects and
  2627. * attributes for SVGElements.
  2628. *
  2629. * @param {Partial<Highcharts.AnimationOptionsObject>} [opt]
  2630. * Animation options.
  2631. *
  2632. * @return {void}
  2633. */
  2634. var animate = H.animate = function (el,
  2635. params,
  2636. opt) {
  2637. var start,
  2638. unit = '',
  2639. end,
  2640. fx,
  2641. args;
  2642. if (!isObject(opt)) { // Number or undefined/null
  2643. args = arguments;
  2644. opt = {
  2645. duration: args[2],
  2646. easing: args[3],
  2647. complete: args[4]
  2648. };
  2649. }
  2650. if (!isNumber(opt.duration)) {
  2651. opt.duration = 400;
  2652. }
  2653. opt.easing = typeof opt.easing === 'function' ?
  2654. opt.easing :
  2655. (Math[opt.easing] || Math.easeInOutSine);
  2656. opt.curAnim = merge(params);
  2657. objectEach(params, function (val, prop) {
  2658. // Stop current running animation of this property
  2659. stop(el, prop);
  2660. fx = new Fx(el, opt, prop);
  2661. end = null;
  2662. if (prop === 'd' && isArray(params.d)) {
  2663. fx.paths = fx.initPath(el, el.pathArray, params.d);
  2664. fx.toD = params.d;
  2665. start = 0;
  2666. end = 1;
  2667. }
  2668. else if (el.attr) {
  2669. start = el.attr(prop);
  2670. }
  2671. else {
  2672. start = parseFloat(getStyle(el, prop)) || 0;
  2673. if (prop !== 'opacity') {
  2674. unit = 'px';
  2675. }
  2676. }
  2677. if (!end) {
  2678. end = val;
  2679. }
  2680. if (end && end.match && end.match('px')) {
  2681. end = end.replace(/px/g, ''); // #4351
  2682. }
  2683. fx.run(start, end, unit);
  2684. });
  2685. };
  2686. /**
  2687. * Factory to create new series prototypes.
  2688. *
  2689. * @function Highcharts.seriesType
  2690. *
  2691. * @param {string} type
  2692. * The series type name.
  2693. *
  2694. * @param {string} parent
  2695. * The parent series type name. Use `line` to inherit from the basic
  2696. * {@link Series} object.
  2697. *
  2698. * @param {Highcharts.SeriesOptionsType|Highcharts.Dictionary<*>} options
  2699. * The additional default options that are merged with the parent's
  2700. * options.
  2701. *
  2702. * @param {Highcharts.Dictionary<*>} [props]
  2703. * The properties (functions and primitives) to set on the new
  2704. * prototype.
  2705. *
  2706. * @param {Highcharts.Dictionary<*>} [pointProps]
  2707. * Members for a series-specific extension of the {@link Point}
  2708. * prototype if needed.
  2709. *
  2710. * @return {Highcharts.Series}
  2711. * The newly created prototype as extended from {@link Series} or its
  2712. * derivatives.
  2713. */
  2714. // docs: add to API + extending Highcharts
  2715. var seriesType = H.seriesType = function (type,
  2716. parent,
  2717. options,
  2718. props,
  2719. pointProps) {
  2720. var defaultOptions = getOptions(),
  2721. seriesTypes = H.seriesTypes;
  2722. // Merge the options
  2723. defaultOptions.plotOptions[type] = merge(defaultOptions.plotOptions[parent], options);
  2724. // Create the class
  2725. seriesTypes[type] = extendClass(seriesTypes[parent] || function () { }, props);
  2726. seriesTypes[type].prototype.type = type;
  2727. // Create the point class if needed
  2728. if (pointProps) {
  2729. seriesTypes[type].prototype.pointClass =
  2730. extendClass(H.Point, pointProps);
  2731. }
  2732. return seriesTypes[type];
  2733. };
  2734. var serialMode;
  2735. /**
  2736. * Get a unique key for using in internal element id's and pointers. The key is
  2737. * composed of a random hash specific to this Highcharts instance, and a
  2738. * counter.
  2739. *
  2740. * @example
  2741. * var id = uniqueKey(); // => 'highcharts-x45f6hp-0'
  2742. *
  2743. * @function Highcharts.uniqueKey
  2744. *
  2745. * @return {string}
  2746. * A unique key.
  2747. */
  2748. var uniqueKey = H.uniqueKey = (function () {
  2749. var hash = Math.random().toString(36).substring(2, 9) + '-';
  2750. var id = 0;
  2751. return function () {
  2752. return 'highcharts-' + (serialMode ? '' : hash) + id++;
  2753. };
  2754. }());
  2755. /**
  2756. * Activates a serial mode for element IDs provided by
  2757. * {@link Highcharts.uniqueKey}. This mode can be used in automated tests, where
  2758. * a simple comparison of two rendered SVG graphics is needed.
  2759. *
  2760. * **Note:** This is only for testing purposes and will break functionality in
  2761. * webpages with multiple charts.
  2762. *
  2763. * @example
  2764. * if (
  2765. * process &&
  2766. * process.env.NODE_ENV === 'development'
  2767. * ) {
  2768. * Highcharts.useSerialIds(true);
  2769. * }
  2770. *
  2771. * @function Highcharts.useSerialIds
  2772. *
  2773. * @param {boolean} [mode]
  2774. * Changes the state of serial mode.
  2775. *
  2776. * @return {boolean|undefined}
  2777. * State of the serial mode.
  2778. */
  2779. var useSerialIds = H.useSerialIds = function (mode) {
  2780. return (serialMode = pick(mode,
  2781. serialMode));
  2782. };
  2783. var isFunction = H.isFunction = function (obj) {
  2784. return typeof obj === 'function';
  2785. };
  2786. /**
  2787. * Get the updated default options. Until 3.0.7, merely exposing defaultOptions
  2788. * for outside modules wasn't enough because the setOptions method created a new
  2789. * object.
  2790. *
  2791. * @function Highcharts.getOptions
  2792. *
  2793. * @return {Highcharts.Options}
  2794. */
  2795. var getOptions = H.getOptions = function () {
  2796. return H.defaultOptions;
  2797. };
  2798. /**
  2799. * Merge the default options with custom options and return the new options
  2800. * structure. Commonly used for defining reusable templates.
  2801. *
  2802. * @sample highcharts/global/useutc-false Setting a global option
  2803. * @sample highcharts/members/setoptions Applying a global theme
  2804. *
  2805. * @function Highcharts.setOptions
  2806. *
  2807. * @param {Highcharts.Options} options
  2808. * The new custom chart options.
  2809. *
  2810. * @return {Highcharts.Options}
  2811. * Updated options.
  2812. */
  2813. var setOptions = H.setOptions = function (options) {
  2814. // Copy in the default options
  2815. H.defaultOptions = merge(true,
  2816. H.defaultOptions,
  2817. options);
  2818. // Update the time object
  2819. if (options.time || options.global) {
  2820. H.time.update(merge(H.defaultOptions.global, H.defaultOptions.time, options.global, options.time));
  2821. }
  2822. return H.defaultOptions;
  2823. };
  2824. // Register Highcharts as a plugin in jQuery
  2825. if (win.jQuery) {
  2826. /**
  2827. * Highcharts-extended JQuery.
  2828. *
  2829. * @external JQuery
  2830. */
  2831. /**
  2832. * Helper function to return the chart of the current JQuery selector
  2833. * element.
  2834. *
  2835. * @function external:JQuery#highcharts
  2836. *
  2837. * @return {Highcharts.Chart}
  2838. * The chart that is linked to the JQuery selector element.
  2839. */ /**
  2840. * Factory function to create a chart in the current JQuery selector
  2841. * element.
  2842. *
  2843. * @function external:JQuery#highcharts
  2844. *
  2845. * @param {'Chart'|'Map'|'StockChart'|string} [className]
  2846. * Name of the factory class in the Highcharts namespace.
  2847. *
  2848. * @param {Highcharts.Options} [options]
  2849. * The chart options structure.
  2850. *
  2851. * @param {Highcharts.ChartCallbackFunction} [callback]
  2852. * Function to run when the chart has loaded and and all external
  2853. * images are loaded. Defining a
  2854. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  2855. * handler is equivalent.
  2856. *
  2857. * @return {JQuery}
  2858. * The current JQuery selector.
  2859. */
  2860. win.jQuery.fn.highcharts = function () {
  2861. var args = [].slice.call(arguments);
  2862. if (this[0]) { // this[0] is the renderTo div
  2863. // Create the chart
  2864. if (args[0]) {
  2865. new H[ // eslint-disable-line computed-property-spacing, no-new
  2866. // Constructor defaults to Chart
  2867. isString(args[0]) ? args.shift() : 'Chart'](this[0], args[0], args[1]);
  2868. return this;
  2869. }
  2870. // When called without parameters or with the return argument,
  2871. // return an existing chart
  2872. return charts[attr(this[0], 'data-highcharts-chart')];
  2873. }
  2874. };
  2875. }
  2876. // TODO use named exports when supported.
  2877. var utilitiesModule = {
  2878. Fx: H.Fx,
  2879. addEvent: addEvent,
  2880. animate: animate,
  2881. animObject: animObject,
  2882. arrayMax: arrayMax,
  2883. arrayMin: arrayMin,
  2884. attr: attr,
  2885. clamp: clamp,
  2886. clearTimeout: internalClearTimeout,
  2887. correctFloat: correctFloat,
  2888. createElement: createElement,
  2889. css: css,
  2890. defined: defined,
  2891. destroyObjectProperties: destroyObjectProperties,
  2892. discardElement: discardElement,
  2893. erase: erase,
  2894. error: error,
  2895. extend: extend,
  2896. extendClass: extendClass,
  2897. find: find,
  2898. fireEvent: fireEvent,
  2899. format: format,
  2900. getDeferredAnimation: getDeferredAnimation,
  2901. getMagnitude: getMagnitude,
  2902. getNestedProperty: getNestedProperty,
  2903. getOptions: getOptions,
  2904. getStyle: getStyle,
  2905. inArray: inArray,
  2906. isArray: isArray,
  2907. isClass: isClass,
  2908. isDOMElement: isDOMElement,
  2909. isFunction: isFunction,
  2910. isNumber: isNumber,
  2911. isObject: isObject,
  2912. isString: isString,
  2913. merge: merge,
  2914. normalizeTickInterval: normalizeTickInterval,
  2915. numberFormat: numberFormat,
  2916. objectEach: objectEach,
  2917. offset: offset,
  2918. pad: pad,
  2919. pick: pick,
  2920. pInt: pInt,
  2921. relativeLength: relativeLength,
  2922. removeEvent: removeEvent,
  2923. seriesType: seriesType,
  2924. setAnimation: setAnimation,
  2925. setOptions: setOptions,
  2926. splat: splat,
  2927. stableSort: stableSort,
  2928. stop: stop,
  2929. syncTimeout: syncTimeout,
  2930. timeUnits: timeUnits,
  2931. uniqueKey: uniqueKey,
  2932. useSerialIds: useSerialIds,
  2933. wrap: wrap
  2934. };
  2935. return utilitiesModule;
  2936. });
  2937. _registerModule(_modules, 'Core/Color.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  2938. /* *
  2939. *
  2940. * (c) 2010-2020 Torstein Honsi
  2941. *
  2942. * License: www.highcharts.com/license
  2943. *
  2944. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2945. *
  2946. * */
  2947. /**
  2948. * A valid color to be parsed and handled by Highcharts. Highcharts internally
  2949. * supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
  2950. * rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
  2951. * browsers and displayed correctly, but Highcharts is not able to process them
  2952. * and apply concepts like opacity and brightening.
  2953. *
  2954. * @typedef {string} Highcharts.ColorString
  2955. */
  2956. /**
  2957. * A valid color type than can be parsed and handled by Highcharts. It can be a
  2958. * color string, a gradient object, or a pattern object.
  2959. *
  2960. * @typedef {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} Highcharts.ColorType
  2961. */
  2962. /**
  2963. * Gradient options instead of a solid color.
  2964. *
  2965. * @example
  2966. * // Linear gradient used as a color option
  2967. * color: {
  2968. * linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
  2969. * stops: [
  2970. * [0, '#003399'], // start
  2971. * [0.5, '#ffffff'], // middle
  2972. * [1, '#3366AA'] // end
  2973. * ]
  2974. * }
  2975. *
  2976. * @interface Highcharts.GradientColorObject
  2977. */ /**
  2978. * Holds an object that defines the start position and the end position relative
  2979. * to the shape.
  2980. * @name Highcharts.GradientColorObject#linearGradient
  2981. * @type {Highcharts.LinearGradientColorObject|undefined}
  2982. */ /**
  2983. * Holds an object that defines the center position and the radius.
  2984. * @name Highcharts.GradientColorObject#radialGradient
  2985. * @type {Highcharts.RadialGradientColorObject|undefined}
  2986. */ /**
  2987. * The first item in each tuple is the position in the gradient, where 0 is the
  2988. * start of the gradient and 1 is the end of the gradient. Multiple stops can be
  2989. * applied. The second item is the color for each stop. This color can also be
  2990. * given in the rgba format.
  2991. * @name Highcharts.GradientColorObject#stops
  2992. * @type {Array<Highcharts.GradientColorStopObject>}
  2993. */
  2994. /**
  2995. * Color stop tuple.
  2996. *
  2997. * @see Highcharts.GradientColorObject
  2998. *
  2999. * @interface Highcharts.GradientColorStopObject
  3000. */ /**
  3001. * @name Highcharts.GradientColorStopObject#0
  3002. * @type {number}
  3003. */ /**
  3004. * @name Highcharts.GradientColorStopObject#1
  3005. * @type {Highcharts.ColorString}
  3006. */ /**
  3007. * @name Highcharts.GradientColorStopObject#color
  3008. * @type {Highcharts.Color|undefined}
  3009. */
  3010. /**
  3011. * Defines the start position and the end position for a gradient relative
  3012. * to the shape. Start position (x1, y1) and end position (x2, y2) are relative
  3013. * to the shape, where 0 means top/left and 1 is bottom/right.
  3014. *
  3015. * @interface Highcharts.LinearGradientColorObject
  3016. */ /**
  3017. * Start horizontal position of the gradient. Float ranges 0-1.
  3018. * @name Highcharts.LinearGradientColorObject#x1
  3019. * @type {number}
  3020. */ /**
  3021. * End horizontal position of the gradient. Float ranges 0-1.
  3022. * @name Highcharts.LinearGradientColorObject#x2
  3023. * @type {number}
  3024. */ /**
  3025. * Start vertical position of the gradient. Float ranges 0-1.
  3026. * @name Highcharts.LinearGradientColorObject#y1
  3027. * @type {number}
  3028. */ /**
  3029. * End vertical position of the gradient. Float ranges 0-1.
  3030. * @name Highcharts.LinearGradientColorObject#y2
  3031. * @type {number}
  3032. */
  3033. /**
  3034. * Defines the center position and the radius for a gradient.
  3035. *
  3036. * @interface Highcharts.RadialGradientColorObject
  3037. */ /**
  3038. * Center horizontal position relative to the shape. Float ranges 0-1.
  3039. * @name Highcharts.RadialGradientColorObject#cx
  3040. * @type {number}
  3041. */ /**
  3042. * Center vertical position relative to the shape. Float ranges 0-1.
  3043. * @name Highcharts.RadialGradientColorObject#cy
  3044. * @type {number}
  3045. */ /**
  3046. * Radius relative to the shape. Float ranges 0-1.
  3047. * @name Highcharts.RadialGradientColorObject#r
  3048. * @type {number}
  3049. */
  3050. var isNumber = U.isNumber,
  3051. merge = U.merge,
  3052. pInt = U.pInt;
  3053. /* eslint-disable no-invalid-this, valid-jsdoc */
  3054. /**
  3055. * Handle color operations. Some object methods are chainable.
  3056. *
  3057. * @class
  3058. * @name Highcharts.Color
  3059. *
  3060. * @param {Highcharts.ColorType} input
  3061. * The input color in either rbga or hex format
  3062. */
  3063. var Color = /** @class */ (function () {
  3064. /* *
  3065. *
  3066. * Constructors
  3067. *
  3068. * */
  3069. function Color(input) {
  3070. // Collection of parsers. This can be extended from the outside by pushing
  3071. // parsers to Highcharts.Color.prototype.parsers.
  3072. this.parsers = [{
  3073. // RGBA color
  3074. // eslint-disable-next-line max-len
  3075. 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*\)/,
  3076. parse: function (result) {
  3077. return [
  3078. pInt(result[1]),
  3079. pInt(result[2]),
  3080. pInt(result[3]),
  3081. parseFloat(result[4], 10)
  3082. ];
  3083. }
  3084. }, {
  3085. // RGB color
  3086. regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
  3087. parse: function (result) {
  3088. return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
  3089. }
  3090. }];
  3091. this.rgba = [];
  3092. // Backwards compatibility, allow instanciation without new (#13053)
  3093. if (!(this instanceof Color)) {
  3094. return new Color(input);
  3095. }
  3096. this.init(input);
  3097. }
  3098. /* *
  3099. *
  3100. * Static Functions
  3101. *
  3102. * */
  3103. /**
  3104. * Creates a color instance out of a color string or object.
  3105. *
  3106. * @function Highcharts.Color.parse
  3107. *
  3108. * @param {Highcharts.ColorType} input
  3109. * The input color in either rbga or hex format.
  3110. *
  3111. * @return {Highcharts.Color}
  3112. * Color instance.
  3113. */
  3114. Color.parse = function (input) {
  3115. return new Color(input);
  3116. };
  3117. /* *
  3118. *
  3119. * Functions
  3120. *
  3121. * */
  3122. /**
  3123. * Parse the input color to rgba array
  3124. *
  3125. * @private
  3126. * @function Highcharts.Color#init
  3127. *
  3128. * @param {Highcharts.ColorType} input
  3129. * The input color in either rbga or hex format
  3130. *
  3131. * @return {void}
  3132. */
  3133. Color.prototype.init = function (input) {
  3134. var result,
  3135. rgba,
  3136. i,
  3137. parser,
  3138. len;
  3139. this.input = input = Color.names[input && input.toLowerCase ?
  3140. input.toLowerCase() :
  3141. ''] || input;
  3142. // Gradients
  3143. if (input && input.stops) {
  3144. this.stops = input.stops.map(function (stop) {
  3145. return new Color(stop[1]);
  3146. });
  3147. // Solid colors
  3148. }
  3149. else {
  3150. // Bitmasking as input[0] is not working for legacy IE.
  3151. if (input &&
  3152. input.charAt &&
  3153. input.charAt() === '#') {
  3154. len = input.length;
  3155. input = parseInt(input.substr(1), 16);
  3156. // Handle long-form, e.g. #AABBCC
  3157. if (len === 7) {
  3158. rgba = [
  3159. (input & 0xFF0000) >> 16,
  3160. (input & 0xFF00) >> 8,
  3161. (input & 0xFF),
  3162. 1
  3163. ];
  3164. // Handle short-form, e.g. #ABC
  3165. // In short form, the value is assumed to be the same
  3166. // for both nibbles for each component. e.g. #ABC = #AABBCC
  3167. }
  3168. else if (len === 4) {
  3169. rgba = [
  3170. (((input & 0xF00) >> 4) |
  3171. (input & 0xF00) >> 8),
  3172. (((input & 0xF0) >> 4) |
  3173. (input & 0xF0)),
  3174. ((input & 0xF) << 4) | (input & 0xF),
  3175. 1
  3176. ];
  3177. }
  3178. }
  3179. // Otherwise, check regex parsers
  3180. if (!rgba) {
  3181. i = this.parsers.length;
  3182. while (i-- && !rgba) {
  3183. parser = this.parsers[i];
  3184. result = parser.regex.exec(input);
  3185. if (result) {
  3186. rgba = parser.parse(result);
  3187. }
  3188. }
  3189. }
  3190. }
  3191. this.rgba = rgba || [];
  3192. };
  3193. /**
  3194. * Return the color or gradient stops in the specified format
  3195. *
  3196. * @function Highcharts.Color#get
  3197. *
  3198. * @param {string} [format]
  3199. * Possible values are 'a', 'rgb', 'rgba' (default).
  3200. *
  3201. * @return {Highcharts.ColorType}
  3202. * This color as a string or gradient stops.
  3203. */
  3204. Color.prototype.get = function (format) {
  3205. var input = this.input,
  3206. rgba = this.rgba,
  3207. ret;
  3208. if (typeof this.stops !== 'undefined') {
  3209. ret = merge(input);
  3210. ret.stops = [].concat(ret.stops);
  3211. this.stops.forEach(function (stop, i) {
  3212. ret.stops[i] = [
  3213. ret.stops[i][0],
  3214. stop.get(format)
  3215. ];
  3216. });
  3217. // it's NaN if gradient colors on a column chart
  3218. }
  3219. else if (rgba && isNumber(rgba[0])) {
  3220. if (format === 'rgb' || (!format && rgba[3] === 1)) {
  3221. ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
  3222. }
  3223. else if (format === 'a') {
  3224. ret = rgba[3];
  3225. }
  3226. else {
  3227. ret = 'rgba(' + rgba.join(',') + ')';
  3228. }
  3229. }
  3230. else {
  3231. ret = input;
  3232. }
  3233. return ret;
  3234. };
  3235. /**
  3236. * Brighten the color instance.
  3237. *
  3238. * @function Highcharts.Color#brighten
  3239. *
  3240. * @param {number} alpha
  3241. * The alpha value.
  3242. *
  3243. * @return {Highcharts.Color}
  3244. * This color with modifications.
  3245. */
  3246. Color.prototype.brighten = function (alpha) {
  3247. var i,
  3248. rgba = this.rgba;
  3249. if (this.stops) {
  3250. this.stops.forEach(function (stop) {
  3251. stop.brighten(alpha);
  3252. });
  3253. }
  3254. else if (isNumber(alpha) && alpha !== 0) {
  3255. for (i = 0; i < 3; i++) {
  3256. rgba[i] += pInt(alpha * 255);
  3257. if (rgba[i] < 0) {
  3258. rgba[i] = 0;
  3259. }
  3260. if (rgba[i] > 255) {
  3261. rgba[i] = 255;
  3262. }
  3263. }
  3264. }
  3265. return this;
  3266. };
  3267. /**
  3268. * Set the color's opacity to a given alpha value.
  3269. *
  3270. * @function Highcharts.Color#setOpacity
  3271. *
  3272. * @param {number} alpha
  3273. * Opacity between 0 and 1.
  3274. *
  3275. * @return {Highcharts.Color}
  3276. * Color with modifications.
  3277. */
  3278. Color.prototype.setOpacity = function (alpha) {
  3279. this.rgba[3] = alpha;
  3280. return this;
  3281. };
  3282. /**
  3283. * Return an intermediate color between two colors.
  3284. *
  3285. * @function Highcharts.Color#tweenTo
  3286. *
  3287. * @param {Highcharts.Color} to
  3288. * The color object to tween to.
  3289. *
  3290. * @param {number} pos
  3291. * The intermediate position, where 0 is the from color (current
  3292. * color item), and 1 is the `to` color.
  3293. *
  3294. * @return {Highcharts.ColorString}
  3295. * The intermediate color in rgba notation.
  3296. */
  3297. Color.prototype.tweenTo = function (to, pos) {
  3298. // Check for has alpha, because rgba colors perform worse due to lack of
  3299. // support in WebKit.
  3300. var fromRgba = this.rgba,
  3301. toRgba = to.rgba,
  3302. hasAlpha,
  3303. ret;
  3304. // Unsupported color, return to-color (#3920, #7034)
  3305. if (!toRgba.length || !fromRgba || !fromRgba.length) {
  3306. ret = to.input || 'none';
  3307. // Interpolate
  3308. }
  3309. else {
  3310. hasAlpha = (toRgba[3] !== 1 || fromRgba[3] !== 1);
  3311. ret = (hasAlpha ? 'rgba(' : 'rgb(') +
  3312. Math.round(toRgba[0] + (fromRgba[0] - toRgba[0]) * (1 - pos)) +
  3313. ',' +
  3314. Math.round(toRgba[1] + (fromRgba[1] - toRgba[1]) * (1 - pos)) +
  3315. ',' +
  3316. Math.round(toRgba[2] + (fromRgba[2] - toRgba[2]) * (1 - pos)) +
  3317. (hasAlpha ?
  3318. (',' +
  3319. (toRgba[3] + (fromRgba[3] - toRgba[3]) * (1 - pos))) :
  3320. '') +
  3321. ')';
  3322. }
  3323. return ret;
  3324. };
  3325. /* *
  3326. *
  3327. * Static Properties
  3328. *
  3329. * */
  3330. // Collection of named colors. Can be extended from the outside by adding
  3331. // colors to Highcharts.Color.names.
  3332. Color.names = {
  3333. white: '#ffffff',
  3334. black: '#000000'
  3335. };
  3336. return Color;
  3337. }());
  3338. H.Color = Color;
  3339. /**
  3340. * Creates a color instance out of a color string.
  3341. *
  3342. * @function Highcharts.color
  3343. *
  3344. * @param {Highcharts.ColorType} input
  3345. * The input color in either rbga or hex format
  3346. *
  3347. * @return {Highcharts.Color}
  3348. * Color instance
  3349. */
  3350. H.color = Color.parse;
  3351. return H.Color;
  3352. });
  3353. _registerModule(_modules, 'Core/Renderer/SVG/SVGElement.js', [_modules['Core/Color.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Color, H, U) {
  3354. /* *
  3355. *
  3356. * (c) 2010-2020 Torstein Honsi
  3357. *
  3358. * License: www.highcharts.com/license
  3359. *
  3360. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3361. *
  3362. * */
  3363. var deg2rad = H.deg2rad,
  3364. doc = H.doc,
  3365. hasTouch = H.hasTouch,
  3366. isFirefox = H.isFirefox,
  3367. noop = H.noop,
  3368. svg = H.svg,
  3369. SVG_NS = H.SVG_NS,
  3370. win = H.win;
  3371. var animate = U.animate,
  3372. animObject = U.animObject,
  3373. attr = U.attr,
  3374. createElement = U.createElement,
  3375. css = U.css,
  3376. defined = U.defined,
  3377. erase = U.erase,
  3378. extend = U.extend,
  3379. fireEvent = U.fireEvent,
  3380. isArray = U.isArray,
  3381. isFunction = U.isFunction,
  3382. isNumber = U.isNumber,
  3383. isString = U.isString,
  3384. merge = U.merge,
  3385. objectEach = U.objectEach,
  3386. pick = U.pick,
  3387. pInt = U.pInt,
  3388. stop = U.stop,
  3389. syncTimeout = U.syncTimeout,
  3390. uniqueKey = U.uniqueKey;
  3391. /**
  3392. * The horizontal alignment of an element.
  3393. *
  3394. * @typedef {"center"|"left"|"right"} Highcharts.AlignValue
  3395. */
  3396. /**
  3397. * Options to align the element relative to the chart or another box.
  3398. *
  3399. * @interface Highcharts.AlignObject
  3400. */ /**
  3401. * Horizontal alignment. Can be one of `left`, `center` and `right`.
  3402. *
  3403. * @name Highcharts.AlignObject#align
  3404. * @type {Highcharts.AlignValue|undefined}
  3405. *
  3406. * @default left
  3407. */ /**
  3408. * Vertical alignment. Can be one of `top`, `middle` and `bottom`.
  3409. *
  3410. * @name Highcharts.AlignObject#verticalAlign
  3411. * @type {Highcharts.VerticalAlignValue|undefined}
  3412. *
  3413. * @default top
  3414. */ /**
  3415. * Horizontal pixel offset from alignment.
  3416. *
  3417. * @name Highcharts.AlignObject#x
  3418. * @type {number|undefined}
  3419. *
  3420. * @default 0
  3421. */ /**
  3422. * Vertical pixel offset from alignment.
  3423. *
  3424. * @name Highcharts.AlignObject#y
  3425. * @type {number|undefined}
  3426. *
  3427. * @default 0
  3428. */ /**
  3429. * Use the `transform` attribute with translateX and translateY custom
  3430. * attributes to align this elements rather than `x` and `y` attributes.
  3431. *
  3432. * @name Highcharts.AlignObject#alignByTranslate
  3433. * @type {boolean|undefined}
  3434. *
  3435. * @default false
  3436. */
  3437. /**
  3438. * Bounding box of an element.
  3439. *
  3440. * @interface Highcharts.BBoxObject
  3441. * @extends Highcharts.PositionObject
  3442. */ /**
  3443. * Height of the bounding box.
  3444. *
  3445. * @name Highcharts.BBoxObject#height
  3446. * @type {number}
  3447. */ /**
  3448. * Width of the bounding box.
  3449. *
  3450. * @name Highcharts.BBoxObject#width
  3451. * @type {number}
  3452. */ /**
  3453. * Horizontal position of the bounding box.
  3454. *
  3455. * @name Highcharts.BBoxObject#x
  3456. * @type {number}
  3457. */ /**
  3458. * Vertical position of the bounding box.
  3459. *
  3460. * @name Highcharts.BBoxObject#y
  3461. * @type {number}
  3462. */
  3463. /**
  3464. * An object of key-value pairs for SVG attributes. Attributes in Highcharts
  3465. * elements for the most parts correspond to SVG, but some are specific to
  3466. * Highcharts, like `zIndex`, `rotation`, `rotationOriginX`,
  3467. * `rotationOriginY`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
  3468. * attributes containing a hyphen are _not_ camel-cased, they should be
  3469. * quoted to preserve the hyphen.
  3470. *
  3471. * @example
  3472. * {
  3473. * 'stroke': '#ff0000', // basic
  3474. * 'stroke-width': 2, // hyphenated
  3475. * 'rotation': 45 // custom
  3476. * 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
  3477. * }
  3478. *
  3479. * @interface Highcharts.SVGAttributes
  3480. */ /**
  3481. * @name Highcharts.SVGAttributes#[key:string]
  3482. * @type {*}
  3483. */ /**
  3484. * @name Highcharts.SVGAttributes#d
  3485. * @type {string|Highcharts.SVGPathArray|undefined}
  3486. */ /**
  3487. * @name Highcharts.SVGAttributes#fill
  3488. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  3489. */ /**
  3490. * @name Highcharts.SVGAttributes#inverted
  3491. * @type {boolean|undefined}
  3492. */ /**
  3493. * @name Highcharts.SVGAttributes#matrix
  3494. * @type {Array<number>|undefined}
  3495. */ /**
  3496. * @name Highcharts.SVGAttributes#rotation
  3497. * @type {number|undefined}
  3498. */ /**
  3499. * @name Highcharts.SVGAttributes#rotationOriginX
  3500. * @type {number|undefined}
  3501. */ /**
  3502. * @name Highcharts.SVGAttributes#rotationOriginY
  3503. * @type {number|undefined}
  3504. */ /**
  3505. * @name Highcharts.SVGAttributes#scaleX
  3506. * @type {number|undefined}
  3507. */ /**
  3508. * @name Highcharts.SVGAttributes#scaleY
  3509. * @type {number|undefined}
  3510. */ /**
  3511. * @name Highcharts.SVGAttributes#stroke
  3512. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  3513. */ /**
  3514. * @name Highcharts.SVGAttributes#style
  3515. * @type {string|Highcharts.CSSObject|undefined}
  3516. */ /**
  3517. * @name Highcharts.SVGAttributes#translateX
  3518. * @type {number|undefined}
  3519. */ /**
  3520. * @name Highcharts.SVGAttributes#translateY
  3521. * @type {number|undefined}
  3522. */ /**
  3523. * @name Highcharts.SVGAttributes#zIndex
  3524. * @type {number|undefined}
  3525. */
  3526. /**
  3527. * An SVG DOM element. The type is a reference to the regular SVGElement in the
  3528. * global scope.
  3529. *
  3530. * @typedef {globals.GlobalSVGElement} Highcharts.SVGDOMElement
  3531. *
  3532. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  3533. */
  3534. /**
  3535. * The vertical alignment of an element.
  3536. *
  3537. * @typedef {"bottom"|"middle"|"top"} Highcharts.VerticalAlignValue
  3538. */
  3539. ''; // detach doclets above
  3540. /* eslint-disable no-invalid-this, valid-jsdoc */
  3541. /**
  3542. * The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
  3543. * rendering layer of Highcharts. Combined with the
  3544. * {@link Highcharts.SVGRenderer}
  3545. * object, these prototypes allow freeform annotation in the charts or even in
  3546. * HTML pages without instanciating a chart. The SVGElement can also wrap HTML
  3547. * labels, when `text` or `label` elements are created with the `useHTML`
  3548. * parameter.
  3549. *
  3550. * The SVGElement instances are created through factory functions on the
  3551. * {@link Highcharts.SVGRenderer}
  3552. * object, like
  3553. * {@link Highcharts.SVGRenderer#rect|rect},
  3554. * {@link Highcharts.SVGRenderer#path|path},
  3555. * {@link Highcharts.SVGRenderer#text|text},
  3556. * {@link Highcharts.SVGRenderer#label|label},
  3557. * {@link Highcharts.SVGRenderer#g|g}
  3558. * and more.
  3559. *
  3560. * @class
  3561. * @name Highcharts.SVGElement
  3562. */
  3563. var SVGElement = /** @class */ (function () {
  3564. function SVGElement() {
  3565. /* *
  3566. *
  3567. * Properties
  3568. *
  3569. * */
  3570. this.element = void 0;
  3571. this.height = void 0;
  3572. this.opacity = 1; // Default base for animation
  3573. this.renderer = void 0;
  3574. this.SVG_NS = SVG_NS;
  3575. // Custom attributes used for symbols, these should be filtered out when
  3576. // setting SVGElement attributes (#9375).
  3577. this.symbolCustomAttribs = [
  3578. 'x',
  3579. 'y',
  3580. 'width',
  3581. 'height',
  3582. 'r',
  3583. 'start',
  3584. 'end',
  3585. 'innerR',
  3586. 'anchorX',
  3587. 'anchorY',
  3588. 'rounded'
  3589. ];
  3590. this.width = void 0;
  3591. }
  3592. /* *
  3593. *
  3594. * Functions
  3595. *
  3596. * */
  3597. /**
  3598. * Get the current value of an attribute or pseudo attribute,
  3599. * used mainly for animation. Called internally from
  3600. * the {@link Highcharts.SVGRenderer#attr} function.
  3601. *
  3602. * @private
  3603. * @function Highcharts.SVGElement#_defaultGetter
  3604. *
  3605. * @param {string} key
  3606. * Property key.
  3607. *
  3608. * @return {number|string}
  3609. * Property value.
  3610. */
  3611. SVGElement.prototype._defaultGetter = function (key) {
  3612. var ret = pick(this[key + 'Value'], // align getter
  3613. this[key],
  3614. this.element ? this.element.getAttribute(key) : null, 0);
  3615. if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
  3616. ret = parseFloat(ret);
  3617. }
  3618. return ret;
  3619. };
  3620. /**
  3621. * @private
  3622. * @function Highcharts.SVGElement#_defaultSetter
  3623. *
  3624. * @param {string} value
  3625. *
  3626. * @param {string} key
  3627. *
  3628. * @param {Highcharts.SVGDOMElement} element
  3629. *
  3630. * @return {void}
  3631. */
  3632. SVGElement.prototype._defaultSetter = function (value, key, element) {
  3633. element.setAttribute(key, value);
  3634. };
  3635. /**
  3636. * Add the element to the DOM. All elements must be added this way.
  3637. *
  3638. * @sample highcharts/members/renderer-g
  3639. * Elements added to a group
  3640. *
  3641. * @function Highcharts.SVGElement#add
  3642. *
  3643. * @param {Highcharts.SVGElement} [parent]
  3644. * The parent item to add it to. If undefined, the element is added
  3645. * to the {@link Highcharts.SVGRenderer.box}.
  3646. *
  3647. * @return {Highcharts.SVGElement}
  3648. * Returns the SVGElement for chaining.
  3649. */
  3650. SVGElement.prototype.add = function (parent) {
  3651. var renderer = this.renderer,
  3652. element = this.element,
  3653. inserted;
  3654. if (parent) {
  3655. this.parentGroup = parent;
  3656. }
  3657. // Mark as inverted
  3658. this.parentInverted = parent && parent.inverted;
  3659. // Build formatted text
  3660. if (typeof this.textStr !== 'undefined' &&
  3661. this.element.nodeName === 'text' // Not for SVGLabel instances
  3662. ) {
  3663. renderer.buildText(this);
  3664. }
  3665. // Mark as added
  3666. this.added = true;
  3667. // If we're adding to renderer root, or other elements in the group
  3668. // have a z index, we need to handle it
  3669. if (!parent || parent.handleZ || this.zIndex) {
  3670. inserted = this.zIndexSetter();
  3671. }
  3672. // If zIndex is not handled, append at the end
  3673. if (!inserted) {
  3674. (parent ?
  3675. parent.element :
  3676. renderer.box).appendChild(element);
  3677. }
  3678. // fire an event for internal hooks
  3679. if (this.onAdd) {
  3680. this.onAdd();
  3681. }
  3682. return this;
  3683. };
  3684. /**
  3685. * Add a class name to an element.
  3686. *
  3687. * @function Highcharts.SVGElement#addClass
  3688. *
  3689. * @param {string} className
  3690. * The new class name to add.
  3691. *
  3692. * @param {boolean} [replace=false]
  3693. * When true, the existing class name(s) will be overwritten with the new
  3694. * one. When false, the new one is added.
  3695. *
  3696. * @return {Highcharts.SVGElement}
  3697. * Return the SVG element for chainability.
  3698. */
  3699. SVGElement.prototype.addClass = function (className, replace) {
  3700. var currentClassName = replace ? '' : (this.attr('class') || '');
  3701. // Trim the string and remove duplicates
  3702. className = (className || '')
  3703. .split(/ /g)
  3704. .reduce(function (newClassName, name) {
  3705. if (currentClassName.indexOf(name) === -1) {
  3706. newClassName.push(name);
  3707. }
  3708. return newClassName;
  3709. }, (currentClassName ?
  3710. [currentClassName] :
  3711. []))
  3712. .join(' ');
  3713. if (className !== currentClassName) {
  3714. this.attr('class', className);
  3715. }
  3716. return this;
  3717. };
  3718. /**
  3719. * This method is executed in the end of `attr()`, after setting all
  3720. * attributes in the hash. In can be used to efficiently consolidate
  3721. * multiple attributes in one SVG property -- e.g., translate, rotate and
  3722. * scale are merged in one "transform" attribute in the SVG node.
  3723. *
  3724. * @private
  3725. * @function Highcharts.SVGElement#afterSetters
  3726. */
  3727. SVGElement.prototype.afterSetters = function () {
  3728. // Update transform. Do this outside the loop to prevent redundant
  3729. // updating for batch setting of attributes.
  3730. if (this.doTransform) {
  3731. this.updateTransform();
  3732. this.doTransform = false;
  3733. }
  3734. };
  3735. /**
  3736. * Align the element relative to the chart or another box.
  3737. *
  3738. * @function Highcharts.SVGElement#align
  3739. *
  3740. * @param {Highcharts.AlignObject} [alignOptions]
  3741. * The alignment options. The function can be called without this
  3742. * parameter in order to re-align an element after the box has been
  3743. * updated.
  3744. *
  3745. * @param {boolean} [alignByTranslate]
  3746. * Align element by translation.
  3747. *
  3748. * @param {string|Highcharts.BBoxObject} [box]
  3749. * The box to align to, needs a width and height. When the box is a
  3750. * string, it refers to an object in the Renderer. For example, when
  3751. * box is `spacingBox`, it refers to `Renderer.spacingBox` which
  3752. * holds `width`, `height`, `x` and `y` properties.
  3753. *
  3754. * @return {Highcharts.SVGElement} Returns the SVGElement for chaining.
  3755. */
  3756. SVGElement.prototype.align = function (alignOptions, alignByTranslate, box) {
  3757. var align,
  3758. vAlign,
  3759. x,
  3760. y,
  3761. attribs = {},
  3762. alignTo,
  3763. renderer = this.renderer,
  3764. alignedObjects = renderer.alignedObjects,
  3765. alignFactor,
  3766. vAlignFactor;
  3767. // First call on instanciate
  3768. if (alignOptions) {
  3769. this.alignOptions = alignOptions;
  3770. this.alignByTranslate = alignByTranslate;
  3771. if (!box || isString(box)) {
  3772. this.alignTo = alignTo = box || 'renderer';
  3773. // prevent duplicates, like legendGroup after resize
  3774. erase(alignedObjects, this);
  3775. alignedObjects.push(this);
  3776. box = void 0; // reassign it below
  3777. }
  3778. // When called on resize, no arguments are supplied
  3779. }
  3780. else {
  3781. alignOptions = this.alignOptions;
  3782. alignByTranslate = this.alignByTranslate;
  3783. alignTo = this.alignTo;
  3784. }
  3785. box = pick(box, renderer[alignTo], renderer);
  3786. // Assign variables
  3787. align = alignOptions.align;
  3788. vAlign = alignOptions.verticalAlign;
  3789. // default: left align
  3790. x = (box.x || 0) + (alignOptions.x || 0);
  3791. // default: top align
  3792. y = (box.y || 0) + (alignOptions.y || 0);
  3793. // Align
  3794. if (align === 'right') {
  3795. alignFactor = 1;
  3796. }
  3797. else if (align === 'center') {
  3798. alignFactor = 2;
  3799. }
  3800. if (alignFactor) {
  3801. x += (box.width - (alignOptions.width || 0)) /
  3802. alignFactor;
  3803. }
  3804. attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
  3805. // Vertical align
  3806. if (vAlign === 'bottom') {
  3807. vAlignFactor = 1;
  3808. }
  3809. else if (vAlign === 'middle') {
  3810. vAlignFactor = 2;
  3811. }
  3812. if (vAlignFactor) {
  3813. y += (box.height - (alignOptions.height || 0)) /
  3814. vAlignFactor;
  3815. }
  3816. attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
  3817. // Animate only if already placed
  3818. this[this.placed ? 'animate' : 'attr'](attribs);
  3819. this.placed = true;
  3820. this.alignAttr = attribs;
  3821. return this;
  3822. };
  3823. /**
  3824. * @private
  3825. * @function Highcharts.SVGElement#alignSetter
  3826. * @param {"left"|"center"|"right"} value
  3827. */
  3828. SVGElement.prototype.alignSetter = function (value) {
  3829. var convert = {
  3830. left: 'start',
  3831. center: 'middle',
  3832. right: 'end'
  3833. };
  3834. if (convert[value]) {
  3835. this.alignValue = value;
  3836. this.element.setAttribute('text-anchor', convert[value]);
  3837. }
  3838. };
  3839. /**
  3840. * Animate to given attributes or CSS properties.
  3841. *
  3842. * @sample highcharts/members/element-on/
  3843. * Setting some attributes by animation
  3844. *
  3845. * @function Highcharts.SVGElement#animate
  3846. *
  3847. * @param {Highcharts.SVGAttributes} params
  3848. * SVG attributes or CSS to animate.
  3849. *
  3850. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [options]
  3851. * Animation options.
  3852. *
  3853. * @param {Function} [complete]
  3854. * Function to perform at the end of animation.
  3855. *
  3856. * @return {Highcharts.SVGElement}
  3857. * Returns the SVGElement for chaining.
  3858. */
  3859. SVGElement.prototype.animate = function (params, options, complete) {
  3860. var _this = this;
  3861. var animOptions = animObject(pick(options,
  3862. this.renderer.globalAnimation,
  3863. true)),
  3864. deferTime = animOptions.defer;
  3865. // When the page is hidden save resources in the background by not
  3866. // running animation at all (#9749).
  3867. if (pick(doc.hidden, doc.msHidden, doc.webkitHidden, false)) {
  3868. animOptions.duration = 0;
  3869. }
  3870. if (animOptions.duration !== 0) {
  3871. // allows using a callback with the global animation without
  3872. // overwriting it
  3873. if (complete) {
  3874. animOptions.complete = complete;
  3875. }
  3876. // If defer option is defined delay the animation #12901
  3877. syncTimeout(function () {
  3878. if (_this.element) {
  3879. animate(_this, params, animOptions);
  3880. }
  3881. }, deferTime);
  3882. }
  3883. else {
  3884. this.attr(params, void 0, complete);
  3885. // Call the end step synchronously
  3886. objectEach(params, function (val, prop) {
  3887. if (animOptions.step) {
  3888. animOptions.step.call(this, val, { prop: prop, pos: 1 });
  3889. }
  3890. }, this);
  3891. }
  3892. return this;
  3893. };
  3894. /**
  3895. * Apply a text outline through a custom CSS property, by copying the text
  3896. * element and apply stroke to the copy. Used internally. Contrast checks at
  3897. * [example](https://jsfiddle.net/highcharts/43soe9m1/2/).
  3898. *
  3899. * @example
  3900. * // Specific color
  3901. * text.css({
  3902. * textOutline: '1px black'
  3903. * });
  3904. * // Automatic contrast
  3905. * text.css({
  3906. * color: '#000000', // black text
  3907. * textOutline: '1px contrast' // => white outline
  3908. * });
  3909. *
  3910. * @private
  3911. * @function Highcharts.SVGElement#applyTextOutline
  3912. *
  3913. * @param {string} textOutline
  3914. * A custom CSS `text-outline` setting, defined by `width color`.
  3915. */
  3916. SVGElement.prototype.applyTextOutline = function (textOutline) {
  3917. var elem = this.element,
  3918. tspans,
  3919. hasContrast = textOutline.indexOf('contrast') !== -1,
  3920. styles = {},
  3921. color,
  3922. strokeWidth,
  3923. firstRealChild;
  3924. // When the text shadow is set to contrast, use dark stroke for light
  3925. // text and vice versa.
  3926. if (hasContrast) {
  3927. styles.textOutline = textOutline = textOutline.replace(/contrast/g, this.renderer.getContrast(elem.style.fill));
  3928. }
  3929. // Extract the stroke width and color
  3930. textOutline = textOutline.split(' ');
  3931. color = textOutline[textOutline.length - 1];
  3932. strokeWidth = textOutline[0];
  3933. if (strokeWidth && strokeWidth !== 'none' && H.svg) {
  3934. this.fakeTS = true; // Fake text shadow
  3935. tspans = [].slice.call(elem.getElementsByTagName('tspan'));
  3936. // In order to get the right y position of the clone,
  3937. // copy over the y setter
  3938. this.ySetter = this.xSetter;
  3939. // Since the stroke is applied on center of the actual outline, we
  3940. // need to double it to get the correct stroke-width outside the
  3941. // glyphs.
  3942. strokeWidth = strokeWidth.replace(/(^[\d\.]+)(.*?)$/g, function (match, digit, unit) {
  3943. return (2 * digit) + unit;
  3944. });
  3945. // Remove shadows from previous runs.
  3946. this.removeTextOutline(tspans);
  3947. // Check if the element contains RTL characters.
  3948. // Comparing against Hebrew and Arabic characters,
  3949. // excluding Arabic digits. Source:
  3950. // https://www.unicode.org/Public/UNIDATA/extracted/DerivedBidiClass.txt
  3951. var isRTL_1 = elem.textContent ?
  3952. /^[\u0591-\u065F\u066A-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]/
  3953. .test(elem.textContent) : false;
  3954. // For each of the tspans, create a stroked copy behind it.
  3955. firstRealChild = elem.firstChild;
  3956. tspans.forEach(function (tspan, y) {
  3957. var clone;
  3958. // Let the first line start at the correct X position
  3959. if (y === 0) {
  3960. tspan.setAttribute('x', elem.getAttribute('x'));
  3961. y = elem.getAttribute('y');
  3962. tspan.setAttribute('y', y || 0);
  3963. if (y === null) {
  3964. elem.setAttribute('y', 0);
  3965. }
  3966. }
  3967. // Create the clone and apply outline properties.
  3968. // For RTL elements apply outline properties for orginal element
  3969. // to prevent outline from overlapping the text.
  3970. // For RTL in Firefox keep the orginal order (#10162).
  3971. clone = tspan.cloneNode(true);
  3972. attr((isRTL_1 && !isFirefox) ? tspan : clone, {
  3973. 'class': 'highcharts-text-outline',
  3974. fill: color,
  3975. stroke: color,
  3976. 'stroke-width': strokeWidth,
  3977. 'stroke-linejoin': 'round'
  3978. });
  3979. elem.insertBefore(clone, firstRealChild);
  3980. });
  3981. // Create a whitespace between tspan and clone,
  3982. // to fix the display of Arabic characters in Firefox.
  3983. if (isRTL_1 && isFirefox && tspans[0]) {
  3984. var whitespace = tspans[0].cloneNode(true);
  3985. whitespace.textContent = ' ';
  3986. elem.insertBefore(whitespace, firstRealChild);
  3987. }
  3988. }
  3989. };
  3990. /**
  3991. * @function Highcharts.SVGElement#attr
  3992. * @param {string} key
  3993. * @return {number|string}
  3994. */ /**
  3995. * Apply native and custom attributes to the SVG elements.
  3996. *
  3997. * In order to set the rotation center for rotation, set x and y to 0 and
  3998. * use `translateX` and `translateY` attributes to position the element
  3999. * instead.
  4000. *
  4001. * Attributes frequently used in Highcharts are `fill`, `stroke`,
  4002. * `stroke-width`.
  4003. *
  4004. * @sample highcharts/members/renderer-rect/
  4005. * Setting some attributes
  4006. *
  4007. * @example
  4008. * // Set multiple attributes
  4009. * element.attr({
  4010. * stroke: 'red',
  4011. * fill: 'blue',
  4012. * x: 10,
  4013. * y: 10
  4014. * });
  4015. *
  4016. * // Set a single attribute
  4017. * element.attr('stroke', 'red');
  4018. *
  4019. * // Get an attribute
  4020. * element.attr('stroke'); // => 'red'
  4021. *
  4022. * @function Highcharts.SVGElement#attr
  4023. *
  4024. * @param {string|Highcharts.SVGAttributes} [hash]
  4025. * The native and custom SVG attributes.
  4026. *
  4027. * @param {number|string|Highcharts.SVGPathArray} [val]
  4028. * If the type of the first argument is `string`, the second can be a
  4029. * value, which will serve as a single attribute setter. If the first
  4030. * argument is a string and the second is undefined, the function
  4031. * serves as a getter and the current value of the property is
  4032. * returned.
  4033. *
  4034. * @param {Function} [complete]
  4035. * A callback function to execute after setting the attributes. This
  4036. * makes the function compliant and interchangeable with the
  4037. * {@link SVGElement#animate} function.
  4038. *
  4039. * @param {boolean} [continueAnimation=true]
  4040. * Used internally when `.attr` is called as part of an animation
  4041. * step. Otherwise, calling `.attr` for an attribute will stop
  4042. * animation for that attribute.
  4043. *
  4044. * @return {Highcharts.SVGElement}
  4045. * If used as a setter, it returns the current
  4046. * {@link Highcharts.SVGElement} so the calls can be chained. If
  4047. * used as a getter, the current value of the attribute is returned.
  4048. */
  4049. SVGElement.prototype.attr = function (hash, val, complete, continueAnimation) {
  4050. var key,
  4051. element = this.element,
  4052. hasSetSymbolSize,
  4053. ret = this,
  4054. skipAttr,
  4055. setter,
  4056. symbolCustomAttribs = this.symbolCustomAttribs;
  4057. // single key-value pair
  4058. if (typeof hash === 'string' && typeof val !== 'undefined') {
  4059. key = hash;
  4060. hash = {};
  4061. hash[key] = val;
  4062. }
  4063. // used as a getter: first argument is a string, second is undefined
  4064. if (typeof hash === 'string') {
  4065. ret = (this[hash + 'Getter'] ||
  4066. this._defaultGetter).call(this, hash, element);
  4067. // setter
  4068. }
  4069. else {
  4070. objectEach(hash, function eachAttribute(val, key) {
  4071. skipAttr = false;
  4072. // Unless .attr is from the animator update, stop current
  4073. // running animation of this property
  4074. if (!continueAnimation) {
  4075. stop(this, key);
  4076. }
  4077. // Special handling of symbol attributes
  4078. if (this.symbolName &&
  4079. symbolCustomAttribs.indexOf(key) !== -1) {
  4080. if (!hasSetSymbolSize) {
  4081. this.symbolAttr(hash);
  4082. hasSetSymbolSize = true;
  4083. }
  4084. skipAttr = true;
  4085. }
  4086. if (this.rotation && (key === 'x' || key === 'y')) {
  4087. this.doTransform = true;
  4088. }
  4089. if (!skipAttr) {
  4090. setter = (this[key + 'Setter'] ||
  4091. this._defaultSetter);
  4092. setter.call(this, val, key, element);
  4093. // Let the shadow follow the main element
  4094. if (!this.styledMode &&
  4095. this.shadows &&
  4096. /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
  4097. this.updateShadows(key, val, setter);
  4098. }
  4099. }
  4100. }, this);
  4101. this.afterSetters();
  4102. }
  4103. // In accordance with animate, run a complete callback
  4104. if (complete) {
  4105. complete.call(this);
  4106. }
  4107. return ret;
  4108. };
  4109. /**
  4110. * Apply a clipping rectangle to this element.
  4111. *
  4112. * @function Highcharts.SVGElement#clip
  4113. *
  4114. * @param {Highcharts.ClipRectElement} [clipRect]
  4115. * The clipping rectangle. If skipped, the current clip is removed.
  4116. *
  4117. * @return {Highcharts.SVGElement}
  4118. * Returns the SVG element to allow chaining.
  4119. */
  4120. SVGElement.prototype.clip = function (clipRect) {
  4121. return this.attr('clip-path', clipRect ?
  4122. 'url(' + this.renderer.url + '#' + clipRect.id + ')' :
  4123. 'none');
  4124. };
  4125. /**
  4126. * Calculate the coordinates needed for drawing a rectangle crisply and
  4127. * return the calculated attributes.
  4128. *
  4129. * @function Highcharts.SVGElement#crisp
  4130. *
  4131. * @param {Highcharts.RectangleObject} rect
  4132. * Rectangle to crisp.
  4133. *
  4134. * @param {number} [strokeWidth]
  4135. * The stroke width to consider when computing crisp positioning. It can
  4136. * also be set directly on the rect parameter.
  4137. *
  4138. * @return {Highcharts.RectangleObject}
  4139. * The modified rectangle arguments.
  4140. */
  4141. SVGElement.prototype.crisp = function (rect, strokeWidth) {
  4142. var wrapper = this,
  4143. normalizer;
  4144. strokeWidth = strokeWidth || rect.strokeWidth || 0;
  4145. // Math.round because strokeWidth can sometimes have roundoff errors
  4146. normalizer = Math.round(strokeWidth) % 2 / 2;
  4147. // normalize for crisp edges
  4148. rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
  4149. rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
  4150. rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
  4151. rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
  4152. if (defined(rect.strokeWidth)) {
  4153. rect.strokeWidth = strokeWidth;
  4154. }
  4155. return rect;
  4156. };
  4157. /**
  4158. * Build and apply an SVG gradient out of a common JavaScript configuration
  4159. * object. This function is called from the attribute setters. An event
  4160. * hook is added for supporting other complex color types.
  4161. *
  4162. * @private
  4163. * @function Highcharts.SVGElement#complexColor
  4164. *
  4165. * @param {Highcharts.GradientColorObject|Highcharts.PatternObject} colorOptions
  4166. * The gradient or pattern options structure.
  4167. *
  4168. * @param {string} prop
  4169. * The property to apply, can either be `fill` or `stroke`.
  4170. *
  4171. * @param {Highcharts.SVGDOMElement} elem
  4172. * SVG element to apply the gradient on.
  4173. */
  4174. SVGElement.prototype.complexColor = function (colorOptions, prop, elem) {
  4175. var renderer = this.renderer,
  4176. colorObject,
  4177. gradName,
  4178. gradAttr,
  4179. radAttr,
  4180. gradients,
  4181. stops,
  4182. stopColor,
  4183. stopOpacity,
  4184. radialReference,
  4185. id,
  4186. key = [],
  4187. value;
  4188. fireEvent(this.renderer, 'complexColor', {
  4189. args: arguments
  4190. }, function () {
  4191. // Apply linear or radial gradients
  4192. if (colorOptions.radialGradient) {
  4193. gradName = 'radialGradient';
  4194. }
  4195. else if (colorOptions.linearGradient) {
  4196. gradName = 'linearGradient';
  4197. }
  4198. if (gradName) {
  4199. gradAttr = colorOptions[gradName];
  4200. gradients = renderer.gradients;
  4201. stops = colorOptions.stops;
  4202. radialReference = elem.radialReference;
  4203. // Keep < 2.2 kompatibility
  4204. if (isArray(gradAttr)) {
  4205. colorOptions[gradName] = gradAttr = {
  4206. x1: gradAttr[0],
  4207. y1: gradAttr[1],
  4208. x2: gradAttr[2],
  4209. y2: gradAttr[3],
  4210. gradientUnits: 'userSpaceOnUse'
  4211. };
  4212. }
  4213. // Correct the radial gradient for the radial reference system
  4214. if (gradName === 'radialGradient' &&
  4215. radialReference &&
  4216. !defined(gradAttr.gradientUnits)) {
  4217. // Save the radial attributes for updating
  4218. radAttr = gradAttr;
  4219. gradAttr = merge(gradAttr, renderer.getRadialAttr(radialReference, radAttr), { gradientUnits: 'userSpaceOnUse' });
  4220. }
  4221. // Build the unique key to detect whether we need to create a
  4222. // new element (#1282)
  4223. objectEach(gradAttr, function (val, n) {
  4224. if (n !== 'id') {
  4225. key.push(n, val);
  4226. }
  4227. });
  4228. objectEach(stops, function (val) {
  4229. key.push(val);
  4230. });
  4231. key = key.join(',');
  4232. // Check if a gradient object with the same config object is
  4233. // created within this renderer
  4234. if (gradients[key]) {
  4235. id = gradients[key].attr('id');
  4236. }
  4237. else {
  4238. // Set the id and create the element
  4239. gradAttr.id = id = uniqueKey();
  4240. var gradientObject_1 = gradients[key] =
  4241. renderer.createElement(gradName)
  4242. .attr(gradAttr)
  4243. .add(renderer.defs);
  4244. gradientObject_1.radAttr = radAttr;
  4245. // The gradient needs to keep a list of stops to be able to
  4246. // destroy them
  4247. gradientObject_1.stops = [];
  4248. stops.forEach(function (stop) {
  4249. var stopObject;
  4250. if (stop[1].indexOf('rgba') === 0) {
  4251. colorObject = Color.parse(stop[1]);
  4252. stopColor = colorObject.get('rgb');
  4253. stopOpacity = colorObject.get('a');
  4254. }
  4255. else {
  4256. stopColor = stop[1];
  4257. stopOpacity = 1;
  4258. }
  4259. stopObject = renderer.createElement('stop').attr({
  4260. offset: stop[0],
  4261. 'stop-color': stopColor,
  4262. 'stop-opacity': stopOpacity
  4263. }).add(gradientObject_1);
  4264. // Add the stop element to the gradient
  4265. gradientObject_1.stops.push(stopObject);
  4266. });
  4267. }
  4268. // Set the reference to the gradient object
  4269. value = 'url(' + renderer.url + '#' + id + ')';
  4270. elem.setAttribute(prop, value);
  4271. elem.gradient = key;
  4272. // Allow the color to be concatenated into tooltips formatters
  4273. // etc. (#2995)
  4274. colorOptions.toString = function () {
  4275. return value;
  4276. };
  4277. }
  4278. });
  4279. };
  4280. /**
  4281. * Set styles for the element. In addition to CSS styles supported by
  4282. * native SVG and HTML elements, there are also some custom made for
  4283. * Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
  4284. * elements.
  4285. *
  4286. * @sample highcharts/members/renderer-text-on-chart/
  4287. * Styled text
  4288. *
  4289. * @function Highcharts.SVGElement#css
  4290. *
  4291. * @param {Highcharts.CSSObject} styles
  4292. * The new CSS styles.
  4293. *
  4294. * @return {Highcharts.SVGElement}
  4295. * Return the SVG element for chaining.
  4296. */
  4297. SVGElement.prototype.css = function (styles) {
  4298. var oldStyles = this.styles, newStyles = {}, elem = this.element, textWidth, serializedCss = '', hyphenate, hasNew = !oldStyles,
  4299. // These CSS properties are interpreted internally by the SVG
  4300. // renderer, but are not supported by SVG and should not be added to
  4301. // the DOM. In styled mode, no CSS should find its way to the DOM
  4302. // whatsoever (#6173, #6474).
  4303. svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
  4304. // convert legacy
  4305. if (styles && styles.color) {
  4306. styles.fill = styles.color;
  4307. }
  4308. // Filter out existing styles to increase performance (#2640)
  4309. if (oldStyles) {
  4310. objectEach(styles, function (style, n) {
  4311. if (oldStyles && oldStyles[n] !== style) {
  4312. newStyles[n] = style;
  4313. hasNew = true;
  4314. }
  4315. });
  4316. }
  4317. if (hasNew) {
  4318. // Merge the new styles with the old ones
  4319. if (oldStyles) {
  4320. styles = extend(oldStyles, newStyles);
  4321. }
  4322. // Get the text width from style
  4323. if (styles) {
  4324. // Previously set, unset it (#8234)
  4325. if (styles.width === null || styles.width === 'auto') {
  4326. delete this.textWidth;
  4327. // Apply new
  4328. }
  4329. else if (elem.nodeName.toLowerCase() === 'text' &&
  4330. styles.width) {
  4331. textWidth = this.textWidth = pInt(styles.width);
  4332. }
  4333. }
  4334. // store object
  4335. this.styles = styles;
  4336. if (textWidth && (!svg && this.renderer.forExport)) {
  4337. delete styles.width;
  4338. }
  4339. // Serialize and set style attribute
  4340. if (elem.namespaceURI === this.SVG_NS) { // #7633
  4341. hyphenate = function (a, b) {
  4342. return '-' + b.toLowerCase();
  4343. };
  4344. objectEach(styles, function (style, n) {
  4345. if (svgPseudoProps.indexOf(n) === -1) {
  4346. serializedCss +=
  4347. n.replace(/([A-Z])/g, hyphenate) + ':' +
  4348. style + ';';
  4349. }
  4350. });
  4351. if (serializedCss) {
  4352. attr(elem, 'style', serializedCss); // #1881
  4353. }
  4354. }
  4355. else {
  4356. css(elem, styles);
  4357. }
  4358. if (this.added) {
  4359. // Rebuild text after added. Cache mechanisms in the buildText
  4360. // will prevent building if there are no significant changes.
  4361. if (this.element.nodeName === 'text') {
  4362. this.renderer.buildText(this);
  4363. }
  4364. // Apply text outline after added
  4365. if (styles && styles.textOutline) {
  4366. this.applyTextOutline(styles.textOutline);
  4367. }
  4368. }
  4369. }
  4370. return this;
  4371. };
  4372. /**
  4373. * @private
  4374. * @function Highcharts.SVGElement#dashstyleSetter
  4375. * @param {string} value
  4376. */
  4377. SVGElement.prototype.dashstyleSetter = function (value) {
  4378. var i,
  4379. strokeWidth = this['stroke-width'];
  4380. // If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new
  4381. // strokeWidth function, we should be able to use that instead.
  4382. if (strokeWidth === 'inherit') {
  4383. strokeWidth = 1;
  4384. }
  4385. value = value && value.toLowerCase();
  4386. if (value) {
  4387. var v = value
  4388. .replace('shortdashdotdot', '3,1,1,1,1,1,')
  4389. .replace('shortdashdot', '3,1,1,1')
  4390. .replace('shortdot', '1,1,')
  4391. .replace('shortdash', '3,1,')
  4392. .replace('longdash', '8,3,')
  4393. .replace(/dot/g, '1,3,')
  4394. .replace('dash', '4,3,')
  4395. .replace(/,$/, '')
  4396. .split(','); // ending comma
  4397. i = v.length;
  4398. while (i--) {
  4399. v[i] = '' + (pInt(v[i]) * pick(strokeWidth, NaN));
  4400. }
  4401. value = v.join(',').replace(/NaN/g, 'none'); // #3226
  4402. this.element.setAttribute('stroke-dasharray', value);
  4403. }
  4404. };
  4405. /**
  4406. * Destroy the element and element wrapper and clear up the DOM and event
  4407. * hooks.
  4408. *
  4409. * @function Highcharts.SVGElement#destroy
  4410. */
  4411. SVGElement.prototype.destroy = function () {
  4412. var wrapper = this,
  4413. element = wrapper.element || {},
  4414. renderer = wrapper.renderer,
  4415. parentToClean = (renderer.isSVG &&
  4416. element.nodeName === 'SPAN' &&
  4417. wrapper.parentGroup ||
  4418. void 0),
  4419. grandParent,
  4420. ownerSVGElement = element.ownerSVGElement,
  4421. i;
  4422. // remove events
  4423. element.onclick = element.onmouseout = element.onmouseover =
  4424. element.onmousemove = element.point = null;
  4425. stop(wrapper); // stop running animations
  4426. if (wrapper.clipPath && ownerSVGElement) {
  4427. var clipPath_1 = wrapper.clipPath;
  4428. // Look for existing references to this clipPath and remove them
  4429. // before destroying the element (#6196).
  4430. // The upper case version is for Edge
  4431. [].forEach.call(ownerSVGElement.querySelectorAll('[clip-path],[CLIP-PATH]'), function (el) {
  4432. var clipPathAttr = el.getAttribute('clip-path');
  4433. if (clipPathAttr.indexOf(clipPath_1.element.id) > -1) {
  4434. el.removeAttribute('clip-path');
  4435. }
  4436. });
  4437. wrapper.clipPath = clipPath_1.destroy();
  4438. }
  4439. // Destroy stops in case this is a gradient object @todo old code?
  4440. if (wrapper.stops) {
  4441. for (i = 0; i < wrapper.stops.length; i++) {
  4442. wrapper.stops[i].destroy();
  4443. }
  4444. wrapper.stops.length = 0;
  4445. wrapper.stops = void 0;
  4446. }
  4447. // remove element
  4448. wrapper.safeRemoveChild(element);
  4449. if (!renderer.styledMode) {
  4450. wrapper.destroyShadows();
  4451. }
  4452. // In case of useHTML, clean up empty containers emulating SVG groups
  4453. // (#1960, #2393, #2697).
  4454. while (parentToClean &&
  4455. parentToClean.div &&
  4456. parentToClean.div.childNodes.length === 0) {
  4457. grandParent = parentToClean.parentGroup;
  4458. wrapper.safeRemoveChild(parentToClean.div);
  4459. delete parentToClean.div;
  4460. parentToClean = grandParent;
  4461. }
  4462. // remove from alignObjects
  4463. if (wrapper.alignTo) {
  4464. erase(renderer.alignedObjects, wrapper);
  4465. }
  4466. objectEach(wrapper, function (val, key) {
  4467. // Destroy child elements of a group
  4468. if (wrapper[key] &&
  4469. wrapper[key].parentGroup === wrapper &&
  4470. wrapper[key].destroy) {
  4471. wrapper[key].destroy();
  4472. }
  4473. // Delete all properties
  4474. delete wrapper[key];
  4475. });
  4476. return;
  4477. };
  4478. /**
  4479. * Destroy shadows on the element.
  4480. *
  4481. * @private
  4482. * @function Highcharts.SVGElement#destroyShadows
  4483. *
  4484. * @return {void}
  4485. */
  4486. SVGElement.prototype.destroyShadows = function () {
  4487. (this.shadows || []).forEach(function (shadow) {
  4488. this.safeRemoveChild(shadow);
  4489. }, this);
  4490. this.shadows = void 0;
  4491. };
  4492. /**
  4493. * @private
  4494. */
  4495. SVGElement.prototype.destroyTextPath = function (elem, path) {
  4496. var textElement = elem.getElementsByTagName('text')[0];
  4497. var tspans;
  4498. if (textElement) {
  4499. // Remove textPath attributes
  4500. textElement.removeAttribute('dx');
  4501. textElement.removeAttribute('dy');
  4502. // Remove ID's:
  4503. path.element.setAttribute('id', '');
  4504. // Check if textElement includes textPath,
  4505. if (this.textPathWrapper &&
  4506. textElement.getElementsByTagName('textPath').length) {
  4507. // Move nodes to <text>
  4508. tspans = this.textPathWrapper.element.childNodes;
  4509. // Now move all <tspan>'s to the <textPath> node
  4510. while (tspans.length) {
  4511. textElement.appendChild(tspans[0]);
  4512. }
  4513. // Remove <textPath> from the DOM
  4514. textElement.removeChild(this.textPathWrapper.element);
  4515. }
  4516. }
  4517. else if (elem.getAttribute('dx') || elem.getAttribute('dy')) {
  4518. // Remove textPath attributes from elem
  4519. // to get correct text-outline position
  4520. elem.removeAttribute('dx');
  4521. elem.removeAttribute('dy');
  4522. }
  4523. if (this.textPathWrapper) {
  4524. // Set textPathWrapper to undefined and destroy it
  4525. this.textPathWrapper = this.textPathWrapper.destroy();
  4526. }
  4527. };
  4528. /**
  4529. * @private
  4530. * @function Highcharts.SVGElement#dSettter
  4531. * @param {number|string|Highcharts.SVGPathArray} value
  4532. * @param {string} key
  4533. * @param {Highcharts.SVGDOMElement} element
  4534. */
  4535. SVGElement.prototype.dSetter = function (value, key, element) {
  4536. if (isArray(value)) {
  4537. // Backwards compatibility, convert one-dimensional array into an
  4538. // array of segments
  4539. if (typeof value[0] === 'string') {
  4540. value = this.renderer.pathToSegments(value);
  4541. }
  4542. this.pathArray = value;
  4543. value = value.reduce(function (acc, seg, i) {
  4544. if (!seg || !seg.join) {
  4545. return (seg || '').toString();
  4546. }
  4547. return (i ? acc + ' ' : '') + seg.join(' ');
  4548. }, '');
  4549. }
  4550. if (/(NaN| {2}|^$)/.test(value)) {
  4551. value = 'M 0 0';
  4552. }
  4553. // Check for cache before resetting. Resetting causes disturbance in the
  4554. // DOM, causing flickering in some cases in Edge/IE (#6747). Also
  4555. // possible performance gain.
  4556. if (this[key] !== value) {
  4557. element.setAttribute(key, value);
  4558. this[key] = value;
  4559. }
  4560. };
  4561. /**
  4562. * Fade out an element by animating its opacity down to 0, and hide it on
  4563. * complete. Used internally for the tooltip.
  4564. *
  4565. * @function Highcharts.SVGElement#fadeOut
  4566. *
  4567. * @param {number} [duration=150]
  4568. * The fade duration in milliseconds.
  4569. */
  4570. SVGElement.prototype.fadeOut = function (duration) {
  4571. var elemWrapper = this;
  4572. elemWrapper.animate({
  4573. opacity: 0
  4574. }, {
  4575. duration: pick(duration, 150),
  4576. complete: function () {
  4577. // #3088, assuming we're only using this for tooltips
  4578. elemWrapper.attr({ y: -9999 }).hide();
  4579. }
  4580. });
  4581. };
  4582. /**
  4583. * @private
  4584. * @function Highcharts.SVGElement#fillSetter
  4585. * @param {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} value
  4586. * @param {string} key
  4587. * @param {Highcharts.SVGDOMElement} element
  4588. */
  4589. SVGElement.prototype.fillSetter = function (value, key, element) {
  4590. if (typeof value === 'string') {
  4591. element.setAttribute(key, value);
  4592. }
  4593. else if (value) {
  4594. this.complexColor(value, key, element);
  4595. }
  4596. };
  4597. /**
  4598. * Get the bounding box (width, height, x and y) for the element. Generally
  4599. * used to get rendered text size. Since this is called a lot in charts,
  4600. * the results are cached based on text properties, in order to save DOM
  4601. * traffic. The returned bounding box includes the rotation, so for example
  4602. * a single text line of rotation 90 will report a greater height, and a
  4603. * width corresponding to the line-height.
  4604. *
  4605. * @sample highcharts/members/renderer-on-chart/
  4606. * Draw a rectangle based on a text's bounding box
  4607. *
  4608. * @function Highcharts.SVGElement#getBBox
  4609. *
  4610. * @param {boolean} [reload]
  4611. * Skip the cache and get the updated DOM bouding box.
  4612. *
  4613. * @param {number} [rot]
  4614. * Override the element's rotation. This is internally used on axis
  4615. * labels with a value of 0 to find out what the bounding box would
  4616. * be have been if it were not rotated.
  4617. *
  4618. * @return {Highcharts.BBoxObject}
  4619. * The bounding box with `x`, `y`, `width` and `height` properties.
  4620. */
  4621. SVGElement.prototype.getBBox = function (reload, rot) {
  4622. var wrapper = this,
  4623. bBox, // = wrapper.bBox,
  4624. renderer = wrapper.renderer,
  4625. width,
  4626. height,
  4627. element = wrapper.element,
  4628. styles = wrapper.styles,
  4629. fontSize,
  4630. textStr = wrapper.textStr,
  4631. toggleTextShadowShim,
  4632. cache = renderer.cache,
  4633. cacheKeys = renderer.cacheKeys,
  4634. isSVG = element.namespaceURI === wrapper.SVG_NS,
  4635. cacheKey;
  4636. var rotation = pick(rot,
  4637. wrapper.rotation, 0);
  4638. fontSize = renderer.styledMode ? (element &&
  4639. SVGElement.prototype.getStyle.call(element, 'font-size')) : (styles && styles.fontSize);
  4640. // Avoid undefined and null (#7316)
  4641. if (defined(textStr)) {
  4642. cacheKey = textStr.toString();
  4643. // Since numbers are monospaced, and numerical labels appear a lot
  4644. // in a chart, we assume that a label of n characters has the same
  4645. // bounding box as others of the same length. Unless there is inner
  4646. // HTML in the label. In that case, leave the numbers as is (#5899).
  4647. if (cacheKey.indexOf('<') === -1) {
  4648. cacheKey = cacheKey.replace(/[0-9]/g, '0');
  4649. }
  4650. // Properties that affect bounding box
  4651. cacheKey += [
  4652. '',
  4653. rotation,
  4654. fontSize,
  4655. wrapper.textWidth,
  4656. styles && styles.textOverflow,
  4657. styles && styles.fontWeight // #12163
  4658. ].join(',');
  4659. }
  4660. if (cacheKey && !reload) {
  4661. bBox = cache[cacheKey];
  4662. }
  4663. // No cache found
  4664. if (!bBox) {
  4665. // SVG elements
  4666. if (isSVG || renderer.forExport) {
  4667. try { // Fails in Firefox if the container has display: none.
  4668. // When the text shadow shim is used, we need to hide the
  4669. // fake shadows to get the correct bounding box (#3872)
  4670. toggleTextShadowShim = this.fakeTS && function (display) {
  4671. [].forEach.call(element.querySelectorAll('.highcharts-text-outline'), function (tspan) {
  4672. tspan.style.display = display;
  4673. });
  4674. };
  4675. // Workaround for #3842, Firefox reporting wrong bounding
  4676. // box for shadows
  4677. if (isFunction(toggleTextShadowShim)) {
  4678. toggleTextShadowShim('none');
  4679. }
  4680. bBox = element.getBBox ?
  4681. // SVG: use extend because IE9 is not allowed to change
  4682. // width and height in case of rotation (below)
  4683. extend({}, element.getBBox()) : {
  4684. // Legacy IE in export mode
  4685. width: element.offsetWidth,
  4686. height: element.offsetHeight
  4687. };
  4688. // #3842
  4689. if (isFunction(toggleTextShadowShim)) {
  4690. toggleTextShadowShim('');
  4691. }
  4692. }
  4693. catch (e) {
  4694. '';
  4695. }
  4696. // If the bBox is not set, the try-catch block above failed. The
  4697. // other condition is for Opera that returns a width of
  4698. // -Infinity on hidden elements.
  4699. if (!bBox || bBox.width < 0) {
  4700. bBox = { width: 0, height: 0 };
  4701. }
  4702. // VML Renderer or useHTML within SVG
  4703. }
  4704. else {
  4705. bBox = wrapper.htmlGetBBox();
  4706. }
  4707. // True SVG elements as well as HTML elements in modern browsers
  4708. // using the .useHTML option need to compensated for rotation
  4709. if (renderer.isSVG) {
  4710. width = bBox.width;
  4711. height = bBox.height;
  4712. // Workaround for wrong bounding box in IE, Edge and Chrome on
  4713. // Windows. With Highcharts' default font, IE and Edge report
  4714. // a box height of 16.899 and Chrome rounds it to 17. If this
  4715. // stands uncorrected, it results in more padding added below
  4716. // the text than above when adding a label border or background.
  4717. // Also vertical positioning is affected.
  4718. // https://jsfiddle.net/highcharts/em37nvuj/
  4719. // (#1101, #1505, #1669, #2568, #6213).
  4720. if (isSVG) {
  4721. bBox.height = height = ({
  4722. '11px,17': 14,
  4723. '13px,20': 16
  4724. }[styles &&
  4725. styles.fontSize + ',' + Math.round(height)] ||
  4726. height);
  4727. }
  4728. // Adjust for rotated text
  4729. if (rotation) {
  4730. var rad = rotation * deg2rad;
  4731. bBox.width = Math.abs(height * Math.sin(rad)) +
  4732. Math.abs(width * Math.cos(rad));
  4733. bBox.height = Math.abs(height * Math.cos(rad)) +
  4734. Math.abs(width * Math.sin(rad));
  4735. }
  4736. }
  4737. // Cache it. When loading a chart in a hidden iframe in Firefox and
  4738. // IE/Edge, the bounding box height is 0, so don't cache it (#5620).
  4739. if (cacheKey && bBox.height > 0) {
  4740. // Rotate (#4681)
  4741. while (cacheKeys.length > 250) {
  4742. delete cache[cacheKeys.shift()];
  4743. }
  4744. if (!cache[cacheKey]) {
  4745. cacheKeys.push(cacheKey);
  4746. }
  4747. cache[cacheKey] = bBox;
  4748. }
  4749. }
  4750. return bBox;
  4751. };
  4752. /**
  4753. * Get the computed style. Only in styled mode.
  4754. *
  4755. * @example
  4756. * chart.series[0].points[0].graphic.getStyle('stroke-width'); // => '1px'
  4757. *
  4758. * @function Highcharts.SVGElement#getStyle
  4759. *
  4760. * @param {string} prop
  4761. * The property name to check for.
  4762. *
  4763. * @return {string}
  4764. * The current computed value.
  4765. */
  4766. SVGElement.prototype.getStyle = function (prop) {
  4767. return win
  4768. .getComputedStyle(this.element || this, '')
  4769. .getPropertyValue(prop);
  4770. };
  4771. /**
  4772. * Check if an element has the given class name.
  4773. *
  4774. * @function Highcharts.SVGElement#hasClass
  4775. *
  4776. * @param {string} className
  4777. * The class name to check for.
  4778. *
  4779. * @return {boolean}
  4780. * Whether the class name is found.
  4781. */
  4782. SVGElement.prototype.hasClass = function (className) {
  4783. return ('' + this.attr('class'))
  4784. .split(' ')
  4785. .indexOf(className) !== -1;
  4786. };
  4787. /**
  4788. * Hide the element, similar to setting the `visibility` attribute to
  4789. * `hidden`.
  4790. *
  4791. * @function Highcharts.SVGElement#hide
  4792. *
  4793. * @param {boolean} [hideByTranslation=false]
  4794. * The flag to determine if element should be hidden by moving out
  4795. * of the viewport. Used for example for dataLabels.
  4796. *
  4797. * @return {Highcharts.SVGElement}
  4798. * Returns the SVGElement for chaining.
  4799. */
  4800. SVGElement.prototype.hide = function (hideByTranslation) {
  4801. if (hideByTranslation) {
  4802. this.attr({ y: -9999 });
  4803. }
  4804. else {
  4805. this.attr({ visibility: 'hidden' });
  4806. }
  4807. return this;
  4808. };
  4809. /**
  4810. * @private
  4811. */
  4812. SVGElement.prototype.htmlGetBBox = function () {
  4813. return { height: 0, width: 0, x: 0, y: 0 };
  4814. };
  4815. /**
  4816. * Initialize the SVG element. This function only exists to make the
  4817. * initialization process overridable. It should not be called directly.
  4818. *
  4819. * @function Highcharts.SVGElement#init
  4820. *
  4821. * @param {Highcharts.SVGRenderer} renderer
  4822. * The SVGRenderer instance to initialize to.
  4823. *
  4824. * @param {string} nodeName
  4825. * The SVG node name.
  4826. */
  4827. SVGElement.prototype.init = function (renderer, nodeName) {
  4828. /**
  4829. * The primary DOM node. Each `SVGElement` instance wraps a main DOM
  4830. * node, but may also represent more nodes.
  4831. *
  4832. * @name Highcharts.SVGElement#element
  4833. * @type {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement}
  4834. */
  4835. this.element = nodeName === 'span' ?
  4836. createElement(nodeName) :
  4837. doc.createElementNS(this.SVG_NS, nodeName);
  4838. /**
  4839. * The renderer that the SVGElement belongs to.
  4840. *
  4841. * @name Highcharts.SVGElement#renderer
  4842. * @type {Highcharts.SVGRenderer}
  4843. */
  4844. this.renderer = renderer;
  4845. fireEvent(this, 'afterInit');
  4846. };
  4847. /**
  4848. * Invert a group, rotate and flip. This is used internally on inverted
  4849. * charts, where the points and graphs are drawn as if not inverted, then
  4850. * the series group elements are inverted.
  4851. *
  4852. * @function Highcharts.SVGElement#invert
  4853. *
  4854. * @param {boolean} inverted
  4855. * Whether to invert or not. An inverted shape can be un-inverted by
  4856. * setting it to false.
  4857. *
  4858. * @return {Highcharts.SVGElement}
  4859. * Return the SVGElement for chaining.
  4860. */
  4861. SVGElement.prototype.invert = function (inverted) {
  4862. var wrapper = this;
  4863. wrapper.inverted = inverted;
  4864. wrapper.updateTransform();
  4865. return wrapper;
  4866. };
  4867. /**
  4868. * Add an event listener. This is a simple setter that replaces all other
  4869. * events of the same type, opposed to the {@link Highcharts#addEvent}
  4870. * function.
  4871. *
  4872. * @sample highcharts/members/element-on/
  4873. * A clickable rectangle
  4874. *
  4875. * @function Highcharts.SVGElement#on
  4876. *
  4877. * @param {string} eventType
  4878. * The event type. If the type is `click`, Highcharts will internally
  4879. * translate it to a `touchstart` event on touch devices, to prevent the
  4880. * browser from waiting for a click event from firing.
  4881. *
  4882. * @param {Function} handler
  4883. * The handler callback.
  4884. *
  4885. * @return {Highcharts.SVGElement}
  4886. * The SVGElement for chaining.
  4887. */
  4888. SVGElement.prototype.on = function (eventType, handler) {
  4889. var svgElement = this,
  4890. element = svgElement.element,
  4891. touchStartPos,
  4892. touchEventFired;
  4893. // touch
  4894. if (hasTouch && eventType === 'click') {
  4895. element.ontouchstart = function (e) {
  4896. // save touch position for later calculation
  4897. touchStartPos = {
  4898. clientX: e.touches[0].clientX,
  4899. clientY: e.touches[0].clientY
  4900. };
  4901. };
  4902. // Instead of ontouchstart, event handlers should be called
  4903. // on touchend - similar to how current mouseup events are called
  4904. element.ontouchend = function (e) {
  4905. // hasMoved is a boolean variable containing logic if page
  4906. // was scrolled, so if touch position changed more than
  4907. // ~4px (value borrowed from general touch handler)
  4908. var hasMoved = touchStartPos.clientX ? Math.sqrt(Math.pow(touchStartPos.clientX - e.changedTouches[0].clientX, 2) +
  4909. Math.pow(touchStartPos.clientY - e.changedTouches[0].clientY, 2)) >= 4 : false;
  4910. if (!hasMoved) { // only call handlers if page was not scrolled
  4911. handler.call(element, e);
  4912. }
  4913. touchEventFired = true;
  4914. // prevent other events from being fired. #9682
  4915. e.preventDefault();
  4916. };
  4917. element.onclick = function (e) {
  4918. // Do not call onclick handler if touch event was fired already.
  4919. if (!touchEventFired) {
  4920. handler.call(element, e);
  4921. }
  4922. };
  4923. }
  4924. else {
  4925. // simplest possible event model for internal use
  4926. element['on' + eventType] = handler;
  4927. }
  4928. return this;
  4929. };
  4930. /**
  4931. * @private
  4932. * @function Highcharts.SVGElement#opacitySetter
  4933. * @param {string} value
  4934. * @param {string} key
  4935. * @param {Highcharts.SVGDOMElement} element
  4936. */
  4937. SVGElement.prototype.opacitySetter = function (value, key, element) {
  4938. this[key] = value;
  4939. element.setAttribute(key, value);
  4940. };
  4941. /**
  4942. * Remove a class name from the element.
  4943. *
  4944. * @function Highcharts.SVGElement#removeClass
  4945. *
  4946. * @param {string|RegExp} className
  4947. * The class name to remove.
  4948. *
  4949. * @return {Highcharts.SVGElement} Returns the SVG element for chainability.
  4950. */
  4951. SVGElement.prototype.removeClass = function (className) {
  4952. return this.attr('class', ('' + this.attr('class'))
  4953. .replace(isString(className) ?
  4954. new RegExp("(^| )" + className + "( |$)") : // #12064, #13590
  4955. className, ' ')
  4956. .replace(/ +/g, ' ')
  4957. .trim());
  4958. };
  4959. /**
  4960. * @private
  4961. * @param {Array<Highcharts.SVGDOMElement>} tspans
  4962. * Text spans.
  4963. */
  4964. SVGElement.prototype.removeTextOutline = function (tspans) {
  4965. // Iterate from the end to
  4966. // support removing items inside the cycle (#6472).
  4967. var i = tspans.length,
  4968. tspan;
  4969. while (i--) {
  4970. tspan = tspans[i];
  4971. if (tspan.getAttribute('class') === 'highcharts-text-outline') {
  4972. // Remove then erase
  4973. erase(tspans, this.element.removeChild(tspan));
  4974. }
  4975. }
  4976. };
  4977. /**
  4978. * Removes an element from the DOM.
  4979. *
  4980. * @private
  4981. * @function Highcharts.SVGElement#safeRemoveChild
  4982. *
  4983. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  4984. * The DOM node to remove.
  4985. */
  4986. SVGElement.prototype.safeRemoveChild = function (element) {
  4987. var parentNode = element.parentNode;
  4988. if (parentNode) {
  4989. parentNode.removeChild(element);
  4990. }
  4991. };
  4992. /**
  4993. * Set the coordinates needed to draw a consistent radial gradient across
  4994. * a shape regardless of positioning inside the chart. Used on pie slices
  4995. * to make all the slices have the same radial reference point.
  4996. *
  4997. * @function Highcharts.SVGElement#setRadialReference
  4998. *
  4999. * @param {Array<number>} coordinates
  5000. * The center reference. The format is `[centerX, centerY, diameter]` in
  5001. * pixels.
  5002. *
  5003. * @return {Highcharts.SVGElement}
  5004. * Returns the SVGElement for chaining.
  5005. */
  5006. SVGElement.prototype.setRadialReference = function (coordinates) {
  5007. var existingGradient = (this.element.gradient &&
  5008. this.renderer.gradients[this.element.gradient]);
  5009. this.element.radialReference = coordinates;
  5010. // On redrawing objects with an existing gradient, the gradient needs
  5011. // to be repositioned (#3801)
  5012. if (existingGradient && existingGradient.radAttr) {
  5013. existingGradient.animate(this.renderer.getRadialAttr(coordinates, existingGradient.radAttr));
  5014. }
  5015. return this;
  5016. };
  5017. /**
  5018. * @private
  5019. * @function Highcharts.SVGElement#setTextPath
  5020. * @param {Highcharts.SVGElement} path
  5021. * Path to follow.
  5022. * @param {Highcharts.DataLabelsTextPathOptionsObject} textPathOptions
  5023. * Options.
  5024. * @return {Highcharts.SVGElement}
  5025. * Returns the SVGElement for chaining.
  5026. */
  5027. SVGElement.prototype.setTextPath = function (path, textPathOptions) {
  5028. var elem = this.element,
  5029. attribsMap = {
  5030. textAnchor: 'text-anchor'
  5031. },
  5032. attrs,
  5033. adder = false,
  5034. textPathElement,
  5035. textPathId,
  5036. textPathWrapper = this.textPathWrapper,
  5037. tspans,
  5038. firstTime = !textPathWrapper;
  5039. // Defaults
  5040. textPathOptions = merge(true, {
  5041. enabled: true,
  5042. attributes: {
  5043. dy: -5,
  5044. startOffset: '50%',
  5045. textAnchor: 'middle'
  5046. }
  5047. }, textPathOptions);
  5048. attrs = textPathOptions.attributes;
  5049. if (path && textPathOptions && textPathOptions.enabled) {
  5050. // In case of fixed width for a text, string is rebuilt
  5051. // (e.g. ellipsis is applied), so we need to rebuild textPath too
  5052. if (textPathWrapper &&
  5053. textPathWrapper.element.parentNode === null) {
  5054. // When buildText functionality was triggered again
  5055. // and deletes textPathWrapper parentNode
  5056. firstTime = true;
  5057. textPathWrapper = textPathWrapper.destroy();
  5058. }
  5059. else if (textPathWrapper) {
  5060. // Case after drillup when spans were added into
  5061. // the DOM outside the textPathWrapper parentGroup
  5062. this.removeTextOutline.call(textPathWrapper.parentGroup, [].slice.call(elem.getElementsByTagName('tspan')));
  5063. }
  5064. // label() has padding, text() doesn't
  5065. if (this.options && this.options.padding) {
  5066. attrs.dx = -this.options.padding;
  5067. }
  5068. if (!textPathWrapper) {
  5069. // Create <textPath>, defer the DOM adder
  5070. this.textPathWrapper = textPathWrapper =
  5071. this.renderer.createElement('textPath');
  5072. adder = true;
  5073. }
  5074. textPathElement = textPathWrapper.element;
  5075. // Set ID for the path
  5076. textPathId = path.element.getAttribute('id');
  5077. if (!textPathId) {
  5078. path.element.setAttribute('id', textPathId = uniqueKey());
  5079. }
  5080. // Change DOM structure, by placing <textPath> tag in <text>
  5081. if (firstTime) {
  5082. tspans = elem.getElementsByTagName('tspan');
  5083. // Now move all <tspan>'s to the <textPath> node
  5084. while (tspans.length) {
  5085. // Remove "y" from tspans, as Firefox translates them
  5086. tspans[0].setAttribute('y', 0);
  5087. // Remove "x" from tspans
  5088. if (isNumber(attrs.dx)) {
  5089. tspans[0].setAttribute('x', -attrs.dx);
  5090. }
  5091. textPathElement.appendChild(tspans[0]);
  5092. }
  5093. }
  5094. // Add <textPath> to the DOM
  5095. if (adder &&
  5096. textPathWrapper) {
  5097. textPathWrapper.add({
  5098. // label() is placed in a group, text() is standalone
  5099. element: this.text ? this.text.element : elem
  5100. });
  5101. }
  5102. // Set basic options:
  5103. // Use `setAttributeNS` because Safari needs this..
  5104. textPathElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.renderer.url + '#' + textPathId);
  5105. // Presentation attributes:
  5106. // dx/dy options must by set on <text> (parent),
  5107. // the rest should be set on <textPath>
  5108. if (defined(attrs.dy)) {
  5109. textPathElement.parentNode
  5110. .setAttribute('dy', attrs.dy);
  5111. delete attrs.dy;
  5112. }
  5113. if (defined(attrs.dx)) {
  5114. textPathElement.parentNode
  5115. .setAttribute('dx', attrs.dx);
  5116. delete attrs.dx;
  5117. }
  5118. // Additional attributes
  5119. objectEach(attrs, function (val, key) {
  5120. textPathElement.setAttribute(attribsMap[key] || key, val);
  5121. });
  5122. // Remove translation, text that follows path does not need that
  5123. elem.removeAttribute('transform');
  5124. // Remove shadows and text outlines
  5125. this.removeTextOutline.call(textPathWrapper, [].slice.call(elem.getElementsByTagName('tspan')));
  5126. // Remove background and border for label(), see #10545
  5127. // Alternatively, we can disable setting background rects in
  5128. // series.drawDataLabels()
  5129. if (this.text && !this.renderer.styledMode) {
  5130. this.attr({
  5131. fill: 'none',
  5132. 'stroke-width': 0
  5133. });
  5134. }
  5135. // Disable some functions
  5136. this.updateTransform = noop;
  5137. this.applyTextOutline = noop;
  5138. }
  5139. else if (textPathWrapper) {
  5140. // Reset to prototype
  5141. delete this.updateTransform;
  5142. delete this.applyTextOutline;
  5143. // Restore DOM structure:
  5144. this.destroyTextPath(elem, path);
  5145. // Bring attributes back
  5146. this.updateTransform();
  5147. // Set textOutline back for text()
  5148. if (this.options && this.options.rotation) {
  5149. this.applyTextOutline(this.options.style.textOutline);
  5150. }
  5151. }
  5152. return this;
  5153. };
  5154. /**
  5155. * Add a shadow to the element. Must be called after the element is added to
  5156. * the DOM. In styled mode, this method is not used, instead use `defs` and
  5157. * filters.
  5158. *
  5159. * @example
  5160. * renderer.rect(10, 100, 100, 100)
  5161. * .attr({ fill: 'red' })
  5162. * .shadow(true);
  5163. *
  5164. * @function Highcharts.SVGElement#shadow
  5165. *
  5166. * @param {boolean|Highcharts.ShadowOptionsObject} [shadowOptions]
  5167. * The shadow options. If `true`, the default options are applied. If
  5168. * `false`, the current shadow will be removed.
  5169. *
  5170. * @param {Highcharts.SVGElement} [group]
  5171. * The SVG group element where the shadows will be applied. The
  5172. * default is to add it to the same parent as the current element.
  5173. * Internally, this is ised for pie slices, where all the shadows are
  5174. * added to an element behind all the slices.
  5175. *
  5176. * @param {boolean} [cutOff]
  5177. * Used internally for column shadows.
  5178. *
  5179. * @return {Highcharts.SVGElement}
  5180. * Returns the SVGElement for chaining.
  5181. */
  5182. SVGElement.prototype.shadow = function (shadowOptions, group, cutOff) {
  5183. var shadows = [],
  5184. i,
  5185. shadow,
  5186. element = this.element,
  5187. strokeWidth,
  5188. shadowElementOpacity,
  5189. update = false,
  5190. oldShadowOptions = this.oldShadowOptions,
  5191. // compensate for inverted plot area
  5192. transform;
  5193. var defaultShadowOptions = {
  5194. color: '#000000',
  5195. offsetX: 1,
  5196. offsetY: 1,
  5197. opacity: 0.15,
  5198. width: 3
  5199. };
  5200. var options;
  5201. if (shadowOptions === true) {
  5202. options = defaultShadowOptions;
  5203. }
  5204. else if (typeof shadowOptions === 'object') {
  5205. options = extend(defaultShadowOptions, shadowOptions);
  5206. }
  5207. // Update shadow when options change (#12091).
  5208. if (options) {
  5209. // Go over each key to look for change
  5210. if (options && oldShadowOptions) {
  5211. objectEach(options, function (value, key) {
  5212. if (value !== oldShadowOptions[key]) {
  5213. update = true;
  5214. }
  5215. });
  5216. }
  5217. if (update) {
  5218. this.destroyShadows();
  5219. }
  5220. this.oldShadowOptions = options;
  5221. }
  5222. if (!options) {
  5223. this.destroyShadows();
  5224. }
  5225. else if (!this.shadows) {
  5226. shadowElementOpacity = options.opacity / options.width;
  5227. transform = this.parentInverted ?
  5228. 'translate(-1,-1)' :
  5229. "translate(" + options.offsetX + ", " + options.offsetY + ")";
  5230. for (i = 1; i <= options.width; i++) {
  5231. shadow = element.cloneNode(false);
  5232. strokeWidth = (options.width * 2) + 1 - (2 * i);
  5233. attr(shadow, {
  5234. stroke: (shadowOptions.color ||
  5235. '#000000'),
  5236. 'stroke-opacity': shadowElementOpacity * i,
  5237. 'stroke-width': strokeWidth,
  5238. transform: transform,
  5239. fill: 'none'
  5240. });
  5241. shadow.setAttribute('class', (shadow.getAttribute('class') || '') + ' highcharts-shadow');
  5242. if (cutOff) {
  5243. attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
  5244. shadow.cutHeight = strokeWidth;
  5245. }
  5246. if (group) {
  5247. group.element.appendChild(shadow);
  5248. }
  5249. else if (element.parentNode) {
  5250. element.parentNode.insertBefore(shadow, element);
  5251. }
  5252. shadows.push(shadow);
  5253. }
  5254. this.shadows = shadows;
  5255. }
  5256. return this;
  5257. };
  5258. /**
  5259. * Show the element after it has been hidden.
  5260. *
  5261. * @function Highcharts.SVGElement#show
  5262. *
  5263. * @param {boolean} [inherit=false]
  5264. * Set the visibility attribute to `inherit` rather than `visible`.
  5265. * The difference is that an element with `visibility="visible"`
  5266. * will be visible even if the parent is hidden.
  5267. *
  5268. * @return {Highcharts.SVGElement}
  5269. * Returns the SVGElement for chaining.
  5270. */
  5271. SVGElement.prototype.show = function (inherit) {
  5272. return this.attr({ visibility: inherit ? 'inherit' : 'visible' });
  5273. };
  5274. /**
  5275. * WebKit and Batik have problems with a stroke-width of zero, so in this
  5276. * case we remove the stroke attribute altogether. #1270, #1369, #3065,
  5277. * #3072.
  5278. *
  5279. * @private
  5280. * @function Highcharts.SVGElement#strokeSetter
  5281. * @param {number|string} value
  5282. * @param {string} key
  5283. * @param {Highcharts.SVGDOMElement} element
  5284. */
  5285. SVGElement.prototype.strokeSetter = function (value, key, element) {
  5286. this[key] = value;
  5287. // Only apply the stroke attribute if the stroke width is defined and
  5288. // larger than 0
  5289. if (this.stroke && this['stroke-width']) {
  5290. // Use prototype as instance may be overridden
  5291. SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element);
  5292. element.setAttribute('stroke-width', this['stroke-width']);
  5293. this.hasStroke = true;
  5294. }
  5295. else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
  5296. element.removeAttribute('stroke');
  5297. this.hasStroke = false;
  5298. }
  5299. else if (this.renderer.styledMode && this['stroke-width']) {
  5300. element.setAttribute('stroke-width', this['stroke-width']);
  5301. this.hasStroke = true;
  5302. }
  5303. };
  5304. /**
  5305. * Get the computed stroke width in pixel values. This is used extensively
  5306. * when drawing shapes to ensure the shapes are rendered crisp and
  5307. * positioned correctly relative to each other. Using
  5308. * `shape-rendering: crispEdges` leaves us less control over positioning,
  5309. * for example when we want to stack columns next to each other, or position
  5310. * things pixel-perfectly within the plot box.
  5311. *
  5312. * The common pattern when placing a shape is:
  5313. * - Create the SVGElement and add it to the DOM. In styled mode, it will
  5314. * now receive a stroke width from the style sheet. In classic mode we
  5315. * will add the `stroke-width` attribute.
  5316. * - Read the computed `elem.strokeWidth()`.
  5317. * - Place it based on the stroke width.
  5318. *
  5319. * @function Highcharts.SVGElement#strokeWidth
  5320. *
  5321. * @return {number}
  5322. * The stroke width in pixels. Even if the given stroke widtch (in CSS or by
  5323. * attributes) is based on `em` or other units, the pixel size is returned.
  5324. */
  5325. SVGElement.prototype.strokeWidth = function () {
  5326. // In non-styled mode, read the stroke width as set by .attr
  5327. if (!this.renderer.styledMode) {
  5328. return this['stroke-width'] || 0;
  5329. }
  5330. // In styled mode, read computed stroke width
  5331. var val = this.getStyle('stroke-width'),
  5332. ret = 0,
  5333. dummy;
  5334. // Read pixel values directly
  5335. if (val.indexOf('px') === val.length - 2) {
  5336. ret = pInt(val);
  5337. // Other values like em, pt etc need to be measured
  5338. }
  5339. else if (val !== '') {
  5340. dummy = doc.createElementNS(SVG_NS, 'rect');
  5341. attr(dummy, {
  5342. width: val,
  5343. 'stroke-width': 0
  5344. });
  5345. this.element.parentNode.appendChild(dummy);
  5346. ret = dummy.getBBox().width;
  5347. dummy.parentNode.removeChild(dummy);
  5348. }
  5349. return ret;
  5350. };
  5351. /**
  5352. * If one of the symbol size affecting parameters are changed,
  5353. * check all the others only once for each call to an element's
  5354. * .attr() method
  5355. *
  5356. * @private
  5357. * @function Highcharts.SVGElement#symbolAttr
  5358. *
  5359. * @param {Highcharts.SVGAttributes} hash
  5360. * The attributes to set.
  5361. */
  5362. SVGElement.prototype.symbolAttr = function (hash) {
  5363. var wrapper = this;
  5364. [
  5365. 'x',
  5366. 'y',
  5367. 'r',
  5368. 'start',
  5369. 'end',
  5370. 'width',
  5371. 'height',
  5372. 'innerR',
  5373. 'anchorX',
  5374. 'anchorY',
  5375. 'clockwise'
  5376. ].forEach(function (key) {
  5377. wrapper[key] = pick(hash[key], wrapper[key]);
  5378. });
  5379. wrapper.attr({
  5380. d: wrapper.renderer.symbols[wrapper.symbolName](wrapper.x, wrapper.y, wrapper.width, wrapper.height, wrapper)
  5381. });
  5382. };
  5383. /**
  5384. * @private
  5385. * @function Highcharts.SVGElement#textSetter
  5386. * @param {string} value
  5387. */
  5388. SVGElement.prototype.textSetter = function (value) {
  5389. if (value !== this.textStr) {
  5390. // Delete size caches when the text changes
  5391. // delete this.bBox; // old code in series-label
  5392. delete this.textPxLength;
  5393. this.textStr = value;
  5394. if (this.added) {
  5395. this.renderer.buildText(this);
  5396. }
  5397. }
  5398. };
  5399. /**
  5400. * @private
  5401. * @function Highcharts.SVGElement#titleSetter
  5402. * @param {string} value
  5403. */
  5404. SVGElement.prototype.titleSetter = function (value) {
  5405. var titleNode = this.element.getElementsByTagName('title')[0];
  5406. if (!titleNode) {
  5407. titleNode = doc.createElementNS(this.SVG_NS, 'title');
  5408. this.element.appendChild(titleNode);
  5409. }
  5410. // Remove text content if it exists
  5411. if (titleNode.firstChild) {
  5412. titleNode.removeChild(titleNode.firstChild);
  5413. }
  5414. titleNode.appendChild(doc.createTextNode(
  5415. // #3276, #3895
  5416. String(pick(value, ''))
  5417. .replace(/<[^>]*>/g, '')
  5418. .replace(/&lt;/g, '<')
  5419. .replace(/&gt;/g, '>')));
  5420. };
  5421. /**
  5422. * Bring the element to the front. Alternatively, a new zIndex can be set.
  5423. *
  5424. * @sample highcharts/members/element-tofront/
  5425. * Click an element to bring it to front
  5426. *
  5427. * @function Highcharts.SVGElement#toFront
  5428. *
  5429. * @return {Highcharts.SVGElement}
  5430. * Returns the SVGElement for chaining.
  5431. */
  5432. SVGElement.prototype.toFront = function () {
  5433. var element = this.element;
  5434. element.parentNode.appendChild(element);
  5435. return this;
  5436. };
  5437. /**
  5438. * Move an object and its children by x and y values.
  5439. *
  5440. * @function Highcharts.SVGElement#translate
  5441. *
  5442. * @param {number} x
  5443. * The x value.
  5444. *
  5445. * @param {number} y
  5446. * The y value.
  5447. *
  5448. * @return {Highcharts.SVGElement}
  5449. */
  5450. SVGElement.prototype.translate = function (x, y) {
  5451. return this.attr({
  5452. translateX: x,
  5453. translateY: y
  5454. });
  5455. };
  5456. /**
  5457. * Update the shadow elements with new attributes.
  5458. *
  5459. * @private
  5460. * @function Highcharts.SVGElement#updateShadows
  5461. *
  5462. * @param {string} key
  5463. * The attribute name.
  5464. *
  5465. * @param {number} value
  5466. * The value of the attribute.
  5467. *
  5468. * @param {Function} setter
  5469. * The setter function, inherited from the parent wrapper.
  5470. */
  5471. SVGElement.prototype.updateShadows = function (key, value, setter) {
  5472. var shadows = this.shadows;
  5473. if (shadows) {
  5474. var i = shadows.length;
  5475. while (i--) {
  5476. setter.call(shadows[i], key === 'height' ?
  5477. Math.max(value - (shadows[i].cutHeight || 0), 0) :
  5478. key === 'd' ? this.d : value, key, shadows[i]);
  5479. }
  5480. }
  5481. };
  5482. /**
  5483. * Update the transform attribute based on internal properties. Deals with
  5484. * the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
  5485. * attributes and updates the SVG `transform` attribute.
  5486. *
  5487. * @private
  5488. * @function Highcharts.SVGElement#updateTransform
  5489. */
  5490. SVGElement.prototype.updateTransform = function () {
  5491. var wrapper = this,
  5492. translateX = wrapper.translateX || 0,
  5493. translateY = wrapper.translateY || 0,
  5494. scaleX = wrapper.scaleX,
  5495. scaleY = wrapper.scaleY,
  5496. inverted = wrapper.inverted,
  5497. rotation = wrapper.rotation,
  5498. matrix = wrapper.matrix,
  5499. element = wrapper.element,
  5500. transform;
  5501. // Flipping affects translate as adjustment for flipping around the
  5502. // group's axis
  5503. if (inverted) {
  5504. translateX += wrapper.width;
  5505. translateY += wrapper.height;
  5506. }
  5507. // Apply translate. Nearly all transformed elements have translation,
  5508. // so instead of checking for translate = 0, do it always (#1767,
  5509. // #1846).
  5510. transform = ['translate(' + translateX + ',' + translateY + ')'];
  5511. // apply matrix
  5512. if (defined(matrix)) {
  5513. transform.push('matrix(' + matrix.join(',') + ')');
  5514. }
  5515. // apply rotation
  5516. if (inverted) {
  5517. transform.push('rotate(90) scale(-1,1)');
  5518. }
  5519. else if (rotation) { // text rotation
  5520. transform.push('rotate(' + rotation + ' ' +
  5521. pick(this.rotationOriginX, element.getAttribute('x'), 0) +
  5522. ' ' +
  5523. pick(this.rotationOriginY, element.getAttribute('y') || 0) + ')');
  5524. }
  5525. // apply scale
  5526. if (defined(scaleX) || defined(scaleY)) {
  5527. transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
  5528. }
  5529. if (transform.length) {
  5530. element.setAttribute('transform', transform.join(' '));
  5531. }
  5532. };
  5533. /**
  5534. * @private
  5535. * @function Highcharts.SVGElement#visibilitySetter
  5536. *
  5537. * @param {string} value
  5538. *
  5539. * @param {string} key
  5540. *
  5541. * @param {Highcharts.SVGDOMElement} element
  5542. *
  5543. * @return {void}
  5544. */
  5545. SVGElement.prototype.visibilitySetter = function (value, key, element) {
  5546. // IE9-11 doesn't handle visibilty:inherit well, so we remove the
  5547. // attribute instead (#2881, #3909)
  5548. if (value === 'inherit') {
  5549. element.removeAttribute(key);
  5550. }
  5551. else if (this[key] !== value) { // #6747
  5552. element.setAttribute(key, value);
  5553. }
  5554. this[key] = value;
  5555. };
  5556. /**
  5557. * @private
  5558. * @function Highcharts.SVGElement#xGetter
  5559. *
  5560. * @param {string} key
  5561. *
  5562. * @return {number|string|null}
  5563. */
  5564. SVGElement.prototype.xGetter = function (key) {
  5565. if (this.element.nodeName === 'circle') {
  5566. if (key === 'x') {
  5567. key = 'cx';
  5568. }
  5569. else if (key === 'y') {
  5570. key = 'cy';
  5571. }
  5572. }
  5573. return this._defaultGetter(key);
  5574. };
  5575. /**
  5576. * @private
  5577. * @function Highcharts.SVGElement#zIndexSetter
  5578. * @param {number} [value]
  5579. * @param {string} [key]
  5580. * @return {boolean}
  5581. */
  5582. SVGElement.prototype.zIndexSetter = function (value, key) {
  5583. var renderer = this.renderer,
  5584. parentGroup = this.parentGroup,
  5585. parentWrapper = parentGroup || renderer,
  5586. parentNode = parentWrapper.element || renderer.box,
  5587. childNodes,
  5588. otherElement,
  5589. otherZIndex,
  5590. element = this.element,
  5591. inserted = false,
  5592. undefinedOtherZIndex,
  5593. svgParent = parentNode === renderer.box,
  5594. run = this.added,
  5595. i;
  5596. if (defined(value)) {
  5597. // So we can read it for other elements in the group
  5598. element.setAttribute('data-z-index', value);
  5599. value = +value;
  5600. if (this[key] === value) {
  5601. // Only update when needed (#3865)
  5602. run = false;
  5603. }
  5604. }
  5605. else if (defined(this[key])) {
  5606. element.removeAttribute('data-z-index');
  5607. }
  5608. this[key] = value;
  5609. // Insert according to this and other elements' zIndex. Before .add() is
  5610. // called, nothing is done. Then on add, or by later calls to
  5611. // zIndexSetter, the node is placed on the right place in the DOM.
  5612. if (run) {
  5613. value = this.zIndex;
  5614. if (value && parentGroup) {
  5615. parentGroup.handleZ = true;
  5616. }
  5617. childNodes = parentNode.childNodes;
  5618. for (i = childNodes.length - 1; i >= 0 && !inserted; i--) {
  5619. otherElement = childNodes[i];
  5620. otherZIndex = otherElement.getAttribute('data-z-index');
  5621. undefinedOtherZIndex = !defined(otherZIndex);
  5622. if (otherElement !== element) {
  5623. if (
  5624. // Negative zIndex versus no zIndex:
  5625. // On all levels except the highest. If the parent is
  5626. // <svg>, then we don't want to put items before <desc>
  5627. // or <defs>
  5628. value < 0 &&
  5629. undefinedOtherZIndex &&
  5630. !svgParent &&
  5631. !i) {
  5632. parentNode.insertBefore(element, childNodes[i]);
  5633. inserted = true;
  5634. }
  5635. else if (
  5636. // Insert after the first element with a lower zIndex
  5637. pInt(otherZIndex) <= value ||
  5638. // If negative zIndex, add this before first undefined
  5639. // zIndex element
  5640. (undefinedOtherZIndex &&
  5641. (!defined(value) || value >= 0))) {
  5642. parentNode.insertBefore(element, childNodes[i + 1] || null // null for oldIE export
  5643. );
  5644. inserted = true;
  5645. }
  5646. }
  5647. }
  5648. if (!inserted) {
  5649. parentNode.insertBefore(element, childNodes[svgParent ? 3 : 0] || null // null for oldIE
  5650. );
  5651. inserted = true;
  5652. }
  5653. }
  5654. return inserted;
  5655. };
  5656. return SVGElement;
  5657. }());
  5658. // Some shared setters and getters
  5659. SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter;
  5660. SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
  5661. SVGElement.prototype.matrixSetter =
  5662. SVGElement.prototype.rotationOriginXSetter =
  5663. SVGElement.prototype.rotationOriginYSetter =
  5664. SVGElement.prototype.rotationSetter =
  5665. SVGElement.prototype.scaleXSetter =
  5666. SVGElement.prototype.scaleYSetter =
  5667. SVGElement.prototype.translateXSetter =
  5668. SVGElement.prototype.translateYSetter =
  5669. SVGElement.prototype.verticalAlignSetter = function (value, key) {
  5670. this[key] = value;
  5671. this.doTransform = true;
  5672. };
  5673. H.SVGElement = SVGElement;
  5674. return H.SVGElement;
  5675. });
  5676. _registerModule(_modules, 'Core/Renderer/SVG/SVGLabel.js', [_modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (SVGElement, U) {
  5677. /* *
  5678. *
  5679. * (c) 2010-2020 Torstein Honsi
  5680. *
  5681. * License: www.highcharts.com/license
  5682. *
  5683. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5684. *
  5685. * */
  5686. var __extends = (this && this.__extends) || (function () {
  5687. var extendStatics = function (d,
  5688. b) {
  5689. extendStatics = Object.setPrototypeOf ||
  5690. ({ __proto__: [] } instanceof Array && function (d,
  5691. b) { d.__proto__ = b; }) ||
  5692. function (d,
  5693. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5694. return extendStatics(d, b);
  5695. };
  5696. return function (d, b) {
  5697. extendStatics(d, b);
  5698. function __() { this.constructor = d; }
  5699. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5700. };
  5701. })();
  5702. var defined = U.defined,
  5703. extend = U.extend,
  5704. isNumber = U.isNumber,
  5705. merge = U.merge,
  5706. removeEvent = U.removeEvent;
  5707. /**
  5708. * SVG label to render text.
  5709. * @private
  5710. * @class
  5711. * @name Highcharts.SVGLabel
  5712. * @augments Highcharts.SVGElement
  5713. */
  5714. var SVGLabel = /** @class */ (function (_super) {
  5715. __extends(SVGLabel, _super);
  5716. /* *
  5717. *
  5718. * Constructors
  5719. *
  5720. * */
  5721. function SVGLabel(renderer, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  5722. var _this = _super.call(this) || this;
  5723. _this.init(renderer, 'g');
  5724. _this.textStr = str;
  5725. _this.x = x;
  5726. _this.y = y;
  5727. _this.anchorX = anchorX;
  5728. _this.anchorY = anchorY;
  5729. _this.baseline = baseline;
  5730. _this.className = className;
  5731. if (className !== 'button') {
  5732. _this.addClass('highcharts-label');
  5733. }
  5734. if (className) {
  5735. _this.addClass('highcharts-' + className);
  5736. }
  5737. _this.text = renderer.text('', 0, 0, useHTML)
  5738. .attr({
  5739. zIndex: 1
  5740. });
  5741. // Validate the shape argument
  5742. var hasBGImage;
  5743. if (typeof shape === 'string') {
  5744. hasBGImage = /^url\((.*?)\)$/.test(shape);
  5745. if (_this.renderer.symbols[shape] || hasBGImage) {
  5746. _this.symbolKey = shape;
  5747. }
  5748. }
  5749. _this.bBox = SVGLabel.emptyBBox;
  5750. _this.padding = 3;
  5751. _this.paddingLeft = 0;
  5752. _this.baselineOffset = 0;
  5753. _this.needsBox = renderer.styledMode || hasBGImage;
  5754. _this.deferredAttr = {};
  5755. _this.alignFactor = 0;
  5756. return _this;
  5757. }
  5758. /* *
  5759. *
  5760. * Functions
  5761. *
  5762. * */
  5763. SVGLabel.prototype.alignSetter = function (value) {
  5764. var alignFactor = {
  5765. left: 0,
  5766. center: 0.5,
  5767. right: 1
  5768. }[value];
  5769. if (alignFactor !== this.alignFactor) {
  5770. this.alignFactor = alignFactor;
  5771. // Bounding box exists, means we're dynamically changing
  5772. if (this.bBox && isNumber(this.xSetting)) {
  5773. this.attr({ x: this.xSetting }); // #5134
  5774. }
  5775. }
  5776. };
  5777. SVGLabel.prototype.anchorXSetter = function (value, key) {
  5778. this.anchorX = value;
  5779. this.boxAttr(key, Math.round(value) - this.getCrispAdjust() - this.xSetting);
  5780. };
  5781. SVGLabel.prototype.anchorYSetter = function (value, key) {
  5782. this.anchorY = value;
  5783. this.boxAttr(key, value - this.ySetting);
  5784. };
  5785. /*
  5786. * Set a box attribute, or defer it if the box is not yet created
  5787. */
  5788. SVGLabel.prototype.boxAttr = function (key, value) {
  5789. if (this.box) {
  5790. this.box.attr(key, value);
  5791. }
  5792. else {
  5793. this.deferredAttr[key] = value;
  5794. }
  5795. };
  5796. /*
  5797. * Pick up some properties and apply them to the text instead of the
  5798. * wrapper.
  5799. */
  5800. SVGLabel.prototype.css = function (styles) {
  5801. if (styles) {
  5802. var textStyles = {},
  5803. isWidth,
  5804. isFontStyle;
  5805. // Create a copy to avoid altering the original object
  5806. // (#537)
  5807. styles = merge(styles);
  5808. SVGLabel.textProps.forEach(function (prop) {
  5809. if (typeof styles[prop] !== 'undefined') {
  5810. textStyles[prop] = styles[prop];
  5811. delete styles[prop];
  5812. }
  5813. });
  5814. this.text.css(textStyles);
  5815. isWidth = 'width' in textStyles;
  5816. isFontStyle = 'fontSize' in textStyles ||
  5817. 'fontWeight' in textStyles;
  5818. // Update existing text, box (#9400, #12163)
  5819. if (isWidth || isFontStyle) {
  5820. this.updateBoxSize();
  5821. // Keep updated (#9400, #12163)
  5822. if (isFontStyle) {
  5823. this.updateTextPadding();
  5824. }
  5825. }
  5826. }
  5827. return SVGElement.prototype.css.call(this, styles);
  5828. };
  5829. /*
  5830. * Destroy and release memory.
  5831. */
  5832. SVGLabel.prototype.destroy = function () {
  5833. // Added by button implementation
  5834. removeEvent(this.element, 'mouseenter');
  5835. removeEvent(this.element, 'mouseleave');
  5836. if (this.text) {
  5837. this.text.destroy();
  5838. }
  5839. if (this.box) {
  5840. this.box = this.box.destroy();
  5841. }
  5842. // Call base implementation to destroy the rest
  5843. SVGElement.prototype.destroy.call(this);
  5844. return void 0;
  5845. };
  5846. SVGLabel.prototype.fillSetter = function (value, key) {
  5847. if (value) {
  5848. this.needsBox = true;
  5849. }
  5850. // for animation getter (#6776)
  5851. this.fill = value;
  5852. this.boxAttr(key, value);
  5853. };
  5854. /*
  5855. * Return the bounding box of the box, not the group.
  5856. */
  5857. SVGLabel.prototype.getBBox = function () {
  5858. var bBox = this.bBox;
  5859. var padding = this.padding;
  5860. return {
  5861. width: bBox.width + 2 * padding,
  5862. height: bBox.height + 2 * padding,
  5863. x: bBox.x - padding,
  5864. y: bBox.y - padding
  5865. };
  5866. };
  5867. SVGLabel.prototype.getCrispAdjust = function () {
  5868. return this.renderer.styledMode && this.box ?
  5869. this.box.strokeWidth() % 2 / 2 :
  5870. (this['stroke-width'] ? parseInt(this['stroke-width'], 10) : 0) % 2 / 2;
  5871. };
  5872. SVGLabel.prototype.heightSetter = function (value) {
  5873. this.heightSetting = value;
  5874. };
  5875. // Event handling. In case of useHTML, we need to make sure that events
  5876. // are captured on the span as well, and that mouseenter/mouseleave
  5877. // between the SVG group and the HTML span are not treated as real
  5878. // enter/leave events. #13310.
  5879. SVGLabel.prototype.on = function (eventType, handler) {
  5880. var label = this;
  5881. var text = label.text;
  5882. var span = text && text.element.tagName === 'SPAN' ? text : void 0;
  5883. var selectiveHandler;
  5884. if (span) {
  5885. selectiveHandler = function (e) {
  5886. if ((eventType === 'mouseenter' ||
  5887. eventType === 'mouseleave') &&
  5888. e.relatedTarget instanceof Element &&
  5889. (label.element.contains(e.relatedTarget) ||
  5890. span.element.contains(e.relatedTarget))) {
  5891. return;
  5892. }
  5893. handler.call(label.element, e);
  5894. };
  5895. span.on(eventType, selectiveHandler);
  5896. }
  5897. SVGElement.prototype.on.call(label, eventType, selectiveHandler || handler);
  5898. return label;
  5899. };
  5900. /*
  5901. * After the text element is added, get the desired size of the border
  5902. * box and add it before the text in the DOM.
  5903. */
  5904. SVGLabel.prototype.onAdd = function () {
  5905. var str = this.textStr;
  5906. this.text.add(this);
  5907. this.attr({
  5908. // Alignment is available now (#3295, 0 not rendered if given
  5909. // as a value)
  5910. text: (defined(str) ? str : ''),
  5911. x: this.x,
  5912. y: this.y
  5913. });
  5914. if (this.box && defined(this.anchorX)) {
  5915. this.attr({
  5916. anchorX: this.anchorX,
  5917. anchorY: this.anchorY
  5918. });
  5919. }
  5920. };
  5921. SVGLabel.prototype.paddingSetter = function (value) {
  5922. if (defined(value) && value !== this.padding) {
  5923. this.padding = value;
  5924. this.updateTextPadding();
  5925. }
  5926. };
  5927. SVGLabel.prototype.paddingLeftSetter = function (value) {
  5928. if (defined(value) && value !== this.paddingLeft) {
  5929. this.paddingLeft = value;
  5930. this.updateTextPadding();
  5931. }
  5932. };
  5933. SVGLabel.prototype.rSetter = function (value, key) {
  5934. this.boxAttr(key, value);
  5935. };
  5936. SVGLabel.prototype.shadow = function (b) {
  5937. if (b && !this.renderer.styledMode) {
  5938. this.updateBoxSize();
  5939. if (this.box) {
  5940. this.box.shadow(b);
  5941. }
  5942. }
  5943. return this;
  5944. };
  5945. SVGLabel.prototype.strokeSetter = function (value, key) {
  5946. // for animation getter (#6776)
  5947. this.stroke = value;
  5948. this.boxAttr(key, value);
  5949. };
  5950. SVGLabel.prototype['stroke-widthSetter'] = function (value, key) {
  5951. if (value) {
  5952. this.needsBox = true;
  5953. }
  5954. this['stroke-width'] = value;
  5955. this.boxAttr(key, value);
  5956. };
  5957. SVGLabel.prototype['text-alignSetter'] = function (value) {
  5958. this.textAlign = value;
  5959. };
  5960. SVGLabel.prototype.textSetter = function (text) {
  5961. if (typeof text !== 'undefined') {
  5962. // Must use .attr to ensure transforms are done (#10009)
  5963. this.text.attr({ text: text });
  5964. }
  5965. this.updateBoxSize();
  5966. this.updateTextPadding();
  5967. };
  5968. /*
  5969. * This function runs after the label is added to the DOM (when the bounding
  5970. * box is available), and after the text of the label is updated to detect
  5971. * the new bounding box and reflect it in the border box.
  5972. */
  5973. SVGLabel.prototype.updateBoxSize = function () {
  5974. var style = this.text.element.style,
  5975. crispAdjust,
  5976. attribs = {};
  5977. var padding = this.padding;
  5978. var paddingLeft = this.paddingLeft;
  5979. // #12165 error when width is null (auto)
  5980. // #12163 when fontweight: bold, recalculate bBox withot cache
  5981. // #3295 && 3514 box failure when string equals 0
  5982. var bBox = ((!isNumber(this.widthSetting) || !isNumber(this.heightSetting) || this.textAlign) &&
  5983. defined(this.text.textStr)) ?
  5984. this.text.getBBox() : SVGLabel.emptyBBox;
  5985. this.width = ((this.widthSetting || bBox.width || 0) +
  5986. 2 * padding +
  5987. paddingLeft);
  5988. this.height = (this.heightSetting || bBox.height || 0) + 2 * padding;
  5989. // Update the label-scoped y offset. Math.min because of inline
  5990. // style (#9400)
  5991. this.baselineOffset = padding + Math.min(this.renderer.fontMetrics(style && style.fontSize, this.text).b,
  5992. // When the height is 0, there is no bBox, so go with the font
  5993. // metrics. Highmaps CSS demos.
  5994. bBox.height || Infinity);
  5995. if (this.needsBox) {
  5996. // Create the border box if it is not already present
  5997. if (!this.box) {
  5998. // Symbol definition exists (#5324)
  5999. var box = this.box = this.symbolKey ?
  6000. this.renderer.symbol(this.symbolKey) :
  6001. this.renderer.rect();
  6002. box.addClass(// Don't use label className for buttons
  6003. (this.className === 'button' ? '' : 'highcharts-label-box') +
  6004. (this.className ? ' highcharts-' + this.className + '-box' : ''));
  6005. box.add(this);
  6006. crispAdjust = this.getCrispAdjust();
  6007. attribs.x = crispAdjust;
  6008. attribs.y = (this.baseline ? -this.baselineOffset : 0) + crispAdjust;
  6009. }
  6010. // Apply the box attributes
  6011. attribs.width = Math.round(this.width);
  6012. attribs.height = Math.round(this.height);
  6013. this.box.attr(extend(attribs, this.deferredAttr));
  6014. this.deferredAttr = {};
  6015. }
  6016. this.bBox = bBox;
  6017. };
  6018. /*
  6019. * This function runs after setting text or padding, but only if padding
  6020. * is changed.
  6021. */
  6022. SVGLabel.prototype.updateTextPadding = function () {
  6023. var text = this.text;
  6024. // Determine y based on the baseline
  6025. var textY = this.baseline ? 0 : this.baselineOffset;
  6026. var textX = this.paddingLeft + this.padding;
  6027. // compensate for alignment
  6028. if (defined(this.widthSetting) &&
  6029. this.bBox &&
  6030. (this.textAlign === 'center' || this.textAlign === 'right')) {
  6031. textX += { center: 0.5, right: 1 }[this.textAlign] *
  6032. (this.widthSetting - this.bBox.width);
  6033. }
  6034. // update if anything changed
  6035. if (textX !== text.x || textY !== text.y) {
  6036. text.attr('x', textX);
  6037. // #8159 - prevent misplaced data labels in treemap
  6038. // (useHTML: true)
  6039. if (text.hasBoxWidthChanged) {
  6040. this.bBox = text.getBBox(true);
  6041. this.updateBoxSize();
  6042. }
  6043. if (typeof textY !== 'undefined') {
  6044. text.attr('y', textY);
  6045. }
  6046. }
  6047. // record current values
  6048. text.x = textX;
  6049. text.y = textY;
  6050. };
  6051. SVGLabel.prototype.widthSetter = function (value) {
  6052. // width:auto => null
  6053. this.widthSetting = isNumber(value) ? value : void 0;
  6054. };
  6055. SVGLabel.prototype.xSetter = function (value) {
  6056. this.x = value; // for animation getter
  6057. if (this.alignFactor) {
  6058. value -= this.alignFactor * ((this.widthSetting || this.bBox.width) +
  6059. 2 * this.padding);
  6060. // Force animation even when setting to the same value (#7898)
  6061. this['forceAnimate:x'] = true;
  6062. }
  6063. this.xSetting = Math.round(value);
  6064. this.attr('translateX', this.xSetting);
  6065. };
  6066. SVGLabel.prototype.ySetter = function (value) {
  6067. this.ySetting = this.y = Math.round(value);
  6068. this.attr('translateY', this.ySetting);
  6069. };
  6070. /* *
  6071. *
  6072. * Static Properties
  6073. *
  6074. * */
  6075. SVGLabel.emptyBBox = { width: 0, height: 0, x: 0, y: 0 };
  6076. /* *
  6077. *
  6078. * Properties
  6079. *
  6080. * */
  6081. /**
  6082. * For labels, these CSS properties are applied to the `text` node directly.
  6083. *
  6084. * @private
  6085. * @name Highcharts.SVGLabel#textProps
  6086. * @type {Array<string>}
  6087. */
  6088. SVGLabel.textProps = [
  6089. 'color', 'cursor', 'direction', 'fontFamily', 'fontSize', 'fontStyle',
  6090. 'fontWeight', 'lineHeight', 'textAlign', 'textDecoration',
  6091. 'textOutline', 'textOverflow', 'width'
  6092. ];
  6093. return SVGLabel;
  6094. }(SVGElement));
  6095. return SVGLabel;
  6096. });
  6097. _registerModule(_modules, 'Core/Renderer/SVG/SVGRenderer.js', [_modules['Core/Color.js'], _modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGLabel.js'], _modules['Core/Utilities.js']], function (Color, H, SVGElement, SVGLabel, U) {
  6098. /* *
  6099. *
  6100. * (c) 2010-2020 Torstein Honsi
  6101. *
  6102. * License: www.highcharts.com/license
  6103. *
  6104. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6105. *
  6106. * */
  6107. var addEvent = U.addEvent,
  6108. attr = U.attr,
  6109. createElement = U.createElement,
  6110. css = U.css,
  6111. defined = U.defined,
  6112. destroyObjectProperties = U.destroyObjectProperties,
  6113. extend = U.extend,
  6114. isArray = U.isArray,
  6115. isNumber = U.isNumber,
  6116. isObject = U.isObject,
  6117. isString = U.isString,
  6118. merge = U.merge,
  6119. objectEach = U.objectEach,
  6120. pick = U.pick,
  6121. pInt = U.pInt,
  6122. splat = U.splat,
  6123. uniqueKey = U.uniqueKey;
  6124. /**
  6125. * A clipping rectangle that can be applied to one or more {@link SVGElement}
  6126. * instances. It is instanciated with the {@link SVGRenderer#clipRect} function
  6127. * and applied with the {@link SVGElement#clip} function.
  6128. *
  6129. * @example
  6130. * var circle = renderer.circle(100, 100, 100)
  6131. * .attr({ fill: 'red' })
  6132. * .add();
  6133. * var clipRect = renderer.clipRect(100, 100, 100, 100);
  6134. *
  6135. * // Leave only the lower right quarter visible
  6136. * circle.clip(clipRect);
  6137. *
  6138. * @typedef {Highcharts.SVGElement} Highcharts.ClipRectElement
  6139. */
  6140. /**
  6141. * The font metrics.
  6142. *
  6143. * @interface Highcharts.FontMetricsObject
  6144. */ /**
  6145. * The baseline relative to the top of the box.
  6146. *
  6147. * @name Highcharts.FontMetricsObject#b
  6148. * @type {number}
  6149. */ /**
  6150. * The font size.
  6151. *
  6152. * @name Highcharts.FontMetricsObject#f
  6153. * @type {number}
  6154. */ /**
  6155. * The line height.
  6156. *
  6157. * @name Highcharts.FontMetricsObject#h
  6158. * @type {number}
  6159. */
  6160. /**
  6161. * An object containing `x` and `y` properties for the position of an element.
  6162. *
  6163. * @interface Highcharts.PositionObject
  6164. */ /**
  6165. * X position of the element.
  6166. * @name Highcharts.PositionObject#x
  6167. * @type {number}
  6168. */ /**
  6169. * Y position of the element.
  6170. * @name Highcharts.PositionObject#y
  6171. * @type {number}
  6172. */
  6173. /**
  6174. * A rectangle.
  6175. *
  6176. * @interface Highcharts.RectangleObject
  6177. */ /**
  6178. * Height of the rectangle.
  6179. * @name Highcharts.RectangleObject#height
  6180. * @type {number}
  6181. */ /**
  6182. * Width of the rectangle.
  6183. * @name Highcharts.RectangleObject#width
  6184. * @type {number}
  6185. */ /**
  6186. * Horizontal position of the rectangle.
  6187. * @name Highcharts.RectangleObject#x
  6188. * @type {number}
  6189. */ /**
  6190. * Vertical position of the rectangle.
  6191. * @name Highcharts.RectangleObject#y
  6192. * @type {number}
  6193. */
  6194. /**
  6195. * The shadow options.
  6196. *
  6197. * @interface Highcharts.ShadowOptionsObject
  6198. */ /**
  6199. * The shadow color.
  6200. * @name Highcharts.ShadowOptionsObject#color
  6201. * @type {Highcharts.ColorString|undefined}
  6202. * @default #000000
  6203. */ /**
  6204. * The horizontal offset from the element.
  6205. *
  6206. * @name Highcharts.ShadowOptionsObject#offsetX
  6207. * @type {number|undefined}
  6208. * @default 1
  6209. */ /**
  6210. * The vertical offset from the element.
  6211. * @name Highcharts.ShadowOptionsObject#offsetY
  6212. * @type {number|undefined}
  6213. * @default 1
  6214. */ /**
  6215. * The shadow opacity.
  6216. *
  6217. * @name Highcharts.ShadowOptionsObject#opacity
  6218. * @type {number|undefined}
  6219. * @default 0.15
  6220. */ /**
  6221. * The shadow width or distance from the element.
  6222. * @name Highcharts.ShadowOptionsObject#width
  6223. * @type {number|undefined}
  6224. * @default 3
  6225. */
  6226. /**
  6227. * @interface Highcharts.SizeObject
  6228. */ /**
  6229. * @name Highcharts.SizeObject#height
  6230. * @type {number}
  6231. */ /**
  6232. * @name Highcharts.SizeObject#width
  6233. * @type {number}
  6234. */
  6235. /**
  6236. * Serialized form of an SVG definition, including children. Some key
  6237. * property names are reserved: tagName, textContent, and children.
  6238. *
  6239. * @interface Highcharts.SVGDefinitionObject
  6240. */ /**
  6241. * @name Highcharts.SVGDefinitionObject#[key:string]
  6242. * @type {boolean|number|string|Array<Highcharts.SVGDefinitionObject>|undefined}
  6243. */ /**
  6244. * @name Highcharts.SVGDefinitionObject#children
  6245. * @type {Array<Highcharts.SVGDefinitionObject>|undefined}
  6246. */ /**
  6247. * @name Highcharts.SVGDefinitionObject#tagName
  6248. * @type {string|undefined}
  6249. */ /**
  6250. * @name Highcharts.SVGDefinitionObject#textContent
  6251. * @type {string|undefined}
  6252. */
  6253. /**
  6254. * Array of path commands, that will go into the `d` attribute of an SVG
  6255. * element.
  6256. *
  6257. * @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
  6258. */
  6259. /**
  6260. * Possible path commands in an SVG path array. Valid values are `A`, `C`, `H`,
  6261. * `L`, `M`, `Q`, `S`, `T`, `V`, `Z`.
  6262. *
  6263. * @typedef {string} Highcharts.SVGPathCommand
  6264. * @validvalue ["a","c","h","l","m","q","s","t","v","z","A","C","H","L","M","Q","S","T","V","Z"]
  6265. */
  6266. /**
  6267. * An extendable collection of functions for defining symbol paths. Symbols are
  6268. * used internally for point markers, button and label borders and backgrounds,
  6269. * or custom shapes. Extendable by adding to {@link SVGRenderer#symbols}.
  6270. *
  6271. * @interface Highcharts.SymbolDictionary
  6272. */ /**
  6273. * @name Highcharts.SymbolDictionary#[key:string]
  6274. * @type {Function|undefined}
  6275. */ /**
  6276. * @name Highcharts.SymbolDictionary#arc
  6277. * @type {Function|undefined}
  6278. */ /**
  6279. * @name Highcharts.SymbolDictionary#callout
  6280. * @type {Function|undefined}
  6281. */ /**
  6282. * @name Highcharts.SymbolDictionary#circle
  6283. * @type {Function|undefined}
  6284. */ /**
  6285. * @name Highcharts.SymbolDictionary#diamond
  6286. * @type {Function|undefined}
  6287. */ /**
  6288. * @name Highcharts.SymbolDictionary#square
  6289. * @type {Function|undefined}
  6290. */ /**
  6291. * @name Highcharts.SymbolDictionary#triangle
  6292. * @type {Function|undefined}
  6293. */
  6294. /**
  6295. * Can be one of `arc`, `callout`, `circle`, `diamond`, `square`, `triangle`,
  6296. * and `triangle-down`. Symbols are used internally for point markers, button
  6297. * and label borders and backgrounds, or custom shapes. Extendable by adding to
  6298. * {@link SVGRenderer#symbols}.
  6299. *
  6300. * @typedef {"arc"|"callout"|"circle"|"diamond"|"square"|"triangle"|"triangle-down"} Highcharts.SymbolKeyValue
  6301. */
  6302. /**
  6303. * Additional options, depending on the actual symbol drawn.
  6304. *
  6305. * @interface Highcharts.SymbolOptionsObject
  6306. */ /**
  6307. * The anchor X position for the `callout` symbol. This is where the chevron
  6308. * points to.
  6309. *
  6310. * @name Highcharts.SymbolOptionsObject#anchorX
  6311. * @type {number|undefined}
  6312. */ /**
  6313. * The anchor Y position for the `callout` symbol. This is where the chevron
  6314. * points to.
  6315. *
  6316. * @name Highcharts.SymbolOptionsObject#anchorY
  6317. * @type {number|undefined}
  6318. */ /**
  6319. * The end angle of an `arc` symbol.
  6320. *
  6321. * @name Highcharts.SymbolOptionsObject#end
  6322. * @type {number|undefined}
  6323. */ /**
  6324. * Whether to draw `arc` symbol open or closed.
  6325. *
  6326. * @name Highcharts.SymbolOptionsObject#open
  6327. * @type {boolean|undefined}
  6328. */ /**
  6329. * The radius of an `arc` symbol, or the border radius for the `callout` symbol.
  6330. *
  6331. * @name Highcharts.SymbolOptionsObject#r
  6332. * @type {number|undefined}
  6333. */ /**
  6334. * The start angle of an `arc` symbol.
  6335. *
  6336. * @name Highcharts.SymbolOptionsObject#start
  6337. * @type {number|undefined}
  6338. */
  6339. /* eslint-disable no-invalid-this, valid-jsdoc */
  6340. var charts = H.charts,
  6341. deg2rad = H.deg2rad,
  6342. doc = H.doc,
  6343. isFirefox = H.isFirefox,
  6344. isMS = H.isMS,
  6345. isWebKit = H.isWebKit,
  6346. noop = H.noop,
  6347. svg = H.svg,
  6348. SVG_NS = H.SVG_NS,
  6349. symbolSizes = H.symbolSizes,
  6350. win = H.win;
  6351. /**
  6352. * Allows direct access to the Highcharts rendering layer in order to draw
  6353. * primitive shapes like circles, rectangles, paths or text directly on a chart,
  6354. * or independent from any chart. The SVGRenderer represents a wrapper object
  6355. * for SVG in modern browsers. Through the VMLRenderer, part of the `oldie.js`
  6356. * module, it also brings vector graphics to IE <= 8.
  6357. *
  6358. * An existing chart's renderer can be accessed through {@link Chart.renderer}.
  6359. * The renderer can also be used completely decoupled from a chart.
  6360. *
  6361. * @sample highcharts/members/renderer-on-chart
  6362. * Annotating a chart programmatically.
  6363. * @sample highcharts/members/renderer-basic
  6364. * Independent SVG drawing.
  6365. *
  6366. * @example
  6367. * // Use directly without a chart object.
  6368. * var renderer = new Highcharts.Renderer(parentNode, 600, 400);
  6369. *
  6370. * @class
  6371. * @name Highcharts.SVGRenderer
  6372. *
  6373. * @param {Highcharts.HTMLDOMElement} container
  6374. * Where to put the SVG in the web page.
  6375. *
  6376. * @param {number} width
  6377. * The width of the SVG.
  6378. *
  6379. * @param {number} height
  6380. * The height of the SVG.
  6381. *
  6382. * @param {Highcharts.CSSObject} [style]
  6383. * The box style, if not in styleMode
  6384. *
  6385. * @param {boolean} [forExport=false]
  6386. * Whether the rendered content is intended for export.
  6387. *
  6388. * @param {boolean} [allowHTML=true]
  6389. * Whether the renderer is allowed to include HTML text, which will be
  6390. * projected on top of the SVG.
  6391. *
  6392. * @param {boolean} [styledMode=false]
  6393. * Whether the renderer belongs to a chart that is in styled mode.
  6394. * If it does, it will avoid setting presentational attributes in
  6395. * some cases, but not when set explicitly through `.attr` and `.css`
  6396. * etc.
  6397. */
  6398. var SVGRenderer = /** @class */ (function () {
  6399. /* *
  6400. *
  6401. * Constructors
  6402. *
  6403. * */
  6404. function SVGRenderer(container, width, height, style, forExport, allowHTML, styledMode) {
  6405. /* *
  6406. *
  6407. * Properties
  6408. *
  6409. * */
  6410. this.alignedObjects = void 0;
  6411. /**
  6412. * The root `svg` node of the renderer.
  6413. *
  6414. * @name Highcharts.SVGRenderer#box
  6415. * @type {Highcharts.SVGDOMElement}
  6416. */
  6417. this.box = void 0;
  6418. /**
  6419. * The wrapper for the root `svg` node of the renderer.
  6420. *
  6421. * @name Highcharts.SVGRenderer#boxWrapper
  6422. * @type {Highcharts.SVGElement}
  6423. */
  6424. this.boxWrapper = void 0;
  6425. this.cache = void 0;
  6426. this.cacheKeys = void 0;
  6427. this.chartIndex = void 0;
  6428. /**
  6429. * A pointer to the `defs` node of the root SVG.
  6430. *
  6431. * @name Highcharts.SVGRenderer#defs
  6432. * @type {Highcharts.SVGElement}
  6433. */
  6434. this.defs = void 0;
  6435. this.globalAnimation = void 0;
  6436. this.gradients = void 0;
  6437. this.height = void 0;
  6438. this.imgCount = void 0;
  6439. this.isSVG = void 0;
  6440. this.style = void 0;
  6441. /**
  6442. * Page url used for internal references.
  6443. *
  6444. * @private
  6445. * @name Highcharts.SVGRenderer#url
  6446. * @type {string}
  6447. */
  6448. this.url = void 0;
  6449. this.width = void 0;
  6450. this.init(container, width, height, style, forExport, allowHTML, styledMode);
  6451. }
  6452. /* *
  6453. *
  6454. * Functions
  6455. *
  6456. * */
  6457. /**
  6458. * Initialize the SVGRenderer. Overridable initializer function that takes
  6459. * the same parameters as the constructor.
  6460. *
  6461. * @function Highcharts.SVGRenderer#init
  6462. *
  6463. * @param {Highcharts.HTMLDOMElement} container
  6464. * Where to put the SVG in the web page.
  6465. *
  6466. * @param {number} width
  6467. * The width of the SVG.
  6468. *
  6469. * @param {number} height
  6470. * The height of the SVG.
  6471. *
  6472. * @param {Highcharts.CSSObject} [style]
  6473. * The box style, if not in styleMode
  6474. *
  6475. * @param {boolean} [forExport=false]
  6476. * Whether the rendered content is intended for export.
  6477. *
  6478. * @param {boolean} [allowHTML=true]
  6479. * Whether the renderer is allowed to include HTML text, which will be
  6480. * projected on top of the SVG.
  6481. *
  6482. * @param {boolean} [styledMode=false]
  6483. * Whether the renderer belongs to a chart that is in styled mode. If it
  6484. * does, it will avoid setting presentational attributes in some cases, but
  6485. * not when set explicitly through `.attr` and `.css` etc.
  6486. */
  6487. SVGRenderer.prototype.init = function (container, width, height, style, forExport, allowHTML, styledMode) {
  6488. var renderer = this,
  6489. boxWrapper,
  6490. element,
  6491. desc;
  6492. boxWrapper = renderer.createElement('svg')
  6493. .attr({
  6494. version: '1.1',
  6495. 'class': 'highcharts-root'
  6496. });
  6497. if (!styledMode) {
  6498. boxWrapper.css(this.getStyle(style));
  6499. }
  6500. element = boxWrapper.element;
  6501. container.appendChild(element);
  6502. // Always use ltr on the container, otherwise text-anchor will be
  6503. // flipped and text appear outside labels, buttons, tooltip etc (#3482)
  6504. attr(container, 'dir', 'ltr');
  6505. // For browsers other than IE, add the namespace attribute (#1978)
  6506. if (container.innerHTML.indexOf('xmlns') === -1) {
  6507. attr(element, 'xmlns', this.SVG_NS);
  6508. }
  6509. // object properties
  6510. renderer.isSVG = true;
  6511. this.box = element;
  6512. this.boxWrapper = boxWrapper;
  6513. renderer.alignedObjects = [];
  6514. // #24, #672, #1070
  6515. this.url = ((isFirefox || isWebKit) &&
  6516. doc.getElementsByTagName('base').length) ?
  6517. win.location.href
  6518. .split('#')[0] // remove the hash
  6519. .replace(/<[^>]*>/g, '') // wing cut HTML
  6520. // escape parantheses and quotes
  6521. .replace(/([\('\)])/g, '\\$1')
  6522. // replace spaces (needed for Safari only)
  6523. .replace(/ /g, '%20') :
  6524. '';
  6525. // Add description
  6526. desc = this.createElement('desc').add();
  6527. desc.element.appendChild(doc.createTextNode('Created with Highcharts 8.2.0'));
  6528. renderer.defs = this.createElement('defs').add();
  6529. renderer.allowHTML = allowHTML;
  6530. renderer.forExport = forExport;
  6531. renderer.styledMode = styledMode;
  6532. renderer.gradients = {}; // Object where gradient SvgElements are stored
  6533. renderer.cache = {}; // Cache for numerical bounding boxes
  6534. renderer.cacheKeys = [];
  6535. renderer.imgCount = 0;
  6536. renderer.setSize(width, height, false);
  6537. // Issue 110 workaround:
  6538. // In Firefox, if a div is positioned by percentage, its pixel position
  6539. // may land between pixels. The container itself doesn't display this,
  6540. // but an SVG element inside this container will be drawn at subpixel
  6541. // precision. In order to draw sharp lines, this must be compensated
  6542. // for. This doesn't seem to work inside iframes though (like in
  6543. // jsFiddle).
  6544. var subPixelFix,
  6545. rect;
  6546. if (isFirefox && container.getBoundingClientRect) {
  6547. subPixelFix = function () {
  6548. css(container, { left: 0, top: 0 });
  6549. rect = container.getBoundingClientRect();
  6550. css(container, {
  6551. left: (Math.ceil(rect.left) - rect.left) + 'px',
  6552. top: (Math.ceil(rect.top) - rect.top) + 'px'
  6553. });
  6554. };
  6555. // run the fix now
  6556. subPixelFix();
  6557. // run it on resize
  6558. renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
  6559. }
  6560. };
  6561. /**
  6562. * General method for adding a definition to the SVG `defs` tag. Can be used
  6563. * for gradients, fills, filters etc. Styled mode only. A hook for adding
  6564. * general definitions to the SVG's defs tag. Definitions can be referenced
  6565. * from the CSS by its `id`. Read more in
  6566. * [gradients, shadows and patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns).
  6567. * Styled mode only.
  6568. *
  6569. * @function Highcharts.SVGRenderer#definition
  6570. *
  6571. * @param {Highcharts.SVGDefinitionObject} def
  6572. * A serialized form of an SVG definition, including children.
  6573. *
  6574. * @return {Highcharts.SVGElement}
  6575. * The inserted node.
  6576. */
  6577. SVGRenderer.prototype.definition = function (def) {
  6578. var ren = this;
  6579. /**
  6580. * @private
  6581. * @param {Highcharts.SVGDefinitionObject} config - SVG definition
  6582. * @param {Highcharts.SVGElement} [parent] - parent node
  6583. */
  6584. function recurse(config, parent) {
  6585. var ret;
  6586. splat(config).forEach(function (item) {
  6587. var node = ren.createElement(item.tagName),
  6588. attr = {};
  6589. // Set attributes
  6590. objectEach(item, function (val, key) {
  6591. if (key !== 'tagName' &&
  6592. key !== 'children' &&
  6593. key !== 'textContent') {
  6594. attr[key] = val;
  6595. }
  6596. });
  6597. node.attr(attr);
  6598. // Add to the tree
  6599. node.add(parent || ren.defs);
  6600. // Add text content
  6601. if (item.textContent) {
  6602. node.element.appendChild(doc.createTextNode(item.textContent));
  6603. }
  6604. // Recurse
  6605. recurse(item.children || [], node);
  6606. ret = node;
  6607. });
  6608. // Return last node added (on top level it's the only one)
  6609. return ret;
  6610. }
  6611. return recurse(def);
  6612. };
  6613. /**
  6614. * Get the global style setting for the renderer.
  6615. *
  6616. * @private
  6617. * @function Highcharts.SVGRenderer#getStyle
  6618. *
  6619. * @param {Highcharts.CSSObject} style
  6620. * Style settings.
  6621. *
  6622. * @return {Highcharts.CSSObject}
  6623. * The style settings mixed with defaults.
  6624. */
  6625. SVGRenderer.prototype.getStyle = function (style) {
  6626. this.style = extend({
  6627. fontFamily: '"Lucida Grande", "Lucida Sans Unicode", ' +
  6628. 'Arial, Helvetica, sans-serif',
  6629. fontSize: '12px'
  6630. }, style);
  6631. return this.style;
  6632. };
  6633. /**
  6634. * Apply the global style on the renderer, mixed with the default styles.
  6635. *
  6636. * @function Highcharts.SVGRenderer#setStyle
  6637. *
  6638. * @param {Highcharts.CSSObject} style
  6639. * CSS to apply.
  6640. */
  6641. SVGRenderer.prototype.setStyle = function (style) {
  6642. this.boxWrapper.css(this.getStyle(style));
  6643. };
  6644. /**
  6645. * Detect whether the renderer is hidden. This happens when one of the
  6646. * parent elements has `display: none`. Used internally to detect when we
  6647. * needto render preliminarily in another div to get the text bounding boxes
  6648. * right.
  6649. *
  6650. * @function Highcharts.SVGRenderer#isHidden
  6651. *
  6652. * @return {boolean}
  6653. * True if it is hidden.
  6654. */
  6655. SVGRenderer.prototype.isHidden = function () {
  6656. return !this.boxWrapper.getBBox().width;
  6657. };
  6658. /**
  6659. * Destroys the renderer and its allocated members.
  6660. *
  6661. * @function Highcharts.SVGRenderer#destroy
  6662. *
  6663. * @return {null}
  6664. */
  6665. SVGRenderer.prototype.destroy = function () {
  6666. var renderer = this,
  6667. rendererDefs = renderer.defs;
  6668. renderer.box = null;
  6669. renderer.boxWrapper = renderer.boxWrapper.destroy();
  6670. // Call destroy on all gradient elements
  6671. destroyObjectProperties(renderer.gradients || {});
  6672. renderer.gradients = null;
  6673. // Defs are null in VMLRenderer
  6674. // Otherwise, destroy them here.
  6675. if (rendererDefs) {
  6676. renderer.defs = rendererDefs.destroy();
  6677. }
  6678. // Remove sub pixel fix handler (#982)
  6679. if (renderer.unSubPixelFix) {
  6680. renderer.unSubPixelFix();
  6681. }
  6682. renderer.alignedObjects = null;
  6683. return null;
  6684. };
  6685. /**
  6686. * Create a wrapper for an SVG element. Serves as a factory for
  6687. * {@link SVGElement}, but this function is itself mostly called from
  6688. * primitive factories like {@link SVGRenderer#path}, {@link
  6689. * SVGRenderer#rect} or {@link SVGRenderer#text}.
  6690. *
  6691. * @function Highcharts.SVGRenderer#createElement
  6692. *
  6693. * @param {string} nodeName
  6694. * The node name, for example `rect`, `g` etc.
  6695. *
  6696. * @return {Highcharts.SVGElement}
  6697. * The generated SVGElement.
  6698. */
  6699. SVGRenderer.prototype.createElement = function (nodeName) {
  6700. var wrapper = new this.Element();
  6701. wrapper.init(this, nodeName);
  6702. return wrapper;
  6703. };
  6704. /**
  6705. * Get converted radial gradient attributes according to the radial
  6706. * reference. Used internally from the {@link SVGElement#colorGradient}
  6707. * function.
  6708. *
  6709. * @private
  6710. * @function Highcharts.SVGRenderer#getRadialAttr
  6711. */
  6712. SVGRenderer.prototype.getRadialAttr = function (radialReference, gradAttr) {
  6713. return {
  6714. cx: (radialReference[0] - radialReference[2] / 2) +
  6715. gradAttr.cx * radialReference[2],
  6716. cy: (radialReference[1] - radialReference[2] / 2) +
  6717. gradAttr.cy * radialReference[2],
  6718. r: gradAttr.r * radialReference[2]
  6719. };
  6720. };
  6721. /**
  6722. * Truncate the text node contents to a given length. Used when the css
  6723. * width is set. If the `textOverflow` is `ellipsis`, the text is truncated
  6724. * character by character to the given length. If not, the text is
  6725. * word-wrapped line by line.
  6726. *
  6727. * @private
  6728. * @function Highcharts.SVGRenderer#truncate
  6729. *
  6730. * @return {boolean}
  6731. * True if tspan is too long.
  6732. */
  6733. SVGRenderer.prototype.truncate = function (wrapper, tspan, text, words, startAt, width, getString) {
  6734. var renderer = this,
  6735. rotation = wrapper.rotation,
  6736. str,
  6737. // Word wrap can not be truncated to shorter than one word, ellipsis
  6738. // text can be completely blank.
  6739. minIndex = words ? 1 : 0,
  6740. maxIndex = (text || words).length,
  6741. currentIndex = maxIndex,
  6742. // Cache the lengths to avoid checking the same twice
  6743. lengths = [],
  6744. updateTSpan = function (s) {
  6745. if (tspan.firstChild) {
  6746. tspan.removeChild(tspan.firstChild);
  6747. }
  6748. if (s) {
  6749. tspan.appendChild(doc.createTextNode(s));
  6750. }
  6751. }, getSubStringLength = function (charEnd, concatenatedEnd) {
  6752. // charEnd is useed when finding the character-by-character
  6753. // break for ellipsis, concatenatedEnd is used for word-by-word
  6754. // break for word wrapping.
  6755. var end = concatenatedEnd || charEnd;
  6756. if (typeof lengths[end] === 'undefined') {
  6757. // Modern browsers
  6758. if (tspan.getSubStringLength) {
  6759. // Fails with DOM exception on unit-tests/legend/members
  6760. // of unknown reason. Desired width is 0, text content
  6761. // is "5" and end is 1.
  6762. try {
  6763. lengths[end] = startAt +
  6764. tspan.getSubStringLength(0, words ? end + 1 : end);
  6765. }
  6766. catch (e) {
  6767. '';
  6768. }
  6769. // Legacy
  6770. }
  6771. else if (renderer.getSpanWidth) { // #9058 jsdom
  6772. updateTSpan(getString(text || words, charEnd));
  6773. lengths[end] = startAt +
  6774. renderer.getSpanWidth(wrapper, tspan);
  6775. }
  6776. }
  6777. return lengths[end];
  6778. }, actualWidth, truncated;
  6779. wrapper.rotation = 0; // discard rotation when computing box
  6780. actualWidth = getSubStringLength(tspan.textContent.length);
  6781. truncated = startAt + actualWidth > width;
  6782. if (truncated) {
  6783. // Do a binary search for the index where to truncate the text
  6784. while (minIndex <= maxIndex) {
  6785. currentIndex = Math.ceil((minIndex + maxIndex) / 2);
  6786. // When checking words for word-wrap, we need to build the
  6787. // string and measure the subStringLength at the concatenated
  6788. // word length.
  6789. if (words) {
  6790. str = getString(words, currentIndex);
  6791. }
  6792. actualWidth = getSubStringLength(currentIndex, str && str.length - 1);
  6793. if (minIndex === maxIndex) {
  6794. // Complete
  6795. minIndex = maxIndex + 1;
  6796. }
  6797. else if (actualWidth > width) {
  6798. // Too large. Set max index to current.
  6799. maxIndex = currentIndex - 1;
  6800. }
  6801. else {
  6802. // Within width. Set min index to current.
  6803. minIndex = currentIndex;
  6804. }
  6805. }
  6806. // If max index was 0 it means the shortest possible text was also
  6807. // too large. For ellipsis that means only the ellipsis, while for
  6808. // word wrap it means the whole first word.
  6809. if (maxIndex === 0) {
  6810. // Remove ellipsis
  6811. updateTSpan('');
  6812. // If the new text length is one less than the original, we don't
  6813. // need the ellipsis
  6814. }
  6815. else if (!(text && maxIndex === text.length - 1)) {
  6816. updateTSpan(str || getString(text || words, currentIndex));
  6817. }
  6818. }
  6819. // When doing line wrapping, prepare for the next line by removing the
  6820. // items from this line.
  6821. if (words) {
  6822. words.splice(0, currentIndex);
  6823. }
  6824. wrapper.actualWidth = actualWidth;
  6825. wrapper.rotation = rotation; // Apply rotation again.
  6826. return truncated;
  6827. };
  6828. /**
  6829. * Parse a simple HTML string into SVG tspans. Called internally when text
  6830. * is set on an SVGElement. The function supports a subset of HTML tags, CSS
  6831. * text features like `width`, `text-overflow`, `white-space`, and also
  6832. * attributes like `href` and `style`.
  6833. *
  6834. * @private
  6835. * @function Highcharts.SVGRenderer#buildText
  6836. *
  6837. * @param {Highcharts.SVGElement} wrapper
  6838. * The parent SVGElement.
  6839. */
  6840. SVGRenderer.prototype.buildText = function (wrapper) {
  6841. var textNode = wrapper.element, renderer = this, forExport = renderer.forExport, textStr = pick(wrapper.textStr, '').toString(), hasMarkup = textStr.indexOf('<') !== -1, lines, childNodes = textNode.childNodes, truncated, parentX = attr(textNode, 'x'), textStyles = wrapper.styles, width = wrapper.textWidth, textLineHeight = textStyles && textStyles.lineHeight, textOutline = textStyles && textStyles.textOutline, ellipsis = textStyles && textStyles.textOverflow === 'ellipsis', noWrap = textStyles && textStyles.whiteSpace === 'nowrap', fontSize = textStyles && textStyles.fontSize, textCache, isSubsequentLine, i = childNodes.length, tempParent = width && !wrapper.added && this.box, getLineHeight = function (tspan) {
  6842. var fontSizeStyle;
  6843. if (!renderer.styledMode) {
  6844. fontSizeStyle =
  6845. /(px|em)$/.test(tspan && tspan.style.fontSize) ?
  6846. tspan.style.fontSize :
  6847. (fontSize || renderer.style.fontSize || 12);
  6848. }
  6849. return textLineHeight ?
  6850. pInt(textLineHeight) :
  6851. renderer.fontMetrics(fontSizeStyle,
  6852. // Get the computed size from parent if not explicit
  6853. (tspan.getAttribute('style') ? tspan : textNode)).h;
  6854. }, unescapeEntities = function (inputStr, except) {
  6855. objectEach(renderer.escapes, function (value, key) {
  6856. if (!except || except.indexOf(value) === -1) {
  6857. inputStr = inputStr.toString().replace(new RegExp(value, 'g'), key);
  6858. }
  6859. });
  6860. return inputStr;
  6861. }, parseAttribute = function (s, attr) {
  6862. var start,
  6863. delimiter;
  6864. start = s.indexOf('<');
  6865. s = s.substring(start, s.indexOf('>') - start);
  6866. start = s.indexOf(attr + '=');
  6867. if (start !== -1) {
  6868. start = start + attr.length + 1;
  6869. delimiter = s.charAt(start);
  6870. if (delimiter === '"' || delimiter === "'") { // eslint-disable-line quotes
  6871. s = s.substring(start + 1);
  6872. return s.substring(0, s.indexOf(delimiter));
  6873. }
  6874. }
  6875. };
  6876. var regexMatchBreaks = /<br.*?>/g;
  6877. // The buildText code is quite heavy, so if we're not changing something
  6878. // that affects the text, skip it (#6113).
  6879. textCache = [
  6880. textStr,
  6881. ellipsis,
  6882. noWrap,
  6883. textLineHeight,
  6884. textOutline,
  6885. fontSize,
  6886. width
  6887. ].join(',');
  6888. if (textCache === wrapper.textCache) {
  6889. return;
  6890. }
  6891. wrapper.textCache = textCache;
  6892. // Remove old text
  6893. while (i--) {
  6894. textNode.removeChild(childNodes[i]);
  6895. }
  6896. // Skip tspans, add text directly to text node. The forceTSpan is a hook
  6897. // used in text outline hack.
  6898. if (!hasMarkup &&
  6899. !textOutline &&
  6900. !ellipsis &&
  6901. !width &&
  6902. (textStr.indexOf(' ') === -1 ||
  6903. (noWrap && !regexMatchBreaks.test(textStr)))) {
  6904. textNode.appendChild(doc.createTextNode(unescapeEntities(textStr)));
  6905. // Complex strings, add more logic
  6906. }
  6907. else {
  6908. if (tempParent) {
  6909. // attach it to the DOM to read offset width
  6910. tempParent.appendChild(textNode);
  6911. }
  6912. if (hasMarkup) {
  6913. lines = renderer.styledMode ? (textStr
  6914. .replace(/<(b|strong)>/g, '<span class="highcharts-strong">')
  6915. .replace(/<(i|em)>/g, '<span class="highcharts-emphasized">')) : (textStr
  6916. .replace(/<(b|strong)>/g, '<span style="font-weight:bold">')
  6917. .replace(/<(i|em)>/g, '<span style="font-style:italic">'));
  6918. lines = lines
  6919. .replace(/<a/g, '<span')
  6920. .replace(/<\/(b|strong|i|em|a)>/g, '</span>')
  6921. .split(regexMatchBreaks);
  6922. }
  6923. else {
  6924. lines = [textStr];
  6925. }
  6926. // Trim empty lines (#5261)
  6927. lines = lines.filter(function (line) {
  6928. return line !== '';
  6929. });
  6930. // build the lines
  6931. lines.forEach(function (line, lineNo) {
  6932. var spans,
  6933. spanNo = 0,
  6934. lineLength = 0;
  6935. line = line
  6936. // Trim to prevent useless/costly process on the spaces
  6937. // (#5258)
  6938. .replace(/^\s+|\s+$/g, '')
  6939. .replace(/<span/g, '|||<span')
  6940. .replace(/<\/span>/g, '</span>|||');
  6941. spans = line.split('|||');
  6942. spans.forEach(function buildTextSpans(span) {
  6943. if (span !== '' || spans.length === 1) {
  6944. var attributes = {},
  6945. tspan = doc.createElementNS(renderer.SVG_NS, 'tspan'),
  6946. a,
  6947. classAttribute,
  6948. styleAttribute, // #390
  6949. hrefAttribute;
  6950. classAttribute = parseAttribute(span, 'class');
  6951. if (classAttribute) {
  6952. attr(tspan, 'class', classAttribute);
  6953. }
  6954. styleAttribute = parseAttribute(span, 'style');
  6955. if (styleAttribute) {
  6956. styleAttribute = styleAttribute.replace(/(;| |^)color([ :])/, '$1fill$2');
  6957. attr(tspan, 'style', styleAttribute);
  6958. }
  6959. // For anchors, wrap the tspan in an <a> tag and apply
  6960. // the href attribute as is (#13559). Not for export
  6961. // (#1529)
  6962. hrefAttribute = parseAttribute(span, 'href');
  6963. if (hrefAttribute && !forExport) {
  6964. if (
  6965. // Stop JavaScript links, vulnerable to XSS
  6966. hrefAttribute.split(':')[0].toLowerCase()
  6967. .indexOf('javascript') === -1) {
  6968. a = doc.createElementNS(renderer.SVG_NS, 'a');
  6969. attr(a, 'href', hrefAttribute);
  6970. attr(tspan, 'class', 'highcharts-anchor');
  6971. a.appendChild(tspan);
  6972. if (!renderer.styledMode) {
  6973. css(tspan, { cursor: 'pointer' });
  6974. }
  6975. }
  6976. }
  6977. // Strip away unsupported HTML tags (#7126)
  6978. span = unescapeEntities(span.replace(/<[a-zA-Z\/](.|\n)*?>/g, '') || ' ');
  6979. // Nested tags aren't supported, and cause crash in
  6980. // Safari (#1596)
  6981. if (span !== ' ') {
  6982. // add the text node
  6983. tspan.appendChild(doc.createTextNode(span));
  6984. // First span in a line, align it to the left
  6985. if (!spanNo) {
  6986. if (lineNo && parentX !== null) {
  6987. attributes.x = parentX;
  6988. }
  6989. }
  6990. else {
  6991. attributes.dx = 0; // #16
  6992. }
  6993. // add attributes
  6994. attr(tspan, attributes);
  6995. // Append it
  6996. textNode.appendChild(a || tspan);
  6997. // first span on subsequent line, add the line
  6998. // height
  6999. if (!spanNo && isSubsequentLine) {
  7000. // allow getting the right offset height in
  7001. // exporting in IE
  7002. if (!svg && forExport) {
  7003. css(tspan, { display: 'block' });
  7004. }
  7005. // Set the line height based on the font size of
  7006. // either the text element or the tspan element
  7007. attr(tspan, 'dy', getLineHeight(tspan));
  7008. }
  7009. // Check width and apply soft breaks or ellipsis
  7010. if (width) {
  7011. var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
  7012. hasWhiteSpace = !noWrap && (spans.length > 1 ||
  7013. lineNo ||
  7014. words.length > 1),
  7015. wrapLineNo = 0,
  7016. dy = getLineHeight(tspan);
  7017. if (ellipsis) {
  7018. truncated = renderer.truncate(wrapper, tspan, span, void 0, 0,
  7019. // Target width
  7020. Math.max(0,
  7021. // Substract the font face to make
  7022. // room for the ellipsis itself
  7023. width - parseInt(fontSize || 12, 10)),
  7024. // Build the text to test for
  7025. function (text, currentIndex) {
  7026. return text.substring(0, currentIndex) + '\u2026';
  7027. });
  7028. }
  7029. else if (hasWhiteSpace) {
  7030. while (words.length) {
  7031. // For subsequent lines, create tspans
  7032. // with the same style attributes as the
  7033. // parent text node.
  7034. if (words.length &&
  7035. !noWrap &&
  7036. wrapLineNo > 0) {
  7037. tspan = doc.createElementNS(SVG_NS, 'tspan');
  7038. attr(tspan, {
  7039. dy: dy,
  7040. x: parentX
  7041. });
  7042. if (styleAttribute) { // #390
  7043. attr(tspan, 'style', styleAttribute);
  7044. }
  7045. // Start by appending the full
  7046. // remaining text
  7047. tspan.appendChild(doc.createTextNode(words.join(' ')
  7048. .replace(/- /g, '-')));
  7049. textNode.appendChild(tspan);
  7050. }
  7051. // For each line, truncate the remaining
  7052. // words into the line length.
  7053. renderer.truncate(wrapper, tspan, null, words, wrapLineNo === 0 ? lineLength : 0, width,
  7054. // Build the text to test for
  7055. function (text, currentIndex) {
  7056. return words
  7057. .slice(0, currentIndex)
  7058. .join(' ')
  7059. .replace(/- /g, '-');
  7060. });
  7061. lineLength = wrapper.actualWidth;
  7062. wrapLineNo++;
  7063. }
  7064. }
  7065. }
  7066. spanNo++;
  7067. }
  7068. }
  7069. });
  7070. // To avoid beginning lines that doesn't add to the textNode
  7071. // (#6144)
  7072. isSubsequentLine = (isSubsequentLine ||
  7073. textNode.childNodes.length);
  7074. });
  7075. if (ellipsis && truncated) {
  7076. wrapper.attr('title', unescapeEntities(wrapper.textStr || '', ['&lt;', '&gt;']) // #7179
  7077. );
  7078. }
  7079. if (tempParent) {
  7080. tempParent.removeChild(textNode);
  7081. }
  7082. // Apply the text outline
  7083. if (isString(textOutline) && wrapper.applyTextOutline) {
  7084. wrapper.applyTextOutline(textOutline);
  7085. }
  7086. }
  7087. };
  7088. /**
  7089. * Returns white for dark colors and black for bright colors.
  7090. *
  7091. * @function Highcharts.SVGRenderer#getContrast
  7092. *
  7093. * @param {Highcharts.ColorString} rgba
  7094. * The color to get the contrast for.
  7095. *
  7096. * @return {Highcharts.ColorString}
  7097. * The contrast color, either `#000000` or `#FFFFFF`.
  7098. */
  7099. SVGRenderer.prototype.getContrast = function (rgba) {
  7100. rgba = Color.parse(rgba).rgba;
  7101. // The threshold may be discussed. Here's a proposal for adding
  7102. // different weight to the color channels (#6216)
  7103. rgba[0] *= 1; // red
  7104. rgba[1] *= 1.2; // green
  7105. rgba[2] *= 0.5; // blue
  7106. return rgba[0] + rgba[1] + rgba[2] >
  7107. 1.8 * 255 ?
  7108. '#000000' :
  7109. '#FFFFFF';
  7110. };
  7111. /**
  7112. * Create a button with preset states.
  7113. *
  7114. * @function Highcharts.SVGRenderer#button
  7115. *
  7116. * @param {string} text
  7117. * The text or HTML to draw.
  7118. *
  7119. * @param {number} x
  7120. * The x position of the button's left side.
  7121. *
  7122. * @param {number} y
  7123. * The y position of the button's top side.
  7124. *
  7125. * @param {Highcharts.EventCallbackFunction<Highcharts.SVGElement>} callback
  7126. * The function to execute on button click or touch.
  7127. *
  7128. * @param {Highcharts.SVGAttributes} [normalState]
  7129. * SVG attributes for the normal state.
  7130. *
  7131. * @param {Highcharts.SVGAttributes} [hoverState]
  7132. * SVG attributes for the hover state.
  7133. *
  7134. * @param {Highcharts.SVGAttributes} [pressedState]
  7135. * SVG attributes for the pressed state.
  7136. *
  7137. * @param {Highcharts.SVGAttributes} [disabledState]
  7138. * SVG attributes for the disabled state.
  7139. *
  7140. * @param {Highcharts.SymbolKeyValue} [shape=rect]
  7141. * The shape type.
  7142. *
  7143. * @param {boolean} [useHTML=false]
  7144. * Wether to use HTML to render the label.
  7145. *
  7146. * @return {Highcharts.SVGElement}
  7147. * The button element.
  7148. */
  7149. SVGRenderer.prototype.button = function (text, x, y, callback, normalState, hoverState, pressedState, disabledState, shape, useHTML) {
  7150. var label = this.label(text,
  7151. x,
  7152. y,
  7153. shape,
  7154. void 0,
  7155. void 0,
  7156. useHTML,
  7157. void 0, 'button'),
  7158. curState = 0,
  7159. styledMode = this.styledMode,
  7160. // Make a copy of normalState (#13798)
  7161. // (reference to options.rangeSelector.buttonTheme)
  7162. normalState = normalState ? merge(normalState) : normalState,
  7163. userNormalStyle = normalState && normalState.style || {};
  7164. // Remove stylable attributes
  7165. if (normalState && normalState.style) {
  7166. delete normalState.style;
  7167. }
  7168. // Default, non-stylable attributes
  7169. label.attr(merge({ padding: 8, r: 2 }, normalState));
  7170. if (!styledMode) {
  7171. // Presentational
  7172. var normalStyle,
  7173. hoverStyle,
  7174. pressedStyle,
  7175. disabledStyle;
  7176. // Normal state - prepare the attributes
  7177. normalState = merge({
  7178. fill: '#f7f7f7',
  7179. stroke: '#cccccc',
  7180. 'stroke-width': 1,
  7181. style: {
  7182. color: '#333333',
  7183. cursor: 'pointer',
  7184. fontWeight: 'normal'
  7185. }
  7186. }, {
  7187. style: userNormalStyle
  7188. }, normalState);
  7189. normalStyle = normalState.style;
  7190. delete normalState.style;
  7191. // Hover state
  7192. hoverState = merge(normalState, {
  7193. fill: '#e6e6e6'
  7194. }, hoverState);
  7195. hoverStyle = hoverState.style;
  7196. delete hoverState.style;
  7197. // Pressed state
  7198. pressedState = merge(normalState, {
  7199. fill: '#e6ebf5',
  7200. style: {
  7201. color: '#000000',
  7202. fontWeight: 'bold'
  7203. }
  7204. }, pressedState);
  7205. pressedStyle = pressedState.style;
  7206. delete pressedState.style;
  7207. // Disabled state
  7208. disabledState = merge(normalState, {
  7209. style: {
  7210. color: '#cccccc'
  7211. }
  7212. }, disabledState);
  7213. disabledStyle = disabledState.style;
  7214. delete disabledState.style;
  7215. }
  7216. // Add the events. IE9 and IE10 need mouseover and mouseout to funciton
  7217. // (#667).
  7218. addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function () {
  7219. if (curState !== 3) {
  7220. label.setState(1);
  7221. }
  7222. });
  7223. addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function () {
  7224. if (curState !== 3) {
  7225. label.setState(curState);
  7226. }
  7227. });
  7228. label.setState = function (state) {
  7229. // Hover state is temporary, don't record it
  7230. if (state !== 1) {
  7231. label.state = curState = state;
  7232. }
  7233. // Update visuals
  7234. label
  7235. .removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
  7236. .addClass('highcharts-button-' +
  7237. ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
  7238. if (!styledMode) {
  7239. label
  7240. .attr([
  7241. normalState,
  7242. hoverState,
  7243. pressedState,
  7244. disabledState
  7245. ][state || 0])
  7246. .css([
  7247. normalStyle,
  7248. hoverStyle,
  7249. pressedStyle,
  7250. disabledStyle
  7251. ][state || 0]);
  7252. }
  7253. };
  7254. // Presentational attributes
  7255. if (!styledMode) {
  7256. label
  7257. .attr(normalState)
  7258. .css(extend({ cursor: 'default' }, normalStyle));
  7259. }
  7260. return label
  7261. .on('click', function (e) {
  7262. if (curState !== 3) {
  7263. callback.call(label, e);
  7264. }
  7265. });
  7266. };
  7267. /**
  7268. * Make a straight line crisper by not spilling out to neighbour pixels.
  7269. *
  7270. * @function Highcharts.SVGRenderer#crispLine
  7271. *
  7272. * @param {Highcharts.SVGPathArray} points
  7273. * The original points on the format `[['M', 0, 0], ['L', 100, 0]]`.
  7274. *
  7275. * @param {number} width
  7276. * The width of the line.
  7277. *
  7278. * @param {string} roundingFunction
  7279. * The rounding function name on the `Math` object, can be one of
  7280. * `round`, `floor` or `ceil`.
  7281. *
  7282. * @return {Highcharts.SVGPathArray}
  7283. * The original points array, but modified to render crisply.
  7284. */
  7285. SVGRenderer.prototype.crispLine = function (points, width, roundingFunction) {
  7286. if (roundingFunction === void 0) { roundingFunction = 'round'; }
  7287. var start = points[0];
  7288. var end = points[1];
  7289. // Normalize to a crisp line
  7290. if (start[1] === end[1]) {
  7291. // Substract due to #1129. Now bottom and left axis gridlines behave
  7292. // the same.
  7293. start[1] = end[1] =
  7294. Math[roundingFunction](start[1]) - (width % 2 / 2);
  7295. }
  7296. if (start[2] === end[2]) {
  7297. start[2] = end[2] =
  7298. Math[roundingFunction](start[2]) + (width % 2 / 2);
  7299. }
  7300. return points;
  7301. };
  7302. /**
  7303. * Draw a path, wraps the SVG `path` element.
  7304. *
  7305. * @sample highcharts/members/renderer-path-on-chart/
  7306. * Draw a path in a chart
  7307. * @sample highcharts/members/renderer-path/
  7308. * Draw a path independent from a chart
  7309. *
  7310. * @example
  7311. * var path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
  7312. * .attr({ stroke: '#ff00ff' })
  7313. * .add();
  7314. *
  7315. * @function Highcharts.SVGRenderer#path
  7316. *
  7317. * @param {Highcharts.SVGPathArray} [path]
  7318. * An SVG path definition in array form.
  7319. *
  7320. * @return {Highcharts.SVGElement}
  7321. * The generated wrapper element.
  7322. *
  7323. */ /**
  7324. * Draw a path, wraps the SVG `path` element.
  7325. *
  7326. * @function Highcharts.SVGRenderer#path
  7327. *
  7328. * @param {Highcharts.SVGAttributes} [attribs]
  7329. * The initial attributes.
  7330. *
  7331. * @return {Highcharts.SVGElement}
  7332. * The generated wrapper element.
  7333. */
  7334. SVGRenderer.prototype.path = function (path) {
  7335. var attribs = (this.styledMode ? {} : {
  7336. fill: 'none'
  7337. });
  7338. if (isArray(path)) {
  7339. attribs.d = path;
  7340. }
  7341. else if (isObject(path)) { // attributes
  7342. extend(attribs, path);
  7343. }
  7344. return this.createElement('path').attr(attribs);
  7345. };
  7346. /**
  7347. * Draw a circle, wraps the SVG `circle` element.
  7348. *
  7349. * @sample highcharts/members/renderer-circle/
  7350. * Drawing a circle
  7351. *
  7352. * @function Highcharts.SVGRenderer#circle
  7353. *
  7354. * @param {number} [x]
  7355. * The center x position.
  7356. *
  7357. * @param {number} [y]
  7358. * The center y position.
  7359. *
  7360. * @param {number} [r]
  7361. * The radius.
  7362. *
  7363. * @return {Highcharts.SVGElement}
  7364. * The generated wrapper element.
  7365. */ /**
  7366. * Draw a circle, wraps the SVG `circle` element.
  7367. *
  7368. * @function Highcharts.SVGRenderer#circle
  7369. *
  7370. * @param {Highcharts.SVGAttributes} [attribs]
  7371. * The initial attributes.
  7372. *
  7373. * @return {Highcharts.SVGElement}
  7374. * The generated wrapper element.
  7375. */
  7376. SVGRenderer.prototype.circle = function (x, y, r) {
  7377. var attribs = (isObject(x) ?
  7378. x :
  7379. typeof x === 'undefined' ? {} : { x: x, y: y, r: r }), wrapper = this.createElement('circle');
  7380. // Setting x or y translates to cx and cy
  7381. wrapper.xSetter = wrapper.ySetter = function (value, key, element) {
  7382. element.setAttribute('c' + key, value);
  7383. };
  7384. return wrapper.attr(attribs);
  7385. };
  7386. /**
  7387. * Draw and return an arc.
  7388. *
  7389. * @sample highcharts/members/renderer-arc/
  7390. * Drawing an arc
  7391. *
  7392. * @function Highcharts.SVGRenderer#arc
  7393. *
  7394. * @param {number} [x=0]
  7395. * Center X position.
  7396. *
  7397. * @param {number} [y=0]
  7398. * Center Y position.
  7399. *
  7400. * @param {number} [r=0]
  7401. * The outer radius' of the arc.
  7402. *
  7403. * @param {number} [innerR=0]
  7404. * Inner radius like used in donut charts.
  7405. *
  7406. * @param {number} [start=0]
  7407. * The starting angle of the arc in radians, where 0 is to the right and
  7408. * `-Math.PI/2` is up.
  7409. *
  7410. * @param {number} [end=0]
  7411. * The ending angle of the arc in radians, where 0 is to the right and
  7412. * `-Math.PI/2` is up.
  7413. *
  7414. * @return {Highcharts.SVGElement}
  7415. * The generated wrapper element.
  7416. */ /**
  7417. * Draw and return an arc. Overloaded function that takes arguments object.
  7418. *
  7419. * @function Highcharts.SVGRenderer#arc
  7420. *
  7421. * @param {Highcharts.SVGAttributes} attribs
  7422. * Initial SVG attributes.
  7423. *
  7424. * @return {Highcharts.SVGElement}
  7425. * The generated wrapper element.
  7426. */
  7427. SVGRenderer.prototype.arc = function (x, y, r, innerR, start, end) {
  7428. var arc,
  7429. options;
  7430. if (isObject(x)) {
  7431. options = x;
  7432. y = options.y;
  7433. r = options.r;
  7434. innerR = options.innerR;
  7435. start = options.start;
  7436. end = options.end;
  7437. x = options.x;
  7438. }
  7439. else {
  7440. options = {
  7441. innerR: innerR,
  7442. start: start,
  7443. end: end
  7444. };
  7445. }
  7446. // Arcs are defined as symbols for the ability to set
  7447. // attributes in attr and animate
  7448. arc = this.symbol('arc', x, y, r, r, options);
  7449. arc.r = r; // #959
  7450. return arc;
  7451. };
  7452. /**
  7453. * Draw and return a rectangle.
  7454. *
  7455. * @function Highcharts.SVGRenderer#rect
  7456. *
  7457. * @param {number} [x]
  7458. * Left position.
  7459. *
  7460. * @param {number} [y]
  7461. * Top position.
  7462. *
  7463. * @param {number} [width]
  7464. * Width of the rectangle.
  7465. *
  7466. * @param {number} [height]
  7467. * Height of the rectangle.
  7468. *
  7469. * @param {number} [r]
  7470. * Border corner radius.
  7471. *
  7472. * @param {number} [strokeWidth]
  7473. * A stroke width can be supplied to allow crisp drawing.
  7474. *
  7475. * @return {Highcharts.SVGElement}
  7476. * The generated wrapper element.
  7477. */ /**
  7478. * Draw and return a rectangle.
  7479. *
  7480. * @sample highcharts/members/renderer-rect-on-chart/
  7481. * Draw a rectangle in a chart
  7482. * @sample highcharts/members/renderer-rect/
  7483. * Draw a rectangle independent from a chart
  7484. *
  7485. * @function Highcharts.SVGRenderer#rect
  7486. *
  7487. * @param {Highcharts.SVGAttributes} [attributes]
  7488. * General SVG attributes for the rectangle.
  7489. *
  7490. * @return {Highcharts.SVGElement}
  7491. * The generated wrapper element.
  7492. */
  7493. SVGRenderer.prototype.rect = function (x, y, width, height, r, strokeWidth) {
  7494. r = isObject(x) ? x.r : r;
  7495. var wrapper = this.createElement('rect'),
  7496. attribs = isObject(x) ?
  7497. x :
  7498. typeof x === 'undefined' ?
  7499. {} :
  7500. {
  7501. x: x,
  7502. y: y,
  7503. width: Math.max(width, 0),
  7504. height: Math.max(height, 0)
  7505. };
  7506. if (!this.styledMode) {
  7507. if (typeof strokeWidth !== 'undefined') {
  7508. attribs.strokeWidth = strokeWidth;
  7509. attribs = wrapper.crisp(attribs);
  7510. }
  7511. attribs.fill = 'none';
  7512. }
  7513. if (r) {
  7514. attribs.r = r;
  7515. }
  7516. wrapper.rSetter = function (value, key, element) {
  7517. wrapper.r = value;
  7518. attr(element, {
  7519. rx: value,
  7520. ry: value
  7521. });
  7522. };
  7523. wrapper.rGetter = function () {
  7524. return wrapper.r;
  7525. };
  7526. return wrapper.attr(attribs);
  7527. };
  7528. /**
  7529. * Resize the {@link SVGRenderer#box} and re-align all aligned child
  7530. * elements.
  7531. *
  7532. * @sample highcharts/members/renderer-g/
  7533. * Show and hide grouped objects
  7534. *
  7535. * @function Highcharts.SVGRenderer#setSize
  7536. *
  7537. * @param {number} width
  7538. * The new pixel width.
  7539. *
  7540. * @param {number} height
  7541. * The new pixel height.
  7542. *
  7543. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animate=true]
  7544. * Whether and how to animate.
  7545. */
  7546. SVGRenderer.prototype.setSize = function (width, height, animate) {
  7547. var renderer = this,
  7548. alignedObjects = renderer.alignedObjects,
  7549. i = alignedObjects.length;
  7550. renderer.width = width;
  7551. renderer.height = height;
  7552. renderer.boxWrapper.animate({
  7553. width: width,
  7554. height: height
  7555. }, {
  7556. step: function () {
  7557. this.attr({
  7558. viewBox: '0 0 ' + this.attr('width') + ' ' +
  7559. this.attr('height')
  7560. });
  7561. },
  7562. duration: pick(animate, true) ? void 0 : 0
  7563. });
  7564. while (i--) {
  7565. alignedObjects[i].align();
  7566. }
  7567. };
  7568. /**
  7569. * Create and return an svg group element. Child
  7570. * {@link Highcharts.SVGElement} objects are added to the group by using the
  7571. * group as the first parameter in {@link Highcharts.SVGElement#add|add()}.
  7572. *
  7573. * @function Highcharts.SVGRenderer#g
  7574. *
  7575. * @param {string} [name]
  7576. * The group will be given a class name of `highcharts-{name}`. This
  7577. * can be used for styling and scripting.
  7578. *
  7579. * @return {Highcharts.SVGElement}
  7580. * The generated wrapper element.
  7581. */
  7582. SVGRenderer.prototype.g = function (name) {
  7583. var elem = this.createElement('g');
  7584. return name ?
  7585. elem.attr({ 'class': 'highcharts-' + name }) :
  7586. elem;
  7587. };
  7588. /**
  7589. * Display an image.
  7590. *
  7591. * @sample highcharts/members/renderer-image-on-chart/
  7592. * Add an image in a chart
  7593. * @sample highcharts/members/renderer-image/
  7594. * Add an image independent of a chart
  7595. *
  7596. * @function Highcharts.SVGRenderer#image
  7597. *
  7598. * @param {string} src
  7599. * The image source.
  7600. *
  7601. * @param {number} [x]
  7602. * The X position.
  7603. *
  7604. * @param {number} [y]
  7605. * The Y position.
  7606. *
  7607. * @param {number} [width]
  7608. * The image width. If omitted, it defaults to the image file width.
  7609. *
  7610. * @param {number} [height]
  7611. * The image height. If omitted it defaults to the image file
  7612. * height.
  7613. *
  7614. * @param {Function} [onload]
  7615. * Event handler for image load.
  7616. *
  7617. * @return {Highcharts.SVGElement}
  7618. * The generated wrapper element.
  7619. */
  7620. SVGRenderer.prototype.image = function (src, x, y, width, height, onload) {
  7621. var attribs = { preserveAspectRatio: 'none' }, elemWrapper, dummy, setSVGImageSource = function (el, src) {
  7622. // Set the href in the xlink namespace
  7623. if (el.setAttributeNS) {
  7624. el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', src);
  7625. }
  7626. else {
  7627. // could be exporting in IE
  7628. // using href throws "not supported" in ie7 and under,
  7629. // requries regex shim to fix later
  7630. el.setAttribute('hc-svg-href', src);
  7631. }
  7632. }, onDummyLoad = function (e) {
  7633. setSVGImageSource(elemWrapper.element, src);
  7634. onload.call(elemWrapper, e);
  7635. };
  7636. // optional properties
  7637. if (arguments.length > 1) {
  7638. extend(attribs, {
  7639. x: x,
  7640. y: y,
  7641. width: width,
  7642. height: height
  7643. });
  7644. }
  7645. elemWrapper = this.createElement('image').attr(attribs);
  7646. // Add load event if supplied
  7647. if (onload) {
  7648. // We have to use a dummy HTML image since IE support for SVG image
  7649. // load events is very buggy. First set a transparent src, wait for
  7650. // dummy to load, and then add the real src to the SVG image.
  7651. setSVGImageSource(elemWrapper.element, 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' /* eslint-disable-line */);
  7652. dummy = new win.Image();
  7653. addEvent(dummy, 'load', onDummyLoad);
  7654. dummy.src = src;
  7655. if (dummy.complete) {
  7656. onDummyLoad({});
  7657. }
  7658. }
  7659. else {
  7660. setSVGImageSource(elemWrapper.element, src);
  7661. }
  7662. return elemWrapper;
  7663. };
  7664. /**
  7665. * Draw a symbol out of pre-defined shape paths from
  7666. * {@link SVGRenderer#symbols}.
  7667. * It is used in Highcharts for point makers, which cake a `symbol` option,
  7668. * and label and button backgrounds like in the tooltip and stock flags.
  7669. *
  7670. * @function Highcharts.SVGRenderer#symbol
  7671. *
  7672. * @param {string} symbol
  7673. * The symbol name.
  7674. *
  7675. * @param {number} [x]
  7676. * The X coordinate for the top left position.
  7677. *
  7678. * @param {number} [y]
  7679. * The Y coordinate for the top left position.
  7680. *
  7681. * @param {number} [width]
  7682. * The pixel width.
  7683. *
  7684. * @param {number} [height]
  7685. * The pixel height.
  7686. *
  7687. * @param {Highcharts.SymbolOptionsObject} [options]
  7688. * Additional options, depending on the actual symbol drawn.
  7689. *
  7690. * @return {Highcharts.SVGElement}
  7691. */
  7692. SVGRenderer.prototype.symbol = function (symbol, x, y, width, height, options) {
  7693. var ren = this,
  7694. obj,
  7695. imageRegex = /^url\((.*?)\)$/,
  7696. isImage = imageRegex.test(symbol),
  7697. sym = (!isImage && (this.symbols[symbol] ? symbol : 'circle')),
  7698. // get the symbol definition function
  7699. symbolFn = (sym && this.symbols[sym]),
  7700. path,
  7701. imageSrc,
  7702. centerImage;
  7703. if (symbolFn) {
  7704. // Check if there's a path defined for this symbol
  7705. if (typeof x === 'number') {
  7706. path = symbolFn.call(this.symbols, Math.round(x || 0), Math.round(y || 0), width || 0, height || 0, options);
  7707. }
  7708. obj = this.path(path);
  7709. if (!ren.styledMode) {
  7710. obj.attr('fill', 'none');
  7711. }
  7712. // expando properties for use in animate and attr
  7713. extend(obj, {
  7714. symbolName: sym,
  7715. x: x,
  7716. y: y,
  7717. width: width,
  7718. height: height
  7719. });
  7720. if (options) {
  7721. extend(obj, options);
  7722. }
  7723. // Image symbols
  7724. }
  7725. else if (isImage) {
  7726. imageSrc = symbol.match(imageRegex)[1];
  7727. // Create the image synchronously, add attribs async
  7728. obj = this.image(imageSrc);
  7729. // The image width is not always the same as the symbol width. The
  7730. // image may be centered within the symbol, as is the case when
  7731. // image shapes are used as label backgrounds, for example in flags.
  7732. obj.imgwidth = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].width, options && options.width);
  7733. obj.imgheight = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].height, options && options.height);
  7734. /**
  7735. * Set the size and position
  7736. */
  7737. centerImage = function () {
  7738. obj.attr({
  7739. width: obj.width,
  7740. height: obj.height
  7741. });
  7742. };
  7743. /**
  7744. * Width and height setters that take both the image's physical size
  7745. * and the label size into consideration, and translates the image
  7746. * to center within the label.
  7747. */
  7748. ['width', 'height'].forEach(function (key) {
  7749. obj[key + 'Setter'] = function (value, key) {
  7750. var attribs = {}, imgSize = this['img' + key], trans = key === 'width' ? 'translateX' : 'translateY';
  7751. this[key] = value;
  7752. if (defined(imgSize)) {
  7753. // Scale and center the image within its container.
  7754. // The name `backgroundSize` is taken from the CSS spec,
  7755. // but the value `within` is made up. Other possible
  7756. // values in the spec, `cover` and `contain`, can be
  7757. // implemented if needed.
  7758. if (options &&
  7759. options.backgroundSize === 'within' &&
  7760. this.width &&
  7761. this.height) {
  7762. imgSize = Math.round(imgSize * Math.min(this.width / this.imgwidth, this.height / this.imgheight));
  7763. }
  7764. if (this.element) {
  7765. this.element.setAttribute(key, imgSize);
  7766. }
  7767. if (!this.alignByTranslate) {
  7768. attribs[trans] = ((this[key] || 0) - imgSize) / 2;
  7769. this.attr(attribs);
  7770. }
  7771. }
  7772. };
  7773. });
  7774. if (defined(x)) {
  7775. obj.attr({
  7776. x: x,
  7777. y: y
  7778. });
  7779. }
  7780. obj.isImg = true;
  7781. if (defined(obj.imgwidth) && defined(obj.imgheight)) {
  7782. centerImage();
  7783. }
  7784. else {
  7785. // Initialize image to be 0 size so export will still function
  7786. // if there's no cached sizes.
  7787. obj.attr({ width: 0, height: 0 });
  7788. // Create a dummy JavaScript image to get the width and height.
  7789. createElement('img', {
  7790. onload: function () {
  7791. var chart = charts[ren.chartIndex];
  7792. // Special case for SVGs on IE11, the width is not
  7793. // accessible until the image is part of the DOM
  7794. // (#2854).
  7795. if (this.width === 0) {
  7796. css(this, {
  7797. position: 'absolute',
  7798. top: '-999em'
  7799. });
  7800. doc.body.appendChild(this);
  7801. }
  7802. // Center the image
  7803. symbolSizes[imageSrc] = {
  7804. width: this.width,
  7805. height: this.height
  7806. };
  7807. obj.imgwidth = this.width;
  7808. obj.imgheight = this.height;
  7809. if (obj.element) {
  7810. centerImage();
  7811. }
  7812. // Clean up after #2854 workaround.
  7813. if (this.parentNode) {
  7814. this.parentNode.removeChild(this);
  7815. }
  7816. // Fire the load event when all external images are
  7817. // loaded
  7818. ren.imgCount--;
  7819. if (!ren.imgCount && chart && !chart.hasLoaded) {
  7820. chart.onload();
  7821. }
  7822. },
  7823. src: imageSrc
  7824. });
  7825. this.imgCount++;
  7826. }
  7827. }
  7828. return obj;
  7829. };
  7830. /**
  7831. * Define a clipping rectangle. The clipping rectangle is later applied
  7832. * to {@link SVGElement} objects through the {@link SVGElement#clip}
  7833. * function.
  7834. *
  7835. * @example
  7836. * var circle = renderer.circle(100, 100, 100)
  7837. * .attr({ fill: 'red' })
  7838. * .add();
  7839. * var clipRect = renderer.clipRect(100, 100, 100, 100);
  7840. *
  7841. * // Leave only the lower right quarter visible
  7842. * circle.clip(clipRect);
  7843. *
  7844. * @function Highcharts.SVGRenderer#clipRect
  7845. *
  7846. * @param {number} [x]
  7847. *
  7848. * @param {number} [y]
  7849. *
  7850. * @param {number} [width]
  7851. *
  7852. * @param {number} [height]
  7853. *
  7854. * @return {Highcharts.ClipRectElement}
  7855. * A clipping rectangle.
  7856. */
  7857. SVGRenderer.prototype.clipRect = function (x, y, width, height) {
  7858. var wrapper,
  7859. // Add a hyphen at the end to avoid confusion in testing indexes
  7860. // -1 and -10, -11 etc (#6550)
  7861. id = uniqueKey() + '-', clipPath = this.createElement('clipPath').attr({
  7862. id: id
  7863. }).add(this.defs);
  7864. wrapper = this.rect(x, y, width, height, 0).add(clipPath);
  7865. wrapper.id = id;
  7866. wrapper.clipPath = clipPath;
  7867. wrapper.count = 0;
  7868. return wrapper;
  7869. };
  7870. /**
  7871. * Draw text. The text can contain a subset of HTML, like spans and anchors
  7872. * and some basic text styling of these. For more advanced features like
  7873. * border and background, use {@link Highcharts.SVGRenderer#label} instead.
  7874. * To update the text after render, run `text.attr({ text: 'New text' })`.
  7875. *
  7876. * @sample highcharts/members/renderer-text-on-chart/
  7877. * Annotate the chart freely
  7878. * @sample highcharts/members/renderer-on-chart/
  7879. * Annotate with a border and in response to the data
  7880. * @sample highcharts/members/renderer-text/
  7881. * Formatted text
  7882. *
  7883. * @function Highcharts.SVGRenderer#text
  7884. *
  7885. * @param {string} [str]
  7886. * The text of (subset) HTML to draw.
  7887. *
  7888. * @param {number} [x]
  7889. * The x position of the text's lower left corner.
  7890. *
  7891. * @param {number} [y]
  7892. * The y position of the text's lower left corner.
  7893. *
  7894. * @param {boolean} [useHTML=false]
  7895. * Use HTML to render the text.
  7896. *
  7897. * @return {Highcharts.SVGElement}
  7898. * The text object.
  7899. */
  7900. SVGRenderer.prototype.text = function (str, x, y, useHTML) {
  7901. // declare variables
  7902. var renderer = this,
  7903. wrapper,
  7904. attribs = {};
  7905. if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
  7906. return renderer.html(str, x, y);
  7907. }
  7908. attribs.x = Math.round(x || 0); // X always needed for line-wrap logic
  7909. if (y) {
  7910. attribs.y = Math.round(y);
  7911. }
  7912. if (defined(str)) {
  7913. attribs.text = str;
  7914. }
  7915. wrapper = renderer.createElement('text')
  7916. .attr(attribs);
  7917. if (!useHTML) {
  7918. wrapper.xSetter = function (value, key, element) {
  7919. var tspans = element.getElementsByTagName('tspan'),
  7920. tspan,
  7921. parentVal = element.getAttribute(key),
  7922. i;
  7923. for (i = 0; i < tspans.length; i++) {
  7924. tspan = tspans[i];
  7925. // If the x values are equal, the tspan represents a
  7926. // linebreak
  7927. if (tspan.getAttribute(key) === parentVal) {
  7928. tspan.setAttribute(key, value);
  7929. }
  7930. }
  7931. element.setAttribute(key, value);
  7932. };
  7933. }
  7934. return wrapper;
  7935. };
  7936. /**
  7937. * Utility to return the baseline offset and total line height from the font
  7938. * size.
  7939. *
  7940. * @function Highcharts.SVGRenderer#fontMetrics
  7941. *
  7942. * @param {number|string} [fontSize]
  7943. * The current font size to inspect. If not given, the font size
  7944. * will be found from the DOM element.
  7945. *
  7946. * @param {Highcharts.SVGElement|Highcharts.SVGDOMElement} [elem]
  7947. * The element to inspect for a current font size.
  7948. *
  7949. * @return {Highcharts.FontMetricsObject}
  7950. * The font metrics.
  7951. */
  7952. SVGRenderer.prototype.fontMetrics = function (fontSize, elem) {
  7953. var lineHeight,
  7954. baseline;
  7955. if ((this.styledMode || !/px/.test(fontSize)) &&
  7956. win.getComputedStyle // old IE doesn't support it
  7957. ) {
  7958. fontSize = elem && SVGElement.prototype.getStyle.call(elem, 'font-size');
  7959. }
  7960. else {
  7961. fontSize = fontSize ||
  7962. // When the elem is a DOM element (#5932)
  7963. (elem && elem.style && elem.style.fontSize) ||
  7964. // Fall back on the renderer style default
  7965. (this.style && this.style.fontSize);
  7966. }
  7967. // Handle different units
  7968. if (/px/.test(fontSize)) {
  7969. fontSize = pInt(fontSize);
  7970. }
  7971. else {
  7972. fontSize = 12;
  7973. }
  7974. // Empirical values found by comparing font size and bounding box
  7975. // height. Applies to the default font family.
  7976. // https://jsfiddle.net/highcharts/7xvn7/
  7977. lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
  7978. baseline = Math.round(lineHeight * 0.8);
  7979. return {
  7980. h: lineHeight,
  7981. b: baseline,
  7982. f: fontSize
  7983. };
  7984. };
  7985. /**
  7986. * Correct X and Y positioning of a label for rotation (#1764).
  7987. *
  7988. * @private
  7989. * @function Highcharts.SVGRenderer#rotCorr
  7990. *
  7991. * @param {number} baseline
  7992. *
  7993. * @param {number} rotation
  7994. *
  7995. * @param {boolean} [alterY]
  7996. *
  7997. * @param {Highcharts.PositionObject}
  7998. */
  7999. SVGRenderer.prototype.rotCorr = function (baseline, rotation, alterY) {
  8000. var y = baseline;
  8001. if (rotation && alterY) {
  8002. y = Math.max(y * Math.cos(rotation * deg2rad), 4);
  8003. }
  8004. return {
  8005. x: (-baseline / 3) * Math.sin(rotation * deg2rad),
  8006. y: y
  8007. };
  8008. };
  8009. /**
  8010. * Compatibility function to convert the legacy one-dimensional path array
  8011. * into an array of segments.
  8012. *
  8013. * It is used in maps to parse the `path` option, and in SVGRenderer.dSetter
  8014. * to support legacy paths from demos.
  8015. *
  8016. * @private
  8017. * @function Highcharts.SVGRenderer#pathToSegments
  8018. */
  8019. SVGRenderer.prototype.pathToSegments = function (path) {
  8020. var ret = [];
  8021. var segment = [];
  8022. var commandLength = {
  8023. A: 8,
  8024. C: 7,
  8025. H: 2,
  8026. L: 3,
  8027. M: 3,
  8028. Q: 5,
  8029. S: 5,
  8030. T: 3,
  8031. V: 2
  8032. };
  8033. // Short, non-typesafe parsing of the one-dimensional array. It splits
  8034. // the path on any string. This is not type checked against the tuple
  8035. // types, but is shorter, and doesn't require specific checks for any
  8036. // command type in SVG.
  8037. for (var i = 0; i < path.length; i++) {
  8038. // Command skipped, repeat previous or insert L/l for M/m
  8039. if (isString(segment[0]) &&
  8040. isNumber(path[i]) &&
  8041. segment.length === commandLength[(segment[0].toUpperCase())]) {
  8042. path.splice(i, 0, segment[0].replace('M', 'L').replace('m', 'l'));
  8043. }
  8044. // Split on string
  8045. if (typeof path[i] === 'string') {
  8046. if (segment.length) {
  8047. ret.push(segment.slice(0));
  8048. }
  8049. segment.length = 0;
  8050. }
  8051. segment.push(path[i]);
  8052. }
  8053. ret.push(segment.slice(0));
  8054. return ret;
  8055. /*
  8056. // Fully type-safe version where each tuple type is checked. The
  8057. // downside is filesize and a lack of flexibility for unsupported
  8058. // commands
  8059. const ret: SVGPath = [],
  8060. commands = {
  8061. A: 7,
  8062. C: 6,
  8063. H: 1,
  8064. L: 2,
  8065. M: 2,
  8066. Q: 4,
  8067. S: 4,
  8068. T: 2,
  8069. V: 1,
  8070. Z: 0
  8071. };
  8072. let i = 0,
  8073. lastI = 0,
  8074. lastCommand;
  8075. while (i < path.length) {
  8076. const item = path[i];
  8077. let command;
  8078. if (typeof item === 'string') {
  8079. command = item;
  8080. i += 1;
  8081. } else {
  8082. command = lastCommand || 'M';
  8083. }
  8084. // Upper case
  8085. const commandUC = command.toUpperCase();
  8086. if (commandUC in commands) {
  8087. // No numeric parameters
  8088. if (command === 'Z' || command === 'z') {
  8089. ret.push([command]);
  8090. // One numeric parameter
  8091. } else {
  8092. const val0 = path[i];
  8093. if (typeof val0 === 'number') {
  8094. // Horizontal line to
  8095. if (command === 'H' || command === 'h') {
  8096. ret.push([command, val0]);
  8097. i += 1;
  8098. // Vertical line to
  8099. } else if (command === 'V' || command === 'v') {
  8100. ret.push([command, val0]);
  8101. i += 1;
  8102. // Two numeric parameters
  8103. } else {
  8104. const val1 = path[i + 1];
  8105. if (typeof val1 === 'number') {
  8106. // lineTo
  8107. if (command === 'L' || command === 'l') {
  8108. ret.push([command, val0, val1]);
  8109. i += 2;
  8110. // moveTo
  8111. } else if (command === 'M' || command === 'm') {
  8112. ret.push([command, val0, val1]);
  8113. i += 2;
  8114. // Smooth quadratic bezier
  8115. } else if (command === 'T' || command === 't') {
  8116. ret.push([command, val0, val1]);
  8117. i += 2;
  8118. // Four numeric parameters
  8119. } else {
  8120. const val2 = path[i + 2],
  8121. val3 = path[i + 3];
  8122. if (
  8123. typeof val2 === 'number' &&
  8124. typeof val3 === 'number'
  8125. ) {
  8126. // Quadratic bezier to
  8127. if (
  8128. command === 'Q' ||
  8129. command === 'q'
  8130. ) {
  8131. ret.push([
  8132. command,
  8133. val0,
  8134. val1,
  8135. val2,
  8136. val3
  8137. ]);
  8138. i += 4;
  8139. // Smooth cubic bezier to
  8140. } else if (
  8141. command === 'S' ||
  8142. command === 's'
  8143. ) {
  8144. ret.push([
  8145. command,
  8146. val0,
  8147. val1,
  8148. val2,
  8149. val3
  8150. ]);
  8151. i += 4;
  8152. // Six numeric parameters
  8153. } else {
  8154. const val4 = path[i + 4],
  8155. val5 = path[i + 5];
  8156. if (
  8157. typeof val4 === 'number' &&
  8158. typeof val5 === 'number'
  8159. ) {
  8160. // Curve to
  8161. if (
  8162. command === 'C' ||
  8163. command === 'c'
  8164. ) {
  8165. ret.push([
  8166. command,
  8167. val0,
  8168. val1,
  8169. val2,
  8170. val3,
  8171. val4,
  8172. val5
  8173. ]);
  8174. i += 6;
  8175. // Seven numeric parameters
  8176. } else {
  8177. const val6 = path[i + 6];
  8178. // Arc to
  8179. if (
  8180. typeof val6 ===
  8181. 'number' &&
  8182. (
  8183. command === 'A' ||
  8184. command === 'a'
  8185. )
  8186. ) {
  8187. ret.push([
  8188. command,
  8189. val0,
  8190. val1,
  8191. val2,
  8192. val3,
  8193. val4,
  8194. val5,
  8195. val6
  8196. ]);
  8197. i += 7;
  8198. }
  8199. }
  8200. }
  8201. }
  8202. }
  8203. }
  8204. }
  8205. }
  8206. }
  8207. }
  8208. }
  8209. // An unmarked command following a moveTo is a lineTo
  8210. lastCommand = command === 'M' ? 'L' : command;
  8211. if (i === lastI) {
  8212. break;
  8213. }
  8214. lastI = i;
  8215. }
  8216. return ret;
  8217. */
  8218. };
  8219. /**
  8220. * Draw a label, which is an extended text element with support for border
  8221. * and background. Highcharts creates a `g` element with a text and a `path`
  8222. * or `rect` inside, to make it behave somewhat like a HTML div. Border and
  8223. * background are set through `stroke`, `stroke-width` and `fill` attributes
  8224. * using the {@link Highcharts.SVGElement#attr|attr} method. To update the
  8225. * text after render, run `label.attr({ text: 'New text' })`.
  8226. *
  8227. * @sample highcharts/members/renderer-label-on-chart/
  8228. * A label on the chart
  8229. *
  8230. * @function Highcharts.SVGRenderer#label
  8231. *
  8232. * @param {string} str
  8233. * The initial text string or (subset) HTML to render.
  8234. *
  8235. * @param {number} x
  8236. * The x position of the label's left side.
  8237. *
  8238. * @param {number} [y]
  8239. * The y position of the label's top side or baseline, depending on
  8240. * the `baseline` parameter.
  8241. *
  8242. * @param {string} [shape='rect']
  8243. * The shape of the label's border/background, if any. Defaults to
  8244. * `rect`. Other possible values are `callout` or other shapes
  8245. * defined in {@link Highcharts.SVGRenderer#symbols}.
  8246. *
  8247. * @param {number} [anchorX]
  8248. * In case the `shape` has a pointer, like a flag, this is the
  8249. * coordinates it should be pinned to.
  8250. *
  8251. * @param {number} [anchorY]
  8252. * In case the `shape` has a pointer, like a flag, this is the
  8253. * coordinates it should be pinned to.
  8254. *
  8255. * @param {boolean} [useHTML=false]
  8256. * Wether to use HTML to render the label.
  8257. *
  8258. * @param {boolean} [baseline=false]
  8259. * Whether to position the label relative to the text baseline,
  8260. * like {@link Highcharts.SVGRenderer#text|renderer.text}, or to the
  8261. * upper border of the rectangle.
  8262. *
  8263. * @param {string} [className]
  8264. * Class name for the group.
  8265. *
  8266. * @return {Highcharts.SVGElement}
  8267. * The generated label.
  8268. */
  8269. SVGRenderer.prototype.label = function (str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  8270. return new SVGLabel(this, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className);
  8271. };
  8272. return SVGRenderer;
  8273. }());
  8274. /**
  8275. * A pointer to the renderer's associated Element class. The VMLRenderer
  8276. * will have a pointer to VMLElement here.
  8277. *
  8278. * @name Highcharts.SVGRenderer#Element
  8279. * @type {Highcharts.SVGElement}
  8280. */
  8281. SVGRenderer.prototype.Element = SVGElement;
  8282. /**
  8283. * @private
  8284. */
  8285. SVGRenderer.prototype.SVG_NS = SVG_NS;
  8286. /**
  8287. * Dummy function for plugins, called every time the renderer is updated.
  8288. * Prior to Highcharts 5, this was used for the canvg renderer.
  8289. *
  8290. * @deprecated
  8291. * @function Highcharts.SVGRenderer#draw
  8292. */
  8293. SVGRenderer.prototype.draw = noop;
  8294. /**
  8295. * A collection of characters mapped to HTML entities. When `useHTML` on an
  8296. * element is true, these entities will be rendered correctly by HTML. In
  8297. * the SVG pseudo-HTML, they need to be unescaped back to simple characters,
  8298. * so for example `&lt;` will render as `<`.
  8299. *
  8300. * @example
  8301. * // Add support for unescaping quotes
  8302. * Highcharts.SVGRenderer.prototype.escapes['"'] = '&quot;';
  8303. *
  8304. * @name Highcharts.SVGRenderer#escapes
  8305. * @type {Highcharts.Dictionary<string>}
  8306. */
  8307. SVGRenderer.prototype.escapes = {
  8308. '&': '&amp;',
  8309. '<': '&lt;',
  8310. '>': '&gt;',
  8311. "'": '&#39;',
  8312. '"': '&quot;'
  8313. };
  8314. /**
  8315. * An extendable collection of functions for defining symbol paths.
  8316. *
  8317. * @name Highcharts.SVGRenderer#symbols
  8318. * @type {Highcharts.SymbolDictionary}
  8319. */
  8320. SVGRenderer.prototype.symbols = {
  8321. circle: function (x, y, w, h) {
  8322. // Return a full arc
  8323. return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
  8324. start: Math.PI * 0.5,
  8325. end: Math.PI * 2.5,
  8326. open: false
  8327. });
  8328. },
  8329. square: function (x, y, w, h) {
  8330. return [
  8331. ['M', x, y],
  8332. ['L', x + w, y],
  8333. ['L', x + w, y + h],
  8334. ['L', x, y + h],
  8335. ['Z']
  8336. ];
  8337. },
  8338. triangle: function (x, y, w, h) {
  8339. return [
  8340. ['M', x + w / 2, y],
  8341. ['L', x + w, y + h],
  8342. ['L', x, y + h],
  8343. ['Z']
  8344. ];
  8345. },
  8346. 'triangle-down': function (x, y, w, h) {
  8347. return [
  8348. ['M', x, y],
  8349. ['L', x + w, y],
  8350. ['L', x + w / 2, y + h],
  8351. ['Z']
  8352. ];
  8353. },
  8354. diamond: function (x, y, w, h) {
  8355. return [
  8356. ['M', x + w / 2, y],
  8357. ['L', x + w, y + h / 2],
  8358. ['L', x + w / 2, y + h],
  8359. ['L', x, y + h / 2],
  8360. ['Z']
  8361. ];
  8362. },
  8363. arc: function (x, y, w, h, options) {
  8364. var arc = [];
  8365. if (options) {
  8366. var start = options.start || 0,
  8367. end = options.end || 0,
  8368. rx = options.r || w,
  8369. ry = options.r || h || w,
  8370. proximity = 0.001,
  8371. fullCircle = Math.abs(end - start - 2 * Math.PI) <
  8372. proximity,
  8373. // Substract a small number to prevent cos and sin of start and
  8374. // end from becoming equal on 360 arcs (related: #1561)
  8375. end = end - proximity,
  8376. innerRadius = options.innerR,
  8377. open = pick(options.open,
  8378. fullCircle),
  8379. cosStart = Math.cos(start),
  8380. sinStart = Math.sin(start),
  8381. cosEnd = Math.cos(end),
  8382. sinEnd = Math.sin(end),
  8383. // Proximity takes care of rounding errors around PI (#6971)
  8384. longArc = pick(options.longArc,
  8385. end - start - Math.PI < proximity ? 0 : 1);
  8386. arc.push([
  8387. 'M',
  8388. x + rx * cosStart,
  8389. y + ry * sinStart
  8390. ], [
  8391. 'A',
  8392. rx,
  8393. ry,
  8394. 0,
  8395. longArc,
  8396. pick(options.clockwise, 1),
  8397. x + rx * cosEnd,
  8398. y + ry * sinEnd
  8399. ]);
  8400. if (defined(innerRadius)) {
  8401. arc.push(open ?
  8402. [
  8403. 'M',
  8404. x + innerRadius * cosEnd,
  8405. y + innerRadius * sinEnd
  8406. ] : [
  8407. 'L',
  8408. x + innerRadius * cosEnd,
  8409. y + innerRadius * sinEnd
  8410. ], [
  8411. 'A',
  8412. innerRadius,
  8413. innerRadius,
  8414. 0,
  8415. longArc,
  8416. // Clockwise - opposite to the outer arc clockwise
  8417. defined(options.clockwise) ? 1 - options.clockwise : 0,
  8418. x + innerRadius * cosStart,
  8419. y + innerRadius * sinStart
  8420. ]);
  8421. }
  8422. if (!open) {
  8423. arc.push(['Z']);
  8424. }
  8425. }
  8426. return arc;
  8427. },
  8428. /**
  8429. * Callout shape used for default tooltips, also used for rounded
  8430. * rectangles in VML
  8431. */
  8432. callout: function (x, y, w, h, options) {
  8433. var arrowLength = 6,
  8434. halfDistance = 6,
  8435. r = Math.min((options && options.r) || 0,
  8436. w,
  8437. h),
  8438. safeDistance = r + halfDistance,
  8439. anchorX = options && options.anchorX || 0,
  8440. anchorY = options && options.anchorY || 0,
  8441. path;
  8442. path = [
  8443. ['M', x + r, y],
  8444. ['L', x + w - r, y],
  8445. ['C', x + w, y, x + w, y, x + w, y + r],
  8446. ['L', x + w, y + h - r],
  8447. ['C', x + w, y + h, x + w, y + h, x + w - r, y + h],
  8448. ['L', x + r, y + h],
  8449. ['C', x, y + h, x, y + h, x, y + h - r],
  8450. ['L', x, y + r],
  8451. ['C', x, y, x, y, x + r, y] // top-left corner
  8452. ];
  8453. // Anchor on right side
  8454. if (anchorX && anchorX > w) {
  8455. // Chevron
  8456. if (anchorY > y + safeDistance &&
  8457. anchorY < y + h - safeDistance) {
  8458. 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]);
  8459. // Simple connector
  8460. }
  8461. else {
  8462. path.splice(3, 1, ['L', x + w, h / 2], ['L', anchorX, anchorY], ['L', x + w, h / 2], ['L', x + w, y + h - r]);
  8463. }
  8464. // Anchor on left side
  8465. }
  8466. else if (anchorX && anchorX < 0) {
  8467. // Chevron
  8468. if (anchorY > y + safeDistance &&
  8469. anchorY < y + h - safeDistance) {
  8470. path.splice(7, 1, ['L', x, anchorY + halfDistance], ['L', x - arrowLength, anchorY], ['L', x, anchorY - halfDistance], ['L', x, y + r]);
  8471. // Simple connector
  8472. }
  8473. else {
  8474. path.splice(7, 1, ['L', x, h / 2], ['L', anchorX, anchorY], ['L', x, h / 2], ['L', x, y + r]);
  8475. }
  8476. }
  8477. else if ( // replace bottom
  8478. anchorY &&
  8479. anchorY > h &&
  8480. anchorX > x + safeDistance &&
  8481. anchorX < x + w - safeDistance) {
  8482. path.splice(5, 1, ['L', anchorX + halfDistance, y + h], ['L', anchorX, y + h + arrowLength], ['L', anchorX - halfDistance, y + h], ['L', x + r, y + h]);
  8483. }
  8484. else if ( // replace top
  8485. anchorY &&
  8486. anchorY < 0 &&
  8487. anchorX > x + safeDistance &&
  8488. anchorX < x + w - safeDistance) {
  8489. path.splice(1, 1, ['L', anchorX - halfDistance, y], ['L', anchorX, y - arrowLength], ['L', anchorX + halfDistance, y], ['L', w - r, y]);
  8490. }
  8491. return path;
  8492. }
  8493. };
  8494. H.SVGRenderer = SVGRenderer;
  8495. H.Renderer = H.SVGRenderer;
  8496. return H.Renderer;
  8497. });
  8498. _registerModule(_modules, 'Core/Renderer/HTML/HTML.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (H, SVGElement, SVGRenderer, U) {
  8499. /* *
  8500. *
  8501. * (c) 2010-2020 Torstein Honsi
  8502. *
  8503. * License: www.highcharts.com/license
  8504. *
  8505. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8506. *
  8507. * */
  8508. var attr = U.attr,
  8509. createElement = U.createElement,
  8510. css = U.css,
  8511. defined = U.defined,
  8512. extend = U.extend,
  8513. pick = U.pick,
  8514. pInt = U.pInt;
  8515. var isFirefox = H.isFirefox,
  8516. isMS = H.isMS,
  8517. isWebKit = H.isWebKit,
  8518. win = H.win;
  8519. /* eslint-disable valid-jsdoc */
  8520. // Extend SvgElement for useHTML option.
  8521. extend(SVGElement.prototype, /** @lends SVGElement.prototype */ {
  8522. /**
  8523. * Apply CSS to HTML elements. This is used in text within SVG rendering and
  8524. * by the VML renderer
  8525. *
  8526. * @private
  8527. * @function Highcharts.SVGElement#htmlCss
  8528. *
  8529. * @param {Highcharts.CSSObject} styles
  8530. *
  8531. * @return {Highcharts.SVGElement}
  8532. */
  8533. htmlCss: function (styles) {
  8534. var wrapper = this,
  8535. element = wrapper.element,
  8536. // When setting or unsetting the width style, we need to update
  8537. // transform (#8809)
  8538. isSettingWidth = (element.tagName === 'SPAN' &&
  8539. styles &&
  8540. 'width' in styles),
  8541. textWidth = pick(isSettingWidth && styles.width,
  8542. void 0),
  8543. doTransform;
  8544. if (isSettingWidth) {
  8545. delete styles.width;
  8546. wrapper.textWidth = textWidth;
  8547. doTransform = true;
  8548. }
  8549. if (styles && styles.textOverflow === 'ellipsis') {
  8550. styles.whiteSpace = 'nowrap';
  8551. styles.overflow = 'hidden';
  8552. }
  8553. wrapper.styles = extend(wrapper.styles, styles);
  8554. css(wrapper.element, styles);
  8555. // Now that all styles are applied, to the transform
  8556. if (doTransform) {
  8557. wrapper.htmlUpdateTransform();
  8558. }
  8559. return wrapper;
  8560. },
  8561. /**
  8562. * VML and useHTML method for calculating the bounding box based on offsets.
  8563. *
  8564. * @private
  8565. * @function Highcharts.SVGElement#htmlGetBBox
  8566. *
  8567. * @param {boolean} refresh
  8568. * Whether to force a fresh value from the DOM or to use the cached
  8569. * value.
  8570. *
  8571. * @return {Highcharts.BBoxObject}
  8572. * A hash containing values for x, y, width and height.
  8573. */
  8574. htmlGetBBox: function () {
  8575. var wrapper = this,
  8576. element = wrapper.element;
  8577. return {
  8578. x: element.offsetLeft,
  8579. y: element.offsetTop,
  8580. width: element.offsetWidth,
  8581. height: element.offsetHeight
  8582. };
  8583. },
  8584. /**
  8585. * VML override private method to update elements based on internal
  8586. * properties based on SVG transform.
  8587. *
  8588. * @private
  8589. * @function Highcharts.SVGElement#htmlUpdateTransform
  8590. * @return {void}
  8591. */
  8592. htmlUpdateTransform: function () {
  8593. // aligning non added elements is expensive
  8594. if (!this.added) {
  8595. this.alignOnAdd = true;
  8596. return;
  8597. }
  8598. var wrapper = this,
  8599. renderer = wrapper.renderer,
  8600. elem = wrapper.element,
  8601. translateX = wrapper.translateX || 0,
  8602. translateY = wrapper.translateY || 0,
  8603. x = wrapper.x || 0,
  8604. y = wrapper.y || 0,
  8605. align = wrapper.textAlign || 'left',
  8606. alignCorrection = {
  8607. left: 0,
  8608. center: 0.5,
  8609. right: 1
  8610. }[align],
  8611. styles = wrapper.styles,
  8612. whiteSpace = styles && styles.whiteSpace;
  8613. /**
  8614. * @private
  8615. * @return {number}
  8616. */
  8617. function getTextPxLength() {
  8618. // Reset multiline/ellipsis in order to read width (#4928,
  8619. // #5417)
  8620. css(elem, {
  8621. width: '',
  8622. whiteSpace: whiteSpace || 'nowrap'
  8623. });
  8624. return elem.offsetWidth;
  8625. }
  8626. // apply translate
  8627. css(elem, {
  8628. marginLeft: translateX,
  8629. marginTop: translateY
  8630. });
  8631. if (!renderer.styledMode && wrapper.shadows) { // used in labels/tooltip
  8632. wrapper.shadows.forEach(function (shadow) {
  8633. css(shadow, {
  8634. marginLeft: translateX + 1,
  8635. marginTop: translateY + 1
  8636. });
  8637. });
  8638. }
  8639. // apply inversion
  8640. if (wrapper.inverted) { // wrapper is a group
  8641. [].forEach.call(elem.childNodes, function (child) {
  8642. renderer.invertChild(child, elem);
  8643. });
  8644. }
  8645. if (elem.tagName === 'SPAN') {
  8646. var rotation = wrapper.rotation, baseline, textWidth = wrapper.textWidth && pInt(wrapper.textWidth), currentTextTransform = [
  8647. rotation,
  8648. align,
  8649. elem.innerHTML,
  8650. wrapper.textWidth,
  8651. wrapper.textAlign
  8652. ].join(',');
  8653. // Update textWidth. Use the memoized textPxLength if possible, to
  8654. // avoid the getTextPxLength function using elem.offsetWidth.
  8655. // Calling offsetWidth affects rendering time as it forces layout
  8656. // (#7656).
  8657. if (textWidth !== wrapper.oldTextWidth &&
  8658. ((textWidth > wrapper.oldTextWidth) ||
  8659. (wrapper.textPxLength || getTextPxLength()) > textWidth) && (
  8660. // Only set the width if the text is able to word-wrap, or
  8661. // text-overflow is ellipsis (#9537)
  8662. /[ \-]/.test(elem.textContent || elem.innerText) ||
  8663. elem.style.textOverflow === 'ellipsis')) { // #983, #1254
  8664. css(elem, {
  8665. width: textWidth + 'px',
  8666. display: 'block',
  8667. whiteSpace: whiteSpace || 'normal' // #3331
  8668. });
  8669. wrapper.oldTextWidth = textWidth;
  8670. wrapper.hasBoxWidthChanged = true; // #8159
  8671. }
  8672. else {
  8673. wrapper.hasBoxWidthChanged = false; // #8159
  8674. }
  8675. // Do the calculations and DOM access only if properties changed
  8676. if (currentTextTransform !== wrapper.cTT) {
  8677. baseline = renderer.fontMetrics(elem.style.fontSize, elem).b;
  8678. // Renderer specific handling of span rotation, but only if we
  8679. // have something to update.
  8680. if (defined(rotation) &&
  8681. ((rotation !== (wrapper.oldRotation || 0)) ||
  8682. (align !== wrapper.oldAlign))) {
  8683. wrapper.setSpanRotation(rotation, alignCorrection, baseline);
  8684. }
  8685. wrapper.getSpanCorrection(
  8686. // Avoid elem.offsetWidth if we can, it affects rendering
  8687. // time heavily (#7656)
  8688. ((!defined(rotation) && wrapper.textPxLength) || // #7920
  8689. elem.offsetWidth), baseline, alignCorrection, rotation, align);
  8690. }
  8691. // apply position with correction
  8692. css(elem, {
  8693. left: (x + (wrapper.xCorr || 0)) + 'px',
  8694. top: (y + (wrapper.yCorr || 0)) + 'px'
  8695. });
  8696. // record current text transform
  8697. wrapper.cTT = currentTextTransform;
  8698. wrapper.oldRotation = rotation;
  8699. wrapper.oldAlign = align;
  8700. }
  8701. },
  8702. /**
  8703. * Set the rotation of an individual HTML span.
  8704. *
  8705. * @private
  8706. * @function Highcharts.SVGElement#setSpanRotation
  8707. * @param {number} rotation
  8708. * @param {number} alignCorrection
  8709. * @param {number} baseline
  8710. * @return {void}
  8711. */
  8712. setSpanRotation: function (rotation, alignCorrection, baseline) {
  8713. var rotationStyle = {},
  8714. cssTransformKey = this.renderer.getTransformKey();
  8715. rotationStyle[cssTransformKey] = rotationStyle.transform =
  8716. 'rotate(' + rotation + 'deg)';
  8717. rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] =
  8718. rotationStyle.transformOrigin =
  8719. (alignCorrection * 100) + '% ' + baseline + 'px';
  8720. css(this.element, rotationStyle);
  8721. },
  8722. /**
  8723. * Get the correction in X and Y positioning as the element is rotated.
  8724. *
  8725. * @private
  8726. * @function Highcharts.SVGElement#getSpanCorrection
  8727. * @param {number} width
  8728. * @param {number} baseline
  8729. * @param {number} alignCorrection
  8730. * @return {void}
  8731. */
  8732. getSpanCorrection: function (width, baseline, alignCorrection) {
  8733. this.xCorr = -width * alignCorrection;
  8734. this.yCorr = -baseline;
  8735. }
  8736. });
  8737. // Extend SvgRenderer for useHTML option.
  8738. extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {
  8739. /**
  8740. * @private
  8741. * @function Highcharts.SVGRenderer#getTransformKey
  8742. *
  8743. * @return {string}
  8744. */
  8745. getTransformKey: function () {
  8746. return isMS && !/Edge/.test(win.navigator.userAgent) ?
  8747. '-ms-transform' :
  8748. isWebKit ?
  8749. '-webkit-transform' :
  8750. isFirefox ?
  8751. 'MozTransform' :
  8752. win.opera ?
  8753. '-o-transform' :
  8754. '';
  8755. },
  8756. /**
  8757. * Create HTML text node. This is used by the VML renderer as well as the
  8758. * SVG renderer through the useHTML option.
  8759. *
  8760. * @private
  8761. * @function Highcharts.SVGRenderer#html
  8762. *
  8763. * @param {string} str
  8764. * The text of (subset) HTML to draw.
  8765. *
  8766. * @param {number} x
  8767. * The x position of the text's lower left corner.
  8768. *
  8769. * @param {number} y
  8770. * The y position of the text's lower left corner.
  8771. *
  8772. * @return {Highcharts.HTMLDOMElement}
  8773. */
  8774. html: function (str, x, y) {
  8775. var wrapper = this.createElement('span'), element = wrapper.element, renderer = wrapper.renderer, isSVG = renderer.isSVG, addSetters = function (gWrapper, style) {
  8776. // These properties are set as attributes on the SVG group, and
  8777. // as identical CSS properties on the div. (#3542)
  8778. ['opacity', 'visibility'].forEach(function (prop) {
  8779. gWrapper[prop + 'Setter'] = function (value, key, elem) {
  8780. var styleObject = gWrapper.div ?
  8781. gWrapper.div.style :
  8782. style;
  8783. SVGElement.prototype[prop + 'Setter']
  8784. .call(this, value, key, elem);
  8785. if (styleObject) {
  8786. styleObject[key] = value;
  8787. }
  8788. };
  8789. });
  8790. gWrapper.addedSetters = true;
  8791. };
  8792. // Text setter
  8793. wrapper.textSetter = function (value) {
  8794. if (value !== element.innerHTML) {
  8795. delete this.bBox;
  8796. delete this.oldTextWidth;
  8797. }
  8798. this.textStr = value;
  8799. element.innerHTML = pick(value, '');
  8800. wrapper.doTransform = true;
  8801. };
  8802. // Add setters for the element itself (#4938)
  8803. if (isSVG) { // #4938, only for HTML within SVG
  8804. addSetters(wrapper, wrapper.element.style);
  8805. }
  8806. // Various setters which rely on update transform
  8807. wrapper.xSetter =
  8808. wrapper.ySetter =
  8809. wrapper.alignSetter =
  8810. wrapper.rotationSetter =
  8811. function (value, key) {
  8812. if (key === 'align') {
  8813. // Do not overwrite the SVGElement.align method. Same as VML.
  8814. wrapper.alignValue = wrapper.textAlign = value;
  8815. }
  8816. else {
  8817. wrapper[key] = value;
  8818. }
  8819. wrapper.doTransform = true;
  8820. };
  8821. // Runs at the end of .attr()
  8822. wrapper.afterSetters = function () {
  8823. // Update transform. Do this outside the loop to prevent redundant
  8824. // updating for batch setting of attributes.
  8825. if (this.doTransform) {
  8826. this.htmlUpdateTransform();
  8827. this.doTransform = false;
  8828. }
  8829. };
  8830. // Set the default attributes
  8831. wrapper
  8832. .attr({
  8833. text: str,
  8834. x: Math.round(x),
  8835. y: Math.round(y)
  8836. })
  8837. .css({
  8838. position: 'absolute'
  8839. });
  8840. if (!renderer.styledMode) {
  8841. wrapper.css({
  8842. fontFamily: this.style.fontFamily,
  8843. fontSize: this.style.fontSize
  8844. });
  8845. }
  8846. // Keep the whiteSpace style outside the wrapper.styles collection
  8847. element.style.whiteSpace = 'nowrap';
  8848. // Use the HTML specific .css method
  8849. wrapper.css = wrapper.htmlCss;
  8850. // This is specific for HTML within SVG
  8851. if (isSVG) {
  8852. wrapper.add = function (svgGroupWrapper) {
  8853. var htmlGroup,
  8854. container = renderer.box.parentNode,
  8855. parentGroup,
  8856. parents = [];
  8857. this.parentGroup = svgGroupWrapper;
  8858. // Create a mock group to hold the HTML elements
  8859. if (svgGroupWrapper) {
  8860. htmlGroup = svgGroupWrapper.div;
  8861. if (!htmlGroup) {
  8862. // Read the parent chain into an array and read from top
  8863. // down
  8864. parentGroup = svgGroupWrapper;
  8865. while (parentGroup) {
  8866. parents.push(parentGroup);
  8867. // Move up to the next parent group
  8868. parentGroup = parentGroup.parentGroup;
  8869. }
  8870. // Ensure dynamically updating position when any parent
  8871. // is translated
  8872. parents.reverse().forEach(function (parentGroup) {
  8873. var htmlGroupStyle,
  8874. cls = attr(parentGroup.element, 'class');
  8875. /**
  8876. * Common translate setter for X and Y on the HTML
  8877. * group. Reverted the fix for #6957 du to
  8878. * positioning problems and offline export (#7254,
  8879. * #7280, #7529)
  8880. * @private
  8881. * @param {*} value
  8882. * @param {string} key
  8883. * @return {void}
  8884. */
  8885. function translateSetter(value, key) {
  8886. parentGroup[key] = value;
  8887. if (key === 'translateX') {
  8888. htmlGroupStyle.left = value + 'px';
  8889. }
  8890. else {
  8891. htmlGroupStyle.top = value + 'px';
  8892. }
  8893. parentGroup.doTransform = true;
  8894. }
  8895. // Create a HTML div and append it to the parent div
  8896. // to emulate the SVG group structure
  8897. htmlGroup =
  8898. parentGroup.div =
  8899. parentGroup.div || createElement('div', cls ? { className: cls } : void 0, {
  8900. position: 'absolute',
  8901. left: (parentGroup.translateX || 0) + 'px',
  8902. top: (parentGroup.translateY || 0) + 'px',
  8903. display: parentGroup.display,
  8904. opacity: parentGroup.opacity,
  8905. pointerEvents: (parentGroup.styles &&
  8906. parentGroup.styles.pointerEvents) // #5595
  8907. // the top group is appended to container
  8908. }, htmlGroup || container);
  8909. // Shortcut
  8910. htmlGroupStyle = htmlGroup.style;
  8911. // Set listeners to update the HTML div's position
  8912. // whenever the SVG group position is changed.
  8913. extend(parentGroup, {
  8914. // (#7287) Pass htmlGroup to use
  8915. // the related group
  8916. classSetter: (function (htmlGroup) {
  8917. return function (value) {
  8918. this.element.setAttribute('class', value);
  8919. htmlGroup.className = value;
  8920. };
  8921. }(htmlGroup)),
  8922. on: function () {
  8923. if (parents[0].div) { // #6418
  8924. wrapper.on.apply({ element: parents[0].div }, arguments);
  8925. }
  8926. return parentGroup;
  8927. },
  8928. translateXSetter: translateSetter,
  8929. translateYSetter: translateSetter
  8930. });
  8931. if (!parentGroup.addedSetters) {
  8932. addSetters(parentGroup);
  8933. }
  8934. });
  8935. }
  8936. }
  8937. else {
  8938. htmlGroup = container;
  8939. }
  8940. htmlGroup.appendChild(element);
  8941. // Shared with VML:
  8942. wrapper.added = true;
  8943. if (wrapper.alignOnAdd) {
  8944. wrapper.htmlUpdateTransform();
  8945. }
  8946. return wrapper;
  8947. };
  8948. }
  8949. return wrapper;
  8950. }
  8951. });
  8952. });
  8953. _registerModule(_modules, 'Core/Axis/Tick.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  8954. /* *
  8955. *
  8956. * (c) 2010-2020 Torstein Honsi
  8957. *
  8958. * License: www.highcharts.com/license
  8959. *
  8960. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8961. *
  8962. * */
  8963. /**
  8964. * Optional parameters for the tick.
  8965. * @private
  8966. * @interface Highcharts.TickParametersObject
  8967. */ /**
  8968. * Set category for the tick.
  8969. * @name Highcharts.TickParametersObject#category
  8970. * @type {string|undefined}
  8971. */ /**
  8972. * @name Highcharts.TickParametersObject#options
  8973. * @type {Highcharts.Dictionary<any>|undefined}
  8974. */ /**
  8975. * Set tickmarkOffset for the tick.
  8976. * @name Highcharts.TickParametersObject#tickmarkOffset
  8977. * @type {number|undefined}
  8978. */
  8979. var clamp = U.clamp,
  8980. correctFloat = U.correctFloat,
  8981. defined = U.defined,
  8982. destroyObjectProperties = U.destroyObjectProperties,
  8983. extend = U.extend,
  8984. fireEvent = U.fireEvent,
  8985. isNumber = U.isNumber,
  8986. merge = U.merge,
  8987. objectEach = U.objectEach,
  8988. pick = U.pick;
  8989. var deg2rad = H.deg2rad;
  8990. /* eslint-disable no-invalid-this, valid-jsdoc */
  8991. /**
  8992. * The Tick class.
  8993. *
  8994. * @class
  8995. * @name Highcharts.Tick
  8996. *
  8997. * @param {Highcharts.Axis} axis
  8998. * The axis of the tick.
  8999. *
  9000. * @param {number} pos
  9001. * The position of the tick on the axis in terms of axis values.
  9002. *
  9003. * @param {string} [type]
  9004. * The type of tick, either 'minor' or an empty string
  9005. *
  9006. * @param {boolean} [noLabel=false]
  9007. * Whether to disable the label or not. Defaults to false.
  9008. *
  9009. * @param {object} [parameters]
  9010. * Optional parameters for the tick.
  9011. */
  9012. var Tick = /** @class */ (function () {
  9013. /* *
  9014. *
  9015. * Constructors
  9016. *
  9017. * */
  9018. function Tick(axis, pos, type, noLabel, parameters) {
  9019. this.isNew = true;
  9020. this.isNewLabel = true;
  9021. /**
  9022. * The related axis of the tick.
  9023. * @name Highcharts.Tick#axis
  9024. * @type {Highcharts.Axis}
  9025. */
  9026. this.axis = axis;
  9027. /**
  9028. * The logical position of the tick on the axis in terms of axis values.
  9029. * @name Highcharts.Tick#pos
  9030. * @type {number}
  9031. */
  9032. this.pos = pos;
  9033. /**
  9034. * The tick type, which can be `"minor"`, or an empty string.
  9035. * @name Highcharts.Tick#type
  9036. * @type {string}
  9037. */
  9038. this.type = type || '';
  9039. this.parameters = parameters || {};
  9040. /**
  9041. * The mark offset of the tick on the axis. Usually `undefined`, numeric
  9042. * for grid axes.
  9043. * @name Highcharts.Tick#tickmarkOffset
  9044. * @type {number|undefined}
  9045. */
  9046. this.tickmarkOffset = this.parameters.tickmarkOffset;
  9047. this.options = this.parameters.options;
  9048. fireEvent(this, 'init');
  9049. if (!type && !noLabel) {
  9050. this.addLabel();
  9051. }
  9052. }
  9053. /* *
  9054. *
  9055. * Functions
  9056. *
  9057. * */
  9058. /**
  9059. * Write the tick label.
  9060. *
  9061. * @private
  9062. * @function Highcharts.Tick#addLabel
  9063. * @return {void}
  9064. */
  9065. Tick.prototype.addLabel = function () {
  9066. var tick = this,
  9067. axis = tick.axis,
  9068. options = axis.options,
  9069. chart = axis.chart,
  9070. categories = axis.categories,
  9071. log = axis.logarithmic,
  9072. names = axis.names,
  9073. pos = tick.pos,
  9074. labelOptions = pick(tick.options && tick.options.labels,
  9075. options.labels),
  9076. str,
  9077. tickPositions = axis.tickPositions,
  9078. isFirst = pos === tickPositions[0],
  9079. isLast = pos === tickPositions[tickPositions.length - 1],
  9080. value = this.parameters.category || (categories ?
  9081. pick(categories[pos],
  9082. names[pos],
  9083. pos) :
  9084. pos),
  9085. label = tick.label,
  9086. animateLabels = (!labelOptions.step || labelOptions.step === 1) &&
  9087. axis.tickInterval === 1,
  9088. tickPositionInfo = tickPositions.info,
  9089. dateTimeLabelFormat,
  9090. dateTimeLabelFormats,
  9091. i,
  9092. list;
  9093. // Set the datetime label format. If a higher rank is set for this
  9094. // position, use that. If not, use the general format.
  9095. if (axis.dateTime && tickPositionInfo) {
  9096. dateTimeLabelFormats = chart.time.resolveDTLFormat(options.dateTimeLabelFormats[(!options.grid &&
  9097. tickPositionInfo.higherRanks[pos]) ||
  9098. tickPositionInfo.unitName]);
  9099. dateTimeLabelFormat = dateTimeLabelFormats.main;
  9100. }
  9101. // set properties for access in render method
  9102. /**
  9103. * True if the tick is the first one on the axis.
  9104. * @name Highcharts.Tick#isFirst
  9105. * @readonly
  9106. * @type {boolean|undefined}
  9107. */
  9108. tick.isFirst = isFirst;
  9109. /**
  9110. * True if the tick is the last one on the axis.
  9111. * @name Highcharts.Tick#isLast
  9112. * @readonly
  9113. * @type {boolean|undefined}
  9114. */
  9115. tick.isLast = isLast;
  9116. // Get the string
  9117. tick.formatCtx = {
  9118. axis: axis,
  9119. chart: chart,
  9120. isFirst: isFirst,
  9121. isLast: isLast,
  9122. dateTimeLabelFormat: dateTimeLabelFormat,
  9123. tickPositionInfo: tickPositionInfo,
  9124. value: log ? correctFloat(log.lin2log(value)) : value,
  9125. pos: pos
  9126. };
  9127. str = axis.labelFormatter.call(tick.formatCtx, this.formatCtx);
  9128. // Set up conditional formatting based on the format list if existing.
  9129. list = dateTimeLabelFormats && dateTimeLabelFormats.list;
  9130. if (list) {
  9131. tick.shortenLabel = function () {
  9132. for (i = 0; i < list.length; i++) {
  9133. label.attr({
  9134. text: axis.labelFormatter.call(extend(tick.formatCtx, { dateTimeLabelFormat: list[i] }))
  9135. });
  9136. if (label.getBBox().width <
  9137. axis.getSlotWidth(tick) - 2 *
  9138. pick(labelOptions.padding, 5)) {
  9139. return;
  9140. }
  9141. }
  9142. label.attr({
  9143. text: ''
  9144. });
  9145. };
  9146. }
  9147. // Call only after first render
  9148. if (animateLabels && axis._addedPlotLB) {
  9149. tick.moveLabel(str, labelOptions);
  9150. }
  9151. // First call
  9152. if (!defined(label) && !tick.movedLabel) {
  9153. /**
  9154. * The rendered text label of the tick.
  9155. * @name Highcharts.Tick#label
  9156. * @type {Highcharts.SVGElement|undefined}
  9157. */
  9158. tick.label = label = tick.createLabel({ x: 0, y: 0 }, str, labelOptions);
  9159. // Base value to detect change for new calls to getBBox
  9160. tick.rotation = 0;
  9161. // update
  9162. }
  9163. else if (label && label.textStr !== str && !animateLabels) {
  9164. // When resetting text, also reset the width if dynamically set
  9165. // (#8809)
  9166. if (label.textWidth &&
  9167. !(labelOptions.style && labelOptions.style.width) &&
  9168. !label.styles.width) {
  9169. label.css({ width: null });
  9170. }
  9171. label.attr({ text: str });
  9172. label.textPxLength = label.getBBox().width;
  9173. }
  9174. };
  9175. /**
  9176. * Render and return the label of the tick.
  9177. *
  9178. * @private
  9179. * @function Highcharts.Tick#createLabel
  9180. * @param {Highcharts.PositionObject} xy
  9181. * @param {string} str
  9182. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  9183. * @return {Highcharts.SVGElement|undefined}
  9184. */
  9185. Tick.prototype.createLabel = function (xy, str, labelOptions) {
  9186. var axis = this.axis,
  9187. chart = axis.chart,
  9188. label = defined(str) && labelOptions.enabled ?
  9189. chart.renderer
  9190. .text(str,
  9191. xy.x,
  9192. xy.y,
  9193. labelOptions.useHTML)
  9194. .add(axis.labelGroup) :
  9195. null;
  9196. // Un-rotated length
  9197. if (label) {
  9198. // Without position absolute, IE export sometimes is wrong
  9199. if (!chart.styledMode) {
  9200. label.css(merge(labelOptions.style));
  9201. }
  9202. label.textPxLength = label.getBBox().width;
  9203. }
  9204. return label;
  9205. };
  9206. /**
  9207. * Destructor for the tick prototype
  9208. *
  9209. * @private
  9210. * @function Highcharts.Tick#destroy
  9211. * @return {void}
  9212. */
  9213. Tick.prototype.destroy = function () {
  9214. destroyObjectProperties(this, this.axis);
  9215. };
  9216. /**
  9217. * Gets the x and y positions for ticks in terms of pixels.
  9218. *
  9219. * @private
  9220. * @function Highcharts.Tick#getPosition
  9221. *
  9222. * @param {boolean} horiz
  9223. * Whether the tick is on an horizontal axis or not.
  9224. *
  9225. * @param {number} tickPos
  9226. * Position of the tick.
  9227. *
  9228. * @param {number} tickmarkOffset
  9229. * Tickmark offset for all ticks.
  9230. *
  9231. * @param {boolean} [old]
  9232. * Whether the axis has changed or not.
  9233. *
  9234. * @return {Highcharts.PositionObject}
  9235. * The tick position.
  9236. *
  9237. * @fires Highcharts.Tick#event:afterGetPosition
  9238. */
  9239. Tick.prototype.getPosition = function (horiz, tickPos, tickmarkOffset, old) {
  9240. var axis = this.axis,
  9241. chart = axis.chart,
  9242. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  9243. pos;
  9244. pos = {
  9245. x: horiz ?
  9246. correctFloat(axis.translate(tickPos + tickmarkOffset, null, null, old) +
  9247. axis.transB) :
  9248. (axis.left +
  9249. axis.offset +
  9250. (axis.opposite ?
  9251. (((old && chart.oldChartWidth) ||
  9252. chart.chartWidth) -
  9253. axis.right -
  9254. axis.left) :
  9255. 0)),
  9256. y: horiz ?
  9257. (cHeight -
  9258. axis.bottom +
  9259. axis.offset -
  9260. (axis.opposite ? axis.height : 0)) :
  9261. correctFloat(cHeight -
  9262. axis.translate(tickPos + tickmarkOffset, null, null, old) -
  9263. axis.transB)
  9264. };
  9265. // Chrome workaround for #10516
  9266. pos.y = clamp(pos.y, -1e5, 1e5);
  9267. fireEvent(this, 'afterGetPosition', { pos: pos });
  9268. return pos;
  9269. };
  9270. /**
  9271. * Get the x, y position of the tick label
  9272. *
  9273. * @private
  9274. * @return {Highcharts.PositionObject}
  9275. */
  9276. Tick.prototype.getLabelPosition = function (x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
  9277. var axis = this.axis,
  9278. transA = axis.transA,
  9279. reversed = ( // #7911
  9280. axis.isLinked && axis.linkedParent ?
  9281. axis.linkedParent.reversed :
  9282. axis.reversed),
  9283. staggerLines = axis.staggerLines,
  9284. rotCorr = axis.tickRotCorr || { x: 0,
  9285. y: 0 },
  9286. yOffset = labelOptions.y,
  9287. // Adjust for label alignment if we use reserveSpace: true (#5286)
  9288. labelOffsetCorrection = (!horiz && !axis.reserveSpaceDefault ?
  9289. -axis.labelOffset * (axis.labelAlign === 'center' ? 0.5 : 1) :
  9290. 0),
  9291. line,
  9292. pos = {};
  9293. if (!defined(yOffset)) {
  9294. if (axis.side === 0) {
  9295. yOffset = label.rotation ? -8 : -label.getBBox().height;
  9296. }
  9297. else if (axis.side === 2) {
  9298. yOffset = rotCorr.y + 8;
  9299. }
  9300. else {
  9301. // #3140, #3140
  9302. yOffset = Math.cos(label.rotation * deg2rad) *
  9303. (rotCorr.y - label.getBBox(false, 0).height / 2);
  9304. }
  9305. }
  9306. x = x +
  9307. labelOptions.x +
  9308. labelOffsetCorrection +
  9309. rotCorr.x -
  9310. (tickmarkOffset && horiz ?
  9311. tickmarkOffset * transA * (reversed ? -1 : 1) :
  9312. 0);
  9313. y = y + yOffset - (tickmarkOffset && !horiz ?
  9314. tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
  9315. // Correct for staggered labels
  9316. if (staggerLines) {
  9317. line = (index / (step || 1) % staggerLines);
  9318. if (axis.opposite) {
  9319. line = staggerLines - line - 1;
  9320. }
  9321. y += line * (axis.labelOffset / staggerLines);
  9322. }
  9323. pos.x = x;
  9324. pos.y = Math.round(y);
  9325. fireEvent(this, 'afterGetLabelPosition', { pos: pos, tickmarkOffset: tickmarkOffset, index: index });
  9326. return pos;
  9327. };
  9328. /**
  9329. * Get the offset height or width of the label
  9330. *
  9331. * @private
  9332. * @function Highcharts.Tick#getLabelSize
  9333. * @return {number}
  9334. */
  9335. Tick.prototype.getLabelSize = function () {
  9336. return this.label ?
  9337. this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
  9338. 0;
  9339. };
  9340. /**
  9341. * Extendible method to return the path of the marker
  9342. *
  9343. * @private
  9344. *
  9345. */
  9346. Tick.prototype.getMarkPath = function (x, y, tickLength, tickWidth, horiz, renderer) {
  9347. return renderer.crispLine([[
  9348. 'M',
  9349. x,
  9350. y
  9351. ], [
  9352. 'L',
  9353. x + (horiz ? 0 : -tickLength),
  9354. y + (horiz ? tickLength : 0)
  9355. ]], tickWidth);
  9356. };
  9357. /**
  9358. * Handle the label overflow by adjusting the labels to the left and right
  9359. * edge, or hide them if they collide into the neighbour label.
  9360. *
  9361. * @private
  9362. * @function Highcharts.Tick#handleOverflow
  9363. * @param {Highcharts.PositionObject} xy
  9364. * @return {void}
  9365. */
  9366. Tick.prototype.handleOverflow = function (xy) {
  9367. var tick = this,
  9368. axis = this.axis,
  9369. labelOptions = axis.options.labels,
  9370. pxPos = xy.x,
  9371. chartWidth = axis.chart.chartWidth,
  9372. spacing = axis.chart.spacing,
  9373. leftBound = pick(axis.labelLeft,
  9374. Math.min(axis.pos,
  9375. spacing[3])),
  9376. rightBound = pick(axis.labelRight,
  9377. Math.max(!axis.isRadial ? axis.pos + axis.len : 0,
  9378. chartWidth - spacing[1])),
  9379. label = this.label,
  9380. rotation = this.rotation,
  9381. factor = {
  9382. left: 0,
  9383. center: 0.5,
  9384. right: 1
  9385. }[axis.labelAlign || label.attr('align')],
  9386. labelWidth = label.getBBox().width,
  9387. slotWidth = axis.getSlotWidth(tick),
  9388. modifiedSlotWidth = slotWidth,
  9389. xCorrection = factor,
  9390. goRight = 1,
  9391. leftPos,
  9392. rightPos,
  9393. textWidth,
  9394. css = {};
  9395. // Check if the label overshoots the chart spacing box. If it does, move
  9396. // it. If it now overshoots the slotWidth, add ellipsis.
  9397. if (!rotation &&
  9398. pick(labelOptions.overflow, 'justify') === 'justify') {
  9399. leftPos = pxPos - factor * labelWidth;
  9400. rightPos = pxPos + (1 - factor) * labelWidth;
  9401. if (leftPos < leftBound) {
  9402. modifiedSlotWidth =
  9403. xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
  9404. }
  9405. else if (rightPos > rightBound) {
  9406. modifiedSlotWidth =
  9407. rightBound - xy.x + modifiedSlotWidth * factor;
  9408. goRight = -1;
  9409. }
  9410. modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
  9411. if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
  9412. xy.x += (goRight *
  9413. (slotWidth -
  9414. modifiedSlotWidth -
  9415. xCorrection * (slotWidth - Math.min(labelWidth, modifiedSlotWidth))));
  9416. }
  9417. // If the label width exceeds the available space, set a text width
  9418. // to be picked up below. Also, if a width has been set before, we
  9419. // need to set a new one because the reported labelWidth will be
  9420. // limited by the box (#3938).
  9421. if (labelWidth > modifiedSlotWidth ||
  9422. (axis.autoRotation && (label.styles || {}).width)) {
  9423. textWidth = modifiedSlotWidth;
  9424. }
  9425. // Add ellipsis to prevent rotated labels to be clipped against the edge
  9426. // of the chart
  9427. }
  9428. else if (rotation < 0 &&
  9429. pxPos - factor * labelWidth < leftBound) {
  9430. textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
  9431. }
  9432. else if (rotation > 0 &&
  9433. pxPos + factor * labelWidth > rightBound) {
  9434. textWidth = Math.round((chartWidth - pxPos) /
  9435. Math.cos(rotation * deg2rad));
  9436. }
  9437. if (textWidth) {
  9438. if (tick.shortenLabel) {
  9439. tick.shortenLabel();
  9440. }
  9441. else {
  9442. css.width = Math.floor(textWidth) + 'px';
  9443. if (!(labelOptions.style || {}).textOverflow) {
  9444. css.textOverflow = 'ellipsis';
  9445. }
  9446. label.css(css);
  9447. }
  9448. }
  9449. };
  9450. /**
  9451. * Try to replace the label if the same one already exists.
  9452. *
  9453. * @private
  9454. * @function Highcharts.Tick#moveLabel
  9455. * @param {string} str
  9456. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  9457. *
  9458. * @return {void}
  9459. */
  9460. Tick.prototype.moveLabel = function (str, labelOptions) {
  9461. var tick = this,
  9462. label = tick.label,
  9463. moved = false,
  9464. axis = tick.axis,
  9465. labelPos,
  9466. reversed = axis.reversed,
  9467. xPos,
  9468. yPos;
  9469. if (label && label.textStr === str) {
  9470. tick.movedLabel = label;
  9471. moved = true;
  9472. delete tick.label;
  9473. }
  9474. else { // Find a label with the same string
  9475. objectEach(axis.ticks, function (currentTick) {
  9476. if (!moved &&
  9477. !currentTick.isNew &&
  9478. currentTick !== tick &&
  9479. currentTick.label &&
  9480. currentTick.label.textStr === str) {
  9481. tick.movedLabel = currentTick.label;
  9482. moved = true;
  9483. currentTick.labelPos = tick.movedLabel.xy;
  9484. delete currentTick.label;
  9485. }
  9486. });
  9487. }
  9488. // Create new label if the actual one is moved
  9489. if (!moved && (tick.labelPos || label)) {
  9490. labelPos = tick.labelPos || label.xy;
  9491. xPos = axis.horiz ?
  9492. (reversed ? 0 : axis.width + axis.left) : labelPos.x;
  9493. yPos = axis.horiz ?
  9494. labelPos.y : (reversed ? (axis.width + axis.left) : 0);
  9495. tick.movedLabel = tick.createLabel({ x: xPos, y: yPos }, str, labelOptions);
  9496. if (tick.movedLabel) {
  9497. tick.movedLabel.attr({ opacity: 0 });
  9498. }
  9499. }
  9500. };
  9501. /**
  9502. * Put everything in place
  9503. *
  9504. * @private
  9505. * @param {number} index
  9506. * @param {boolean} [old]
  9507. * Use old coordinates to prepare an animation into new position
  9508. * @param {number} [opacity]
  9509. * @return {voids}
  9510. */
  9511. Tick.prototype.render = function (index, old, opacity) {
  9512. var tick = this,
  9513. axis = tick.axis,
  9514. horiz = axis.horiz,
  9515. pos = tick.pos,
  9516. tickmarkOffset = pick(tick.tickmarkOffset,
  9517. axis.tickmarkOffset),
  9518. xy = tick.getPosition(horiz,
  9519. pos,
  9520. tickmarkOffset,
  9521. old),
  9522. x = xy.x,
  9523. y = xy.y,
  9524. reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
  9525. (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
  9526. opacity = pick(opacity, 1);
  9527. this.isActive = true;
  9528. // Create the grid line
  9529. this.renderGridLine(old, opacity, reverseCrisp);
  9530. // create the tick mark
  9531. this.renderMark(xy, opacity, reverseCrisp);
  9532. // the label is created on init - now move it into place
  9533. this.renderLabel(xy, old, opacity, index);
  9534. tick.isNew = false;
  9535. fireEvent(this, 'afterRender');
  9536. };
  9537. /**
  9538. * Renders the gridLine.
  9539. *
  9540. * @private
  9541. * @param {boolean} old Whether or not the tick is old
  9542. * @param {number} opacity The opacity of the grid line
  9543. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  9544. * @return {void}
  9545. */
  9546. Tick.prototype.renderGridLine = function (old, opacity, reverseCrisp) {
  9547. var tick = this, axis = tick.axis, options = axis.options, gridLine = tick.gridLine, gridLinePath, attribs = {}, pos = tick.pos, type = tick.type, tickmarkOffset = pick(tick.tickmarkOffset, axis.tickmarkOffset), renderer = axis.chart.renderer, gridPrefix = type ? type + 'Grid' : 'grid', gridLineWidth = options[gridPrefix + 'LineWidth'], gridLineColor = options[gridPrefix + 'LineColor'], dashStyle = options[gridPrefix + 'LineDashStyle'];
  9548. if (!gridLine) {
  9549. if (!axis.chart.styledMode) {
  9550. attribs.stroke = gridLineColor;
  9551. attribs['stroke-width'] = gridLineWidth;
  9552. if (dashStyle) {
  9553. attribs.dashstyle = dashStyle;
  9554. }
  9555. }
  9556. if (!type) {
  9557. attribs.zIndex = 1;
  9558. }
  9559. if (old) {
  9560. opacity = 0;
  9561. }
  9562. /**
  9563. * The rendered grid line of the tick.
  9564. * @name Highcharts.Tick#gridLine
  9565. * @type {Highcharts.SVGElement|undefined}
  9566. */
  9567. tick.gridLine = gridLine = renderer.path()
  9568. .attr(attribs)
  9569. .addClass('highcharts-' + (type ? type + '-' : '') + 'grid-line')
  9570. .add(axis.gridGroup);
  9571. }
  9572. if (gridLine) {
  9573. gridLinePath = axis.getPlotLinePath({
  9574. value: pos + tickmarkOffset,
  9575. lineWidth: gridLine.strokeWidth() * reverseCrisp,
  9576. force: 'pass',
  9577. old: old
  9578. });
  9579. // If the parameter 'old' is set, the current call will be followed
  9580. // by another call, therefore do not do any animations this time
  9581. if (gridLinePath) {
  9582. gridLine[old || tick.isNew ? 'attr' : 'animate']({
  9583. d: gridLinePath,
  9584. opacity: opacity
  9585. });
  9586. }
  9587. }
  9588. };
  9589. /**
  9590. * Renders the tick mark.
  9591. *
  9592. * @private
  9593. * @param {Highcharts.PositionObject} xy The position vector of the mark
  9594. * @param {number} opacity The opacity of the mark
  9595. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  9596. * @return {void}
  9597. */
  9598. Tick.prototype.renderMark = function (xy, opacity, reverseCrisp) {
  9599. var tick = this, axis = tick.axis, options = axis.options, renderer = axis.chart.renderer, type = tick.type, tickPrefix = type ? type + 'Tick' : 'tick', tickSize = axis.tickSize(tickPrefix), mark = tick.mark, isNewMark = !mark, x = xy.x, y = xy.y, tickWidth = pick(options[tickPrefix + 'Width'], !type && axis.isXAxis ? 1 : 0), // X axis defaults to 1
  9600. tickColor = options[tickPrefix + 'Color'];
  9601. if (tickSize) {
  9602. // negate the length
  9603. if (axis.opposite) {
  9604. tickSize[0] = -tickSize[0];
  9605. }
  9606. // First time, create it
  9607. if (isNewMark) {
  9608. /**
  9609. * The rendered mark of the tick.
  9610. * @name Highcharts.Tick#mark
  9611. * @type {Highcharts.SVGElement|undefined}
  9612. */
  9613. tick.mark = mark = renderer.path()
  9614. .addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
  9615. .add(axis.axisGroup);
  9616. if (!axis.chart.styledMode) {
  9617. mark.attr({
  9618. stroke: tickColor,
  9619. 'stroke-width': tickWidth
  9620. });
  9621. }
  9622. }
  9623. mark[isNewMark ? 'attr' : 'animate']({
  9624. d: tick.getMarkPath(x, y, tickSize[0], mark.strokeWidth() * reverseCrisp, axis.horiz, renderer),
  9625. opacity: opacity
  9626. });
  9627. }
  9628. };
  9629. /**
  9630. * Renders the tick label.
  9631. * Note: The label should already be created in init(), so it should only
  9632. * have to be moved into place.
  9633. *
  9634. * @private
  9635. * @param {Highcharts.PositionObject} xy The position vector of the label
  9636. * @param {boolean} old Whether or not the tick is old
  9637. * @param {number} opacity The opacity of the label
  9638. * @param {number} index The index of the tick
  9639. * @return {void}
  9640. */
  9641. Tick.prototype.renderLabel = function (xy, old, opacity, index) {
  9642. var tick = this,
  9643. axis = tick.axis,
  9644. horiz = axis.horiz,
  9645. options = axis.options,
  9646. label = tick.label,
  9647. labelOptions = options.labels,
  9648. step = labelOptions.step,
  9649. tickmarkOffset = pick(tick.tickmarkOffset,
  9650. axis.tickmarkOffset),
  9651. show = true,
  9652. x = xy.x,
  9653. y = xy.y;
  9654. if (label && isNumber(x)) {
  9655. label.xy = xy = tick.getLabelPosition(x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
  9656. // Apply show first and show last. If the tick is both first and
  9657. // last, it is a single centered tick, in which case we show the
  9658. // label anyway (#2100).
  9659. if ((tick.isFirst &&
  9660. !tick.isLast &&
  9661. !pick(options.showFirstLabel, 1)) ||
  9662. (tick.isLast &&
  9663. !tick.isFirst &&
  9664. !pick(options.showLastLabel, 1))) {
  9665. show = false;
  9666. // Handle label overflow and show or hide accordingly
  9667. }
  9668. else if (horiz &&
  9669. !labelOptions.step &&
  9670. !labelOptions.rotation &&
  9671. !old &&
  9672. opacity !== 0) {
  9673. tick.handleOverflow(xy);
  9674. }
  9675. // apply step
  9676. if (step && index % step) {
  9677. // show those indices dividable by step
  9678. show = false;
  9679. }
  9680. // Set the new position, and show or hide
  9681. if (show && isNumber(xy.y)) {
  9682. xy.opacity = opacity;
  9683. label[tick.isNewLabel ? 'attr' : 'animate'](xy);
  9684. tick.isNewLabel = false;
  9685. }
  9686. else {
  9687. label.attr('y', -9999); // #1338
  9688. tick.isNewLabel = true;
  9689. }
  9690. }
  9691. };
  9692. /**
  9693. * Replace labels with the moved ones to perform animation. Additionally
  9694. * destroy unused labels.
  9695. *
  9696. * @private
  9697. * @function Highcharts.Tick#replaceMovedLabel
  9698. * @return {void}
  9699. */
  9700. Tick.prototype.replaceMovedLabel = function () {
  9701. var tick = this,
  9702. label = tick.label,
  9703. axis = tick.axis,
  9704. reversed = axis.reversed,
  9705. x,
  9706. y;
  9707. // Animate and destroy
  9708. if (label && !tick.isNew) {
  9709. x = axis.horiz ? (reversed ? axis.left : axis.width + axis.left) : label.xy.x;
  9710. y = axis.horiz ?
  9711. label.xy.y :
  9712. (reversed ? axis.width + axis.top : axis.top);
  9713. label.animate({ x: x, y: y, opacity: 0 }, void 0, label.destroy);
  9714. delete tick.label;
  9715. }
  9716. axis.isDirty = true;
  9717. tick.label = tick.movedLabel;
  9718. delete tick.movedLabel;
  9719. };
  9720. return Tick;
  9721. }());
  9722. H.Tick = Tick;
  9723. return H.Tick;
  9724. });
  9725. _registerModule(_modules, 'Core/Time.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Highcharts, U) {
  9726. /* *
  9727. *
  9728. * (c) 2010-2020 Torstein Honsi
  9729. *
  9730. * License: www.highcharts.com/license
  9731. *
  9732. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9733. *
  9734. * */
  9735. /**
  9736. * Normalized interval.
  9737. *
  9738. * @interface Highcharts.TimeNormalizedObject
  9739. */ /**
  9740. * The count.
  9741. *
  9742. * @name Highcharts.TimeNormalizedObject#count
  9743. * @type {number}
  9744. */ /**
  9745. * The interval in axis values (ms).
  9746. *
  9747. * @name Highcharts.TimeNormalizedObject#unitRange
  9748. * @type {number}
  9749. */
  9750. /**
  9751. * Function of an additional date format specifier.
  9752. *
  9753. * @callback Highcharts.TimeFormatCallbackFunction
  9754. *
  9755. * @param {number} timestamp
  9756. * The time to format.
  9757. *
  9758. * @return {string}
  9759. * The formatted portion of the date.
  9760. */
  9761. /**
  9762. * Additonal time tick information.
  9763. *
  9764. * @interface Highcharts.TimeTicksInfoObject
  9765. * @extends Highcharts.TimeNormalizedObject
  9766. */ /**
  9767. * @name Highcharts.TimeTicksInfoObject#higherRanks
  9768. * @type {Array<string>}
  9769. */ /**
  9770. * @name Highcharts.TimeTicksInfoObject#totalRange
  9771. * @type {number}
  9772. */
  9773. /**
  9774. * Time ticks.
  9775. *
  9776. * @interface Highcharts.AxisTickPositionsArray
  9777. * @extends global.Array<number>
  9778. */ /**
  9779. * @name Highcharts.AxisTickPositionsArray#info
  9780. * @type {Highcharts.TimeTicksInfoObject|undefined}
  9781. */
  9782. /**
  9783. * A callback to return the time zone offset for a given datetime. It
  9784. * takes the timestamp in terms of milliseconds since January 1 1970,
  9785. * and returns the timezone offset in minutes. This provides a hook
  9786. * for drawing time based charts in specific time zones using their
  9787. * local DST crossover dates, with the help of external libraries.
  9788. *
  9789. * @callback Highcharts.TimezoneOffsetCallbackFunction
  9790. *
  9791. * @param {number} timestamp
  9792. * Timestamp in terms of milliseconds since January 1 1970.
  9793. *
  9794. * @return {number}
  9795. * Timezone offset in minutes.
  9796. */
  9797. /**
  9798. * Allows to manually load the `moment.js` library from Highcharts options
  9799. * instead of the `window`.
  9800. * In case of loading the library from a `script` tag,
  9801. * this option is not needed, it will be loaded from there by default.
  9802. *
  9803. * @type {function}
  9804. * @since 8.2.0
  9805. * @apioption time.moment
  9806. */
  9807. var defined = U.defined,
  9808. error = U.error,
  9809. extend = U.extend,
  9810. isObject = U.isObject,
  9811. merge = U.merge,
  9812. objectEach = U.objectEach,
  9813. pad = U.pad,
  9814. pick = U.pick,
  9815. splat = U.splat,
  9816. timeUnits = U.timeUnits;
  9817. var H = Highcharts,
  9818. win = H.win;
  9819. /* eslint-disable no-invalid-this, valid-jsdoc */
  9820. /**
  9821. * The Time class. Time settings are applied in general for each page using
  9822. * `Highcharts.setOptions`, or individually for each Chart item through the
  9823. * [time](https://api.highcharts.com/highcharts/time) options set.
  9824. *
  9825. * The Time object is available from {@link Highcharts.Chart#time},
  9826. * which refers to `Highcharts.time` if no individual time settings are
  9827. * applied.
  9828. *
  9829. * @example
  9830. * // Apply time settings globally
  9831. * Highcharts.setOptions({
  9832. * time: {
  9833. * timezone: 'Europe/London'
  9834. * }
  9835. * });
  9836. *
  9837. * // Apply time settings by instance
  9838. * var chart = Highcharts.chart('container', {
  9839. * time: {
  9840. * timezone: 'America/New_York'
  9841. * },
  9842. * series: [{
  9843. * data: [1, 4, 3, 5]
  9844. * }]
  9845. * });
  9846. *
  9847. * // Use the Time object
  9848. * console.log(
  9849. * 'Current time in New York',
  9850. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  9851. * );
  9852. *
  9853. * @since 6.0.5
  9854. *
  9855. * @class
  9856. * @name Highcharts.Time
  9857. *
  9858. * @param {Highcharts.TimeOptions} options
  9859. * Time options as defined in [chart.options.time](/highcharts/time).
  9860. */
  9861. var Time = /** @class */ (function () {
  9862. /* *
  9863. *
  9864. * Constructors
  9865. *
  9866. * */
  9867. function Time(options) {
  9868. /* *
  9869. *
  9870. * Properties
  9871. *
  9872. * */
  9873. this.options = {};
  9874. this.useUTC = false;
  9875. this.variableTimezone = false;
  9876. this.Date = win.Date;
  9877. /**
  9878. * Get the time zone offset based on the current timezone information as
  9879. * set in the global options.
  9880. *
  9881. * @function Highcharts.Time#getTimezoneOffset
  9882. *
  9883. * @param {number} timestamp
  9884. * The JavaScript timestamp to inspect.
  9885. *
  9886. * @return {number}
  9887. * The timezone offset in minutes compared to UTC.
  9888. */
  9889. this.getTimezoneOffset = this.timezoneOffsetFunction();
  9890. this.update(options);
  9891. }
  9892. /* *
  9893. *
  9894. * Functions
  9895. *
  9896. * */
  9897. /**
  9898. * Time units used in `Time.get` and `Time.set`
  9899. *
  9900. * @typedef {"Date"|"Day"|"FullYear"|"Hours"|"Milliseconds"|"Minutes"|"Month"|"Seconds"} Highcharts.TimeUnitValue
  9901. */
  9902. /**
  9903. * Get the value of a date object in given units, and subject to the Time
  9904. * object's current timezone settings. This function corresponds directly to
  9905. * JavaScripts `Date.getXXX / Date.getUTCXXX`, so instead of calling
  9906. * `date.getHours()` or `date.getUTCHours()` we will call
  9907. * `time.get('Hours')`.
  9908. *
  9909. * @function Highcharts.Time#get
  9910. *
  9911. * @param {Highcharts.TimeUnitValue} unit
  9912. * @param {Date} date
  9913. *
  9914. * @return {number}
  9915. * The given time unit
  9916. */
  9917. Time.prototype.get = function (unit, date) {
  9918. if (this.variableTimezone || this.timezoneOffset) {
  9919. var realMs = date.getTime();
  9920. var ms = realMs - this.getTimezoneOffset(date);
  9921. date.setTime(ms); // Temporary adjust to timezone
  9922. var ret = date['getUTC' + unit]();
  9923. date.setTime(realMs); // Reset
  9924. return ret;
  9925. }
  9926. // UTC time with no timezone handling
  9927. if (this.useUTC) {
  9928. return date['getUTC' + unit]();
  9929. }
  9930. // Else, local time
  9931. return date['get' + unit]();
  9932. };
  9933. /**
  9934. * Set the value of a date object in given units, and subject to the Time
  9935. * object's current timezone settings. This function corresponds directly to
  9936. * JavaScripts `Date.setXXX / Date.setUTCXXX`, so instead of calling
  9937. * `date.setHours(0)` or `date.setUTCHours(0)` we will call
  9938. * `time.set('Hours', 0)`.
  9939. *
  9940. * @function Highcharts.Time#set
  9941. *
  9942. * @param {Highcharts.TimeUnitValue} unit
  9943. * @param {Date} date
  9944. * @param {number} value
  9945. *
  9946. * @return {number}
  9947. * The epoch milliseconds of the updated date
  9948. */
  9949. Time.prototype.set = function (unit, date, value) {
  9950. // UTC time with timezone handling
  9951. if (this.variableTimezone || this.timezoneOffset) {
  9952. // For lower order time units, just set it directly using UTC
  9953. // time
  9954. if (unit === 'Milliseconds' ||
  9955. unit === 'Seconds' ||
  9956. unit === 'Minutes') {
  9957. return date['setUTC' + unit](value);
  9958. }
  9959. // Higher order time units need to take the time zone into
  9960. // account
  9961. // Adjust by timezone
  9962. var offset = this.getTimezoneOffset(date);
  9963. var ms = date.getTime() - offset;
  9964. date.setTime(ms);
  9965. date['setUTC' + unit](value);
  9966. var newOffset = this.getTimezoneOffset(date);
  9967. ms = date.getTime() + newOffset;
  9968. return date.setTime(ms);
  9969. }
  9970. // UTC time with no timezone handling
  9971. if (this.useUTC) {
  9972. return date['setUTC' + unit](value);
  9973. }
  9974. // Else, local time
  9975. return date['set' + unit](value);
  9976. };
  9977. /**
  9978. * Update the Time object with current options. It is called internally on
  9979. * initializing Highcharts, after running `Highcharts.setOptions` and on
  9980. * `Chart.update`.
  9981. *
  9982. * @private
  9983. * @function Highcharts.Time#update
  9984. *
  9985. * @param {Highcharts.TimeOptions} options
  9986. *
  9987. * @return {void}
  9988. */
  9989. Time.prototype.update = function (options) {
  9990. var useUTC = pick(options && options.useUTC,
  9991. true),
  9992. time = this;
  9993. this.options = options = merge(true, this.options || {}, options);
  9994. // Allow using a different Date class
  9995. this.Date = options.Date || win.Date || Date;
  9996. this.useUTC = useUTC;
  9997. this.timezoneOffset = (useUTC && options.timezoneOffset);
  9998. this.getTimezoneOffset = this.timezoneOffsetFunction();
  9999. /*
  10000. * The time object has options allowing for variable time zones, meaning
  10001. * the axis ticks or series data needs to consider this.
  10002. */
  10003. this.variableTimezone = !!(!useUTC ||
  10004. options.getTimezoneOffset ||
  10005. options.timezone);
  10006. };
  10007. /**
  10008. * Make a time and returns milliseconds. Interprets the inputs as UTC time,
  10009. * local time or a specific timezone time depending on the current time
  10010. * settings.
  10011. *
  10012. * @function Highcharts.Time#makeTime
  10013. *
  10014. * @param {number} year
  10015. * The year
  10016. *
  10017. * @param {number} month
  10018. * The month. Zero-based, so January is 0.
  10019. *
  10020. * @param {number} [date=1]
  10021. * The day of the month
  10022. *
  10023. * @param {number} [hours=0]
  10024. * The hour of the day, 0-23.
  10025. *
  10026. * @param {number} [minutes=0]
  10027. * The minutes
  10028. *
  10029. * @param {number} [seconds=0]
  10030. * The seconds
  10031. *
  10032. * @return {number}
  10033. * The time in milliseconds since January 1st 1970.
  10034. */
  10035. Time.prototype.makeTime = function (year, month, date, hours, minutes, seconds) {
  10036. var d,
  10037. offset,
  10038. newOffset;
  10039. if (this.useUTC) {
  10040. d = this.Date.UTC.apply(0, arguments);
  10041. offset = this.getTimezoneOffset(d);
  10042. d += offset;
  10043. newOffset = this.getTimezoneOffset(d);
  10044. if (offset !== newOffset) {
  10045. d += newOffset - offset;
  10046. // A special case for transitioning from summer time to winter time.
  10047. // When the clock is set back, the same time is repeated twice, i.e.
  10048. // 02:30 am is repeated since the clock is set back from 3 am to
  10049. // 2 am. We need to make the same time as local Date does.
  10050. }
  10051. else if (offset - 36e5 === this.getTimezoneOffset(d - 36e5) &&
  10052. !H.isSafari) {
  10053. d -= 36e5;
  10054. }
  10055. }
  10056. else {
  10057. d = new this.Date(year, month, pick(date, 1), pick(hours, 0), pick(minutes, 0), pick(seconds, 0)).getTime();
  10058. }
  10059. return d;
  10060. };
  10061. /**
  10062. * Sets the getTimezoneOffset function. If the `timezone` option is set, a
  10063. * default getTimezoneOffset function with that timezone is returned. If
  10064. * a `getTimezoneOffset` option is defined, it is returned. If neither are
  10065. * specified, the function using the `timezoneOffset` option or 0 offset is
  10066. * returned.
  10067. *
  10068. * @private
  10069. * @function Highcharts.Time#timezoneOffsetFunction
  10070. *
  10071. * @return {Function}
  10072. * A getTimezoneOffset function
  10073. */
  10074. Time.prototype.timezoneOffsetFunction = function () {
  10075. var time = this,
  10076. options = this.options,
  10077. moment = options.moment || win.moment;
  10078. if (!this.useUTC) {
  10079. return function (timestamp) {
  10080. return new Date(timestamp.toString()).getTimezoneOffset() * 60000;
  10081. };
  10082. }
  10083. if (options.timezone) {
  10084. if (!moment) {
  10085. // getTimezoneOffset-function stays undefined because it depends
  10086. // on Moment.js
  10087. error(25);
  10088. }
  10089. else {
  10090. return function (timestamp) {
  10091. return -moment.tz(timestamp, options.timezone).utcOffset() * 60000;
  10092. };
  10093. }
  10094. }
  10095. // If not timezone is set, look for the getTimezoneOffset callback
  10096. if (this.useUTC && options.getTimezoneOffset) {
  10097. return function (timestamp) {
  10098. return options.getTimezoneOffset(timestamp.valueOf()) * 60000;
  10099. };
  10100. }
  10101. // Last, use the `timezoneOffset` option if set
  10102. return function () {
  10103. return (time.timezoneOffset || 0) * 60000;
  10104. };
  10105. };
  10106. /**
  10107. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970)
  10108. * into a human readable date string. The available format keys are listed
  10109. * below. Additional formats can be given in the
  10110. * {@link Highcharts.dateFormats} hook.
  10111. *
  10112. * Supported format keys:
  10113. * - `%a`: Short weekday, like 'Mon'
  10114. * - `%A`: Long weekday, like 'Monday'
  10115. * - `%d`: Two digit day of the month, 01 to 31
  10116. * - `%e`: Day of the month, 1 through 31
  10117. * - `%w`: Day of the week, 0 through 6
  10118. * - `%b`: Short month, like 'Jan'
  10119. * - `%B`: Long month, like 'January'
  10120. * - `%m`: Two digit month number, 01 through 12
  10121. * - `%y`: Two digits year, like 09 for 2009
  10122. * - `%Y`: Four digits year, like 2009
  10123. * - `%H`: Two digits hours in 24h format, 00 through 23
  10124. * - `%k`: Hours in 24h format, 0 through 23
  10125. * - `%I`: Two digits hours in 12h format, 00 through 11
  10126. * - `%l`: Hours in 12h format, 1 through 12
  10127. * - `%M`: Two digits minutes, 00 through 59
  10128. * - `%p`: Upper case AM or PM
  10129. * - `%P`: Lower case AM or PM
  10130. * - `%S`: Two digits seconds, 00 through 59
  10131. * - `%L`: Milliseconds (naming from Ruby)
  10132. *
  10133. * @example
  10134. * const time = new Highcharts.Time();
  10135. * const s = time.dateFormat('%Y-%m-%d %H:%M:%S', Date.UTC(2020, 0, 1));
  10136. * console.log(s); // => 2020-01-01 00:00:00
  10137. *
  10138. * @function Highcharts.Time#dateFormat
  10139. *
  10140. * @param {string} format
  10141. * The desired format where various time representations are
  10142. * prefixed with %.
  10143. *
  10144. * @param {number} timestamp
  10145. * The JavaScript timestamp.
  10146. *
  10147. * @param {boolean} [capitalize=false]
  10148. * Upper case first letter in the return.
  10149. *
  10150. * @return {string}
  10151. * The formatted date.
  10152. */
  10153. Time.prototype.dateFormat = function (format, timestamp, capitalize) {
  10154. var _a;
  10155. if (!defined(timestamp) || isNaN(timestamp)) {
  10156. return ((_a = H.defaultOptions.lang) === null || _a === void 0 ? void 0 : _a.invalidDate) || '';
  10157. }
  10158. format = pick(format, '%Y-%m-%d %H:%M:%S');
  10159. var time = this, date = new this.Date(timestamp),
  10160. // get the basic time values
  10161. 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 === null || lang === void 0 ? void 0 : lang.weekdays, shortWeekdays = lang === null || lang === void 0 ? void 0 : lang.shortWeekdays,
  10162. // List all format keys. Custom formats can be added from the
  10163. // outside.
  10164. replacements = extend({
  10165. // Day
  10166. // Short weekday, like 'Mon'
  10167. a: shortWeekdays ?
  10168. shortWeekdays[day] :
  10169. langWeekdays[day].substr(0, 3),
  10170. // Long weekday, like 'Monday'
  10171. A: langWeekdays[day],
  10172. // Two digit day of the month, 01 to 31
  10173. d: pad(dayOfMonth),
  10174. // Day of the month, 1 through 31
  10175. e: pad(dayOfMonth, 2, ' '),
  10176. // Day of the week, 0 through 6
  10177. w: day,
  10178. // Week (none implemented)
  10179. // 'W': weekNumber(),
  10180. // Month
  10181. // Short month, like 'Jan'
  10182. b: lang.shortMonths[month],
  10183. // Long month, like 'January'
  10184. B: lang.months[month],
  10185. // Two digit month number, 01 through 12
  10186. m: pad(month + 1),
  10187. // Month number, 1 through 12 (#8150)
  10188. o: month + 1,
  10189. // Year
  10190. // Two digits year, like 09 for 2009
  10191. y: fullYear.toString().substr(2, 2),
  10192. // Four digits year, like 2009
  10193. Y: fullYear,
  10194. // Time
  10195. // Two digits hours in 24h format, 00 through 23
  10196. H: pad(hours),
  10197. // Hours in 24h format, 0 through 23
  10198. k: hours,
  10199. // Two digits hours in 12h format, 00 through 11
  10200. I: pad((hours % 12) || 12),
  10201. // Hours in 12h format, 1 through 12
  10202. l: (hours % 12) || 12,
  10203. // Two digits minutes, 00 through 59
  10204. M: pad(this.get('Minutes', date)),
  10205. // Upper case AM or PM
  10206. p: hours < 12 ? 'AM' : 'PM',
  10207. // Lower case AM or PM
  10208. P: hours < 12 ? 'am' : 'pm',
  10209. // Two digits seconds, 00 through 59
  10210. S: pad(date.getSeconds()),
  10211. // Milliseconds (naming from Ruby)
  10212. L: pad(Math.floor(timestamp % 1000), 3)
  10213. }, H.dateFormats);
  10214. // Do the replaces
  10215. objectEach(replacements, function (val, key) {
  10216. // Regex would do it in one line, but this is faster
  10217. while (format.indexOf('%' + key) !== -1) {
  10218. format = format.replace('%' + key, typeof val === 'function' ? val.call(time, timestamp) : val);
  10219. }
  10220. });
  10221. // Optionally capitalize the string and return
  10222. return capitalize ?
  10223. (format.substr(0, 1).toUpperCase() +
  10224. format.substr(1)) :
  10225. format;
  10226. };
  10227. /**
  10228. * Resolve legacy formats of dateTimeLabelFormats (strings and arrays) into
  10229. * an object.
  10230. * @private
  10231. * @param {string|Array<T>|Highcharts.Dictionary<T>} f - General format description
  10232. * @return {Highcharts.Dictionary<T>} - The object definition
  10233. */
  10234. Time.prototype.resolveDTLFormat = function (f) {
  10235. if (!isObject(f, true)) { // check for string or array
  10236. f = splat(f);
  10237. return {
  10238. main: f[0],
  10239. from: f[1],
  10240. to: f[2]
  10241. };
  10242. }
  10243. return f;
  10244. };
  10245. /**
  10246. * Return an array with time positions distributed on round time values
  10247. * right and right after min and max. Used in datetime axes as well as for
  10248. * grouping data on a datetime axis.
  10249. *
  10250. * @function Highcharts.Time#getTimeTicks
  10251. *
  10252. * @param {Highcharts.TimeNormalizedObject} normalizedInterval
  10253. * The interval in axis values (ms) and the count
  10254. *
  10255. * @param {number} [min]
  10256. * The minimum in axis values
  10257. *
  10258. * @param {number} [max]
  10259. * The maximum in axis values
  10260. *
  10261. * @param {number} [startOfWeek=1]
  10262. *
  10263. * @return {Highcharts.AxisTickPositionsArray}
  10264. */
  10265. Time.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek) {
  10266. var time = this,
  10267. Date = time.Date,
  10268. tickPositions = [],
  10269. i,
  10270. higherRanks = {},
  10271. minYear, // used in months and years as a basis for Date.UTC()
  10272. // When crossing DST, use the max. Resolves #6278.
  10273. minDate = new Date(min),
  10274. interval = normalizedInterval.unitRange,
  10275. count = normalizedInterval.count || 1,
  10276. variableDayLength,
  10277. minDay;
  10278. startOfWeek = pick(startOfWeek, 1);
  10279. if (defined(min)) { // #1300
  10280. time.set('Milliseconds', minDate, interval >= timeUnits.second ?
  10281. 0 : // #3935
  10282. count * Math.floor(time.get('Milliseconds', minDate) / count)); // #3652, #3654
  10283. if (interval >= timeUnits.second) { // second
  10284. time.set('Seconds', minDate, interval >= timeUnits.minute ?
  10285. 0 : // #3935
  10286. count * Math.floor(time.get('Seconds', minDate) / count));
  10287. }
  10288. if (interval >= timeUnits.minute) { // minute
  10289. time.set('Minutes', minDate, interval >= timeUnits.hour ?
  10290. 0 :
  10291. count * Math.floor(time.get('Minutes', minDate) / count));
  10292. }
  10293. if (interval >= timeUnits.hour) { // hour
  10294. time.set('Hours', minDate, interval >= timeUnits.day ?
  10295. 0 :
  10296. count * Math.floor(time.get('Hours', minDate) / count));
  10297. }
  10298. if (interval >= timeUnits.day) { // day
  10299. time.set('Date', minDate, interval >= timeUnits.month ?
  10300. 1 :
  10301. Math.max(1, count * Math.floor(time.get('Date', minDate) / count)));
  10302. }
  10303. if (interval >= timeUnits.month) { // month
  10304. time.set('Month', minDate, interval >= timeUnits.year ? 0 :
  10305. count * Math.floor(time.get('Month', minDate) / count));
  10306. minYear = time.get('FullYear', minDate);
  10307. }
  10308. if (interval >= timeUnits.year) { // year
  10309. minYear -= minYear % count;
  10310. time.set('FullYear', minDate, minYear);
  10311. }
  10312. // week is a special case that runs outside the hierarchy
  10313. if (interval === timeUnits.week) {
  10314. // get start of current week, independent of count
  10315. minDay = time.get('Day', minDate);
  10316. time.set('Date', minDate, (time.get('Date', minDate) -
  10317. minDay + startOfWeek +
  10318. // We don't want to skip days that are before
  10319. // startOfWeek (#7051)
  10320. (minDay < startOfWeek ? -7 : 0)));
  10321. }
  10322. // Get basics for variable time spans
  10323. minYear = time.get('FullYear', minDate);
  10324. var minMonth = time.get('Month', minDate), minDateDate = time.get('Date', minDate), minHours = time.get('Hours', minDate);
  10325. // Redefine min to the floored/rounded minimum time (#7432)
  10326. min = minDate.getTime();
  10327. // Handle local timezone offset
  10328. if (time.variableTimezone) {
  10329. // Detect whether we need to take the DST crossover into
  10330. // consideration. If we're crossing over DST, the day length may
  10331. // be 23h or 25h and we need to compute the exact clock time for
  10332. // each tick instead of just adding hours. This comes at a cost,
  10333. // so first we find out if it is needed (#4951).
  10334. variableDayLength = (
  10335. // Long range, assume we're crossing over.
  10336. max - min > 4 * timeUnits.month ||
  10337. // Short range, check if min and max are in different time
  10338. // zones.
  10339. time.getTimezoneOffset(min) !==
  10340. time.getTimezoneOffset(max));
  10341. }
  10342. // Iterate and add tick positions at appropriate values
  10343. var t = minDate.getTime();
  10344. i = 1;
  10345. while (t < max) {
  10346. tickPositions.push(t);
  10347. // if the interval is years, use Date.UTC to increase years
  10348. if (interval === timeUnits.year) {
  10349. t = time.makeTime(minYear + i * count, 0);
  10350. // if the interval is months, use Date.UTC to increase months
  10351. }
  10352. else if (interval === timeUnits.month) {
  10353. t = time.makeTime(minYear, minMonth + i * count);
  10354. // if we're using global time, the interval is not fixed as it
  10355. // jumps one hour at the DST crossover
  10356. }
  10357. else if (variableDayLength &&
  10358. (interval === timeUnits.day || interval === timeUnits.week)) {
  10359. t = time.makeTime(minYear, minMonth, minDateDate +
  10360. i * count * (interval === timeUnits.day ? 1 : 7));
  10361. }
  10362. else if (variableDayLength &&
  10363. interval === timeUnits.hour &&
  10364. count > 1) {
  10365. // make sure higher ranks are preserved across DST (#6797,
  10366. // #7621)
  10367. t = time.makeTime(minYear, minMonth, minDateDate, minHours + i * count);
  10368. // else, the interval is fixed and we use simple addition
  10369. }
  10370. else {
  10371. t += interval * count;
  10372. }
  10373. i++;
  10374. }
  10375. // push the last time
  10376. tickPositions.push(t);
  10377. // Handle higher ranks. Mark new days if the time is on midnight
  10378. // (#950, #1649, #1760, #3349). Use a reasonable dropout threshold
  10379. // to prevent looping over dense data grouping (#6156).
  10380. if (interval <= timeUnits.hour && tickPositions.length < 10000) {
  10381. tickPositions.forEach(function (t) {
  10382. if (
  10383. // Speed optimization, no need to run dateFormat unless
  10384. // we're on a full or half hour
  10385. t % 1800000 === 0 &&
  10386. // Check for local or global midnight
  10387. time.dateFormat('%H%M%S%L', t) === '000000000') {
  10388. higherRanks[t] = 'day';
  10389. }
  10390. });
  10391. }
  10392. }
  10393. // record information on the chosen unit - for dynamic label formatter
  10394. tickPositions.info = extend(normalizedInterval, {
  10395. higherRanks: higherRanks,
  10396. totalRange: interval * count
  10397. });
  10398. return tickPositions;
  10399. };
  10400. return Time;
  10401. }());
  10402. H.Time = Time;
  10403. return H.Time;
  10404. });
  10405. _registerModule(_modules, 'Core/Options.js', [_modules['Core/Globals.js'], _modules['Core/Time.js'], _modules['Core/Color.js'], _modules['Core/Utilities.js']], function (H, Time, Color, U) {
  10406. /* *
  10407. *
  10408. * (c) 2010-2020 Torstein Honsi
  10409. *
  10410. * License: www.highcharts.com/license
  10411. *
  10412. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10413. *
  10414. * */
  10415. /**
  10416. * @typedef {"plotBox"|"spacingBox"} Highcharts.ButtonRelativeToValue
  10417. */
  10418. /**
  10419. * Gets fired when a series is added to the chart after load time, using the
  10420. * `addSeries` method. Returning `false` prevents the series from being added.
  10421. *
  10422. * @callback Highcharts.ChartAddSeriesCallbackFunction
  10423. *
  10424. * @param {Highcharts.Chart} this
  10425. * The chart on which the event occured.
  10426. *
  10427. * @param {Highcharts.ChartAddSeriesEventObject} event
  10428. * The event that occured.
  10429. */
  10430. /**
  10431. * Contains common event information. Through the `options` property you can
  10432. * access the series options that were passed to the `addSeries` method.
  10433. *
  10434. * @interface Highcharts.ChartAddSeriesEventObject
  10435. */ /**
  10436. * The series options that were passed to the `addSeries` method.
  10437. * @name Highcharts.ChartAddSeriesEventObject#options
  10438. * @type {Highcharts.SeriesOptionsType}
  10439. */ /**
  10440. * Prevents the default behaviour of the event.
  10441. * @name Highcharts.ChartAddSeriesEventObject#preventDefault
  10442. * @type {Function}
  10443. */ /**
  10444. * The event target.
  10445. * @name Highcharts.ChartAddSeriesEventObject#target
  10446. * @type {Highcharts.Chart}
  10447. */ /**
  10448. * The event type.
  10449. * @name Highcharts.ChartAddSeriesEventObject#type
  10450. * @type {"addSeries"}
  10451. */
  10452. /**
  10453. * Gets fired when clicking on the plot background.
  10454. *
  10455. * @callback Highcharts.ChartClickCallbackFunction
  10456. *
  10457. * @param {Highcharts.Chart} this
  10458. * The chart on which the event occured.
  10459. *
  10460. * @param {Highcharts.PointerEventObject} event
  10461. * The event that occured.
  10462. */
  10463. /**
  10464. * Contains an axes of the clicked spot.
  10465. *
  10466. * @interface Highcharts.ChartClickEventAxisObject
  10467. */ /**
  10468. * Axis at the clicked spot.
  10469. * @name Highcharts.ChartClickEventAxisObject#axis
  10470. * @type {Highcharts.Axis}
  10471. */ /**
  10472. * Axis value at the clicked spot.
  10473. * @name Highcharts.ChartClickEventAxisObject#value
  10474. * @type {number}
  10475. */
  10476. /**
  10477. * Contains information about the clicked spot on the chart. Remember the unit
  10478. * of a datetime axis is milliseconds since 1970-01-01 00:00:00.
  10479. *
  10480. * @interface Highcharts.ChartClickEventObject
  10481. * @extends Highcharts.PointerEventObject
  10482. */ /**
  10483. * Information about the x-axis on the clicked spot.
  10484. * @name Highcharts.ChartClickEventObject#xAxis
  10485. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  10486. */ /**
  10487. * Information about the y-axis on the clicked spot.
  10488. * @name Highcharts.ChartClickEventObject#yAxis
  10489. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  10490. */ /**
  10491. * Information about the z-axis on the clicked spot.
  10492. * @name Highcharts.ChartClickEventObject#zAxis
  10493. * @type {Array<Highcharts.ChartClickEventAxisObject>|undefined}
  10494. */
  10495. /**
  10496. * Gets fired when the chart is finished loading.
  10497. *
  10498. * @callback Highcharts.ChartLoadCallbackFunction
  10499. *
  10500. * @param {Highcharts.Chart} this
  10501. * The chart on which the event occured.
  10502. *
  10503. * @param {global.Event} event
  10504. * The event that occured.
  10505. */
  10506. /**
  10507. * Fires when the chart is redrawn, either after a call to `chart.redraw()` or
  10508. * after an axis, series or point is modified with the `redraw` option set to
  10509. * `true`.
  10510. *
  10511. * @callback Highcharts.ChartRedrawCallbackFunction
  10512. *
  10513. * @param {Highcharts.Chart} this
  10514. * The chart on which the event occured.
  10515. *
  10516. * @param {global.Event} event
  10517. * The event that occured.
  10518. */
  10519. /**
  10520. * Gets fired after initial load of the chart (directly after the `load` event),
  10521. * and after each redraw (directly after the `redraw` event).
  10522. *
  10523. * @callback Highcharts.ChartRenderCallbackFunction
  10524. *
  10525. * @param {Highcharts.Chart} this
  10526. * The chart on which the event occured.
  10527. *
  10528. * @param {global.Event} event
  10529. * The event that occured.
  10530. */
  10531. /**
  10532. * Gets fired when an area of the chart has been selected. The default action
  10533. * for the selection event is to zoom the chart to the selected area. It can be
  10534. * prevented by calling `event.preventDefault()` or return false.
  10535. *
  10536. * @callback Highcharts.ChartSelectionCallbackFunction
  10537. *
  10538. * @param {Highcharts.Chart} this
  10539. * The chart on which the event occured.
  10540. *
  10541. * @param {global.ChartSelectionContextObject} event
  10542. * Event informations
  10543. *
  10544. * @return {boolean|undefined}
  10545. * Return false to prevent the default action, usually zoom.
  10546. */
  10547. /**
  10548. * The primary axes are `xAxis[0]` and `yAxis[0]`. Remember the unit of a
  10549. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  10550. *
  10551. * @interface Highcharts.ChartSelectionContextObject
  10552. * @extends global.Event
  10553. */ /**
  10554. * Arrays containing the axes of each dimension and each axis' min and max
  10555. * values.
  10556. * @name Highcharts.ChartSelectionContextObject#xAxis
  10557. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  10558. */ /**
  10559. * Arrays containing the axes of each dimension and each axis' min and max
  10560. * values.
  10561. * @name Highcharts.ChartSelectionContextObject#yAxis
  10562. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  10563. */
  10564. /**
  10565. * Axis context of the selection.
  10566. *
  10567. * @interface Highcharts.ChartSelectionAxisContextObject
  10568. */ /**
  10569. * The selected Axis.
  10570. * @name Highcharts.ChartSelectionAxisContextObject#axis
  10571. * @type {Highcharts.Axis}
  10572. */ /**
  10573. * The maximum axis value, either automatic or set manually.
  10574. * @name Highcharts.ChartSelectionAxisContextObject#max
  10575. * @type {number}
  10576. */ /**
  10577. * The minimum axis value, either automatic or set manually.
  10578. * @name Highcharts.ChartSelectionAxisContextObject#min
  10579. * @type {number}
  10580. */
  10581. var color = Color.parse;
  10582. var merge = U.merge;
  10583. var isTouchDevice = H.isTouchDevice,
  10584. svg = H.svg;
  10585. /* ************************************************************************** *
  10586. * Handle the options *
  10587. * ************************************************************************** */
  10588. /**
  10589. * Global default settings.
  10590. *
  10591. * @name Highcharts.defaultOptions
  10592. * @type {Highcharts.Options}
  10593. */ /**
  10594. * @optionparent
  10595. */
  10596. H.defaultOptions = {
  10597. /**
  10598. * An array containing the default colors for the chart's series. When
  10599. * all colors are used, new colors are pulled from the start again.
  10600. *
  10601. * Default colors can also be set on a series or series.type basis,
  10602. * see [column.colors](#plotOptions.column.colors),
  10603. * [pie.colors](#plotOptions.pie.colors).
  10604. *
  10605. * In styled mode, the colors option doesn't exist. Instead, colors
  10606. * are defined in CSS and applied either through series or point class
  10607. * names, or through the [chart.colorCount](#chart.colorCount) option.
  10608. *
  10609. *
  10610. * ### Legacy
  10611. *
  10612. * In Highcharts 3.x, the default colors were:
  10613. * ```js
  10614. * colors: ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce',
  10615. * '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']
  10616. * ```
  10617. *
  10618. * In Highcharts 2.x, the default colors were:
  10619. * ```js
  10620. * colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE',
  10621. * '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
  10622. * ```
  10623. *
  10624. * @sample {highcharts} highcharts/chart/colors/
  10625. * Assign a global color theme
  10626. *
  10627. * @type {Array<Highcharts.ColorString>}
  10628. * @default ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9",
  10629. * "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
  10630. */
  10631. colors: '#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1'.split(' '),
  10632. /**
  10633. * Styled mode only. Configuration object for adding SVG definitions for
  10634. * reusable elements. See [gradients, shadows and
  10635. * patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns)
  10636. * for more information and code examples.
  10637. *
  10638. * @type {*}
  10639. * @since 5.0.0
  10640. * @apioption defs
  10641. */
  10642. /**
  10643. * @ignore-option
  10644. */
  10645. symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
  10646. /**
  10647. * The language object is global and it can't be set on each chart
  10648. * initialization. Instead, use `Highcharts.setOptions` to set it before any
  10649. * chart is initialized.
  10650. *
  10651. * ```js
  10652. * Highcharts.setOptions({
  10653. * lang: {
  10654. * months: [
  10655. * 'Janvier', 'Février', 'Mars', 'Avril',
  10656. * 'Mai', 'Juin', 'Juillet', 'Août',
  10657. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  10658. * ],
  10659. * weekdays: [
  10660. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  10661. * 'Jeudi', 'Vendredi', 'Samedi'
  10662. * ]
  10663. * }
  10664. * });
  10665. * ```
  10666. */
  10667. lang: {
  10668. /**
  10669. * The loading text that appears when the chart is set into the loading
  10670. * state following a call to `chart.showLoading`.
  10671. */
  10672. loading: 'Loading...',
  10673. /**
  10674. * An array containing the months names. Corresponds to the `%B` format
  10675. * in `Highcharts.dateFormat()`.
  10676. *
  10677. * @type {Array<string>}
  10678. * @default ["January", "February", "March", "April", "May", "June",
  10679. * "July", "August", "September", "October", "November",
  10680. * "December"]
  10681. */
  10682. months: [
  10683. 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  10684. 'August', 'September', 'October', 'November', 'December'
  10685. ],
  10686. /**
  10687. * An array containing the months names in abbreviated form. Corresponds
  10688. * to the `%b` format in `Highcharts.dateFormat()`.
  10689. *
  10690. * @type {Array<string>}
  10691. * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  10692. * "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  10693. */
  10694. shortMonths: [
  10695. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
  10696. 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
  10697. ],
  10698. /**
  10699. * An array containing the weekday names.
  10700. *
  10701. * @type {Array<string>}
  10702. * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
  10703. * "Friday", "Saturday"]
  10704. */
  10705. weekdays: [
  10706. 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  10707. 'Thursday', 'Friday', 'Saturday'
  10708. ],
  10709. /**
  10710. * Short week days, starting Sunday. If not specified, Highcharts uses
  10711. * the first three letters of the `lang.weekdays` option.
  10712. *
  10713. * @sample highcharts/lang/shortweekdays/
  10714. * Finnish two-letter abbreviations
  10715. *
  10716. * @type {Array<string>}
  10717. * @since 4.2.4
  10718. * @apioption lang.shortWeekdays
  10719. */
  10720. /**
  10721. * What to show in a date field for invalid dates. Defaults to an empty
  10722. * string.
  10723. *
  10724. * @type {string}
  10725. * @since 4.1.8
  10726. * @product highcharts highstock
  10727. * @apioption lang.invalidDate
  10728. */
  10729. /**
  10730. * The title appearing on hovering the zoom in button. The text itself
  10731. * defaults to "+" and can be changed in the button options.
  10732. *
  10733. * @type {string}
  10734. * @default Zoom in
  10735. * @product highmaps
  10736. * @apioption lang.zoomIn
  10737. */
  10738. /**
  10739. * The title appearing on hovering the zoom out button. The text itself
  10740. * defaults to "-" and can be changed in the button options.
  10741. *
  10742. * @type {string}
  10743. * @default Zoom out
  10744. * @product highmaps
  10745. * @apioption lang.zoomOut
  10746. */
  10747. /**
  10748. * The default decimal point used in the `Highcharts.numberFormat`
  10749. * method unless otherwise specified in the function arguments.
  10750. *
  10751. * @since 1.2.2
  10752. */
  10753. decimalPoint: '.',
  10754. /**
  10755. * [Metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) used
  10756. * to shorten high numbers in axis labels. Replacing any of the
  10757. * positions with `null` causes the full number to be written. Setting
  10758. * `numericSymbols` to `null` disables shortening altogether.
  10759. *
  10760. * @sample {highcharts} highcharts/lang/numericsymbols/
  10761. * Replacing the symbols with text
  10762. * @sample {highstock} highcharts/lang/numericsymbols/
  10763. * Replacing the symbols with text
  10764. *
  10765. * @type {Array<string>}
  10766. * @default ["k", "M", "G", "T", "P", "E"]
  10767. * @since 2.3.0
  10768. */
  10769. numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'],
  10770. /**
  10771. * The magnitude of [numericSymbols](#lang.numericSymbol) replacements.
  10772. * Use 10000 for Japanese, Korean and various Chinese locales, which
  10773. * use symbols for 10^4, 10^8 and 10^12.
  10774. *
  10775. * @sample highcharts/lang/numericsymbolmagnitude/
  10776. * 10000 magnitude for Japanese
  10777. *
  10778. * @type {number}
  10779. * @default 1000
  10780. * @since 5.0.3
  10781. * @apioption lang.numericSymbolMagnitude
  10782. */
  10783. /**
  10784. * The text for the label appearing when a chart is zoomed.
  10785. *
  10786. * @since 1.2.4
  10787. */
  10788. resetZoom: 'Reset zoom',
  10789. /**
  10790. * The tooltip title for the label appearing when a chart is zoomed.
  10791. *
  10792. * @since 1.2.4
  10793. */
  10794. resetZoomTitle: 'Reset zoom level 1:1',
  10795. /**
  10796. * The default thousands separator used in the `Highcharts.numberFormat`
  10797. * method unless otherwise specified in the function arguments. Defaults
  10798. * to a single space character, which is recommended in
  10799. * [ISO 31-0](https://en.wikipedia.org/wiki/ISO_31-0#Numbers) and works
  10800. * across Anglo-American and continental European languages.
  10801. *
  10802. * @default \u0020
  10803. * @since 1.2.2
  10804. */
  10805. thousandsSep: ' '
  10806. },
  10807. /**
  10808. * Global options that don't apply to each chart. These options, like
  10809. * the `lang` options, must be set using the `Highcharts.setOptions`
  10810. * method.
  10811. *
  10812. * ```js
  10813. * Highcharts.setOptions({
  10814. * global: {
  10815. * useUTC: false
  10816. * }
  10817. * });
  10818. * ```
  10819. */
  10820. /**
  10821. * _Canvg rendering for Android 2.x is removed as of Highcharts 5.0\.
  10822. * Use the [libURL](#exporting.libURL) option to configure exporting._
  10823. *
  10824. * The URL to the additional file to lazy load for Android 2.x devices.
  10825. * These devices don't support SVG, so we download a helper file that
  10826. * contains [canvg](https://github.com/canvg/canvg), its dependency
  10827. * rbcolor, and our own CanVG Renderer class. To avoid hotlinking to
  10828. * our site, you can install canvas-tools.js on your own server and
  10829. * change this option accordingly.
  10830. *
  10831. * @deprecated
  10832. *
  10833. * @type {string}
  10834. * @default https://code.highcharts.com/{version}/modules/canvas-tools.js
  10835. * @product highcharts highmaps
  10836. * @apioption global.canvasToolsURL
  10837. */
  10838. /**
  10839. * This option is deprecated since v6.0.5. Instead, use
  10840. * [time.useUTC](#time.useUTC) that supports individual time settings
  10841. * per chart.
  10842. *
  10843. * @deprecated
  10844. *
  10845. * @type {boolean}
  10846. * @apioption global.useUTC
  10847. */
  10848. /**
  10849. * This option is deprecated since v6.0.5. Instead, use
  10850. * [time.Date](#time.Date) that supports individual time settings
  10851. * per chart.
  10852. *
  10853. * @deprecated
  10854. *
  10855. * @type {Function}
  10856. * @product highcharts highstock
  10857. * @apioption global.Date
  10858. */
  10859. /**
  10860. * This option is deprecated since v6.0.5. Instead, use
  10861. * [time.getTimezoneOffset](#time.getTimezoneOffset) that supports
  10862. * individual time settings per chart.
  10863. *
  10864. * @deprecated
  10865. *
  10866. * @type {Function}
  10867. * @product highcharts highstock
  10868. * @apioption global.getTimezoneOffset
  10869. */
  10870. /**
  10871. * This option is deprecated since v6.0.5. Instead, use
  10872. * [time.timezone](#time.timezone) that supports individual time
  10873. * settings per chart.
  10874. *
  10875. * @deprecated
  10876. *
  10877. * @type {string}
  10878. * @product highcharts highstock
  10879. * @apioption global.timezone
  10880. */
  10881. /**
  10882. * This option is deprecated since v6.0.5. Instead, use
  10883. * [time.timezoneOffset](#time.timezoneOffset) that supports individual
  10884. * time settings per chart.
  10885. *
  10886. * @deprecated
  10887. *
  10888. * @type {number}
  10889. * @product highcharts highstock
  10890. * @apioption global.timezoneOffset
  10891. */
  10892. global: {},
  10893. /**
  10894. * Time options that can apply globally or to individual charts. These
  10895. * settings affect how `datetime` axes are laid out, how tooltips are
  10896. * formatted, how series
  10897. * [pointIntervalUnit](#plotOptions.series.pointIntervalUnit) works and how
  10898. * the Highstock range selector handles time.
  10899. *
  10900. * The common use case is that all charts in the same Highcharts object
  10901. * share the same time settings, in which case the global settings are set
  10902. * using `setOptions`.
  10903. *
  10904. * ```js
  10905. * // Apply time settings globally
  10906. * Highcharts.setOptions({
  10907. * time: {
  10908. * timezone: 'Europe/London'
  10909. * }
  10910. * });
  10911. * // Apply time settings by instance
  10912. * var chart = Highcharts.chart('container', {
  10913. * time: {
  10914. * timezone: 'America/New_York'
  10915. * },
  10916. * series: [{
  10917. * data: [1, 4, 3, 5]
  10918. * }]
  10919. * });
  10920. *
  10921. * // Use the Time object
  10922. * console.log(
  10923. * 'Current time in New York',
  10924. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  10925. * );
  10926. * ```
  10927. *
  10928. * Since v6.0.5, the time options were moved from the `global` obect to the
  10929. * `time` object, and time options can be set on each individual chart.
  10930. *
  10931. * @sample {highcharts|highstock}
  10932. * highcharts/time/timezone/
  10933. * Set the timezone globally
  10934. * @sample {highcharts}
  10935. * highcharts/time/individual/
  10936. * Set the timezone per chart instance
  10937. * @sample {highstock}
  10938. * stock/time/individual/
  10939. * Set the timezone per chart instance
  10940. *
  10941. * @since 6.0.5
  10942. * @optionparent time
  10943. */
  10944. time: {
  10945. /**
  10946. * A custom `Date` class for advanced date handling. For example,
  10947. * [JDate](https://github.com/tahajahangir/jdate) can be hooked in to
  10948. * handle Jalali dates.
  10949. *
  10950. * @type {*}
  10951. * @since 4.0.4
  10952. * @product highcharts highstock gantt
  10953. */
  10954. Date: void 0,
  10955. /**
  10956. * A callback to return the time zone offset for a given datetime. It
  10957. * takes the timestamp in terms of milliseconds since January 1 1970,
  10958. * and returns the timezone offset in minutes. This provides a hook
  10959. * for drawing time based charts in specific time zones using their
  10960. * local DST crossover dates, with the help of external libraries.
  10961. *
  10962. * @see [global.timezoneOffset](#global.timezoneOffset)
  10963. *
  10964. * @sample {highcharts|highstock} highcharts/time/gettimezoneoffset/
  10965. * Use moment.js to draw Oslo time regardless of browser locale
  10966. *
  10967. * @type {Highcharts.TimezoneOffsetCallbackFunction}
  10968. * @since 4.1.0
  10969. * @product highcharts highstock gantt
  10970. */
  10971. getTimezoneOffset: void 0,
  10972. /**
  10973. * Requires [moment.js](https://momentjs.com/). If the timezone option
  10974. * is specified, it creates a default
  10975. * [getTimezoneOffset](#time.getTimezoneOffset) function that looks
  10976. * up the specified timezone in moment.js. If moment.js is not included,
  10977. * this throws a Highcharts error in the console, but does not crash the
  10978. * chart.
  10979. *
  10980. * @see [getTimezoneOffset](#time.getTimezoneOffset)
  10981. *
  10982. * @sample {highcharts|highstock} highcharts/time/timezone/
  10983. * Europe/Oslo
  10984. *
  10985. * @type {string}
  10986. * @since 5.0.7
  10987. * @product highcharts highstock gantt
  10988. */
  10989. timezone: void 0,
  10990. /**
  10991. * The timezone offset in minutes. Positive values are west, negative
  10992. * values are east of UTC, as in the ECMAScript
  10993. * [getTimezoneOffset](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
  10994. * method. Use this to display UTC based data in a predefined time zone.
  10995. *
  10996. * @see [time.getTimezoneOffset](#time.getTimezoneOffset)
  10997. *
  10998. * @sample {highcharts|highstock} highcharts/time/timezoneoffset/
  10999. * Timezone offset
  11000. *
  11001. * @since 3.0.8
  11002. * @product highcharts highstock gantt
  11003. */
  11004. timezoneOffset: 0,
  11005. /**
  11006. * Whether to use UTC time for axis scaling, tickmark placement and
  11007. * time display in `Highcharts.dateFormat`. Advantages of using UTC
  11008. * is that the time displays equally regardless of the user agent's
  11009. * time zone settings. Local time can be used when the data is loaded
  11010. * in real time or when correct Daylight Saving Time transitions are
  11011. * required.
  11012. *
  11013. * @sample {highcharts} highcharts/time/useutc-true/
  11014. * True by default
  11015. * @sample {highcharts} highcharts/time/useutc-false/
  11016. * False
  11017. */
  11018. useUTC: true
  11019. },
  11020. /**
  11021. * General options for the chart.
  11022. */
  11023. chart: {
  11024. /**
  11025. * Default `mapData` for all series. If set to a string, it functions
  11026. * as an index into the `Highcharts.maps` array. Otherwise it is
  11027. * interpreted as map data.
  11028. *
  11029. * @see [mapData](#series.map.mapData)
  11030. *
  11031. * @sample maps/demo/geojson
  11032. * Loading geoJSON data
  11033. * @sample maps/chart/topojson
  11034. * Loading topoJSON converted to geoJSON
  11035. *
  11036. * @type {string|Array<*>|Highcharts.GeoJSON}
  11037. * @since 5.0.0
  11038. * @product highmaps
  11039. * @apioption chart.map
  11040. */
  11041. /**
  11042. * Set lat/lon transformation definitions for the chart. If not defined,
  11043. * these are extracted from the map data.
  11044. *
  11045. * @type {*}
  11046. * @since 5.0.0
  11047. * @product highmaps
  11048. * @apioption chart.mapTransforms
  11049. */
  11050. /**
  11051. * When using multiple axis, the ticks of two or more opposite axes
  11052. * will automatically be aligned by adding ticks to the axis or axes
  11053. * with the least ticks, as if `tickAmount` were specified.
  11054. *
  11055. * This can be prevented by setting `alignTicks` to false. If the grid
  11056. * lines look messy, it's a good idea to hide them for the secondary
  11057. * axis by setting `gridLineWidth` to 0.
  11058. *
  11059. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  11060. * then the `alignTicks ` will be disabled for the Axis.
  11061. *
  11062. * Disabled for logarithmic axes.
  11063. *
  11064. * @sample {highcharts} highcharts/chart/alignticks-true/
  11065. * True by default
  11066. * @sample {highcharts} highcharts/chart/alignticks-false/
  11067. * False
  11068. * @sample {highstock} stock/chart/alignticks-true/
  11069. * True by default
  11070. * @sample {highstock} stock/chart/alignticks-false/
  11071. * False
  11072. *
  11073. * @type {boolean}
  11074. * @default true
  11075. * @product highcharts highstock gantt
  11076. * @apioption chart.alignTicks
  11077. */
  11078. /**
  11079. * Set the overall animation for all chart updating. Animation can be
  11080. * disabled throughout the chart by setting it to false here. It can
  11081. * be overridden for each individual API method as a function parameter.
  11082. * The only animation not affected by this option is the initial series
  11083. * animation, see [plotOptions.series.animation](
  11084. * #plotOptions.series.animation).
  11085. *
  11086. * The animation can either be set as a boolean or a configuration
  11087. * object. If `true`, it will use the 'swing' jQuery easing and a
  11088. * duration of 500 ms. If used as a configuration object, the following
  11089. * properties are supported:
  11090. *
  11091. * - `defer`: The animation delay time in milliseconds.
  11092. *
  11093. * - `duration`: The duration of the animation in milliseconds.
  11094. *
  11095. * - `easing`: A string reference to an easing function set on the
  11096. * `Math` object. See
  11097. * [the easing demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-animation-easing/).
  11098. *
  11099. * When zooming on a series with less than 100 points, the chart redraw
  11100. * will be done with animation, but in case of more data points, it is
  11101. * necessary to set this option to ensure animation on zoom.
  11102. *
  11103. * @sample {highcharts} highcharts/chart/animation-none/
  11104. * Updating with no animation
  11105. * @sample {highcharts} highcharts/chart/animation-duration/
  11106. * With a longer duration
  11107. * @sample {highcharts} highcharts/chart/animation-easing/
  11108. * With a jQuery UI easing
  11109. * @sample {highmaps} maps/chart/animation-none/
  11110. * Updating with no animation
  11111. * @sample {highmaps} maps/chart/animation-duration/
  11112. * With a longer duration
  11113. *
  11114. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  11115. * @default undefined
  11116. * @apioption chart.animation
  11117. */
  11118. /**
  11119. * A CSS class name to apply to the charts container `div`, allowing
  11120. * unique CSS styling for each chart.
  11121. *
  11122. * @type {string}
  11123. * @apioption chart.className
  11124. */
  11125. /**
  11126. * Event listeners for the chart.
  11127. *
  11128. * @apioption chart.events
  11129. */
  11130. /**
  11131. * Fires when a series is added to the chart after load time, using the
  11132. * `addSeries` method. One parameter, `event`, is passed to the
  11133. * function, containing common event information. Through
  11134. * `event.options` you can access the series options that were passed to
  11135. * the `addSeries` method. Returning false prevents the series from
  11136. * being added.
  11137. *
  11138. * @sample {highcharts} highcharts/chart/events-addseries/
  11139. * Alert on add series
  11140. * @sample {highstock} stock/chart/events-addseries/
  11141. * Alert on add series
  11142. *
  11143. * @type {Highcharts.ChartAddSeriesCallbackFunction}
  11144. * @since 1.2.0
  11145. * @context Highcharts.Chart
  11146. * @apioption chart.events.addSeries
  11147. */
  11148. /**
  11149. * Fires when clicking on the plot background. One parameter, `event`,
  11150. * is passed to the function, containing common event information.
  11151. *
  11152. * Information on the clicked spot can be found through `event.xAxis`
  11153. * and `event.yAxis`, which are arrays containing the axes of each
  11154. * dimension and each axis' value at the clicked spot. The primary axes
  11155. * are `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  11156. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  11157. *
  11158. * ```js
  11159. * click: function(e) {
  11160. * console.log(
  11161. * Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', e.xAxis[0].value),
  11162. * e.yAxis[0].value
  11163. * )
  11164. * }
  11165. * ```
  11166. *
  11167. * @sample {highcharts} highcharts/chart/events-click/
  11168. * Alert coordinates on click
  11169. * @sample {highcharts} highcharts/chart/events-container/
  11170. * Alternatively, attach event to container
  11171. * @sample {highstock} stock/chart/events-click/
  11172. * Alert coordinates on click
  11173. * @sample {highstock} highcharts/chart/events-container/
  11174. * Alternatively, attach event to container
  11175. * @sample {highmaps} maps/chart/events-click/
  11176. * Record coordinates on click
  11177. * @sample {highmaps} highcharts/chart/events-container/
  11178. * Alternatively, attach event to container
  11179. *
  11180. * @type {Highcharts.ChartClickCallbackFunction}
  11181. * @since 1.2.0
  11182. * @context Highcharts.Chart
  11183. * @apioption chart.events.click
  11184. */
  11185. /**
  11186. * Fires when the chart is finished loading. Since v4.2.2, it also waits
  11187. * for images to be loaded, for example from point markers. One
  11188. * parameter, `event`, is passed to the function, containing common
  11189. * event information.
  11190. *
  11191. * There is also a second parameter to the chart constructor where a
  11192. * callback function can be passed to be executed on chart.load.
  11193. *
  11194. * @sample {highcharts} highcharts/chart/events-load/
  11195. * Alert on chart load
  11196. * @sample {highstock} stock/chart/events-load/
  11197. * Alert on chart load
  11198. * @sample {highmaps} maps/chart/events-load/
  11199. * Add series on chart load
  11200. *
  11201. * @type {Highcharts.ChartLoadCallbackFunction}
  11202. * @context Highcharts.Chart
  11203. * @apioption chart.events.load
  11204. */
  11205. /**
  11206. * Fires when the chart is redrawn, either after a call to
  11207. * `chart.redraw()` or after an axis, series or point is modified with
  11208. * the `redraw` option set to `true`. One parameter, `event`, is passed
  11209. * to the function, containing common event information.
  11210. *
  11211. * @sample {highcharts} highcharts/chart/events-redraw/
  11212. * Alert on chart redraw
  11213. * @sample {highstock} stock/chart/events-redraw/
  11214. * Alert on chart redraw when adding a series or moving the
  11215. * zoomed range
  11216. * @sample {highmaps} maps/chart/events-redraw/
  11217. * Set subtitle on chart redraw
  11218. *
  11219. * @type {Highcharts.ChartRedrawCallbackFunction}
  11220. * @since 1.2.0
  11221. * @context Highcharts.Chart
  11222. * @apioption chart.events.redraw
  11223. */
  11224. /**
  11225. * Fires after initial load of the chart (directly after the `load`
  11226. * event), and after each redraw (directly after the `redraw` event).
  11227. *
  11228. * @type {Highcharts.ChartRenderCallbackFunction}
  11229. * @since 5.0.7
  11230. * @context Highcharts.Chart
  11231. * @apioption chart.events.render
  11232. */
  11233. /**
  11234. * Fires when an area of the chart has been selected. Selection is
  11235. * enabled by setting the chart's zoomType. One parameter, `event`, is
  11236. * passed to the function, containing common event information. The
  11237. * default action for the selection event is to zoom the chart to the
  11238. * selected area. It can be prevented by calling
  11239. * `event.preventDefault()` or return false.
  11240. *
  11241. * Information on the selected area can be found through `event.xAxis`
  11242. * and `event.yAxis`, which are arrays containing the axes of each
  11243. * dimension and each axis' min and max values. The primary axes are
  11244. * `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  11245. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  11246. *
  11247. * ```js
  11248. * selection: function(event) {
  11249. * // log the min and max of the primary, datetime x-axis
  11250. * console.log(
  11251. * Highcharts.dateFormat(
  11252. * '%Y-%m-%d %H:%M:%S',
  11253. * event.xAxis[0].min
  11254. * ),
  11255. * Highcharts.dateFormat(
  11256. * '%Y-%m-%d %H:%M:%S',
  11257. * event.xAxis[0].max
  11258. * )
  11259. * );
  11260. * // log the min and max of the y axis
  11261. * console.log(event.yAxis[0].min, event.yAxis[0].max);
  11262. * }
  11263. * ```
  11264. *
  11265. * @sample {highcharts} highcharts/chart/events-selection/
  11266. * Report on selection and reset
  11267. * @sample {highcharts} highcharts/chart/events-selection-points/
  11268. * Select a range of points through a drag selection
  11269. * @sample {highstock} stock/chart/events-selection/
  11270. * Report on selection and reset
  11271. * @sample {highstock} highcharts/chart/events-selection-points/
  11272. * Select a range of points through a drag selection
  11273. * (Highcharts)
  11274. *
  11275. * @type {Highcharts.ChartSelectionCallbackFunction}
  11276. * @apioption chart.events.selection
  11277. */
  11278. /**
  11279. * The margin between the outer edge of the chart and the plot area.
  11280. * The numbers in the array designate top, right, bottom and left
  11281. * respectively. Use the options `marginTop`, `marginRight`,
  11282. * `marginBottom` and `marginLeft` for shorthand setting of one option.
  11283. *
  11284. * By default there is no margin. The actual space is dynamically
  11285. * calculated from the offset of axis labels, axis title, title,
  11286. * subtitle and legend in addition to the `spacingTop`, `spacingRight`,
  11287. * `spacingBottom` and `spacingLeft` options.
  11288. *
  11289. * @sample {highcharts} highcharts/chart/margins-zero/
  11290. * Zero margins
  11291. * @sample {highstock} stock/chart/margin-zero/
  11292. * Zero margins
  11293. *
  11294. * @type {number|Array<number>}
  11295. * @apioption chart.margin
  11296. */
  11297. /**
  11298. * The margin between the bottom outer edge of the chart and the plot
  11299. * area. Use this to set a fixed pixel value for the margin as opposed
  11300. * to the default dynamic margin. See also `spacingBottom`.
  11301. *
  11302. * @sample {highcharts} highcharts/chart/marginbottom/
  11303. * 100px bottom margin
  11304. * @sample {highstock} stock/chart/marginbottom/
  11305. * 100px bottom margin
  11306. * @sample {highmaps} maps/chart/margin/
  11307. * 100px margins
  11308. *
  11309. * @type {number}
  11310. * @since 2.0
  11311. * @apioption chart.marginBottom
  11312. */
  11313. /**
  11314. * The margin between the left outer edge of the chart and the plot
  11315. * area. Use this to set a fixed pixel value for the margin as opposed
  11316. * to the default dynamic margin. See also `spacingLeft`.
  11317. *
  11318. * @sample {highcharts} highcharts/chart/marginleft/
  11319. * 150px left margin
  11320. * @sample {highstock} stock/chart/marginleft/
  11321. * 150px left margin
  11322. * @sample {highmaps} maps/chart/margin/
  11323. * 100px margins
  11324. *
  11325. * @type {number}
  11326. * @since 2.0
  11327. * @apioption chart.marginLeft
  11328. */
  11329. /**
  11330. * The margin between the right outer edge of the chart and the plot
  11331. * area. Use this to set a fixed pixel value for the margin as opposed
  11332. * to the default dynamic margin. See also `spacingRight`.
  11333. *
  11334. * @sample {highcharts} highcharts/chart/marginright/
  11335. * 100px right margin
  11336. * @sample {highstock} stock/chart/marginright/
  11337. * 100px right margin
  11338. * @sample {highmaps} maps/chart/margin/
  11339. * 100px margins
  11340. *
  11341. * @type {number}
  11342. * @since 2.0
  11343. * @apioption chart.marginRight
  11344. */
  11345. /**
  11346. * The margin between the top outer edge of the chart and the plot area.
  11347. * Use this to set a fixed pixel value for the margin as opposed to
  11348. * the default dynamic margin. See also `spacingTop`.
  11349. *
  11350. * @sample {highcharts} highcharts/chart/margintop/ 100px top margin
  11351. * @sample {highstock} stock/chart/margintop/
  11352. * 100px top margin
  11353. * @sample {highmaps} maps/chart/margin/
  11354. * 100px margins
  11355. *
  11356. * @type {number}
  11357. * @since 2.0
  11358. * @apioption chart.marginTop
  11359. */
  11360. /**
  11361. * Callback function to override the default function that formats all
  11362. * the numbers in the chart. Returns a string with the formatted number.
  11363. *
  11364. * @sample highcharts/members/highcharts-numberformat
  11365. * Arabic digits in Highcharts
  11366. * @type {Highcharts.NumberFormatterCallbackFunction}
  11367. * @since 8.0.0
  11368. * @apioption chart.numberFormatter
  11369. */
  11370. /**
  11371. * Allows setting a key to switch between zooming and panning. Can be
  11372. * one of `alt`, `ctrl`, `meta` (the command key on Mac and Windows
  11373. * key on Windows) or `shift`. The keys are mapped directly to the key
  11374. * properties of the click event argument (`event.altKey`,
  11375. * `event.ctrlKey`, `event.metaKey` and `event.shiftKey`).
  11376. *
  11377. * @type {string}
  11378. * @since 4.0.3
  11379. * @product highcharts gantt
  11380. * @validvalue ["alt", "ctrl", "meta", "shift"]
  11381. * @apioption chart.panKey
  11382. */
  11383. /**
  11384. * Allow panning in a chart. Best used with [panKey](#chart.panKey)
  11385. * to combine zooming and panning.
  11386. *
  11387. * On touch devices, when the [tooltip.followTouchMove](
  11388. * #tooltip.followTouchMove) option is `true` (default), panning
  11389. * requires two fingers. To allow panning with one finger, set
  11390. * `followTouchMove` to `false`.
  11391. *
  11392. * @sample {highcharts} highcharts/chart/pankey/ Zooming and panning
  11393. * @sample {highstock} stock/chart/panning/ Zooming and xy panning
  11394. *
  11395. * @product highcharts highstock gantt
  11396. * @apioption chart.panning
  11397. */
  11398. /**
  11399. * Enable or disable chart panning.
  11400. *
  11401. * @type {boolean}
  11402. * @default {highcharts} false
  11403. * @default {highstock} true
  11404. * @apioption chart.panning.enabled
  11405. */
  11406. /**
  11407. * Decides in what dimensions the user can pan the chart. Can be
  11408. * one of `x`, `y`, or `xy`.
  11409. *
  11410. * @sample {highcharts} highcharts/chart/panning-type
  11411. * Zooming and xy panning
  11412. *
  11413. * @type {string}
  11414. * @validvalue ["x", "y", "xy"]
  11415. * @default x
  11416. * @apioption chart.panning.type
  11417. */
  11418. /**
  11419. * Equivalent to [zoomType](#chart.zoomType), but for multitouch
  11420. * gestures only. By default, the `pinchType` is the same as the
  11421. * `zoomType` setting. However, pinching can be enabled separately in
  11422. * some cases, for example in stock charts where a mouse drag pans the
  11423. * chart, while pinching is enabled. When [tooltip.followTouchMove](
  11424. * #tooltip.followTouchMove) is true, pinchType only applies to
  11425. * two-finger touches.
  11426. *
  11427. * @type {string}
  11428. * @default {highcharts} undefined
  11429. * @default {highstock} x
  11430. * @since 3.0
  11431. * @product highcharts highstock gantt
  11432. * @validvalue ["x", "y", "xy"]
  11433. * @apioption chart.pinchType
  11434. */
  11435. /**
  11436. * Whether to apply styled mode. When in styled mode, no presentational
  11437. * attributes or CSS are applied to the chart SVG. Instead, CSS rules
  11438. * are required to style the chart. The default style sheet is
  11439. * available from `https://code.highcharts.com/css/highcharts.css`.
  11440. *
  11441. * @type {boolean}
  11442. * @default false
  11443. * @since 7.0
  11444. * @apioption chart.styledMode
  11445. */
  11446. styledMode: false,
  11447. /**
  11448. * The corner radius of the outer chart border.
  11449. *
  11450. * @sample {highcharts} highcharts/chart/borderradius/
  11451. * 20px radius
  11452. * @sample {highstock} stock/chart/border/
  11453. * 10px radius
  11454. * @sample {highmaps} maps/chart/border/
  11455. * Border options
  11456. *
  11457. */
  11458. borderRadius: 0,
  11459. /**
  11460. * In styled mode, this sets how many colors the class names
  11461. * should rotate between. With ten colors, series (or points) are
  11462. * given class names like `highcharts-color-0`, `highcharts-color-0`
  11463. * [...] `highcharts-color-9`. The equivalent in non-styled mode
  11464. * is to set colors using the [colors](#colors) setting.
  11465. *
  11466. * @since 5.0.0
  11467. */
  11468. colorCount: 10,
  11469. /**
  11470. * Alias of `type`.
  11471. *
  11472. * @sample {highcharts} highcharts/chart/defaultseriestype/
  11473. * Bar
  11474. *
  11475. * @deprecated
  11476. *
  11477. * @product highcharts
  11478. */
  11479. defaultSeriesType: 'line',
  11480. /**
  11481. * If true, the axes will scale to the remaining visible series once
  11482. * one series is hidden. If false, hiding and showing a series will
  11483. * not affect the axes or the other series. For stacks, once one series
  11484. * within the stack is hidden, the rest of the stack will close in
  11485. * around it even if the axis is not affected.
  11486. *
  11487. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true/
  11488. * True by default
  11489. * @sample {highcharts} highcharts/chart/ignorehiddenseries-false/
  11490. * False
  11491. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true-stacked/
  11492. * True with stack
  11493. * @sample {highstock} stock/chart/ignorehiddenseries-true/
  11494. * True by default
  11495. * @sample {highstock} stock/chart/ignorehiddenseries-false/
  11496. * False
  11497. *
  11498. * @since 1.2.0
  11499. * @product highcharts highstock gantt
  11500. */
  11501. ignoreHiddenSeries: true,
  11502. /**
  11503. * Whether to invert the axes so that the x axis is vertical and y axis
  11504. * is horizontal. When `true`, the x axis is [reversed](#xAxis.reversed)
  11505. * by default.
  11506. *
  11507. * @productdesc {highcharts}
  11508. * If a bar series is present in the chart, it will be inverted
  11509. * automatically. Inverting the chart doesn't have an effect if there
  11510. * are no cartesian series in the chart, or if the chart is
  11511. * [polar](#chart.polar).
  11512. *
  11513. * @sample {highcharts} highcharts/chart/inverted/
  11514. * Inverted line
  11515. * @sample {highstock} stock/navigator/inverted/
  11516. * Inverted stock chart
  11517. *
  11518. * @type {boolean}
  11519. * @default false
  11520. * @product highcharts highstock gantt
  11521. * @apioption chart.inverted
  11522. */
  11523. /**
  11524. * The distance between the outer edge of the chart and the content,
  11525. * like title or legend, or axis title and labels if present. The
  11526. * numbers in the array designate top, right, bottom and left
  11527. * respectively. Use the options spacingTop, spacingRight, spacingBottom
  11528. * and spacingLeft options for shorthand setting of one option.
  11529. *
  11530. * @type {Array<number>}
  11531. * @see [chart.margin](#chart.margin)
  11532. * @default [10, 10, 15, 10]
  11533. * @since 3.0.6
  11534. */
  11535. spacing: [10, 10, 15, 10],
  11536. /**
  11537. * The button that appears after a selection zoom, allowing the user
  11538. * to reset zoom.
  11539. */
  11540. resetZoomButton: {
  11541. /**
  11542. * What frame the button placement should be related to. Can be
  11543. * either `plotBox` or `spacingBox`.
  11544. *
  11545. * @sample {highcharts} highcharts/chart/resetzoombutton-relativeto/
  11546. * Relative to the chart
  11547. * @sample {highstock} highcharts/chart/resetzoombutton-relativeto/
  11548. * Relative to the chart
  11549. *
  11550. * @type {Highcharts.ButtonRelativeToValue}
  11551. * @default plot
  11552. * @since 2.2
  11553. * @apioption chart.resetZoomButton.relativeTo
  11554. */
  11555. /**
  11556. * A collection of attributes for the button. The object takes SVG
  11557. * attributes like `fill`, `stroke`, `stroke-width` or `r`, the
  11558. * border radius. The theme also supports `style`, a collection of
  11559. * CSS properties for the text. Equivalent attributes for the hover
  11560. * state are given in `theme.states.hover`.
  11561. *
  11562. * @sample {highcharts} highcharts/chart/resetzoombutton-theme/
  11563. * Theming the button
  11564. * @sample {highstock} highcharts/chart/resetzoombutton-theme/
  11565. * Theming the button
  11566. *
  11567. * @type {Highcharts.SVGAttributes}
  11568. * @since 2.2
  11569. */
  11570. theme: {
  11571. /** @internal */
  11572. zIndex: 6
  11573. },
  11574. /**
  11575. * The position of the button.
  11576. *
  11577. * @sample {highcharts} highcharts/chart/resetzoombutton-position/
  11578. * Above the plot area
  11579. * @sample {highstock} highcharts/chart/resetzoombutton-position/
  11580. * Above the plot area
  11581. * @sample {highmaps} highcharts/chart/resetzoombutton-position/
  11582. * Above the plot area
  11583. *
  11584. * @type {Highcharts.AlignObject}
  11585. * @since 2.2
  11586. */
  11587. position: {
  11588. /**
  11589. * The horizontal alignment of the button.
  11590. */
  11591. align: 'right',
  11592. /**
  11593. * The horizontal offset of the button.
  11594. */
  11595. x: -10,
  11596. /**
  11597. * The vertical alignment of the button.
  11598. *
  11599. * @type {Highcharts.VerticalAlignValue}
  11600. * @default top
  11601. * @apioption chart.resetZoomButton.position.verticalAlign
  11602. */
  11603. /**
  11604. * The vertical offset of the button.
  11605. */
  11606. y: 10
  11607. }
  11608. },
  11609. /**
  11610. * The pixel width of the plot area border.
  11611. *
  11612. * @sample {highcharts} highcharts/chart/plotborderwidth/
  11613. * 1px border
  11614. * @sample {highstock} stock/chart/plotborder/
  11615. * 2px border
  11616. * @sample {highmaps} maps/chart/plotborder/
  11617. * Plot border options
  11618. *
  11619. * @type {number}
  11620. * @default 0
  11621. * @apioption chart.plotBorderWidth
  11622. */
  11623. /**
  11624. * Whether to apply a drop shadow to the plot area. Requires that
  11625. * plotBackgroundColor be set. The shadow can be an object configuration
  11626. * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
  11627. *
  11628. * @sample {highcharts} highcharts/chart/plotshadow/
  11629. * Plot shadow
  11630. * @sample {highstock} stock/chart/plotshadow/
  11631. * Plot shadow
  11632. * @sample {highmaps} maps/chart/plotborder/
  11633. * Plot border options
  11634. *
  11635. * @type {boolean|Highcharts.CSSObject}
  11636. * @default false
  11637. * @apioption chart.plotShadow
  11638. */
  11639. /**
  11640. * When true, cartesian charts like line, spline, area and column are
  11641. * transformed into the polar coordinate system. This produces _polar
  11642. * charts_, also known as _radar charts_.
  11643. *
  11644. * @sample {highcharts} highcharts/demo/polar/
  11645. * Polar chart
  11646. * @sample {highcharts} highcharts/demo/polar-wind-rose/
  11647. * Wind rose, stacked polar column chart
  11648. * @sample {highcharts} highcharts/demo/polar-spider/
  11649. * Spider web chart
  11650. * @sample {highcharts} highcharts/parallel-coordinates/polar/
  11651. * Star plot, multivariate data in a polar chart
  11652. *
  11653. * @type {boolean}
  11654. * @default false
  11655. * @since 2.3.0
  11656. * @product highcharts
  11657. * @requires highcharts-more
  11658. * @apioption chart.polar
  11659. */
  11660. /**
  11661. * Whether to reflow the chart to fit the width of the container div
  11662. * on resizing the window.
  11663. *
  11664. * @sample {highcharts} highcharts/chart/reflow-true/
  11665. * True by default
  11666. * @sample {highcharts} highcharts/chart/reflow-false/
  11667. * False
  11668. * @sample {highstock} stock/chart/reflow-true/
  11669. * True by default
  11670. * @sample {highstock} stock/chart/reflow-false/
  11671. * False
  11672. * @sample {highmaps} maps/chart/reflow-true/
  11673. * True by default
  11674. * @sample {highmaps} maps/chart/reflow-false/
  11675. * False
  11676. *
  11677. * @type {boolean}
  11678. * @default true
  11679. * @since 2.1
  11680. * @apioption chart.reflow
  11681. */
  11682. /**
  11683. * The HTML element where the chart will be rendered. If it is a string,
  11684. * the element by that id is used. The HTML element can also be passed
  11685. * by direct reference, or as the first argument of the chart
  11686. * constructor, in which case the option is not needed.
  11687. *
  11688. * @sample {highcharts} highcharts/chart/reflow-true/
  11689. * String
  11690. * @sample {highcharts} highcharts/chart/renderto-object/
  11691. * Object reference
  11692. * @sample {highcharts} highcharts/chart/renderto-jquery/
  11693. * Object reference through jQuery
  11694. * @sample {highstock} stock/chart/renderto-string/
  11695. * String
  11696. * @sample {highstock} stock/chart/renderto-object/
  11697. * Object reference
  11698. * @sample {highstock} stock/chart/renderto-jquery/
  11699. * Object reference through jQuery
  11700. *
  11701. * @type {string|Highcharts.HTMLDOMElement}
  11702. * @apioption chart.renderTo
  11703. */
  11704. /**
  11705. * The background color of the marker square when selecting (zooming
  11706. * in on) an area of the chart.
  11707. *
  11708. * @see In styled mode, the selection marker fill is set with the
  11709. * `.highcharts-selection-marker` class.
  11710. *
  11711. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11712. * @default rgba(51,92,173,0.25)
  11713. * @since 2.1.7
  11714. * @apioption chart.selectionMarkerFill
  11715. */
  11716. /**
  11717. * Whether to apply a drop shadow to the outer chart area. Requires
  11718. * that backgroundColor be set. The shadow can be an object
  11719. * configuration containing `color`, `offsetX`, `offsetY`, `opacity` and
  11720. * `width`.
  11721. *
  11722. * @sample {highcharts} highcharts/chart/shadow/
  11723. * Shadow
  11724. * @sample {highstock} stock/chart/shadow/
  11725. * Shadow
  11726. * @sample {highmaps} maps/chart/border/
  11727. * Chart border and shadow
  11728. *
  11729. * @type {boolean|Highcharts.CSSObject}
  11730. * @default false
  11731. * @apioption chart.shadow
  11732. */
  11733. /**
  11734. * Whether to show the axes initially. This only applies to empty charts
  11735. * where series are added dynamically, as axes are automatically added
  11736. * to cartesian series.
  11737. *
  11738. * @sample {highcharts} highcharts/chart/showaxes-false/
  11739. * False by default
  11740. * @sample {highcharts} highcharts/chart/showaxes-true/
  11741. * True
  11742. *
  11743. * @type {boolean}
  11744. * @since 1.2.5
  11745. * @product highcharts gantt
  11746. * @apioption chart.showAxes
  11747. */
  11748. /**
  11749. * The space between the bottom edge of the chart and the content (plot
  11750. * area, axis title and labels, title, subtitle or legend in top
  11751. * position).
  11752. *
  11753. * @sample {highcharts} highcharts/chart/spacingbottom/
  11754. * Spacing bottom set to 100
  11755. * @sample {highstock} stock/chart/spacingbottom/
  11756. * Spacing bottom set to 100
  11757. * @sample {highmaps} maps/chart/spacing/
  11758. * Spacing 100 all around
  11759. *
  11760. * @type {number}
  11761. * @default 15
  11762. * @since 2.1
  11763. * @apioption chart.spacingBottom
  11764. */
  11765. /**
  11766. * The space between the left edge of the chart and the content (plot
  11767. * area, axis title and labels, title, subtitle or legend in top
  11768. * position).
  11769. *
  11770. * @sample {highcharts} highcharts/chart/spacingleft/
  11771. * Spacing left set to 100
  11772. * @sample {highstock} stock/chart/spacingleft/
  11773. * Spacing left set to 100
  11774. * @sample {highmaps} maps/chart/spacing/
  11775. * Spacing 100 all around
  11776. *
  11777. * @type {number}
  11778. * @default 10
  11779. * @since 2.1
  11780. * @apioption chart.spacingLeft
  11781. */
  11782. /**
  11783. * The space between the right edge of the chart and the content (plot
  11784. * area, axis title and labels, title, subtitle or legend in top
  11785. * position).
  11786. *
  11787. * @sample {highcharts} highcharts/chart/spacingright-100/
  11788. * Spacing set to 100
  11789. * @sample {highcharts} highcharts/chart/spacingright-legend/
  11790. * Legend in right position with default spacing
  11791. * @sample {highstock} stock/chart/spacingright/
  11792. * Spacing set to 100
  11793. * @sample {highmaps} maps/chart/spacing/
  11794. * Spacing 100 all around
  11795. *
  11796. * @type {number}
  11797. * @default 10
  11798. * @since 2.1
  11799. * @apioption chart.spacingRight
  11800. */
  11801. /**
  11802. * The space between the top edge of the chart and the content (plot
  11803. * area, axis title and labels, title, subtitle or legend in top
  11804. * position).
  11805. *
  11806. * @sample {highcharts} highcharts/chart/spacingtop-100/
  11807. * A top spacing of 100
  11808. * @sample {highcharts} highcharts/chart/spacingtop-10/
  11809. * Floating chart title makes the plot area align to the default
  11810. * spacingTop of 10.
  11811. * @sample {highstock} stock/chart/spacingtop/
  11812. * A top spacing of 100
  11813. * @sample {highmaps} maps/chart/spacing/
  11814. * Spacing 100 all around
  11815. *
  11816. * @type {number}
  11817. * @default 10
  11818. * @since 2.1
  11819. * @apioption chart.spacingTop
  11820. */
  11821. /**
  11822. * Additional CSS styles to apply inline to the container `div`. Note
  11823. * that since the default font styles are applied in the renderer, it
  11824. * is ignorant of the individual chart options and must be set globally.
  11825. *
  11826. * @see In styled mode, general chart styles can be set with the
  11827. * `.highcharts-root` class.
  11828. * @sample {highcharts} highcharts/chart/style-serif-font/
  11829. * Using a serif type font
  11830. * @sample {highcharts} highcharts/css/em/
  11831. * Styled mode with relative font sizes
  11832. * @sample {highstock} stock/chart/style/
  11833. * Using a serif type font
  11834. * @sample {highmaps} maps/chart/style-serif-font/
  11835. * Using a serif type font
  11836. *
  11837. * @type {Highcharts.CSSObject}
  11838. * @default {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}
  11839. * @apioption chart.style
  11840. */
  11841. /**
  11842. * The default series type for the chart. Can be any of the chart types
  11843. * listed under [plotOptions](#plotOptions) and [series](#series) or can
  11844. * be a series provided by an additional module.
  11845. *
  11846. * In TypeScript this option has no effect in sense of typing and
  11847. * instead the `type` option must always be set in the series.
  11848. *
  11849. * @sample {highcharts} highcharts/chart/type-bar/
  11850. * Bar
  11851. * @sample {highstock} stock/chart/type/
  11852. * Areaspline
  11853. * @sample {highmaps} maps/chart/type-mapline/
  11854. * Mapline
  11855. *
  11856. * @type {string}
  11857. * @default {highcharts} line
  11858. * @default {highstock} line
  11859. * @default {highmaps} map
  11860. * @since 2.1.0
  11861. * @apioption chart.type
  11862. */
  11863. /**
  11864. * Decides in what dimensions the user can zoom by dragging the mouse.
  11865. * Can be one of `x`, `y` or `xy`.
  11866. *
  11867. * @see [panKey](#chart.panKey)
  11868. *
  11869. * @sample {highcharts} highcharts/chart/zoomtype-none/
  11870. * None by default
  11871. * @sample {highcharts} highcharts/chart/zoomtype-x/
  11872. * X
  11873. * @sample {highcharts} highcharts/chart/zoomtype-y/
  11874. * Y
  11875. * @sample {highcharts} highcharts/chart/zoomtype-xy/
  11876. * Xy
  11877. * @sample {highstock} stock/demo/basic-line/
  11878. * None by default
  11879. * @sample {highstock} stock/chart/zoomtype-x/
  11880. * X
  11881. * @sample {highstock} stock/chart/zoomtype-y/
  11882. * Y
  11883. * @sample {highstock} stock/chart/zoomtype-xy/
  11884. * Xy
  11885. *
  11886. * @type {string}
  11887. * @product highcharts highstock gantt
  11888. * @validvalue ["x", "y", "xy"]
  11889. * @apioption chart.zoomType
  11890. */
  11891. /**
  11892. * An explicit width for the chart. By default (when `null`) the width
  11893. * is calculated from the offset width of the containing element.
  11894. *
  11895. * @sample {highcharts} highcharts/chart/width/
  11896. * 800px wide
  11897. * @sample {highstock} stock/chart/width/
  11898. * 800px wide
  11899. * @sample {highmaps} maps/chart/size/
  11900. * Chart with explicit size
  11901. *
  11902. * @type {null|number|string}
  11903. */
  11904. width: null,
  11905. /**
  11906. * An explicit height for the chart. If a _number_, the height is
  11907. * given in pixels. If given a _percentage string_ (for example
  11908. * `'56%'`), the height is given as the percentage of the actual chart
  11909. * width. This allows for preserving the aspect ratio across responsive
  11910. * sizes.
  11911. *
  11912. * By default (when `null`) the height is calculated from the offset
  11913. * height of the containing element, or 400 pixels if the containing
  11914. * element's height is 0.
  11915. *
  11916. * @sample {highcharts} highcharts/chart/height/
  11917. * 500px height
  11918. * @sample {highstock} stock/chart/height/
  11919. * 300px height
  11920. * @sample {highmaps} maps/chart/size/
  11921. * Chart with explicit size
  11922. * @sample highcharts/chart/height-percent/
  11923. * Highcharts with percentage height
  11924. *
  11925. * @type {null|number|string}
  11926. */
  11927. height: null,
  11928. /**
  11929. * The color of the outer chart border.
  11930. *
  11931. * @see In styled mode, the stroke is set with the
  11932. * `.highcharts-background` class.
  11933. *
  11934. * @sample {highcharts} highcharts/chart/bordercolor/
  11935. * Brown border
  11936. * @sample {highstock} stock/chart/border/
  11937. * Brown border
  11938. * @sample {highmaps} maps/chart/border/
  11939. * Border options
  11940. *
  11941. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11942. */
  11943. borderColor: '#335cad',
  11944. /**
  11945. * The pixel width of the outer chart border.
  11946. *
  11947. * @see In styled mode, the stroke is set with the
  11948. * `.highcharts-background` class.
  11949. *
  11950. * @sample {highcharts} highcharts/chart/borderwidth/
  11951. * 5px border
  11952. * @sample {highstock} stock/chart/border/
  11953. * 2px border
  11954. * @sample {highmaps} maps/chart/border/
  11955. * Border options
  11956. *
  11957. * @type {number}
  11958. * @default 0
  11959. * @apioption chart.borderWidth
  11960. */
  11961. /**
  11962. * The background color or gradient for the outer chart area.
  11963. *
  11964. * @see In styled mode, the background is set with the
  11965. * `.highcharts-background` class.
  11966. *
  11967. * @sample {highcharts} highcharts/chart/backgroundcolor-color/
  11968. * Color
  11969. * @sample {highcharts} highcharts/chart/backgroundcolor-gradient/
  11970. * Gradient
  11971. * @sample {highstock} stock/chart/backgroundcolor-color/
  11972. * Color
  11973. * @sample {highstock} stock/chart/backgroundcolor-gradient/
  11974. * Gradient
  11975. * @sample {highmaps} maps/chart/backgroundcolor-color/
  11976. * Color
  11977. * @sample {highmaps} maps/chart/backgroundcolor-gradient/
  11978. * Gradient
  11979. *
  11980. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11981. */
  11982. backgroundColor: '#ffffff',
  11983. /**
  11984. * The background color or gradient for the plot area.
  11985. *
  11986. * @see In styled mode, the plot background is set with the
  11987. * `.highcharts-plot-background` class.
  11988. *
  11989. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-color/
  11990. * Color
  11991. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-gradient/
  11992. * Gradient
  11993. * @sample {highstock} stock/chart/plotbackgroundcolor-color/
  11994. * Color
  11995. * @sample {highstock} stock/chart/plotbackgroundcolor-gradient/
  11996. * Gradient
  11997. * @sample {highmaps} maps/chart/plotbackgroundcolor-color/
  11998. * Color
  11999. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  12000. * Gradient
  12001. *
  12002. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12003. * @apioption chart.plotBackgroundColor
  12004. */
  12005. /**
  12006. * The URL for an image to use as the plot background. To set an image
  12007. * as the background for the entire chart, set a CSS background image
  12008. * to the container element. Note that for the image to be applied to
  12009. * exported charts, its URL needs to be accessible by the export server.
  12010. *
  12011. * @see In styled mode, a plot background image can be set with the
  12012. * `.highcharts-plot-background` class and a [custom pattern](
  12013. * https://www.highcharts.com/docs/chart-design-and-style/
  12014. * gradients-shadows-and-patterns).
  12015. *
  12016. * @sample {highcharts} highcharts/chart/plotbackgroundimage/
  12017. * Skies
  12018. * @sample {highstock} stock/chart/plotbackgroundimage/
  12019. * Skies
  12020. *
  12021. * @type {string}
  12022. * @apioption chart.plotBackgroundImage
  12023. */
  12024. /**
  12025. * The color of the inner chart or plot area border.
  12026. *
  12027. * @see In styled mode, a plot border stroke can be set with the
  12028. * `.highcharts-plot-border` class.
  12029. *
  12030. * @sample {highcharts} highcharts/chart/plotbordercolor/
  12031. * Blue border
  12032. * @sample {highstock} stock/chart/plotborder/
  12033. * Blue border
  12034. * @sample {highmaps} maps/chart/plotborder/
  12035. * Plot border options
  12036. *
  12037. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12038. */
  12039. plotBorderColor: '#cccccc'
  12040. },
  12041. /**
  12042. * The chart's main title.
  12043. *
  12044. * @sample {highmaps} maps/title/title/
  12045. * Title options demonstrated
  12046. */
  12047. title: {
  12048. /**
  12049. * When the title is floating, the plot area will not move to make space
  12050. * for it.
  12051. *
  12052. * @sample {highcharts} highcharts/chart/zoomtype-none/
  12053. * False by default
  12054. * @sample {highcharts} highcharts/title/floating/
  12055. * True - title on top of the plot area
  12056. * @sample {highstock} stock/chart/title-floating/
  12057. * True - title on top of the plot area
  12058. *
  12059. * @type {boolean}
  12060. * @default false
  12061. * @since 2.1
  12062. * @apioption title.floating
  12063. */
  12064. /**
  12065. * CSS styles for the title. Use this for font styling, but use `align`,
  12066. * `x` and `y` for text alignment.
  12067. *
  12068. * In styled mode, the title style is given in the `.highcharts-title`
  12069. * class.
  12070. *
  12071. * @sample {highcharts} highcharts/title/style/
  12072. * Custom color and weight
  12073. * @sample {highstock} stock/chart/title-style/
  12074. * Custom color and weight
  12075. * @sample highcharts/css/titles/
  12076. * Styled mode
  12077. *
  12078. * @type {Highcharts.CSSObject}
  12079. * @default {highcharts|highmaps} { "color": "#333333", "fontSize": "18px" }
  12080. * @default {highstock} { "color": "#333333", "fontSize": "16px" }
  12081. * @apioption title.style
  12082. */
  12083. /**
  12084. * Whether to
  12085. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  12086. * to render the text.
  12087. *
  12088. * @type {boolean}
  12089. * @default false
  12090. * @apioption title.useHTML
  12091. */
  12092. /**
  12093. * The vertical alignment of the title. Can be one of `"top"`,
  12094. * `"middle"` and `"bottom"`. When a value is given, the title behaves
  12095. * as if [floating](#title.floating) were `true`.
  12096. *
  12097. * @sample {highcharts} highcharts/title/verticalalign/
  12098. * Chart title in bottom right corner
  12099. * @sample {highstock} stock/chart/title-verticalalign/
  12100. * Chart title in bottom right corner
  12101. *
  12102. * @type {Highcharts.VerticalAlignValue}
  12103. * @since 2.1
  12104. * @apioption title.verticalAlign
  12105. */
  12106. /**
  12107. * The x position of the title relative to the alignment within
  12108. * `chart.spacingLeft` and `chart.spacingRight`.
  12109. *
  12110. * @sample {highcharts} highcharts/title/align/
  12111. * Aligned to the plot area (x = 70px = margin left - spacing
  12112. * left)
  12113. * @sample {highstock} stock/chart/title-align/
  12114. * Aligned to the plot area (x = 50px = margin left - spacing
  12115. * left)
  12116. *
  12117. * @type {number}
  12118. * @default 0
  12119. * @since 2.0
  12120. * @apioption title.x
  12121. */
  12122. /**
  12123. * The y position of the title relative to the alignment within
  12124. * [chart.spacingTop](#chart.spacingTop) and [chart.spacingBottom](
  12125. * #chart.spacingBottom). By default it depends on the font size.
  12126. *
  12127. * @sample {highcharts} highcharts/title/y/
  12128. * Title inside the plot area
  12129. * @sample {highstock} stock/chart/title-verticalalign/
  12130. * Chart title in bottom right corner
  12131. *
  12132. * @type {number}
  12133. * @since 2.0
  12134. * @apioption title.y
  12135. */
  12136. /**
  12137. * The title of the chart. To disable the title, set the `text` to
  12138. * `undefined`.
  12139. *
  12140. * @sample {highcharts} highcharts/title/text/
  12141. * Custom title
  12142. * @sample {highstock} stock/chart/title-text/
  12143. * Custom title
  12144. *
  12145. * @default {highcharts|highmaps} Chart title
  12146. * @default {highstock} undefined
  12147. */
  12148. text: 'Chart title',
  12149. /**
  12150. * The horizontal alignment of the title. Can be one of "left", "center"
  12151. * and "right".
  12152. *
  12153. * @sample {highcharts} highcharts/title/align/
  12154. * Aligned to the plot area (x = 70px = margin left - spacing
  12155. * left)
  12156. * @sample {highstock} stock/chart/title-align/
  12157. * Aligned to the plot area (x = 50px = margin left - spacing
  12158. * left)
  12159. *
  12160. * @type {Highcharts.AlignValue}
  12161. * @since 2.0
  12162. */
  12163. align: 'center',
  12164. /**
  12165. * The margin between the title and the plot area, or if a subtitle
  12166. * is present, the margin between the subtitle and the plot area.
  12167. *
  12168. * @sample {highcharts} highcharts/title/margin-50/
  12169. * A chart title margin of 50
  12170. * @sample {highcharts} highcharts/title/margin-subtitle/
  12171. * The same margin applied with a subtitle
  12172. * @sample {highstock} stock/chart/title-margin/
  12173. * A chart title margin of 50
  12174. *
  12175. * @since 2.1
  12176. */
  12177. margin: 15,
  12178. /**
  12179. * Adjustment made to the title width, normally to reserve space for
  12180. * the exporting burger menu.
  12181. *
  12182. * @sample highcharts/title/widthadjust/
  12183. * Wider menu, greater padding
  12184. *
  12185. * @since 4.2.5
  12186. */
  12187. widthAdjust: -44
  12188. },
  12189. /**
  12190. * The chart's subtitle. This can be used both to display a subtitle below
  12191. * the main title, and to display random text anywhere in the chart. The
  12192. * subtitle can be updated after chart initialization through the
  12193. * `Chart.setTitle` method.
  12194. *
  12195. * @sample {highmaps} maps/title/subtitle/
  12196. * Subtitle options demonstrated
  12197. */
  12198. subtitle: {
  12199. /**
  12200. * When the subtitle is floating, the plot area will not move to make
  12201. * space for it.
  12202. *
  12203. * @sample {highcharts} highcharts/subtitle/floating/
  12204. * Floating title and subtitle
  12205. * @sample {highstock} stock/chart/subtitle-footnote
  12206. * Footnote floating at bottom right of plot area
  12207. *
  12208. * @type {boolean}
  12209. * @default false
  12210. * @since 2.1
  12211. * @apioption subtitle.floating
  12212. */
  12213. /**
  12214. * CSS styles for the title.
  12215. *
  12216. * In styled mode, the subtitle style is given in the
  12217. * `.highcharts-subtitle` class.
  12218. *
  12219. * @sample {highcharts} highcharts/subtitle/style/
  12220. * Custom color and weight
  12221. * @sample {highcharts} highcharts/css/titles/
  12222. * Styled mode
  12223. * @sample {highstock} stock/chart/subtitle-style
  12224. * Custom color and weight
  12225. * @sample {highstock} highcharts/css/titles/
  12226. * Styled mode
  12227. * @sample {highmaps} highcharts/css/titles/
  12228. * Styled mode
  12229. *
  12230. * @type {Highcharts.CSSObject}
  12231. * @default {"color": "#666666"}
  12232. * @apioption subtitle.style
  12233. */
  12234. /**
  12235. * Whether to
  12236. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  12237. * to render the text.
  12238. *
  12239. * @type {boolean}
  12240. * @default false
  12241. * @apioption subtitle.useHTML
  12242. */
  12243. /**
  12244. * The vertical alignment of the title. Can be one of `"top"`,
  12245. * `"middle"` and `"bottom"`. When middle, the subtitle behaves as
  12246. * floating.
  12247. *
  12248. * @sample {highcharts} highcharts/subtitle/verticalalign/
  12249. * Footnote at the bottom right of plot area
  12250. * @sample {highstock} stock/chart/subtitle-footnote
  12251. * Footnote at the bottom right of plot area
  12252. *
  12253. * @type {Highcharts.VerticalAlignValue}
  12254. * @since 2.1
  12255. * @apioption subtitle.verticalAlign
  12256. */
  12257. /**
  12258. * The x position of the subtitle relative to the alignment within
  12259. * `chart.spacingLeft` and `chart.spacingRight`.
  12260. *
  12261. * @sample {highcharts} highcharts/subtitle/align/
  12262. * Footnote at right of plot area
  12263. * @sample {highstock} stock/chart/subtitle-footnote
  12264. * Footnote at the bottom right of plot area
  12265. *
  12266. * @type {number}
  12267. * @default 0
  12268. * @since 2.0
  12269. * @apioption subtitle.x
  12270. */
  12271. /**
  12272. * The y position of the subtitle relative to the alignment within
  12273. * `chart.spacingTop` and `chart.spacingBottom`. By default the subtitle
  12274. * is laid out below the title unless the title is floating.
  12275. *
  12276. * @sample {highcharts} highcharts/subtitle/verticalalign/
  12277. * Footnote at the bottom right of plot area
  12278. * @sample {highstock} stock/chart/subtitle-footnote
  12279. * Footnote at the bottom right of plot area
  12280. *
  12281. * @type {number}
  12282. * @since 2.0
  12283. * @apioption subtitle.y
  12284. */
  12285. /**
  12286. * The subtitle of the chart.
  12287. *
  12288. * @sample {highcharts|highstock} highcharts/subtitle/text/
  12289. * Custom subtitle
  12290. * @sample {highcharts|highstock} highcharts/subtitle/text-formatted/
  12291. * Formatted and linked text.
  12292. */
  12293. text: '',
  12294. /**
  12295. * The horizontal alignment of the subtitle. Can be one of "left",
  12296. * "center" and "right".
  12297. *
  12298. * @sample {highcharts} highcharts/subtitle/align/
  12299. * Footnote at right of plot area
  12300. * @sample {highstock} stock/chart/subtitle-footnote
  12301. * Footnote at bottom right of plot area
  12302. *
  12303. * @type {Highcharts.AlignValue}
  12304. * @since 2.0
  12305. */
  12306. align: 'center',
  12307. /**
  12308. * Adjustment made to the subtitle width, normally to reserve space
  12309. * for the exporting burger menu.
  12310. *
  12311. * @see [title.widthAdjust](#title.widthAdjust)
  12312. *
  12313. * @sample highcharts/title/widthadjust/
  12314. * Wider menu, greater padding
  12315. *
  12316. * @since 4.2.5
  12317. */
  12318. widthAdjust: -44
  12319. },
  12320. /**
  12321. * The chart's caption, which will render below the chart and will be part
  12322. * of exported charts. The caption can be updated after chart initialization
  12323. * through the `Chart.update` or `Chart.caption.update` methods.
  12324. *
  12325. * @sample highcharts/caption/text/
  12326. * A chart with a caption
  12327. * @since 7.2.0
  12328. */
  12329. caption: {
  12330. /**
  12331. * When the caption is floating, the plot area will not move to make
  12332. * space for it.
  12333. *
  12334. * @type {boolean}
  12335. * @default false
  12336. * @apioption caption.floating
  12337. */
  12338. /**
  12339. * The margin between the caption and the plot area.
  12340. */
  12341. margin: 15,
  12342. /**
  12343. * CSS styles for the caption.
  12344. *
  12345. * In styled mode, the caption style is given in the
  12346. * `.highcharts-caption` class.
  12347. *
  12348. * @sample {highcharts} highcharts/css/titles/
  12349. * Styled mode
  12350. *
  12351. * @type {Highcharts.CSSObject}
  12352. * @default {"color": "#666666"}
  12353. * @apioption caption.style
  12354. */
  12355. /**
  12356. * Whether to
  12357. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  12358. * to render the text.
  12359. *
  12360. * @type {boolean}
  12361. * @default false
  12362. * @apioption caption.useHTML
  12363. */
  12364. /**
  12365. * The x position of the caption relative to the alignment within
  12366. * `chart.spacingLeft` and `chart.spacingRight`.
  12367. *
  12368. * @type {number}
  12369. * @default 0
  12370. * @apioption caption.x
  12371. */
  12372. /**
  12373. * The y position of the caption relative to the alignment within
  12374. * `chart.spacingTop` and `chart.spacingBottom`.
  12375. *
  12376. * @type {number}
  12377. * @apioption caption.y
  12378. */
  12379. /**
  12380. * The caption text of the chart.
  12381. *
  12382. * @sample {highcharts} highcharts/caption/text/
  12383. * Custom caption
  12384. */
  12385. text: '',
  12386. /**
  12387. * The horizontal alignment of the caption. Can be one of "left",
  12388. * "center" and "right".
  12389. *
  12390. * @type {Highcharts.AlignValue}
  12391. */
  12392. align: 'left',
  12393. /**
  12394. * The vertical alignment of the caption. Can be one of `"top"`,
  12395. * `"middle"` and `"bottom"`. When middle, the caption behaves as
  12396. * floating.
  12397. *
  12398. * @type {Highcharts.VerticalAlignValue}
  12399. */
  12400. verticalAlign: 'bottom'
  12401. },
  12402. /**
  12403. * The plotOptions is a wrapper object for config objects for each series
  12404. * type. The config objects for each series can also be overridden for
  12405. * each series item as given in the series array.
  12406. *
  12407. * Configuration options for the series are given in three levels. Options
  12408. * for all series in a chart are given in the [plotOptions.series](
  12409. * #plotOptions.series) object. Then options for all series of a specific
  12410. * type are given in the plotOptions of that type, for example
  12411. * `plotOptions.line`. Next, options for one single series are given in
  12412. * [the series array](#series).
  12413. */
  12414. plotOptions: {},
  12415. /**
  12416. * HTML labels that can be positioned anywhere in the chart area.
  12417. *
  12418. * This option is deprecated since v7.1.2. Instead, use
  12419. * [annotations](#annotations) that support labels.
  12420. *
  12421. * @deprecated
  12422. * @product highcharts highstock
  12423. */
  12424. labels: {
  12425. /**
  12426. * An HTML label that can be positioned anywhere in the chart area.
  12427. *
  12428. * @deprecated
  12429. * @type {Array<*>}
  12430. * @apioption labels.items
  12431. */
  12432. /**
  12433. * Inner HTML or text for the label.
  12434. *
  12435. * @deprecated
  12436. * @type {string}
  12437. * @apioption labels.items.html
  12438. */
  12439. /**
  12440. * CSS styles for each label. To position the label, use left and top
  12441. * like this:
  12442. * ```js
  12443. * style: {
  12444. * left: '100px',
  12445. * top: '100px'
  12446. * }
  12447. * ```
  12448. *
  12449. * @deprecated
  12450. * @type {Highcharts.CSSObject}
  12451. * @apioption labels.items.style
  12452. */
  12453. /**
  12454. * Shared CSS styles for all labels.
  12455. *
  12456. * @deprecated
  12457. * @type {Highcharts.CSSObject}
  12458. * @default {"color": "#333333", "position": "absolute"}
  12459. */
  12460. style: {
  12461. /**
  12462. * @ignore-option
  12463. */
  12464. position: 'absolute',
  12465. /**
  12466. * @ignore-option
  12467. */
  12468. color: '#333333'
  12469. }
  12470. },
  12471. /**
  12472. * The legend is a box containing a symbol and name for each series
  12473. * item or point item in the chart. Each series (or points in case
  12474. * of pie charts) is represented by a symbol and its name in the legend.
  12475. *
  12476. * It is possible to override the symbol creator function and create
  12477. * [custom legend symbols](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/studies/legend-custom-symbol/).
  12478. *
  12479. * @productdesc {highmaps}
  12480. * A Highmaps legend by default contains one legend item per series, but if
  12481. * a `colorAxis` is defined, the axis will be displayed in the legend.
  12482. * Either as a gradient, or as multiple legend items for `dataClasses`.
  12483. */
  12484. legend: {
  12485. /**
  12486. * The background color of the legend.
  12487. *
  12488. * @see In styled mode, the legend background fill can be applied with
  12489. * the `.highcharts-legend-box` class.
  12490. *
  12491. * @sample {highcharts} highcharts/legend/backgroundcolor/
  12492. * Yellowish background
  12493. * @sample {highstock} stock/legend/align/
  12494. * Various legend options
  12495. * @sample {highmaps} maps/legend/border-background/
  12496. * Border and background options
  12497. *
  12498. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12499. * @apioption legend.backgroundColor
  12500. */
  12501. /**
  12502. * The width of the drawn border around the legend.
  12503. *
  12504. * @see In styled mode, the legend border stroke width can be applied
  12505. * with the `.highcharts-legend-box` class.
  12506. *
  12507. * @sample {highcharts} highcharts/legend/borderwidth/
  12508. * 2px border width
  12509. * @sample {highstock} stock/legend/align/
  12510. * Various legend options
  12511. * @sample {highmaps} maps/legend/border-background/
  12512. * Border and background options
  12513. *
  12514. * @type {number}
  12515. * @default 0
  12516. * @apioption legend.borderWidth
  12517. */
  12518. /**
  12519. * Enable or disable the legend. There is also a series-specific option,
  12520. * [showInLegend](#plotOptions.series.showInLegend), that can hide the
  12521. * series from the legend. In some series types this is `false` by
  12522. * default, so it must set to `true` in order to show the legend for the
  12523. * series.
  12524. *
  12525. * @sample {highcharts} highcharts/legend/enabled-false/ Legend disabled
  12526. * @sample {highstock} stock/legend/align/ Various legend options
  12527. * @sample {highmaps} maps/legend/enabled-false/ Legend disabled
  12528. *
  12529. * @default {highstock} false
  12530. * @default {highmaps} true
  12531. * @default {gantt} false
  12532. */
  12533. enabled: true,
  12534. /**
  12535. * The horizontal alignment of the legend box within the chart area.
  12536. * Valid values are `left`, `center` and `right`.
  12537. *
  12538. * In the case that the legend is aligned in a corner position, the
  12539. * `layout` option will determine whether to place it above/below
  12540. * or on the side of the plot area.
  12541. *
  12542. * @sample {highcharts} highcharts/legend/align/
  12543. * Legend at the right of the chart
  12544. * @sample {highstock} stock/legend/align/
  12545. * Various legend options
  12546. * @sample {highmaps} maps/legend/alignment/
  12547. * Legend alignment
  12548. *
  12549. * @type {Highcharts.AlignValue}
  12550. * @since 2.0
  12551. */
  12552. align: 'center',
  12553. /**
  12554. * If the [layout](legend.layout) is `horizontal` and the legend items
  12555. * span over two lines or more, whether to align the items into vertical
  12556. * columns. Setting this to `false` makes room for more items, but will
  12557. * look more messy.
  12558. *
  12559. * @since 6.1.0
  12560. */
  12561. alignColumns: true,
  12562. /**
  12563. * When the legend is floating, the plot area ignores it and is allowed
  12564. * to be placed below it.
  12565. *
  12566. * @sample {highcharts} highcharts/legend/floating-false/
  12567. * False by default
  12568. * @sample {highcharts} highcharts/legend/floating-true/
  12569. * True
  12570. * @sample {highmaps} maps/legend/alignment/
  12571. * Floating legend
  12572. *
  12573. * @type {boolean}
  12574. * @default false
  12575. * @since 2.1
  12576. * @apioption legend.floating
  12577. */
  12578. /**
  12579. * The layout of the legend items. Can be one of `horizontal` or
  12580. * `vertical` or `proximate`. When `proximate`, the legend items will be
  12581. * placed as close as possible to the graphs they're representing,
  12582. * except in inverted charts or when the legend position doesn't allow
  12583. * it.
  12584. *
  12585. * @sample {highcharts} highcharts/legend/layout-horizontal/
  12586. * Horizontal by default
  12587. * @sample {highcharts} highcharts/legend/layout-vertical/
  12588. * Vertical
  12589. * @sample highcharts/legend/layout-proximate
  12590. * Labels proximate to the data
  12591. * @sample {highstock} stock/legend/layout-horizontal/
  12592. * Horizontal by default
  12593. * @sample {highmaps} maps/legend/padding-itemmargin/
  12594. * Vertical with data classes
  12595. * @sample {highmaps} maps/legend/layout-vertical/
  12596. * Vertical with color axis gradient
  12597. *
  12598. * @validvalue ["horizontal", "vertical", "proximate"]
  12599. */
  12600. layout: 'horizontal',
  12601. /**
  12602. * In a legend with horizontal layout, the itemDistance defines the
  12603. * pixel distance between each item.
  12604. *
  12605. * @sample {highcharts} highcharts/legend/layout-horizontal/
  12606. * 50px item distance
  12607. * @sample {highstock} highcharts/legend/layout-horizontal/
  12608. * 50px item distance
  12609. *
  12610. * @type {number}
  12611. * @default {highcharts} 20
  12612. * @default {highstock} 20
  12613. * @default {highmaps} 8
  12614. * @since 3.0.3
  12615. * @apioption legend.itemDistance
  12616. */
  12617. /**
  12618. * The pixel bottom margin for each legend item.
  12619. *
  12620. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  12621. * Padding and item margins demonstrated
  12622. * @sample {highmaps} maps/legend/padding-itemmargin/
  12623. * Padding and item margins demonstrated
  12624. *
  12625. * @type {number}
  12626. * @default 0
  12627. * @since 2.2.0
  12628. * @apioption legend.itemMarginBottom
  12629. */
  12630. /**
  12631. * The pixel top margin for each legend item.
  12632. *
  12633. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  12634. * Padding and item margins demonstrated
  12635. * @sample {highmaps} maps/legend/padding-itemmargin/
  12636. * Padding and item margins demonstrated
  12637. *
  12638. * @type {number}
  12639. * @default 0
  12640. * @since 2.2.0
  12641. * @apioption legend.itemMarginTop
  12642. */
  12643. /**
  12644. * The width for each legend item. By default the items are laid out
  12645. * successively. In a [horizontal layout](legend.layout), if the items
  12646. * are laid out across two rows or more, they will be vertically aligned
  12647. * depending on the [legend.alignColumns](legend.alignColumns) option.
  12648. *
  12649. * @sample {highcharts} highcharts/legend/itemwidth-default/
  12650. * Undefined by default
  12651. * @sample {highcharts} highcharts/legend/itemwidth-80/
  12652. * 80 for aligned legend items
  12653. *
  12654. * @type {number}
  12655. * @since 2.0
  12656. * @apioption legend.itemWidth
  12657. */
  12658. /**
  12659. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  12660. * for each legend label. Available variables relates to properties on
  12661. * the series, or the point in case of pies.
  12662. *
  12663. * @type {string}
  12664. * @default {name}
  12665. * @since 1.3
  12666. * @apioption legend.labelFormat
  12667. */
  12668. /* eslint-disable valid-jsdoc */
  12669. /**
  12670. * Callback function to format each of the series' labels. The `this`
  12671. * keyword refers to the series object, or the point object in case of
  12672. * pie charts. By default the series or point name is printed.
  12673. *
  12674. * @productdesc {highmaps}
  12675. * In Highmaps the context can also be a data class in case of a
  12676. * `colorAxis`.
  12677. *
  12678. * @sample {highcharts} highcharts/legend/labelformatter/
  12679. * Add text
  12680. * @sample {highmaps} maps/legend/labelformatter/
  12681. * Data classes with label formatter
  12682. *
  12683. * @type {Highcharts.FormatterCallbackFunction<Point|Series>}
  12684. */
  12685. labelFormatter: function () {
  12686. /** eslint-enable valid-jsdoc */
  12687. return this.name;
  12688. },
  12689. /**
  12690. * Line height for the legend items. Deprecated as of 2.1\. Instead,
  12691. * the line height for each item can be set using
  12692. * `itemStyle.lineHeight`, and the padding between items using
  12693. * `itemMarginTop` and `itemMarginBottom`.
  12694. *
  12695. * @sample {highcharts} highcharts/legend/lineheight/
  12696. * Setting padding
  12697. *
  12698. * @deprecated
  12699. *
  12700. * @type {number}
  12701. * @default 16
  12702. * @since 2.0
  12703. * @product highcharts gantt
  12704. * @apioption legend.lineHeight
  12705. */
  12706. /**
  12707. * If the plot area sized is calculated automatically and the legend is
  12708. * not floating, the legend margin is the space between the legend and
  12709. * the axis labels or plot area.
  12710. *
  12711. * @sample {highcharts} highcharts/legend/margin-default/
  12712. * 12 pixels by default
  12713. * @sample {highcharts} highcharts/legend/margin-30/
  12714. * 30 pixels
  12715. *
  12716. * @type {number}
  12717. * @default 12
  12718. * @since 2.1
  12719. * @apioption legend.margin
  12720. */
  12721. /**
  12722. * Maximum pixel height for the legend. When the maximum height is
  12723. * extended, navigation will show.
  12724. *
  12725. * @type {number}
  12726. * @since 2.3.0
  12727. * @apioption legend.maxHeight
  12728. */
  12729. /**
  12730. * The color of the drawn border around the legend.
  12731. *
  12732. * @see In styled mode, the legend border stroke can be applied with the
  12733. * `.highcharts-legend-box` class.
  12734. *
  12735. * @sample {highcharts} highcharts/legend/bordercolor/
  12736. * Brown border
  12737. * @sample {highstock} stock/legend/align/
  12738. * Various legend options
  12739. * @sample {highmaps} maps/legend/border-background/
  12740. * Border and background options
  12741. *
  12742. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12743. */
  12744. borderColor: '#999999',
  12745. /**
  12746. * The border corner radius of the legend.
  12747. *
  12748. * @sample {highcharts} highcharts/legend/borderradius-default/
  12749. * Square by default
  12750. * @sample {highcharts} highcharts/legend/borderradius-round/
  12751. * 5px rounded
  12752. * @sample {highmaps} maps/legend/border-background/
  12753. * Border and background options
  12754. */
  12755. borderRadius: 0,
  12756. /**
  12757. * Options for the paging or navigation appearing when the legend is
  12758. * overflown. Navigation works well on screen, but not in static
  12759. * exported images. One way of working around that is to
  12760. * [increase the chart height in
  12761. * export](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/legend/navigation-enabled-false/).
  12762. */
  12763. navigation: {
  12764. /**
  12765. * How to animate the pages when navigating up or down. A value of
  12766. * `true` applies the default navigation given in the
  12767. * `chart.animation` option. Additional options can be given as an
  12768. * object containing values for easing and duration.
  12769. *
  12770. * @sample {highcharts} highcharts/legend/navigation/
  12771. * Legend page navigation demonstrated
  12772. * @sample {highstock} highcharts/legend/navigation/
  12773. * Legend page navigation demonstrated
  12774. *
  12775. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  12776. * @default true
  12777. * @since 2.2.4
  12778. * @apioption legend.navigation.animation
  12779. */
  12780. /**
  12781. * The pixel size of the up and down arrows in the legend paging
  12782. * navigation.
  12783. *
  12784. * @sample {highcharts} highcharts/legend/navigation/
  12785. * Legend page navigation demonstrated
  12786. * @sample {highstock} highcharts/legend/navigation/
  12787. * Legend page navigation demonstrated
  12788. *
  12789. * @type {number}
  12790. * @default 12
  12791. * @since 2.2.4
  12792. * @apioption legend.navigation.arrowSize
  12793. */
  12794. /**
  12795. * Whether to enable the legend navigation. In most cases, disabling
  12796. * the navigation results in an unwanted overflow.
  12797. *
  12798. * See also the [adapt chart to legend](
  12799. * https://www.highcharts.com/products/plugin-registry/single/8/Adapt-Chart-To-Legend)
  12800. * plugin for a solution to extend the chart height to make room for
  12801. * the legend, optionally in exported charts only.
  12802. *
  12803. * @type {boolean}
  12804. * @default true
  12805. * @since 4.2.4
  12806. * @apioption legend.navigation.enabled
  12807. */
  12808. /**
  12809. * Text styles for the legend page navigation.
  12810. *
  12811. * @see In styled mode, the navigation items are styled with the
  12812. * `.highcharts-legend-navigation` class.
  12813. *
  12814. * @sample {highcharts} highcharts/legend/navigation/
  12815. * Legend page navigation demonstrated
  12816. * @sample {highstock} highcharts/legend/navigation/
  12817. * Legend page navigation demonstrated
  12818. *
  12819. * @type {Highcharts.CSSObject}
  12820. * @since 2.2.4
  12821. * @apioption legend.navigation.style
  12822. */
  12823. /**
  12824. * The color for the active up or down arrow in the legend page
  12825. * navigation.
  12826. *
  12827. * @see In styled mode, the active arrow be styled with the
  12828. * `.highcharts-legend-nav-active` class.
  12829. *
  12830. * @sample {highcharts} highcharts/legend/navigation/
  12831. * Legend page navigation demonstrated
  12832. * @sample {highstock} highcharts/legend/navigation/
  12833. * Legend page navigation demonstrated
  12834. *
  12835. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12836. * @since 2.2.4
  12837. */
  12838. activeColor: '#003399',
  12839. /**
  12840. * The color of the inactive up or down arrow in the legend page
  12841. * navigation. .
  12842. *
  12843. * @see In styled mode, the inactive arrow be styled with the
  12844. * `.highcharts-legend-nav-inactive` class.
  12845. *
  12846. * @sample {highcharts} highcharts/legend/navigation/
  12847. * Legend page navigation demonstrated
  12848. * @sample {highstock} highcharts/legend/navigation/
  12849. * Legend page navigation demonstrated
  12850. *
  12851. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12852. * @since 2.2.4
  12853. */
  12854. inactiveColor: '#cccccc'
  12855. },
  12856. /**
  12857. * The inner padding of the legend box.
  12858. *
  12859. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  12860. * Padding and item margins demonstrated
  12861. * @sample {highmaps} maps/legend/padding-itemmargin/
  12862. * Padding and item margins demonstrated
  12863. *
  12864. * @type {number}
  12865. * @default 8
  12866. * @since 2.2.0
  12867. * @apioption legend.padding
  12868. */
  12869. /**
  12870. * Whether to reverse the order of the legend items compared to the
  12871. * order of the series or points as defined in the configuration object.
  12872. *
  12873. * @see [yAxis.reversedStacks](#yAxis.reversedStacks),
  12874. * [series.legendIndex](#series.legendIndex)
  12875. *
  12876. * @sample {highcharts} highcharts/legend/reversed/
  12877. * Stacked bar with reversed legend
  12878. *
  12879. * @type {boolean}
  12880. * @default false
  12881. * @since 1.2.5
  12882. * @apioption legend.reversed
  12883. */
  12884. /**
  12885. * Whether to show the symbol on the right side of the text rather than
  12886. * the left side. This is common in Arabic and Hebraic.
  12887. *
  12888. * @sample {highcharts} highcharts/legend/rtl/
  12889. * Symbol to the right
  12890. *
  12891. * @type {boolean}
  12892. * @default false
  12893. * @since 2.2
  12894. * @apioption legend.rtl
  12895. */
  12896. /**
  12897. * CSS styles for the legend area. In the 1.x versions the position
  12898. * of the legend area was determined by CSS. In 2.x, the position is
  12899. * determined by properties like `align`, `verticalAlign`, `x` and `y`,
  12900. * but the styles are still parsed for backwards compatibility.
  12901. *
  12902. * @deprecated
  12903. *
  12904. * @type {Highcharts.CSSObject}
  12905. * @product highcharts highstock
  12906. * @apioption legend.style
  12907. */
  12908. /**
  12909. * CSS styles for each legend item. Only a subset of CSS is supported,
  12910. * notably those options related to text. The default `textOverflow`
  12911. * property makes long texts truncate. Set it to `undefined` to wrap
  12912. * text instead. A `width` property can be added to control the text
  12913. * width.
  12914. *
  12915. * @see In styled mode, the legend items can be styled with the
  12916. * `.highcharts-legend-item` class.
  12917. *
  12918. * @sample {highcharts} highcharts/legend/itemstyle/
  12919. * Bold black text
  12920. * @sample {highmaps} maps/legend/itemstyle/
  12921. * Item text styles
  12922. *
  12923. * @type {Highcharts.CSSObject}
  12924. * @default {"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}
  12925. */
  12926. itemStyle: {
  12927. /**
  12928. * @ignore
  12929. */
  12930. color: '#333333',
  12931. /**
  12932. * @ignore
  12933. */
  12934. cursor: 'pointer',
  12935. /**
  12936. * @ignore
  12937. */
  12938. fontSize: '12px',
  12939. /**
  12940. * @ignore
  12941. */
  12942. fontWeight: 'bold',
  12943. /**
  12944. * @ignore
  12945. */
  12946. textOverflow: 'ellipsis'
  12947. },
  12948. /**
  12949. * CSS styles for each legend item in hover mode. Only a subset of
  12950. * CSS is supported, notably those options related to text. Properties
  12951. * are inherited from `style` unless overridden here.
  12952. *
  12953. * @see In styled mode, the hovered legend items can be styled with
  12954. * the `.highcharts-legend-item:hover` pesudo-class.
  12955. *
  12956. * @sample {highcharts} highcharts/legend/itemhoverstyle/
  12957. * Red on hover
  12958. * @sample {highmaps} maps/legend/itemstyle/
  12959. * Item text styles
  12960. *
  12961. * @type {Highcharts.CSSObject}
  12962. * @default {"color": "#000000"}
  12963. */
  12964. itemHoverStyle: {
  12965. /**
  12966. * @ignore
  12967. */
  12968. color: '#000000'
  12969. },
  12970. /**
  12971. * CSS styles for each legend item when the corresponding series or
  12972. * point is hidden. Only a subset of CSS is supported, notably those
  12973. * options related to text. Properties are inherited from `style`
  12974. * unless overridden here.
  12975. *
  12976. * @see In styled mode, the hidden legend items can be styled with
  12977. * the `.highcharts-legend-item-hidden` class.
  12978. *
  12979. * @sample {highcharts} highcharts/legend/itemhiddenstyle/
  12980. * Darker gray color
  12981. *
  12982. * @type {Highcharts.CSSObject}
  12983. * @default {"color": "#cccccc"}
  12984. */
  12985. itemHiddenStyle: {
  12986. /**
  12987. * @ignore
  12988. */
  12989. color: '#cccccc'
  12990. },
  12991. /**
  12992. * Whether to apply a drop shadow to the legend. A `backgroundColor`
  12993. * also needs to be applied for this to take effect. The shadow can be
  12994. * an object configuration containing `color`, `offsetX`, `offsetY`,
  12995. * `opacity` and `width`.
  12996. *
  12997. * @sample {highcharts} highcharts/legend/shadow/
  12998. * White background and drop shadow
  12999. * @sample {highstock} stock/legend/align/
  13000. * Various legend options
  13001. * @sample {highmaps} maps/legend/border-background/
  13002. * Border and background options
  13003. *
  13004. * @type {boolean|Highcharts.CSSObject}
  13005. */
  13006. shadow: false,
  13007. /**
  13008. * Default styling for the checkbox next to a legend item when
  13009. * `showCheckbox` is true.
  13010. *
  13011. * @type {Highcharts.CSSObject}
  13012. * @default {"width": "13px", "height": "13px", "position":"absolute"}
  13013. */
  13014. itemCheckboxStyle: {
  13015. /**
  13016. * @ignore
  13017. */
  13018. position: 'absolute',
  13019. /**
  13020. * @ignore
  13021. */
  13022. width: '13px',
  13023. /**
  13024. * @ignore
  13025. */
  13026. height: '13px'
  13027. },
  13028. // itemWidth: undefined,
  13029. /**
  13030. * When this is true, the legend symbol width will be the same as
  13031. * the symbol height, which in turn defaults to the font size of the
  13032. * legend items.
  13033. *
  13034. * @since 5.0.0
  13035. */
  13036. squareSymbol: true,
  13037. /**
  13038. * The pixel height of the symbol for series types that use a rectangle
  13039. * in the legend. Defaults to the font size of legend items.
  13040. *
  13041. * @productdesc {highmaps}
  13042. * In Highmaps, when the symbol is the gradient of a vertical color
  13043. * axis, the height defaults to 200.
  13044. *
  13045. * @sample {highmaps} maps/legend/layout-vertical-sized/
  13046. * Sized vertical gradient
  13047. * @sample {highmaps} maps/legend/padding-itemmargin/
  13048. * No distance between data classes
  13049. *
  13050. * @type {number}
  13051. * @since 3.0.8
  13052. * @apioption legend.symbolHeight
  13053. */
  13054. /**
  13055. * The border radius of the symbol for series types that use a rectangle
  13056. * in the legend. Defaults to half the `symbolHeight`.
  13057. *
  13058. * @sample {highcharts} highcharts/legend/symbolradius/
  13059. * Round symbols
  13060. * @sample {highstock} highcharts/legend/symbolradius/
  13061. * Round symbols
  13062. * @sample {highmaps} highcharts/legend/symbolradius/
  13063. * Round symbols
  13064. *
  13065. * @type {number}
  13066. * @since 3.0.8
  13067. * @apioption legend.symbolRadius
  13068. */
  13069. /**
  13070. * The pixel width of the legend item symbol. When the `squareSymbol`
  13071. * option is set, this defaults to the `symbolHeight`, otherwise 16.
  13072. *
  13073. * @productdesc {highmaps}
  13074. * In Highmaps, when the symbol is the gradient of a horizontal color
  13075. * axis, the width defaults to 200.
  13076. *
  13077. * @sample {highcharts} highcharts/legend/symbolwidth/
  13078. * Greater symbol width and padding
  13079. * @sample {highmaps} maps/legend/padding-itemmargin/
  13080. * Padding and item margins demonstrated
  13081. * @sample {highmaps} maps/legend/layout-vertical-sized/
  13082. * Sized vertical gradient
  13083. *
  13084. * @type {number}
  13085. * @apioption legend.symbolWidth
  13086. */
  13087. /**
  13088. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  13089. * to render the legend item texts.
  13090. *
  13091. * Prior to 4.1.7, when using HTML, [legend.navigation](
  13092. * #legend.navigation) was disabled.
  13093. *
  13094. * @type {boolean}
  13095. * @default false
  13096. * @apioption legend.useHTML
  13097. */
  13098. /**
  13099. * The width of the legend box. If a number is set, it translates to
  13100. * pixels. Since v7.0.2 it allows setting a percent string of the full
  13101. * chart width, for example `40%`.
  13102. *
  13103. * Defaults to the full chart width for legends below or above the
  13104. * chart, half the chart width for legends to the left and right.
  13105. *
  13106. * @sample {highcharts} highcharts/legend/width/
  13107. * Aligned to the plot area
  13108. * @sample {highcharts} highcharts/legend/width-percent/
  13109. * A percent of the chart width
  13110. *
  13111. * @type {number|string}
  13112. * @since 2.0
  13113. * @apioption legend.width
  13114. */
  13115. /**
  13116. * The pixel padding between the legend item symbol and the legend
  13117. * item text.
  13118. *
  13119. * @sample {highcharts} highcharts/legend/symbolpadding/
  13120. * Greater symbol width and padding
  13121. */
  13122. symbolPadding: 5,
  13123. /**
  13124. * The vertical alignment of the legend box. Can be one of `top`,
  13125. * `middle` or `bottom`. Vertical position can be further determined
  13126. * by the `y` option.
  13127. *
  13128. * In the case that the legend is aligned in a corner position, the
  13129. * `layout` option will determine whether to place it above/below
  13130. * or on the side of the plot area.
  13131. *
  13132. * When the [layout](#legend.layout) option is `proximate`, the
  13133. * `verticalAlign` option doesn't apply.
  13134. *
  13135. * @sample {highcharts} highcharts/legend/verticalalign/
  13136. * Legend 100px from the top of the chart
  13137. * @sample {highstock} stock/legend/align/
  13138. * Various legend options
  13139. * @sample {highmaps} maps/legend/alignment/
  13140. * Legend alignment
  13141. *
  13142. * @type {Highcharts.VerticalAlignValue}
  13143. * @since 2.0
  13144. */
  13145. verticalAlign: 'bottom',
  13146. // width: undefined,
  13147. /**
  13148. * The x offset of the legend relative to its horizontal alignment
  13149. * `align` within chart.spacingLeft and chart.spacingRight. Negative
  13150. * x moves it to the left, positive x moves it to the right.
  13151. *
  13152. * @sample {highcharts} highcharts/legend/width/
  13153. * Aligned to the plot area
  13154. *
  13155. * @since 2.0
  13156. */
  13157. x: 0,
  13158. /**
  13159. * The vertical offset of the legend relative to it's vertical alignment
  13160. * `verticalAlign` within chart.spacingTop and chart.spacingBottom.
  13161. * Negative y moves it up, positive y moves it down.
  13162. *
  13163. * @sample {highcharts} highcharts/legend/verticalalign/
  13164. * Legend 100px from the top of the chart
  13165. * @sample {highstock} stock/legend/align/
  13166. * Various legend options
  13167. * @sample {highmaps} maps/legend/alignment/
  13168. * Legend alignment
  13169. *
  13170. * @since 2.0
  13171. */
  13172. y: 0,
  13173. /**
  13174. * A title to be added on top of the legend.
  13175. *
  13176. * @sample {highcharts} highcharts/legend/title/
  13177. * Legend title
  13178. * @sample {highmaps} maps/legend/alignment/
  13179. * Legend with title
  13180. *
  13181. * @since 3.0
  13182. */
  13183. title: {
  13184. /**
  13185. * A text or HTML string for the title.
  13186. *
  13187. * @type {string}
  13188. * @since 3.0
  13189. * @apioption legend.title.text
  13190. */
  13191. /**
  13192. * Generic CSS styles for the legend title.
  13193. *
  13194. * @see In styled mode, the legend title is styled with the
  13195. * `.highcharts-legend-title` class.
  13196. *
  13197. * @type {Highcharts.CSSObject}
  13198. * @default {"fontWeight": "bold"}
  13199. * @since 3.0
  13200. */
  13201. style: {
  13202. /**
  13203. * @ignore
  13204. */
  13205. fontWeight: 'bold'
  13206. }
  13207. }
  13208. },
  13209. /**
  13210. * The loading options control the appearance of the loading screen
  13211. * that covers the plot area on chart operations. This screen only
  13212. * appears after an explicit call to `chart.showLoading()`. It is a
  13213. * utility for developers to communicate to the end user that something
  13214. * is going on, for example while retrieving new data via an XHR connection.
  13215. * The "Loading..." text itself is not part of this configuration
  13216. * object, but part of the `lang` object.
  13217. */
  13218. loading: {
  13219. /**
  13220. * The duration in milliseconds of the fade out effect.
  13221. *
  13222. * @sample highcharts/loading/hideduration/
  13223. * Fade in and out over a second
  13224. *
  13225. * @type {number}
  13226. * @default 100
  13227. * @since 1.2.0
  13228. * @apioption loading.hideDuration
  13229. */
  13230. /**
  13231. * The duration in milliseconds of the fade in effect.
  13232. *
  13233. * @sample highcharts/loading/hideduration/
  13234. * Fade in and out over a second
  13235. *
  13236. * @type {number}
  13237. * @default 100
  13238. * @since 1.2.0
  13239. * @apioption loading.showDuration
  13240. */
  13241. /**
  13242. * CSS styles for the loading label `span`.
  13243. *
  13244. * @see In styled mode, the loading label is styled with the
  13245. * `.highcharts-loading-inner` class.
  13246. *
  13247. * @sample {highcharts|highmaps} highcharts/loading/labelstyle/
  13248. * Vertically centered
  13249. * @sample {highstock} stock/loading/general/
  13250. * Label styles
  13251. *
  13252. * @type {Highcharts.CSSObject}
  13253. * @default {"fontWeight": "bold", "position": "relative", "top": "45%"}
  13254. * @since 1.2.0
  13255. */
  13256. labelStyle: {
  13257. /**
  13258. * @ignore
  13259. */
  13260. fontWeight: 'bold',
  13261. /**
  13262. * @ignore
  13263. */
  13264. position: 'relative',
  13265. /**
  13266. * @ignore
  13267. */
  13268. top: '45%'
  13269. },
  13270. /**
  13271. * CSS styles for the loading screen that covers the plot area.
  13272. *
  13273. * In styled mode, the loading label is styled with the
  13274. * `.highcharts-loading` class.
  13275. *
  13276. * @sample {highcharts|highmaps} highcharts/loading/style/
  13277. * Gray plot area, white text
  13278. * @sample {highstock} stock/loading/general/
  13279. * Gray plot area, white text
  13280. *
  13281. * @type {Highcharts.CSSObject}
  13282. * @default {"position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center"}
  13283. * @since 1.2.0
  13284. */
  13285. style: {
  13286. /**
  13287. * @ignore
  13288. */
  13289. position: 'absolute',
  13290. /**
  13291. * @ignore
  13292. */
  13293. backgroundColor: '#ffffff',
  13294. /**
  13295. * @ignore
  13296. */
  13297. opacity: 0.5,
  13298. /**
  13299. * @ignore
  13300. */
  13301. textAlign: 'center'
  13302. }
  13303. },
  13304. /**
  13305. * Options for the tooltip that appears when the user hovers over a
  13306. * series or point.
  13307. *
  13308. * @declare Highcharts.TooltipOptions
  13309. */
  13310. tooltip: {
  13311. /**
  13312. * The color of the tooltip border. When `undefined`, the border takes
  13313. * the color of the corresponding series or point.
  13314. *
  13315. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13316. * Follow series by default
  13317. * @sample {highcharts} highcharts/tooltip/bordercolor-black/
  13318. * Black border
  13319. * @sample {highstock} stock/tooltip/general/
  13320. * Styled tooltip
  13321. * @sample {highmaps} maps/tooltip/background-border/
  13322. * Background and border demo
  13323. *
  13324. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  13325. * @apioption tooltip.borderColor
  13326. */
  13327. /**
  13328. * A CSS class name to apply to the tooltip's container div,
  13329. * allowing unique CSS styling for each chart.
  13330. *
  13331. * @type {string}
  13332. * @apioption tooltip.className
  13333. */
  13334. /**
  13335. * Since 4.1, the crosshair definitions are moved to the Axis object
  13336. * in order for a better separation from the tooltip. See
  13337. * [xAxis.crosshair](#xAxis.crosshair).
  13338. *
  13339. * @sample {highcharts} highcharts/tooltip/crosshairs-x/
  13340. * Enable a crosshair for the x value
  13341. *
  13342. * @deprecated
  13343. *
  13344. * @type {*}
  13345. * @default true
  13346. * @apioption tooltip.crosshairs
  13347. */
  13348. /**
  13349. * Distance from point to tooltip in pixels.
  13350. *
  13351. * @type {number}
  13352. * @default 16
  13353. * @apioption tooltip.distance
  13354. */
  13355. /**
  13356. * Whether the tooltip should follow the mouse as it moves across
  13357. * columns, pie slices and other point types with an extent.
  13358. * By default it behaves this way for pie, polygon, map, sankey
  13359. * and wordcloud series by override in the `plotOptions`
  13360. * for those series types.
  13361. *
  13362. * For touch moves to behave the same way, [followTouchMove](
  13363. * #tooltip.followTouchMove) must be `true` also.
  13364. *
  13365. * @type {boolean}
  13366. * @default {highcharts} false
  13367. * @default {highstock} false
  13368. * @default {highmaps} true
  13369. * @since 3.0
  13370. * @apioption tooltip.followPointer
  13371. */
  13372. /**
  13373. * Whether the tooltip should update as the finger moves on a touch
  13374. * device. If this is `true` and [chart.panning](#chart.panning) is
  13375. * set,`followTouchMove` will take over one-finger touches, so the user
  13376. * needs to use two fingers for zooming and panning.
  13377. *
  13378. * Note the difference to [followPointer](#tooltip.followPointer) that
  13379. * only defines the _position_ of the tooltip. If `followPointer` is
  13380. * false in for example a column series, the tooltip will show above or
  13381. * below the column, but as `followTouchMove` is true, the tooltip will
  13382. * jump from column to column as the user swipes across the plot area.
  13383. *
  13384. * @type {boolean}
  13385. * @default {highcharts} true
  13386. * @default {highstock} true
  13387. * @default {highmaps} false
  13388. * @since 3.0.1
  13389. * @apioption tooltip.followTouchMove
  13390. */
  13391. /**
  13392. * Callback function to format the text of the tooltip from scratch. In
  13393. * case of single or [shared](#tooltip.shared) tooltips, a string should
  13394. * be returned. In case of [split](#tooltip.split) tooltips, it should
  13395. * return an array where the first item is the header, and subsequent
  13396. * items are mapped to the points. Return `false` to disable tooltip for
  13397. * a specific point on series.
  13398. *
  13399. * A subset of HTML is supported. Unless `useHTML` is true, the HTML of
  13400. * the tooltip is parsed and converted to SVG, therefore this isn't a
  13401. * complete HTML renderer. The following HTML tags are supported: `b`,
  13402. * `br`, `em`, `i`, `span`, `strong`. Spans can be styled with a `style`
  13403. * attribute, but only text-related CSS, that is shared with SVG, is
  13404. * handled.
  13405. *
  13406. * The available data in the formatter differ a bit depending on whether
  13407. * the tooltip is shared or split, or belongs to a single point. In a
  13408. * shared/split tooltip, all properties except `x`, which is common for
  13409. * all points, are kept in an array, `this.points`.
  13410. *
  13411. * Available data are:
  13412. *
  13413. * - **this.percentage (not shared) /**
  13414. * **this.points[i].percentage (shared)**:
  13415. * Stacked series and pies only. The point's percentage of the total.
  13416. *
  13417. * - **this.point (not shared) / this.points[i].point (shared)**:
  13418. * The point object. The point name, if defined, is available through
  13419. * `this.point.name`.
  13420. *
  13421. * - **this.points**:
  13422. * In a shared tooltip, this is an array containing all other
  13423. * properties for each point.
  13424. *
  13425. * - **this.series (not shared) / this.points[i].series (shared)**:
  13426. * The series object. The series name is available through
  13427. * `this.series.name`.
  13428. *
  13429. * - **this.total (not shared) / this.points[i].total (shared)**:
  13430. * Stacked series only. The total value at this point's x value.
  13431. *
  13432. * - **this.x**:
  13433. * The x value. This property is the same regardless of the tooltip
  13434. * being shared or not.
  13435. *
  13436. * - **this.y (not shared) / this.points[i].y (shared)**:
  13437. * The y value.
  13438. *
  13439. * @sample {highcharts} highcharts/tooltip/formatter-simple/
  13440. * Simple string formatting
  13441. * @sample {highcharts} highcharts/tooltip/formatter-shared/
  13442. * Formatting with shared tooltip
  13443. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  13444. * Formatting with split tooltip
  13445. * @sample highcharts/tooltip/formatter-conditional-default/
  13446. * Extending default formatter
  13447. * @sample {highstock} stock/tooltip/formatter/
  13448. * Formatting with shared tooltip
  13449. * @sample {highmaps} maps/tooltip/formatter/
  13450. * String formatting
  13451. *
  13452. * @type {Highcharts.TooltipFormatterCallbackFunction}
  13453. * @apioption tooltip.formatter
  13454. */
  13455. /**
  13456. * Callback function to format the text of the tooltip for
  13457. * visible null points.
  13458. * Works analogously to [formatter](#tooltip.formatter).
  13459. *
  13460. * @sample highcharts/plotoptions/series-nullformat
  13461. * Format data label and tooltip for null point.
  13462. *
  13463. * @type {Highcharts.TooltipFormatterCallbackFunction}
  13464. * @apioption tooltip.nullFormatter
  13465. */
  13466. /**
  13467. * The number of milliseconds to wait until the tooltip is hidden when
  13468. * mouse out from a point or chart.
  13469. *
  13470. * @type {number}
  13471. * @default 500
  13472. * @since 3.0
  13473. * @apioption tooltip.hideDelay
  13474. */
  13475. /**
  13476. * Whether to allow the tooltip to render outside the chart's SVG
  13477. * element box. By default (`false`), the tooltip is rendered within the
  13478. * chart's SVG element, which results in the tooltip being aligned
  13479. * inside the chart area. For small charts, this may result in clipping
  13480. * or overlapping. When `true`, a separate SVG element is created and
  13481. * overlaid on the page, allowing the tooltip to be aligned inside the
  13482. * page itself.
  13483. *
  13484. * Defaults to `true` if `chart.scrollablePlotArea` is activated,
  13485. * otherwise `false`.
  13486. *
  13487. * @sample highcharts/tooltip/outside
  13488. * Small charts with tooltips outside
  13489. *
  13490. * @type {boolean|undefined}
  13491. * @default undefined
  13492. * @since 6.1.1
  13493. * @apioption tooltip.outside
  13494. */
  13495. /**
  13496. * A callback function for formatting the HTML output for a single point
  13497. * in the tooltip. Like the `pointFormat` string, but with more
  13498. * flexibility.
  13499. *
  13500. * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
  13501. * @since 4.1.0
  13502. * @context Highcharts.Point
  13503. * @apioption tooltip.pointFormatter
  13504. */
  13505. /**
  13506. * A callback function to place the tooltip in a default position. The
  13507. * callback receives three parameters: `labelWidth`, `labelHeight` and
  13508. * `point`, where point contains values for `plotX` and `plotY` telling
  13509. * where the reference point is in the plot area. Add `chart.plotLeft`
  13510. * and `chart.plotTop` to get the full coordinates.
  13511. *
  13512. * Since v7, when [tooltip.split](#tooltip.split) option is enabled,
  13513. * positioner is called for each of the boxes separately, including
  13514. * xAxis header. xAxis header is not a point, instead `point` argument
  13515. * contains info:
  13516. * `{ plotX: Number, plotY: Number, isHeader: Boolean }`
  13517. *
  13518. *
  13519. * The return should be an object containing x and y values, for example
  13520. * `{ x: 100, y: 100 }`.
  13521. *
  13522. * @sample {highcharts} highcharts/tooltip/positioner/
  13523. * A fixed tooltip position
  13524. * @sample {highstock} stock/tooltip/positioner/
  13525. * A fixed tooltip position on top of the chart
  13526. * @sample {highmaps} maps/tooltip/positioner/
  13527. * A fixed tooltip position
  13528. * @sample {highstock} stock/tooltip/split-positioner/
  13529. * Split tooltip with fixed positions
  13530. * @sample {highstock} stock/tooltip/positioner-scrollable-plotarea/
  13531. * Scrollable plot area combined with tooltip positioner
  13532. *
  13533. * @type {Highcharts.TooltipPositionerCallbackFunction}
  13534. * @since 2.2.4
  13535. * @apioption tooltip.positioner
  13536. */
  13537. /**
  13538. * The name of a symbol to use for the border around the tooltip. Can
  13539. * be one of: `"callout"`, `"circle"`, or `"square"`. When
  13540. * [tooltip.split](#tooltip.split)
  13541. * option is enabled, shape is applied to all boxes except header, which
  13542. * is controlled by
  13543. * [tooltip.headerShape](#tooltip.headerShape).
  13544. *
  13545. * Custom callbacks for symbol path generation can also be added to
  13546. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  13547. * [series.marker.symbol](plotOptions.line.marker.symbol).
  13548. *
  13549. * @type {Highcharts.TooltipShapeValue}
  13550. * @default callout
  13551. * @since 4.0
  13552. * @apioption tooltip.shape
  13553. */
  13554. /**
  13555. * The name of a symbol to use for the border around the tooltip
  13556. * header. Applies only when [tooltip.split](#tooltip.split) is
  13557. * enabled.
  13558. *
  13559. * Custom callbacks for symbol path generation can also be added to
  13560. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  13561. * [series.marker.symbol](plotOptions.line.marker.symbol).
  13562. *
  13563. * @see [tooltip.shape](#tooltip.shape)
  13564. *
  13565. * @sample {highstock} stock/tooltip/split-positioner/
  13566. * Different shapes for header and split boxes
  13567. *
  13568. * @type {Highcharts.TooltipShapeValue}
  13569. * @default callout
  13570. * @validvalue ["callout", "square"]
  13571. * @since 7.0
  13572. * @apioption tooltip.headerShape
  13573. */
  13574. /**
  13575. * When the tooltip is shared, the entire plot area will capture mouse
  13576. * movement or touch events. Tooltip texts for series types with ordered
  13577. * data (not pie, scatter, flags etc) will be shown in a single bubble.
  13578. * This is recommended for single series charts and for tablet/mobile
  13579. * optimized charts.
  13580. *
  13581. * See also [tooltip.split](#tooltip.split), that is better suited for
  13582. * charts with many series, especially line-type series. The
  13583. * `tooltip.split` option takes precedence over `tooltip.shared`.
  13584. *
  13585. * @sample {highcharts} highcharts/tooltip/shared-false/
  13586. * False by default
  13587. * @sample {highcharts} highcharts/tooltip/shared-true/
  13588. * True
  13589. * @sample {highcharts} highcharts/tooltip/shared-x-crosshair/
  13590. * True with x axis crosshair
  13591. * @sample {highcharts} highcharts/tooltip/shared-true-mixed-types/
  13592. * True with mixed series types
  13593. *
  13594. * @type {boolean}
  13595. * @default false
  13596. * @since 2.1
  13597. * @product highcharts highstock
  13598. * @apioption tooltip.shared
  13599. */
  13600. /**
  13601. * Split the tooltip into one label per series, with the header close
  13602. * to the axis. This is recommended over [shared](#tooltip.shared)
  13603. * tooltips for charts with multiple line series, generally making them
  13604. * easier to read. This option takes precedence over `tooltip.shared`.
  13605. *
  13606. * @productdesc {highstock} In Highstock, tooltips are split by default
  13607. * since v6.0.0. Stock charts typically contain multi-dimension points
  13608. * and multiple panes, making split tooltips the preferred layout over
  13609. * the previous `shared` tooltip.
  13610. *
  13611. * @sample highcharts/tooltip/split/
  13612. * Split tooltip
  13613. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  13614. * Split tooltip and custom formatter callback
  13615. *
  13616. * @type {boolean}
  13617. * @default {highcharts} false
  13618. * @default {highstock} true
  13619. * @since 5.0.0
  13620. * @product highcharts highstock
  13621. * @apioption tooltip.split
  13622. */
  13623. /**
  13624. * Prevents the tooltip from switching or closing, when touched or
  13625. * pointed.
  13626. *
  13627. * @sample highcharts/tooltip/stickoncontact/
  13628. * Tooltip sticks on pointer contact
  13629. *
  13630. * @type {boolean}
  13631. * @since 8.0.1
  13632. * @apioption tooltip.stickOnContact
  13633. */
  13634. /**
  13635. * Use HTML to render the contents of the tooltip instead of SVG. Using
  13636. * HTML allows advanced formatting like tables and images in the
  13637. * tooltip. It is also recommended for rtl languages as it works around
  13638. * rtl bugs in early Firefox.
  13639. *
  13640. * @sample {highcharts|highstock} highcharts/tooltip/footerformat/
  13641. * A table for value alignment
  13642. * @sample {highcharts|highstock} highcharts/tooltip/fullhtml/
  13643. * Full HTML tooltip
  13644. * @sample {highmaps} maps/tooltip/usehtml/
  13645. * Pure HTML tooltip
  13646. *
  13647. * @type {boolean}
  13648. * @default false
  13649. * @since 2.2
  13650. * @apioption tooltip.useHTML
  13651. */
  13652. /**
  13653. * How many decimals to show in each series' y value. This is
  13654. * overridable in each series' tooltip options object. The default is to
  13655. * preserve all decimals.
  13656. *
  13657. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  13658. * Set decimals, prefix and suffix for the value
  13659. * @sample {highmaps} maps/tooltip/valuedecimals/
  13660. * Set decimals, prefix and suffix for the value
  13661. *
  13662. * @type {number}
  13663. * @since 2.2
  13664. * @apioption tooltip.valueDecimals
  13665. */
  13666. /**
  13667. * A string to prepend to each series' y value. Overridable in each
  13668. * series' tooltip options object.
  13669. *
  13670. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  13671. * Set decimals, prefix and suffix for the value
  13672. * @sample {highmaps} maps/tooltip/valuedecimals/
  13673. * Set decimals, prefix and suffix for the value
  13674. *
  13675. * @type {string}
  13676. * @since 2.2
  13677. * @apioption tooltip.valuePrefix
  13678. */
  13679. /**
  13680. * A string to append to each series' y value. Overridable in each
  13681. * series' tooltip options object.
  13682. *
  13683. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  13684. * Set decimals, prefix and suffix for the value
  13685. * @sample {highmaps} maps/tooltip/valuedecimals/
  13686. * Set decimals, prefix and suffix for the value
  13687. *
  13688. * @type {string}
  13689. * @since 2.2
  13690. * @apioption tooltip.valueSuffix
  13691. */
  13692. /**
  13693. * The format for the date in the tooltip header if the X axis is a
  13694. * datetime axis. The default is a best guess based on the smallest
  13695. * distance between points in the chart.
  13696. *
  13697. * @sample {highcharts} highcharts/tooltip/xdateformat/
  13698. * A different format
  13699. *
  13700. * @type {string}
  13701. * @product highcharts highstock gantt
  13702. * @apioption tooltip.xDateFormat
  13703. */
  13704. /**
  13705. * How many decimals to show for the `point.change` value when the
  13706. * `series.compare` option is set. This is overridable in each series'
  13707. * tooltip options object. The default is to preserve all decimals.
  13708. *
  13709. * @type {number}
  13710. * @since 1.0.1
  13711. * @product highstock
  13712. * @apioption tooltip.changeDecimals
  13713. */
  13714. /**
  13715. * Enable or disable the tooltip.
  13716. *
  13717. * @sample {highcharts} highcharts/tooltip/enabled/
  13718. * Disabled
  13719. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  13720. * Disable tooltip and show values on chart instead
  13721. */
  13722. enabled: true,
  13723. /**
  13724. * Enable or disable animation of the tooltip.
  13725. *
  13726. * @type {boolean}
  13727. * @default true
  13728. * @since 2.3.0
  13729. */
  13730. animation: svg,
  13731. /**
  13732. * The radius of the rounded border corners.
  13733. *
  13734. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13735. * 5px by default
  13736. * @sample {highcharts} highcharts/tooltip/borderradius-0/
  13737. * Square borders
  13738. * @sample {highmaps} maps/tooltip/background-border/
  13739. * Background and border demo
  13740. */
  13741. borderRadius: 3,
  13742. /**
  13743. * For series on a datetime axes, the date format in the tooltip's
  13744. * header will by default be guessed based on the closest data points.
  13745. * This member gives the default string representations used for
  13746. * each unit. For an overview of the replacement codes, see
  13747. * [dateFormat](/class-reference/Highcharts#dateFormat).
  13748. *
  13749. * @see [xAxis.dateTimeLabelFormats](#xAxis.dateTimeLabelFormats)
  13750. *
  13751. * @type {Highcharts.Dictionary<string>}
  13752. * @product highcharts highstock gantt
  13753. */
  13754. dateTimeLabelFormats: {
  13755. /** @internal */
  13756. millisecond: '%A, %b %e, %H:%M:%S.%L',
  13757. /** @internal */
  13758. second: '%A, %b %e, %H:%M:%S',
  13759. /** @internal */
  13760. minute: '%A, %b %e, %H:%M',
  13761. /** @internal */
  13762. hour: '%A, %b %e, %H:%M',
  13763. /** @internal */
  13764. day: '%A, %b %e, %Y',
  13765. /** @internal */
  13766. week: 'Week from %A, %b %e, %Y',
  13767. /** @internal */
  13768. month: '%B %Y',
  13769. /** @internal */
  13770. year: '%Y'
  13771. },
  13772. /**
  13773. * A string to append to the tooltip format.
  13774. *
  13775. * @sample {highcharts} highcharts/tooltip/footerformat/
  13776. * A table for value alignment
  13777. * @sample {highmaps} maps/tooltip/format/
  13778. * Format demo
  13779. *
  13780. * @since 2.2
  13781. */
  13782. footerFormat: '',
  13783. /**
  13784. * Padding inside the tooltip, in pixels.
  13785. *
  13786. * @since 5.0.0
  13787. */
  13788. padding: 8,
  13789. /**
  13790. * Proximity snap for graphs or single points. It defaults to 10 for
  13791. * mouse-powered devices and 25 for touch devices.
  13792. *
  13793. * Note that in most cases the whole plot area captures the mouse
  13794. * movement, and in these cases `tooltip.snap` doesn't make sense. This
  13795. * applies when [stickyTracking](#plotOptions.series.stickyTracking)
  13796. * is `true` (default) and when the tooltip is [shared](#tooltip.shared)
  13797. * or [split](#tooltip.split).
  13798. *
  13799. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13800. * 10 px by default
  13801. * @sample {highcharts} highcharts/tooltip/snap-50/
  13802. * 50 px on graph
  13803. *
  13804. * @type {number}
  13805. * @default 10/25
  13806. * @since 1.2.0
  13807. * @product highcharts highstock
  13808. */
  13809. snap: isTouchDevice ? 25 : 10,
  13810. /**
  13811. * The HTML of the tooltip header line. Variables are enclosed by
  13812. * curly brackets. Available variables are `point.key`, `series.name`,
  13813. * `series.color` and other members from the `point` and `series`
  13814. * objects. The `point.key` variable contains the category name, x
  13815. * value or datetime string depending on the type of axis. For datetime
  13816. * axes, the `point.key` date format can be set using
  13817. * `tooltip.xDateFormat`.
  13818. *
  13819. * @sample {highcharts} highcharts/tooltip/footerformat/
  13820. * An HTML table in the tooltip
  13821. * @sample {highstock} highcharts/tooltip/footerformat/
  13822. * An HTML table in the tooltip
  13823. * @sample {highmaps} maps/tooltip/format/
  13824. * Format demo
  13825. *
  13826. * @type {string}
  13827. * @apioption tooltip.headerFormat
  13828. */
  13829. headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
  13830. /**
  13831. * The HTML of the null point's line in the tooltip. Works analogously
  13832. * to [pointFormat](#tooltip.pointFormat).
  13833. *
  13834. * @sample {highcharts} highcharts/plotoptions/series-nullformat
  13835. * Format data label and tooltip for null point.
  13836. *
  13837. * @type {string}
  13838. * @apioption tooltip.nullFormat
  13839. */
  13840. /**
  13841. * The HTML of the point's line in the tooltip. Variables are enclosed
  13842. * by curly brackets. Available variables are point.x, point.y, series.
  13843. * name and series.color and other properties on the same form.
  13844. * Furthermore, `point.y` can be extended by the `tooltip.valuePrefix`
  13845. * and `tooltip.valueSuffix` variables. This can also be overridden for
  13846. * each series, which makes it a good hook for displaying units.
  13847. *
  13848. * In styled mode, the dot is colored by a class name rather
  13849. * than the point color.
  13850. *
  13851. * @sample {highcharts} highcharts/tooltip/pointformat/
  13852. * A different point format with value suffix
  13853. * @sample {highmaps} maps/tooltip/format/
  13854. * Format demo
  13855. *
  13856. * @type {string}
  13857. * @since 2.2
  13858. * @apioption tooltip.pointFormat
  13859. */
  13860. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
  13861. /**
  13862. * The background color or gradient for the tooltip.
  13863. *
  13864. * In styled mode, the stroke width is set in the
  13865. * `.highcharts-tooltip-box` class.
  13866. *
  13867. * @sample {highcharts} highcharts/tooltip/backgroundcolor-solid/
  13868. * Yellowish background
  13869. * @sample {highcharts} highcharts/tooltip/backgroundcolor-gradient/
  13870. * Gradient
  13871. * @sample {highcharts} highcharts/css/tooltip-border-background/
  13872. * Tooltip in styled mode
  13873. * @sample {highstock} stock/tooltip/general/
  13874. * Custom tooltip
  13875. * @sample {highstock} highcharts/css/tooltip-border-background/
  13876. * Tooltip in styled mode
  13877. * @sample {highmaps} maps/tooltip/background-border/
  13878. * Background and border demo
  13879. * @sample {highmaps} highcharts/css/tooltip-border-background/
  13880. * Tooltip in styled mode
  13881. *
  13882. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  13883. */
  13884. backgroundColor: color('#f7f7f7')
  13885. .setOpacity(0.85).get(),
  13886. /**
  13887. * The pixel width of the tooltip border.
  13888. *
  13889. * In styled mode, the stroke width is set in the
  13890. * `.highcharts-tooltip-box` class.
  13891. *
  13892. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13893. * 2px by default
  13894. * @sample {highcharts} highcharts/tooltip/borderwidth/
  13895. * No border (shadow only)
  13896. * @sample {highcharts} highcharts/css/tooltip-border-background/
  13897. * Tooltip in styled mode
  13898. * @sample {highstock} stock/tooltip/general/
  13899. * Custom tooltip
  13900. * @sample {highstock} highcharts/css/tooltip-border-background/
  13901. * Tooltip in styled mode
  13902. * @sample {highmaps} maps/tooltip/background-border/
  13903. * Background and border demo
  13904. * @sample {highmaps} highcharts/css/tooltip-border-background/
  13905. * Tooltip in styled mode
  13906. */
  13907. borderWidth: 1,
  13908. /**
  13909. * Whether to apply a drop shadow to the tooltip.
  13910. *
  13911. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13912. * True by default
  13913. * @sample {highcharts} highcharts/tooltip/shadow/
  13914. * False
  13915. * @sample {highmaps} maps/tooltip/positioner/
  13916. * Fixed tooltip position, border and shadow disabled
  13917. *
  13918. * @type {boolean|Highcharts.ShadowOptionsObject}
  13919. */
  13920. shadow: true,
  13921. /**
  13922. * CSS styles for the tooltip. The tooltip can also be styled through
  13923. * the CSS class `.highcharts-tooltip`.
  13924. *
  13925. * Note that the default `pointerEvents` style makes the tooltip ignore
  13926. * mouse events, so in order to use clickable tooltips, this value must
  13927. * be set to `auto`.
  13928. *
  13929. * @sample {highcharts} highcharts/tooltip/style/
  13930. * Greater padding, bold text
  13931. *
  13932. * @type {Highcharts.CSSObject}
  13933. */
  13934. style: {
  13935. /** @internal */
  13936. color: '#333333',
  13937. /** @internal */
  13938. cursor: 'default',
  13939. /** @internal */
  13940. fontSize: '12px',
  13941. /** @internal */
  13942. whiteSpace: 'nowrap'
  13943. }
  13944. },
  13945. /**
  13946. * Highchart by default puts a credits label in the lower right corner
  13947. * of the chart. This can be changed using these options.
  13948. */
  13949. credits: {
  13950. /**
  13951. * Credits for map source to be concatenated with conventional credit
  13952. * text. By default this is a format string that collects copyright
  13953. * information from the map if available.
  13954. *
  13955. * @see [mapTextFull](#credits.mapTextFull)
  13956. * @see [text](#credits.text)
  13957. *
  13958. * @type {string}
  13959. * @default \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>
  13960. * @since 4.2.2
  13961. * @product highmaps
  13962. * @apioption credits.mapText
  13963. */
  13964. /**
  13965. * Detailed credits for map source to be displayed on hover of credits
  13966. * text. By default this is a format string that collects copyright
  13967. * information from the map if available.
  13968. *
  13969. * @see [mapText](#credits.mapText)
  13970. * @see [text](#credits.text)
  13971. *
  13972. * @type {string}
  13973. * @default {geojson.copyright}
  13974. * @since 4.2.2
  13975. * @product highmaps
  13976. * @apioption credits.mapTextFull
  13977. */
  13978. /**
  13979. * Whether to show the credits text.
  13980. *
  13981. * @sample {highcharts} highcharts/credits/enabled-false/
  13982. * Credits disabled
  13983. * @sample {highstock} stock/credits/enabled/
  13984. * Credits disabled
  13985. * @sample {highmaps} maps/credits/enabled-false/
  13986. * Credits disabled
  13987. */
  13988. enabled: true,
  13989. /**
  13990. * The URL for the credits label.
  13991. *
  13992. * @sample {highcharts} highcharts/credits/href/
  13993. * Custom URL and text
  13994. * @sample {highmaps} maps/credits/customized/
  13995. * Custom URL and text
  13996. */
  13997. href: 'https://www.highcharts.com?credits',
  13998. /**
  13999. * Position configuration for the credits label.
  14000. *
  14001. * @sample {highcharts} highcharts/credits/position-left/
  14002. * Left aligned
  14003. * @sample {highcharts} highcharts/credits/position-left/
  14004. * Left aligned
  14005. * @sample {highmaps} maps/credits/customized/
  14006. * Left aligned
  14007. * @sample {highmaps} maps/credits/customized/
  14008. * Left aligned
  14009. *
  14010. * @type {Highcharts.AlignObject}
  14011. * @since 2.1
  14012. */
  14013. position: {
  14014. /** @internal */
  14015. align: 'right',
  14016. /** @internal */
  14017. x: -10,
  14018. /** @internal */
  14019. verticalAlign: 'bottom',
  14020. /** @internal */
  14021. y: -5
  14022. },
  14023. /**
  14024. * CSS styles for the credits label.
  14025. *
  14026. * @see In styled mode, credits styles can be set with the
  14027. * `.highcharts-credits` class.
  14028. *
  14029. * @type {Highcharts.CSSObject}
  14030. */
  14031. style: {
  14032. /** @internal */
  14033. cursor: 'pointer',
  14034. /** @internal */
  14035. color: '#999999',
  14036. /** @internal */
  14037. fontSize: '9px'
  14038. },
  14039. /**
  14040. * The text for the credits label.
  14041. *
  14042. * @productdesc {highmaps}
  14043. * If a map is loaded as GeoJSON, the text defaults to
  14044. * `Highcharts @ {map-credits}`. Otherwise, it defaults to
  14045. * `Highcharts.com`.
  14046. *
  14047. * @sample {highcharts} highcharts/credits/href/
  14048. * Custom URL and text
  14049. * @sample {highmaps} maps/credits/customized/
  14050. * Custom URL and text
  14051. */
  14052. text: 'Highcharts.com'
  14053. }
  14054. };
  14055. /* eslint-disable spaced-comment */
  14056. '';
  14057. /**
  14058. * Global `Time` object with default options. Since v6.0.5, time settings can be
  14059. * applied individually for each chart. If no individual settings apply, this
  14060. * `Time` object is shared by all instances.
  14061. *
  14062. * @name Highcharts.time
  14063. * @type {Highcharts.Time}
  14064. */
  14065. H.time = new Time(merge(H.defaultOptions.global, H.defaultOptions.time));
  14066. /**
  14067. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970) into a
  14068. * human readable date string. The format is a subset of the formats for PHP's
  14069. * [strftime](https://www.php.net/manual/en/function.strftime.php) function.
  14070. * Additional formats can be given in the {@link Highcharts.dateFormats} hook.
  14071. *
  14072. * Since v6.0.5, all internal dates are formatted through the
  14073. * {@link Highcharts.Chart#time} instance to respect chart-level time settings.
  14074. * The `Highcharts.dateFormat` function only reflects global time settings set
  14075. * with `setOptions`.
  14076. *
  14077. * Supported format keys:
  14078. * - `%a`: Short weekday, like 'Mon'
  14079. * - `%A`: Long weekday, like 'Monday'
  14080. * - `%d`: Two digit day of the month, 01 to 31
  14081. * - `%e`: Day of the month, 1 through 31
  14082. * - `%w`: Day of the week, 0 through 6
  14083. * - `%b`: Short month, like 'Jan'
  14084. * - `%B`: Long month, like 'January'
  14085. * - `%m`: Two digit month number, 01 through 12
  14086. * - `%y`: Two digits year, like 09 for 2009
  14087. * - `%Y`: Four digits year, like 2009
  14088. * - `%H`: Two digits hours in 24h format, 00 through 23
  14089. * - `%k`: Hours in 24h format, 0 through 23
  14090. * - `%I`: Two digits hours in 12h format, 00 through 11
  14091. * - `%l`: Hours in 12h format, 1 through 12
  14092. * - `%M`: Two digits minutes, 00 through 59
  14093. * - `%p`: Upper case AM or PM
  14094. * - `%P`: Lower case AM or PM
  14095. * - `%S`: Two digits seconds, 00 through 59
  14096. * - `%L`: Milliseconds (naming from Ruby)
  14097. *
  14098. * @function Highcharts.dateFormat
  14099. *
  14100. * @param {string} format
  14101. * The desired format where various time representations are prefixed
  14102. * with `%`.
  14103. *
  14104. * @param {number} timestamp
  14105. * The JavaScript timestamp.
  14106. *
  14107. * @param {boolean} [capitalize=false]
  14108. * Upper case first letter in the return.
  14109. *
  14110. * @return {string}
  14111. * The formatted date.
  14112. */
  14113. H.dateFormat = function (format, timestamp, capitalize) {
  14114. return H.time.dateFormat(format, timestamp, capitalize);
  14115. };
  14116. var optionsModule = {
  14117. dateFormat: H.dateFormat,
  14118. defaultOptions: H.defaultOptions,
  14119. time: H.time
  14120. };
  14121. return optionsModule;
  14122. });
  14123. _registerModule(_modules, 'Core/Axis/Axis.js', [_modules['Core/Color.js'], _modules['Core/Globals.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Utilities.js'], _modules['Core/Options.js']], function (Color, H, Tick, U, O) {
  14124. /* *
  14125. *
  14126. * (c) 2010-2020 Torstein Honsi
  14127. *
  14128. * License: www.highcharts.com/license
  14129. *
  14130. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14131. *
  14132. * */
  14133. var addEvent = U.addEvent,
  14134. animObject = U.animObject,
  14135. arrayMax = U.arrayMax,
  14136. arrayMin = U.arrayMin,
  14137. clamp = U.clamp,
  14138. correctFloat = U.correctFloat,
  14139. defined = U.defined,
  14140. destroyObjectProperties = U.destroyObjectProperties,
  14141. error = U.error,
  14142. extend = U.extend,
  14143. fireEvent = U.fireEvent,
  14144. format = U.format,
  14145. getMagnitude = U.getMagnitude,
  14146. isArray = U.isArray,
  14147. isFunction = U.isFunction,
  14148. isNumber = U.isNumber,
  14149. isString = U.isString,
  14150. merge = U.merge,
  14151. normalizeTickInterval = U.normalizeTickInterval,
  14152. objectEach = U.objectEach,
  14153. pick = U.pick,
  14154. relativeLength = U.relativeLength,
  14155. removeEvent = U.removeEvent,
  14156. splat = U.splat,
  14157. syncTimeout = U.syncTimeout;
  14158. /**
  14159. * Options for the path on the Axis to be calculated.
  14160. * @interface Highcharts.AxisPlotLinePathOptionsObject
  14161. */ /**
  14162. * Axis value.
  14163. * @name Highcharts.AxisPlotLinePathOptionsObject#value
  14164. * @type {number|undefined}
  14165. */ /**
  14166. * Line width used for calculation crisp line coordinates. Defaults to 1.
  14167. * @name Highcharts.AxisPlotLinePathOptionsObject#lineWidth
  14168. * @type {number|undefined}
  14169. */ /**
  14170. * If `false`, the function will return null when it falls outside the axis
  14171. * bounds. If `true`, the function will return a path aligned to the plot area
  14172. * sides if it falls outside. If `pass`, it will return a path outside.
  14173. * @name Highcharts.AxisPlotLinePathOptionsObject#force
  14174. * @type {string|boolean|undefined}
  14175. */ /**
  14176. * Used in Highstock. When `true`, plot paths (crosshair, plotLines, gridLines)
  14177. * will be rendered on all axes when defined on the first axis.
  14178. * @name Highcharts.AxisPlotLinePathOptionsObject#acrossPanes
  14179. * @type {boolean|undefined}
  14180. */ /**
  14181. * Use old coordinates (for resizing and rescaling).
  14182. * If not set, defaults to `false`.
  14183. * @name Highcharts.AxisPlotLinePathOptionsObject#old
  14184. * @type {boolean|undefined}
  14185. */ /**
  14186. * If given, return the plot line path of a pixel position on the axis.
  14187. * @name Highcharts.AxisPlotLinePathOptionsObject#translatedValue
  14188. * @type {number|undefined}
  14189. */ /**
  14190. * Used in Polar axes. Reverse the positions for concatenation of polygonal
  14191. * plot bands
  14192. * @name Highcharts.AxisPlotLinePathOptionsObject#reverse
  14193. * @type {boolean|undefined}
  14194. */
  14195. /**
  14196. * Options for crosshairs on axes.
  14197. *
  14198. * @product highstock
  14199. *
  14200. * @typedef {Highcharts.XAxisCrosshairOptions|Highcharts.YAxisCrosshairOptions} Highcharts.AxisCrosshairOptions
  14201. */
  14202. /**
  14203. * @typedef {"navigator"|"pan"|"rangeSelectorButton"|"rangeSelectorInput"|"scrollbar"|"traverseUpButton"|"zoom"} Highcharts.AxisExtremesTriggerValue
  14204. */
  14205. /**
  14206. * @callback Highcharts.AxisEventCallbackFunction
  14207. *
  14208. * @param {Highcharts.Axis} this
  14209. */
  14210. /**
  14211. * @callback Highcharts.AxisLabelsFormatterCallbackFunction
  14212. *
  14213. * @param {Highcharts.AxisLabelsFormatterContextObject<number>} this
  14214. *
  14215. * @param {Highcharts.AxisLabelsFormatterContextObject<string>} that
  14216. *
  14217. * @return {string}
  14218. */
  14219. /**
  14220. * @interface Highcharts.AxisLabelsFormatterContextObject<T>
  14221. */ /**
  14222. * @name Highcharts.AxisLabelsFormatterContextObject<T>#axis
  14223. * @type {Highcharts.Axis}
  14224. */ /**
  14225. * @name Highcharts.AxisLabelsFormatterContextObject<T>#chart
  14226. * @type {Highcharts.Chart}
  14227. */ /**
  14228. * @name Highcharts.AxisLabelsFormatterContextObject<T>#isFirst
  14229. * @type {boolean}
  14230. */ /**
  14231. * @name Highcharts.AxisLabelsFormatterContextObject<T>#isLast
  14232. * @type {boolean}
  14233. */ /**
  14234. * @name Highcharts.AxisLabelsFormatterContextObject<T>#pos
  14235. * @type {number}
  14236. */ /**
  14237. * This can be either a numeric value or a category string.
  14238. * @name Highcharts.AxisLabelsFormatterContextObject<T>#value
  14239. * @type {T}
  14240. */
  14241. /**
  14242. * Options for axes.
  14243. *
  14244. * @typedef {Highcharts.XAxisOptions|Highcharts.YAxisOptions|Highcharts.ZAxisOptions} Highcharts.AxisOptions
  14245. */
  14246. /**
  14247. * @callback Highcharts.AxisPointBreakEventCallbackFunction
  14248. *
  14249. * @param {Highcharts.Axis} this
  14250. *
  14251. * @param {Highcharts.AxisPointBreakEventObject} evt
  14252. */
  14253. /**
  14254. * @interface Highcharts.AxisPointBreakEventObject
  14255. */ /**
  14256. * @name Highcharts.AxisPointBreakEventObject#brk
  14257. * @type {Highcharts.Dictionary<number>}
  14258. */ /**
  14259. * @name Highcharts.AxisPointBreakEventObject#point
  14260. * @type {Highcharts.Point}
  14261. */ /**
  14262. * @name Highcharts.AxisPointBreakEventObject#preventDefault
  14263. * @type {Function}
  14264. */ /**
  14265. * @name Highcharts.AxisPointBreakEventObject#target
  14266. * @type {Highcharts.SVGElement}
  14267. */ /**
  14268. * @name Highcharts.AxisPointBreakEventObject#type
  14269. * @type {"pointBreak"|"pointInBreak"}
  14270. */
  14271. /**
  14272. * @callback Highcharts.AxisSetExtremesEventCallbackFunction
  14273. *
  14274. * @param {Highcharts.Axis} this
  14275. *
  14276. * @param {Highcharts.AxisSetExtremesEventObject} evt
  14277. */
  14278. /**
  14279. * @interface Highcharts.AxisSetExtremesEventObject
  14280. * @extends Highcharts.ExtremesObject
  14281. */ /**
  14282. * @name Highcharts.AxisSetExtremesEventObject#preventDefault
  14283. * @type {Function}
  14284. */ /**
  14285. * @name Highcharts.AxisSetExtremesEventObject#target
  14286. * @type {Highcharts.SVGElement}
  14287. */ /**
  14288. * @name Highcharts.AxisSetExtremesEventObject#trigger
  14289. * @type {Highcharts.AxisExtremesTriggerValue|string}
  14290. */ /**
  14291. * @name Highcharts.AxisSetExtremesEventObject#type
  14292. * @type {"setExtremes"}
  14293. */
  14294. /**
  14295. * @callback Highcharts.AxisTickPositionerCallbackFunction
  14296. *
  14297. * @param {Highcharts.Axis} this
  14298. *
  14299. * @return {Highcharts.AxisTickPositionsArray}
  14300. */
  14301. /**
  14302. * @interface Highcharts.AxisTickPositionsArray
  14303. * @augments Array<number>
  14304. */
  14305. /**
  14306. * @typedef {"high"|"low"|"middle"} Highcharts.AxisTitleAlignValue
  14307. */
  14308. /**
  14309. * @typedef {Highcharts.XAxisTitleOptions|Highcharts.YAxisTitleOptions|Highcharts.ZAxisTitleOptions} Highcharts.AxisTitleOptions
  14310. */
  14311. /**
  14312. * @typedef {"linear"|"logarithmic"|"datetime"|"category"|"treegrid"} Highcharts.AxisTypeValue
  14313. */
  14314. /**
  14315. * The returned object literal from the {@link Highcharts.Axis#getExtremes}
  14316. * function.
  14317. *
  14318. * @interface Highcharts.ExtremesObject
  14319. */ /**
  14320. * The maximum value of the axis' associated series.
  14321. * @name Highcharts.ExtremesObject#dataMax
  14322. * @type {number}
  14323. */ /**
  14324. * The minimum value of the axis' associated series.
  14325. * @name Highcharts.ExtremesObject#dataMin
  14326. * @type {number}
  14327. */ /**
  14328. * The maximum axis value, either automatic or set manually. If the `max` option
  14329. * is not set, `maxPadding` is 0 and `endOnTick` is false, this value will be
  14330. * the same as `dataMax`.
  14331. * @name Highcharts.ExtremesObject#max
  14332. * @type {number}
  14333. */ /**
  14334. * The minimum axis value, either automatic or set manually. If the `min` option
  14335. * is not set, `minPadding` is 0 and `startOnTick` is false, this value will be
  14336. * the same as `dataMin`.
  14337. * @name Highcharts.ExtremesObject#min
  14338. * @type {number}
  14339. */ /**
  14340. * The user defined maximum, either from the `max` option or from a zoom or
  14341. * `setExtremes` action.
  14342. * @name Highcharts.ExtremesObject#userMax
  14343. * @type {number}
  14344. */ /**
  14345. * The user defined minimum, either from the `min` option or from a zoom or
  14346. * `setExtremes` action.
  14347. * @name Highcharts.ExtremesObject#userMin
  14348. * @type {number}
  14349. */
  14350. /**
  14351. * Formatter function for the text of a crosshair label.
  14352. *
  14353. * @callback Highcharts.XAxisCrosshairLabelFormatterCallbackFunction
  14354. *
  14355. * @param {Highcharts.Axis} this
  14356. * Axis context
  14357. *
  14358. * @param {number} value
  14359. * Y value of the data point
  14360. *
  14361. * @return {string}
  14362. */
  14363. var defaultOptions = O.defaultOptions;
  14364. var deg2rad = H.deg2rad;
  14365. /**
  14366. * Create a new axis object. Called internally when instanciating a new chart or
  14367. * adding axes by {@link Highcharts.Chart#addAxis}.
  14368. *
  14369. * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
  14370. * series cartesian chart, there is one X axis and one Y axis.
  14371. *
  14372. * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
  14373. * an array of Axis objects. If there is only one axis, it can be referenced
  14374. * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
  14375. * pattern goes for Y axes.
  14376. *
  14377. * If you need to get the axes from a series object, use the `series.xAxis` and
  14378. * `series.yAxis` properties. These are not arrays, as one series can only be
  14379. * associated to one X and one Y axis.
  14380. *
  14381. * A third way to reference the axis programmatically is by `id`. Add an `id` in
  14382. * the axis configuration options, and get the axis by
  14383. * {@link Highcharts.Chart#get}.
  14384. *
  14385. * Configuration options for the axes are given in options.xAxis and
  14386. * options.yAxis.
  14387. *
  14388. * @class
  14389. * @name Highcharts.Axis
  14390. *
  14391. * @param {Highcharts.Chart} chart
  14392. * The Chart instance to apply the axis on.
  14393. *
  14394. * @param {Highcharts.AxisOptions} userOptions
  14395. * Axis options.
  14396. */
  14397. var Axis = /** @class */ (function () {
  14398. /* *
  14399. *
  14400. * Constructors
  14401. *
  14402. * */
  14403. function Axis(chart, userOptions) {
  14404. this.alternateBands = void 0;
  14405. this.bottom = void 0;
  14406. this.categories = void 0;
  14407. this.chart = void 0;
  14408. this.closestPointRange = void 0;
  14409. this.coll = void 0;
  14410. this.hasNames = void 0;
  14411. this.hasVisibleSeries = void 0;
  14412. this.height = void 0;
  14413. this.isLinked = void 0;
  14414. this.labelEdge = void 0; // @todo
  14415. this.labelFormatter = void 0;
  14416. this.left = void 0;
  14417. this.len = void 0;
  14418. this.max = void 0;
  14419. this.maxLabelLength = void 0;
  14420. this.min = void 0;
  14421. this.minorTickInterval = void 0;
  14422. this.minorTicks = void 0;
  14423. this.minPixelPadding = void 0;
  14424. this.names = void 0;
  14425. this.offset = void 0;
  14426. this.oldMax = void 0;
  14427. this.oldMin = void 0;
  14428. this.options = void 0;
  14429. this.overlap = void 0;
  14430. this.paddedTicks = void 0;
  14431. this.plotLinesAndBands = void 0;
  14432. this.plotLinesAndBandsGroups = void 0;
  14433. this.pointRange = void 0;
  14434. this.pointRangePadding = void 0;
  14435. this.pos = void 0;
  14436. this.positiveValuesOnly = void 0;
  14437. this.right = void 0;
  14438. this.series = void 0;
  14439. this.side = void 0;
  14440. this.tickAmount = void 0;
  14441. this.tickInterval = void 0;
  14442. this.tickmarkOffset = void 0;
  14443. this.tickPositions = void 0;
  14444. this.tickRotCorr = void 0;
  14445. this.ticks = void 0;
  14446. this.top = void 0;
  14447. this.transA = void 0;
  14448. this.transB = void 0;
  14449. this.translationSlope = void 0;
  14450. this.userOptions = void 0;
  14451. this.visible = void 0;
  14452. this.width = void 0;
  14453. this.zoomEnabled = void 0;
  14454. this.init(chart, userOptions);
  14455. }
  14456. /* *
  14457. *
  14458. * Functions
  14459. *
  14460. * */
  14461. /**
  14462. * Overrideable function to initialize the axis.
  14463. *
  14464. * @see {@link Axis}
  14465. *
  14466. * @function Highcharts.Axis#init
  14467. *
  14468. * @param {Highcharts.Chart} chart
  14469. * The Chart instance to apply the axis on.
  14470. *
  14471. * @param {Highcharts.AxisOptions} userOptions
  14472. * Axis options.
  14473. *
  14474. * @fires Highcharts.Axis#event:afterInit
  14475. * @fires Highcharts.Axis#event:init
  14476. */
  14477. Axis.prototype.init = function (chart, userOptions) {
  14478. var isXAxis = userOptions.isX,
  14479. axis = this;
  14480. /**
  14481. * The Chart that the axis belongs to.
  14482. *
  14483. * @name Highcharts.Axis#chart
  14484. * @type {Highcharts.Chart}
  14485. */
  14486. axis.chart = chart;
  14487. /**
  14488. * Whether the axis is horizontal.
  14489. *
  14490. * @name Highcharts.Axis#horiz
  14491. * @type {boolean|undefined}
  14492. */
  14493. axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;
  14494. /**
  14495. * Whether the axis is the x-axis.
  14496. *
  14497. * @name Highcharts.Axis#isXAxis
  14498. * @type {boolean|undefined}
  14499. */
  14500. axis.isXAxis = isXAxis;
  14501. /**
  14502. * The collection where the axis belongs, for example `xAxis`, `yAxis`
  14503. * or `colorAxis`. Corresponds to properties on Chart, for example
  14504. * {@link Chart.xAxis}.
  14505. *
  14506. * @name Highcharts.Axis#coll
  14507. * @type {string}
  14508. */
  14509. axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
  14510. fireEvent(this, 'init', { userOptions: userOptions });
  14511. axis.opposite = userOptions.opposite; // needed in setOptions
  14512. /**
  14513. * The side on which the axis is rendered. 0 is top, 1 is right, 2
  14514. * is bottom and 3 is left.
  14515. *
  14516. * @name Highcharts.Axis#side
  14517. * @type {number}
  14518. */
  14519. axis.side = userOptions.side || (axis.horiz ?
  14520. (axis.opposite ? 0 : 2) : // top : bottom
  14521. (axis.opposite ? 1 : 3)); // right : left
  14522. /**
  14523. * Current options for the axis after merge of defaults and user's
  14524. * options.
  14525. *
  14526. * @name Highcharts.Axis#options
  14527. * @type {Highcharts.AxisOptions}
  14528. */
  14529. axis.setOptions(userOptions);
  14530. var options = this.options,
  14531. type = options.type;
  14532. axis.labelFormatter = (options.labels.formatter ||
  14533. // can be overwritten by dynamic format
  14534. axis.defaultLabelFormatter);
  14535. /**
  14536. * User's options for this axis without defaults.
  14537. *
  14538. * @name Highcharts.Axis#userOptions
  14539. * @type {Highcharts.AxisOptions}
  14540. */
  14541. axis.userOptions = userOptions;
  14542. axis.minPixelPadding = 0;
  14543. /**
  14544. * Whether the axis is reversed. Based on the `axis.reversed`,
  14545. * option, but inverted charts have reversed xAxis by default.
  14546. *
  14547. * @name Highcharts.Axis#reversed
  14548. * @type {boolean}
  14549. */
  14550. axis.reversed = options.reversed;
  14551. axis.visible = options.visible !== false;
  14552. axis.zoomEnabled = options.zoomEnabled !== false;
  14553. // Initial categories
  14554. axis.hasNames =
  14555. type === 'category' || options.categories === true;
  14556. /**
  14557. * If categories are present for the axis, names are used instead of
  14558. * numbers for that axis.
  14559. *
  14560. * Since Highcharts 3.0, categories can also be extracted by giving each
  14561. * point a name and setting axis type to `category`. However, if you
  14562. * have multiple series, best practice remains defining the `categories`
  14563. * array.
  14564. *
  14565. * @see [xAxis.categories](/highcharts/xAxis.categories)
  14566. *
  14567. * @name Highcharts.Axis#categories
  14568. * @type {Array<string>}
  14569. * @readonly
  14570. */
  14571. axis.categories = options.categories || axis.hasNames;
  14572. if (!axis.names) { // Preserve on update (#3830)
  14573. axis.names = [];
  14574. axis.names.keys = {};
  14575. }
  14576. // Placeholder for plotlines and plotbands groups
  14577. axis.plotLinesAndBandsGroups = {};
  14578. // Shorthand types
  14579. axis.positiveValuesOnly = !!axis.logarithmic;
  14580. // Flag, if axis is linked to another axis
  14581. axis.isLinked = defined(options.linkedTo);
  14582. /**
  14583. * List of major ticks mapped by postition on axis.
  14584. *
  14585. * @see {@link Highcharts.Tick}
  14586. *
  14587. * @name Highcharts.Axis#ticks
  14588. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  14589. */
  14590. axis.ticks = {};
  14591. axis.labelEdge = [];
  14592. /**
  14593. * List of minor ticks mapped by position on the axis.
  14594. *
  14595. * @see {@link Highcharts.Tick}
  14596. *
  14597. * @name Highcharts.Axis#minorTicks
  14598. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  14599. */
  14600. axis.minorTicks = {};
  14601. // List of plotLines/Bands
  14602. axis.plotLinesAndBands = [];
  14603. // Alternate bands
  14604. axis.alternateBands = {};
  14605. // Axis metrics
  14606. axis.len = 0;
  14607. axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
  14608. axis.range = options.range;
  14609. axis.offset = options.offset || 0;
  14610. /**
  14611. * The maximum value of the axis. In a logarithmic axis, this is the
  14612. * logarithm of the real value, and the real value can be obtained from
  14613. * {@link Axis#getExtremes}.
  14614. *
  14615. * @name Highcharts.Axis#max
  14616. * @type {number|null}
  14617. */
  14618. axis.max = null;
  14619. /**
  14620. * The minimum value of the axis. In a logarithmic axis, this is the
  14621. * logarithm of the real value, and the real value can be obtained from
  14622. * {@link Axis#getExtremes}.
  14623. *
  14624. * @name Highcharts.Axis#min
  14625. * @type {number|null}
  14626. */
  14627. axis.min = null;
  14628. /**
  14629. * The processed crosshair options.
  14630. *
  14631. * @name Highcharts.Axis#crosshair
  14632. * @type {boolean|Highcharts.AxisCrosshairOptions}
  14633. */
  14634. axis.crosshair = pick(options.crosshair, splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1], false);
  14635. var events = axis.options.events;
  14636. // Register. Don't add it again on Axis.update().
  14637. if (chart.axes.indexOf(axis) === -1) { //
  14638. if (isXAxis) { // #2713
  14639. chart.axes.splice(chart.xAxis.length, 0, axis);
  14640. }
  14641. else {
  14642. chart.axes.push(axis);
  14643. }
  14644. chart[axis.coll].push(axis);
  14645. }
  14646. /**
  14647. * All series associated to the axis.
  14648. *
  14649. * @name Highcharts.Axis#series
  14650. * @type {Array<Highcharts.Series>}
  14651. */
  14652. axis.series = axis.series || []; // populated by Series
  14653. // Reversed axis
  14654. if (chart.inverted &&
  14655. !axis.isZAxis &&
  14656. isXAxis &&
  14657. typeof axis.reversed === 'undefined') {
  14658. axis.reversed = true;
  14659. }
  14660. axis.labelRotation = axis.options.labels.rotation;
  14661. // register event listeners
  14662. objectEach(events, function (event, eventType) {
  14663. if (isFunction(event)) {
  14664. addEvent(axis, eventType, event);
  14665. }
  14666. });
  14667. fireEvent(this, 'afterInit');
  14668. };
  14669. /**
  14670. * Merge and set options.
  14671. *
  14672. * @private
  14673. * @function Highcharts.Axis#setOptions
  14674. *
  14675. * @param {Highcharts.AxisOptions} userOptions
  14676. * Axis options.
  14677. *
  14678. * @fires Highcharts.Axis#event:afterSetOptions
  14679. */
  14680. Axis.prototype.setOptions = function (userOptions) {
  14681. this.options = merge(Axis.defaultOptions, (this.coll === 'yAxis') && Axis.defaultYAxisOptions, [
  14682. Axis.defaultTopAxisOptions,
  14683. Axis.defaultRightAxisOptions,
  14684. Axis.defaultBottomAxisOptions,
  14685. Axis.defaultLeftAxisOptions
  14686. ][this.side], merge(
  14687. // if set in setOptions (#1053):
  14688. defaultOptions[this.coll], userOptions));
  14689. fireEvent(this, 'afterSetOptions', { userOptions: userOptions });
  14690. };
  14691. /**
  14692. * The default label formatter. The context is a special config object for
  14693. * the label. In apps, use the
  14694. * [labels.formatter](https://api.highcharts.com/highcharts/xAxis.labels.formatter)
  14695. * instead, except when a modification is needed.
  14696. *
  14697. * @function Highcharts.Axis#defaultLabelFormatter
  14698. *
  14699. * @param {Highcharts.AxisLabelsFormatterContextObject<number>|Highcharts.AxisLabelsFormatterContextObject<string>} this
  14700. * Formatter context of axis label.
  14701. *
  14702. * @return {string}
  14703. * The formatted label content.
  14704. */
  14705. Axis.prototype.defaultLabelFormatter = function () {
  14706. var axis = this.axis,
  14707. value = isNumber(this.value) ? this.value : NaN,
  14708. time = axis.chart.time,
  14709. categories = axis.categories,
  14710. dateTimeLabelFormat = this.dateTimeLabelFormat,
  14711. lang = defaultOptions.lang,
  14712. numericSymbols = lang.numericSymbols,
  14713. numSymMagnitude = lang.numericSymbolMagnitude || 1000,
  14714. i = numericSymbols && numericSymbols.length,
  14715. multi,
  14716. ret,
  14717. formatOption = axis.options.labels.format,
  14718. // make sure the same symbol is added for all labels on a linear
  14719. // axis
  14720. numericSymbolDetector = axis.logarithmic ?
  14721. Math.abs(value) :
  14722. axis.tickInterval;
  14723. var chart = this.chart;
  14724. var numberFormatter = chart.numberFormatter;
  14725. if (formatOption) {
  14726. ret = format(formatOption, this, chart);
  14727. }
  14728. else if (categories) {
  14729. ret = "" + this.value;
  14730. }
  14731. else if (dateTimeLabelFormat) { // datetime axis
  14732. ret = time.dateFormat(dateTimeLabelFormat, value);
  14733. }
  14734. else if (i && numericSymbolDetector >= 1000) {
  14735. // Decide whether we should add a numeric symbol like k (thousands)
  14736. // or M (millions). If we are to enable this in tooltip or other
  14737. // places as well, we can move this logic to the numberFormatter and
  14738. // enable it by a parameter.
  14739. while (i-- && typeof ret === 'undefined') {
  14740. multi = Math.pow(numSymMagnitude, i + 1);
  14741. if (
  14742. // Only accept a numeric symbol when the distance is more
  14743. // than a full unit. So for example if the symbol is k, we
  14744. // don't accept numbers like 0.5k.
  14745. numericSymbolDetector >= multi &&
  14746. // Accept one decimal before the symbol. Accepts 0.5k but
  14747. // not 0.25k. How does this work with the previous?
  14748. (value * 10) % multi === 0 &&
  14749. numericSymbols[i] !== null &&
  14750. value !== 0) { // #5480
  14751. ret = numberFormatter(value / multi, -1) + numericSymbols[i];
  14752. }
  14753. }
  14754. }
  14755. if (typeof ret === 'undefined') {
  14756. if (Math.abs(value) >= 10000) { // add thousands separators
  14757. ret = numberFormatter(value, -1);
  14758. }
  14759. else { // small numbers
  14760. ret = numberFormatter(value, -1, void 0, ''); // #2466
  14761. }
  14762. }
  14763. return ret;
  14764. };
  14765. /**
  14766. * Get the minimum and maximum for the series of each axis. The function
  14767. * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
  14768. *
  14769. * @private
  14770. * @function Highcharts.Axis#getSeriesExtremes
  14771. *
  14772. * @fires Highcharts.Axis#event:afterGetSeriesExtremes
  14773. * @fires Highcharts.Axis#event:getSeriesExtremes
  14774. */
  14775. Axis.prototype.getSeriesExtremes = function () {
  14776. var axis = this,
  14777. chart = axis.chart,
  14778. xExtremes;
  14779. fireEvent(this, 'getSeriesExtremes', null, function () {
  14780. axis.hasVisibleSeries = false;
  14781. // Reset properties in case we're redrawing (#3353)
  14782. axis.dataMin = axis.dataMax = axis.threshold = null;
  14783. axis.softThreshold = !axis.isXAxis;
  14784. if (axis.stacking) {
  14785. axis.stacking.buildStacks();
  14786. }
  14787. // loop through this axis' series
  14788. axis.series.forEach(function (series) {
  14789. if (series.visible ||
  14790. !chart.options.chart.ignoreHiddenSeries) {
  14791. var seriesOptions = series.options,
  14792. xData,
  14793. threshold = seriesOptions.threshold,
  14794. seriesDataMin,
  14795. seriesDataMax;
  14796. axis.hasVisibleSeries = true;
  14797. // Validate threshold in logarithmic axes
  14798. if (axis.positiveValuesOnly && threshold <= 0) {
  14799. threshold = null;
  14800. }
  14801. // Get dataMin and dataMax for X axes
  14802. if (axis.isXAxis) {
  14803. xData = series.xData;
  14804. if (xData.length) {
  14805. var isPositive = function (number) { return number > 0; };
  14806. xData = axis.logarithmic ?
  14807. xData.filter(axis.validatePositiveValue) :
  14808. xData;
  14809. xExtremes = series.getXExtremes(xData);
  14810. // If xData contains values which is not numbers,
  14811. // then filter them out. To prevent performance hit,
  14812. // we only do this after we have already found
  14813. // seriesDataMin because in most cases all data is
  14814. // valid. #5234.
  14815. seriesDataMin = xExtremes.min;
  14816. seriesDataMax = xExtremes.max;
  14817. if (!isNumber(seriesDataMin) &&
  14818. // #5010:
  14819. !(seriesDataMin instanceof Date)) {
  14820. xData = xData.filter(isNumber);
  14821. xExtremes = series.getXExtremes(xData);
  14822. // Do it again with valid data
  14823. seriesDataMin = xExtremes.min;
  14824. seriesDataMax = xExtremes.max;
  14825. }
  14826. if (xData.length) {
  14827. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  14828. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  14829. }
  14830. }
  14831. // Get dataMin and dataMax for Y axes, as well as handle
  14832. // stacking and processed data
  14833. }
  14834. else {
  14835. // Get this particular series extremes
  14836. var dataExtremes = series.applyExtremes();
  14837. // Get the dataMin and dataMax so far. If percentage is
  14838. // used, the min and max are always 0 and 100. If
  14839. // seriesDataMin and seriesDataMax is null, then series
  14840. // doesn't have active y data, we continue with nulls
  14841. if (isNumber(dataExtremes.dataMin)) {
  14842. seriesDataMin = dataExtremes.dataMin;
  14843. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  14844. }
  14845. if (isNumber(dataExtremes.dataMax)) {
  14846. seriesDataMax = dataExtremes.dataMax;
  14847. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  14848. }
  14849. // Adjust to threshold
  14850. if (defined(threshold)) {
  14851. axis.threshold = threshold;
  14852. }
  14853. // If any series has a hard threshold, it takes
  14854. // precedence
  14855. if (!seriesOptions.softThreshold ||
  14856. axis.positiveValuesOnly) {
  14857. axis.softThreshold = false;
  14858. }
  14859. }
  14860. }
  14861. });
  14862. });
  14863. fireEvent(this, 'afterGetSeriesExtremes');
  14864. };
  14865. /**
  14866. * Translate from axis value to pixel position on the chart, or back. Use
  14867. * the `toPixels` and `toValue` functions in applications.
  14868. *
  14869. * @private
  14870. * @function Highcharts.Axis#translate
  14871. *
  14872. * @param {number} val
  14873. * TO-DO: parameter description
  14874. *
  14875. * @param {boolean|null} [backwards]
  14876. * TO-DO: parameter description
  14877. *
  14878. * @param {boolean|null} [cvsCoord]
  14879. * TO-DO: parameter description
  14880. *
  14881. * @param {boolean|null} [old]
  14882. * TO-DO: parameter description
  14883. *
  14884. * @param {boolean} [handleLog]
  14885. * TO-DO: parameter description
  14886. *
  14887. * @param {number} [pointPlacement]
  14888. * TO-DO: parameter description
  14889. *
  14890. * @return {number|undefined}
  14891. */
  14892. Axis.prototype.translate = function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
  14893. var axis = this.linkedParent || this, // #1417
  14894. sign = 1,
  14895. cvsOffset = 0,
  14896. localA = old ? axis.oldTransA : axis.transA,
  14897. localMin = old ? axis.oldMin : axis.min,
  14898. returnValue = 0,
  14899. minPixelPadding = axis.minPixelPadding,
  14900. doPostTranslate = (axis.isOrdinal ||
  14901. axis.brokenAxis && axis.brokenAxis.hasBreaks ||
  14902. (axis.logarithmic && handleLog)) && axis.lin2val;
  14903. if (!localA) {
  14904. localA = axis.transA;
  14905. }
  14906. // In vertical axes, the canvas coordinates start from 0 at the top like
  14907. // in SVG.
  14908. if (cvsCoord) {
  14909. sign *= -1; // canvas coordinates inverts the value
  14910. cvsOffset = axis.len;
  14911. }
  14912. // Handle reversed axis
  14913. if (axis.reversed) {
  14914. sign *= -1;
  14915. cvsOffset -= sign * (axis.sector || axis.len);
  14916. }
  14917. // From pixels to value
  14918. if (backwards) { // reverse translation
  14919. val = val * sign + cvsOffset;
  14920. val -= minPixelPadding;
  14921. // from chart pixel to value:
  14922. returnValue = val / localA + localMin;
  14923. if (doPostTranslate) { // log and ordinal axes
  14924. returnValue = axis.lin2val(returnValue);
  14925. }
  14926. // From value to pixels
  14927. }
  14928. else {
  14929. if (doPostTranslate) { // log and ordinal axes
  14930. val = axis.val2lin(val);
  14931. }
  14932. returnValue = isNumber(localMin) ?
  14933. (sign * (val - localMin) * localA +
  14934. cvsOffset +
  14935. (sign * minPixelPadding) +
  14936. (isNumber(pointPlacement) ?
  14937. localA * pointPlacement :
  14938. 0)) :
  14939. void 0;
  14940. }
  14941. return returnValue;
  14942. };
  14943. /**
  14944. * Translate a value in terms of axis units into pixels within the chart.
  14945. *
  14946. * @function Highcharts.Axis#toPixels
  14947. *
  14948. * @param {number} value
  14949. * A value in terms of axis units.
  14950. *
  14951. * @param {boolean} paneCoordinates
  14952. * Whether to return the pixel coordinate relative to the chart or just the
  14953. * axis/pane itself.
  14954. *
  14955. * @return {number}
  14956. * Pixel position of the value on the chart or axis.
  14957. */
  14958. Axis.prototype.toPixels = function (value, paneCoordinates) {
  14959. return this.translate(value, false, !this.horiz, null, true) +
  14960. (paneCoordinates ? 0 : this.pos);
  14961. };
  14962. /**
  14963. * Translate a pixel position along the axis to a value in terms of axis
  14964. * units.
  14965. *
  14966. * @function Highcharts.Axis#toValue
  14967. *
  14968. * @param {number} pixel
  14969. * The pixel value coordinate.
  14970. *
  14971. * @param {boolean} [paneCoordinates=false]
  14972. * Whether the input pixel is relative to the chart or just the axis/pane
  14973. * itself.
  14974. *
  14975. * @return {number}
  14976. * The axis value.
  14977. */
  14978. Axis.prototype.toValue = function (pixel, paneCoordinates) {
  14979. return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
  14980. };
  14981. /**
  14982. * Create the path for a plot line that goes from the given value on
  14983. * this axis, across the plot to the opposite side. Also used internally for
  14984. * grid lines and crosshairs.
  14985. *
  14986. * @function Highcharts.Axis#getPlotLinePath
  14987. *
  14988. * @param {Highcharts.AxisPlotLinePathOptionsObject} options
  14989. * Options for the path.
  14990. *
  14991. * @return {Highcharts.SVGPathArray|null}
  14992. * The SVG path definition for the plot line.
  14993. */
  14994. Axis.prototype.getPlotLinePath = function (options) {
  14995. var axis = this,
  14996. chart = axis.chart,
  14997. axisLeft = axis.left,
  14998. axisTop = axis.top,
  14999. old = options.old,
  15000. value = options.value,
  15001. translatedValue = options.translatedValue,
  15002. lineWidth = options.lineWidth,
  15003. force = options.force,
  15004. x1,
  15005. y1,
  15006. x2,
  15007. y2,
  15008. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  15009. cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
  15010. skip,
  15011. transB = axis.transB,
  15012. evt;
  15013. // eslint-disable-next-line valid-jsdoc
  15014. /**
  15015. * Check if x is between a and b. If not, either move to a/b
  15016. * or skip, depending on the force parameter.
  15017. * @private
  15018. */
  15019. function between(x, a, b) {
  15020. if (force !== 'pass' && x < a || x > b) {
  15021. if (force) {
  15022. x = clamp(x, a, b);
  15023. }
  15024. else {
  15025. skip = true;
  15026. }
  15027. }
  15028. return x;
  15029. }
  15030. evt = {
  15031. value: value,
  15032. lineWidth: lineWidth,
  15033. old: old,
  15034. force: force,
  15035. acrossPanes: options.acrossPanes,
  15036. translatedValue: translatedValue
  15037. };
  15038. fireEvent(this, 'getPlotLinePath', evt, function (e) {
  15039. translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
  15040. // Keep the translated value within sane bounds, and avoid Infinity
  15041. // to fail the isNumber test (#7709).
  15042. translatedValue = clamp(translatedValue, -1e5, 1e5);
  15043. x1 = x2 = Math.round(translatedValue + transB);
  15044. y1 = y2 = Math.round(cHeight - translatedValue - transB);
  15045. if (!isNumber(translatedValue)) { // no min or max
  15046. skip = true;
  15047. force = false; // #7175, don't force it when path is invalid
  15048. }
  15049. else if (axis.horiz) {
  15050. y1 = axisTop;
  15051. y2 = cHeight - axis.bottom;
  15052. x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
  15053. }
  15054. else {
  15055. x1 = axisLeft;
  15056. x2 = cWidth - axis.right;
  15057. y1 = y2 = between(y1, axisTop, axisTop + axis.height);
  15058. }
  15059. e.path = skip && !force ?
  15060. null :
  15061. chart.renderer.crispLine([['M', x1, y1], ['L', x2, y2]], lineWidth || 1);
  15062. });
  15063. return evt.path;
  15064. };
  15065. /**
  15066. * Internal function to et the tick positions of a linear axis to round
  15067. * values like whole tens or every five.
  15068. *
  15069. * @function Highcharts.Axis#getLinearTickPositions
  15070. *
  15071. * @param {number} tickInterval
  15072. * The normalized tick interval.
  15073. *
  15074. * @param {number} min
  15075. * Axis minimum.
  15076. *
  15077. * @param {number} max
  15078. * Axis maximum.
  15079. *
  15080. * @return {Array<number>}
  15081. * An array of axis values where ticks should be placed.
  15082. */
  15083. Axis.prototype.getLinearTickPositions = function (tickInterval, min, max) {
  15084. var pos,
  15085. lastPos,
  15086. roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
  15087. roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
  15088. tickPositions = [],
  15089. precision;
  15090. // When the precision is higher than what we filter out in
  15091. // correctFloat, skip it (#6183).
  15092. if (correctFloat(roundedMin + tickInterval) === roundedMin) {
  15093. precision = 20;
  15094. }
  15095. // For single points, add a tick regardless of the relative position
  15096. // (#2662, #6274)
  15097. if (this.single) {
  15098. return [min];
  15099. }
  15100. // Populate the intermediate values
  15101. pos = roundedMin;
  15102. while (pos <= roundedMax) {
  15103. // Place the tick on the rounded value
  15104. tickPositions.push(pos);
  15105. // Always add the raw tickInterval, not the corrected one.
  15106. pos = correctFloat(pos + tickInterval, precision);
  15107. // If the interval is not big enough in the current min - max range
  15108. // to actually increase the loop variable, we need to break out to
  15109. // prevent endless loop. Issue #619
  15110. if (pos === lastPos) {
  15111. break;
  15112. }
  15113. // Record the last value
  15114. lastPos = pos;
  15115. }
  15116. return tickPositions;
  15117. };
  15118. /**
  15119. * Resolve the new minorTicks/minorTickInterval options into the legacy
  15120. * loosely typed minorTickInterval option.
  15121. *
  15122. * @function Highcharts.Axis#getMinorTickInterval
  15123. *
  15124. * @return {number|"auto"|null}
  15125. */
  15126. Axis.prototype.getMinorTickInterval = function () {
  15127. var options = this.options;
  15128. if (options.minorTicks === true) {
  15129. return pick(options.minorTickInterval, 'auto');
  15130. }
  15131. if (options.minorTicks === false) {
  15132. return null;
  15133. }
  15134. return options.minorTickInterval;
  15135. };
  15136. /**
  15137. * Internal function to return the minor tick positions. For logarithmic
  15138. * axes, the same logic as for major ticks is reused.
  15139. *
  15140. * @function Highcharts.Axis#getMinorTickPositions
  15141. *
  15142. * @return {Array<number>}
  15143. * An array of axis values where ticks should be placed.
  15144. */
  15145. Axis.prototype.getMinorTickPositions = function () {
  15146. var axis = this,
  15147. options = axis.options,
  15148. tickPositions = axis.tickPositions,
  15149. minorTickInterval = axis.minorTickInterval,
  15150. minorTickPositions = [],
  15151. pos,
  15152. pointRangePadding = axis.pointRangePadding || 0,
  15153. min = axis.min - pointRangePadding, // #1498
  15154. max = axis.max + pointRangePadding, // #1498
  15155. range = max - min;
  15156. // If minor ticks get too dense, they are hard to read, and may cause
  15157. // long running script. So we don't draw them.
  15158. if (range && range / minorTickInterval < axis.len / 3) { // #3875
  15159. var logarithmic_1 = axis.logarithmic;
  15160. if (logarithmic_1) {
  15161. // For each interval in the major ticks, compute the minor ticks
  15162. // separately.
  15163. this.paddedTicks.forEach(function (_pos, i, paddedTicks) {
  15164. if (i) {
  15165. minorTickPositions.push.apply(minorTickPositions, logarithmic_1.getLogTickPositions(minorTickInterval, paddedTicks[i - 1], paddedTicks[i], true));
  15166. }
  15167. });
  15168. }
  15169. else if (axis.dateTime &&
  15170. this.getMinorTickInterval() === 'auto') { // #1314
  15171. minorTickPositions = minorTickPositions.concat(axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(minorTickInterval), min, max, options.startOfWeek));
  15172. }
  15173. else {
  15174. for (pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval) {
  15175. // Very, very, tight grid lines (#5771)
  15176. if (pos === minorTickPositions[0]) {
  15177. break;
  15178. }
  15179. minorTickPositions.push(pos);
  15180. }
  15181. }
  15182. }
  15183. if (minorTickPositions.length !== 0) {
  15184. axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
  15185. }
  15186. return minorTickPositions;
  15187. };
  15188. /**
  15189. * Adjust the min and max for the minimum range. Keep in mind that the
  15190. * series data is not yet processed, so we don't have information on data
  15191. * cropping and grouping, or updated `axis.pointRange` or
  15192. * `series.pointRange`. The data can't be processed until we have finally
  15193. * established min and max.
  15194. *
  15195. * @private
  15196. * @function Highcharts.Axis#adjustForMinRange
  15197. */
  15198. Axis.prototype.adjustForMinRange = function () {
  15199. var axis = this,
  15200. options = axis.options,
  15201. min = axis.min,
  15202. max = axis.max,
  15203. log = axis.logarithmic,
  15204. zoomOffset,
  15205. spaceAvailable,
  15206. closestDataRange,
  15207. i,
  15208. distance,
  15209. xData,
  15210. loopLength,
  15211. minArgs,
  15212. maxArgs,
  15213. minRange;
  15214. // Set the automatic minimum range based on the closest point distance
  15215. if (axis.isXAxis &&
  15216. typeof axis.minRange === 'undefined' &&
  15217. !log) {
  15218. if (defined(options.min) || defined(options.max)) {
  15219. axis.minRange = null; // don't do this again
  15220. }
  15221. else {
  15222. // Find the closest distance between raw data points, as opposed
  15223. // to closestPointRange that applies to processed points
  15224. // (cropped and grouped)
  15225. axis.series.forEach(function (series) {
  15226. xData = series.xData;
  15227. loopLength = series.xIncrement ? 1 : xData.length - 1;
  15228. for (i = loopLength; i > 0; i--) {
  15229. distance = xData[i] - xData[i - 1];
  15230. if (typeof closestDataRange === 'undefined' ||
  15231. distance < closestDataRange) {
  15232. closestDataRange = distance;
  15233. }
  15234. }
  15235. });
  15236. axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
  15237. }
  15238. }
  15239. // if minRange is exceeded, adjust
  15240. if (max - min < axis.minRange) {
  15241. spaceAvailable =
  15242. axis.dataMax - axis.dataMin >=
  15243. axis.minRange;
  15244. minRange = axis.minRange;
  15245. zoomOffset = (minRange - max + min) / 2;
  15246. // if min and max options have been set, don't go beyond it
  15247. minArgs = [
  15248. min - zoomOffset,
  15249. pick(options.min, min - zoomOffset)
  15250. ];
  15251. // If space is available, stay within the data range
  15252. if (spaceAvailable) {
  15253. minArgs[2] = axis.logarithmic ?
  15254. axis.logarithmic.log2lin(axis.dataMin) :
  15255. axis.dataMin;
  15256. }
  15257. min = arrayMax(minArgs);
  15258. maxArgs = [
  15259. min + minRange,
  15260. pick(options.max, min + minRange)
  15261. ];
  15262. // If space is availabe, stay within the data range
  15263. if (spaceAvailable) {
  15264. maxArgs[2] = log ?
  15265. log.log2lin(axis.dataMax) :
  15266. axis.dataMax;
  15267. }
  15268. max = arrayMin(maxArgs);
  15269. // now if the max is adjusted, adjust the min back
  15270. if (max - min < minRange) {
  15271. minArgs[0] = max - minRange;
  15272. minArgs[1] = pick(options.min, max - minRange);
  15273. min = arrayMax(minArgs);
  15274. }
  15275. }
  15276. // Record modified extremes
  15277. axis.min = min;
  15278. axis.max = max;
  15279. };
  15280. // eslint-disable-next-line valid-jsdoc
  15281. /**
  15282. * Find the closestPointRange across all series.
  15283. *
  15284. * @private
  15285. * @function Highcharts.Axis#getClosest
  15286. */
  15287. Axis.prototype.getClosest = function () {
  15288. var ret;
  15289. if (this.categories) {
  15290. ret = 1;
  15291. }
  15292. else {
  15293. this.series.forEach(function (series) {
  15294. var seriesClosest = series.closestPointRange,
  15295. visible = series.visible ||
  15296. !series.chart.options.chart.ignoreHiddenSeries;
  15297. if (!series.noSharedTooltip &&
  15298. defined(seriesClosest) &&
  15299. visible) {
  15300. ret = defined(ret) ?
  15301. Math.min(ret, seriesClosest) :
  15302. seriesClosest;
  15303. }
  15304. });
  15305. }
  15306. return ret;
  15307. };
  15308. /**
  15309. * When a point name is given and no x, search for the name in the existing
  15310. * categories, or if categories aren't provided, search names or create a
  15311. * new category (#2522).
  15312. * @private
  15313. * @function Highcharts.Axis#nameToX
  15314. *
  15315. * @param {Highcharts.Point} point
  15316. * The point to inspect.
  15317. *
  15318. * @return {number}
  15319. * The X value that the point is given.
  15320. */
  15321. Axis.prototype.nameToX = function (point) {
  15322. var explicitCategories = isArray(this.categories),
  15323. names = explicitCategories ? this.categories : this.names,
  15324. nameX = point.options.x,
  15325. x;
  15326. point.series.requireSorting = false;
  15327. if (!defined(nameX)) {
  15328. nameX = this.options.uniqueNames === false ?
  15329. point.series.autoIncrement() :
  15330. (explicitCategories ?
  15331. names.indexOf(point.name) :
  15332. pick(names.keys[point.name], -1));
  15333. }
  15334. if (nameX === -1) { // Not found in currenct categories
  15335. if (!explicitCategories) {
  15336. x = names.length;
  15337. }
  15338. }
  15339. else {
  15340. x = nameX;
  15341. }
  15342. // Write the last point's name to the names array
  15343. if (typeof x !== 'undefined') {
  15344. this.names[x] = point.name;
  15345. // Backwards mapping is much faster than array searching (#7725)
  15346. this.names.keys[point.name] = x;
  15347. }
  15348. return x;
  15349. };
  15350. /**
  15351. * When changes have been done to series data, update the axis.names.
  15352. *
  15353. * @private
  15354. * @function Highcharts.Axis#updateNames
  15355. */
  15356. Axis.prototype.updateNames = function () {
  15357. var axis = this,
  15358. names = this.names,
  15359. i = names.length;
  15360. if (i > 0) {
  15361. Object.keys(names.keys).forEach(function (key) {
  15362. delete (names.keys)[key];
  15363. });
  15364. names.length = 0;
  15365. this.minRange = this.userMinRange; // Reset
  15366. (this.series || []).forEach(function (series) {
  15367. // Reset incrementer (#5928)
  15368. series.xIncrement = null;
  15369. // When adding a series, points are not yet generated
  15370. if (!series.points || series.isDirtyData) {
  15371. // When we're updating the series with data that is longer
  15372. // than it was, and cropThreshold is passed, we need to make
  15373. // sure that the axis.max is increased _before_ running the
  15374. // premature processData. Otherwise this early iteration of
  15375. // processData will crop the points to axis.max, and the
  15376. // names array will be too short (#5857).
  15377. axis.max = Math.max(axis.max, series.xData.length - 1);
  15378. series.processData();
  15379. series.generatePoints();
  15380. }
  15381. series.data.forEach(function (point, i) {
  15382. var x;
  15383. if (point &&
  15384. point.options &&
  15385. typeof point.name !== 'undefined' // #9562
  15386. ) {
  15387. x = axis.nameToX(point);
  15388. if (typeof x !== 'undefined' && x !== point.x) {
  15389. point.x = x;
  15390. series.xData[i] = x;
  15391. }
  15392. }
  15393. });
  15394. });
  15395. }
  15396. };
  15397. /**
  15398. * Update translation information.
  15399. *
  15400. * @private
  15401. * @function Highcharts.Axis#setAxisTranslation
  15402. *
  15403. * @param {boolean} [saveOld]
  15404. * TO-DO: parameter description
  15405. *
  15406. * @fires Highcharts.Axis#event:afterSetAxisTranslation
  15407. */
  15408. Axis.prototype.setAxisTranslation = function (saveOld) {
  15409. var axis = this,
  15410. range = axis.max - axis.min,
  15411. pointRange = axis.axisPointRange || 0,
  15412. closestPointRange,
  15413. minPointOffset = 0,
  15414. pointRangePadding = 0,
  15415. linkedParent = axis.linkedParent,
  15416. ordinalCorrection,
  15417. hasCategories = !!axis.categories,
  15418. transA = axis.transA,
  15419. isXAxis = axis.isXAxis;
  15420. // Adjust translation for padding. Y axis with categories need to go
  15421. // through the same (#1784).
  15422. if (isXAxis || hasCategories || pointRange) {
  15423. // Get the closest points
  15424. closestPointRange = axis.getClosest();
  15425. if (linkedParent) {
  15426. minPointOffset = linkedParent.minPointOffset;
  15427. pointRangePadding = linkedParent.pointRangePadding;
  15428. }
  15429. else {
  15430. axis.series.forEach(function (series) {
  15431. var seriesPointRange = hasCategories ?
  15432. 1 :
  15433. (isXAxis ?
  15434. pick(series.options.pointRange,
  15435. closestPointRange, 0) :
  15436. (axis.axisPointRange || 0)), // #2806
  15437. pointPlacement = series.options.pointPlacement;
  15438. pointRange = Math.max(pointRange, seriesPointRange);
  15439. if (!axis.single || hasCategories) {
  15440. // TODO: series should internally set x- and y-
  15441. // pointPlacement to simplify this logic.
  15442. var isPointPlacementAxis = series.is('xrange') ? !isXAxis : isXAxis;
  15443. // minPointOffset is the value padding to the left of
  15444. // the axis in order to make room for points with a
  15445. // pointRange, typically columns. When the
  15446. // pointPlacement option is 'between' or 'on', this
  15447. // padding does not apply.
  15448. minPointOffset = Math.max(minPointOffset, isPointPlacementAxis && isString(pointPlacement) ?
  15449. 0 :
  15450. seriesPointRange / 2);
  15451. // Determine the total padding needed to the length of
  15452. // the axis to make room for the pointRange. If the
  15453. // series' pointPlacement is 'on', no padding is added.
  15454. pointRangePadding = Math.max(pointRangePadding, isPointPlacementAxis && pointPlacement === 'on' ?
  15455. 0 :
  15456. seriesPointRange);
  15457. }
  15458. });
  15459. }
  15460. // Record minPointOffset and pointRangePadding
  15461. ordinalCorrection = axis.ordinal && axis.ordinal.slope && closestPointRange ?
  15462. axis.ordinal.slope / closestPointRange :
  15463. 1; // #988, #1853
  15464. axis.minPointOffset = minPointOffset =
  15465. minPointOffset * ordinalCorrection;
  15466. axis.pointRangePadding =
  15467. pointRangePadding = pointRangePadding * ordinalCorrection;
  15468. // pointRange means the width reserved for each point, like in a
  15469. // column chart
  15470. axis.pointRange = Math.min(pointRange, axis.single && hasCategories ? 1 : range);
  15471. // closestPointRange means the closest distance between points. In
  15472. // columns it is mostly equal to pointRange, but in lines pointRange
  15473. // is 0 while closestPointRange is some other value
  15474. if (isXAxis) {
  15475. axis.closestPointRange = closestPointRange;
  15476. }
  15477. }
  15478. // Secondary values
  15479. if (saveOld) {
  15480. axis.oldTransA = transA;
  15481. }
  15482. axis.translationSlope = axis.transA = transA =
  15483. axis.staticScale ||
  15484. axis.len / ((range + pointRangePadding) || 1);
  15485. // Translation addend
  15486. axis.transB = axis.horiz ? axis.left : axis.bottom;
  15487. axis.minPixelPadding = transA * minPointOffset;
  15488. fireEvent(this, 'afterSetAxisTranslation');
  15489. };
  15490. /**
  15491. * @private
  15492. * @function Highcharts.Axis#minFromRange
  15493. *
  15494. * @return {number}
  15495. */
  15496. Axis.prototype.minFromRange = function () {
  15497. var axis = this;
  15498. return axis.max - axis.range;
  15499. };
  15500. /**
  15501. * Set the tick positions to round values and optionally extend the extremes
  15502. * to the nearest tick.
  15503. *
  15504. * @private
  15505. * @function Highcharts.Axis#setTickInterval
  15506. *
  15507. * @param {boolean} secondPass
  15508. * TO-DO: parameter description
  15509. *
  15510. * @fires Highcharts.Axis#event:foundExtremes
  15511. */
  15512. Axis.prototype.setTickInterval = function (secondPass) {
  15513. var axis = this,
  15514. chart = axis.chart,
  15515. log = axis.logarithmic,
  15516. options = axis.options,
  15517. isXAxis = axis.isXAxis,
  15518. isLinked = axis.isLinked,
  15519. maxPadding = options.maxPadding,
  15520. minPadding = options.minPadding,
  15521. length,
  15522. linkedParentExtremes,
  15523. tickIntervalOption = options.tickInterval,
  15524. minTickInterval,
  15525. tickPixelIntervalOption = options.tickPixelInterval,
  15526. categories = axis.categories,
  15527. threshold = isNumber(axis.threshold) ? axis.threshold : null,
  15528. softThreshold = axis.softThreshold,
  15529. thresholdMin,
  15530. thresholdMax,
  15531. hardMin,
  15532. hardMax;
  15533. if (!axis.dateTime && !categories && !isLinked) {
  15534. this.getTickAmount();
  15535. }
  15536. // Min or max set either by zooming/setExtremes or initial options
  15537. hardMin = pick(axis.userMin, options.min);
  15538. hardMax = pick(axis.userMax, options.max);
  15539. // Linked axis gets the extremes from the parent axis
  15540. if (isLinked) {
  15541. axis.linkedParent = chart[axis.coll][options.linkedTo];
  15542. linkedParentExtremes = axis.linkedParent.getExtremes();
  15543. axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
  15544. axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
  15545. if (options.type !== axis.linkedParent.options.type) {
  15546. // Can't link axes of different type
  15547. error(11, 1, chart);
  15548. }
  15549. // Initial min and max from the extreme data values
  15550. }
  15551. else {
  15552. // Adjust to hard threshold
  15553. if (softThreshold && defined(threshold)) {
  15554. if (axis.dataMin >= threshold) {
  15555. thresholdMin = threshold;
  15556. minPadding = 0;
  15557. }
  15558. else if (axis.dataMax <= threshold) {
  15559. thresholdMax = threshold;
  15560. maxPadding = 0;
  15561. }
  15562. }
  15563. axis.min = pick(hardMin, thresholdMin, axis.dataMin);
  15564. axis.max = pick(hardMax, thresholdMax, axis.dataMax);
  15565. }
  15566. if (log) {
  15567. if (axis.positiveValuesOnly &&
  15568. !secondPass &&
  15569. Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978
  15570. // Can't plot negative values on log axis
  15571. error(10, 1, chart);
  15572. }
  15573. // The correctFloat cures #934, float errors on full tens. But it
  15574. // was too aggressive for #4360 because of conversion back to lin,
  15575. // therefore use precision 15.
  15576. axis.min = correctFloat(log.log2lin(axis.min), 16);
  15577. axis.max = correctFloat(log.log2lin(axis.max), 16);
  15578. }
  15579. // handle zoomed range
  15580. if (axis.range && defined(axis.max)) {
  15581. // #618, #6773:
  15582. axis.userMin = axis.min = hardMin =
  15583. Math.max(axis.dataMin, axis.minFromRange());
  15584. axis.userMax = hardMax = axis.max;
  15585. axis.range = null; // don't use it when running setExtremes
  15586. }
  15587. // Hook for Highstock Scroller. Consider combining with beforePadding.
  15588. fireEvent(axis, 'foundExtremes');
  15589. // Hook for adjusting this.min and this.max. Used by bubble series.
  15590. if (axis.beforePadding) {
  15591. axis.beforePadding();
  15592. }
  15593. // adjust min and max for the minimum range
  15594. axis.adjustForMinRange();
  15595. // Pad the values to get clear of the chart's edges. To avoid
  15596. // tickInterval taking the padding into account, we do this after
  15597. // computing tick interval (#1337).
  15598. if (!categories &&
  15599. !axis.axisPointRange &&
  15600. !(axis.stacking && axis.stacking.usePercentage) &&
  15601. !isLinked &&
  15602. defined(axis.min) &&
  15603. defined(axis.max)) {
  15604. length = axis.max - axis.min;
  15605. if (length) {
  15606. if (!defined(hardMin) && minPadding) {
  15607. axis.min -= length * minPadding;
  15608. }
  15609. if (!defined(hardMax) && maxPadding) {
  15610. axis.max += length * maxPadding;
  15611. }
  15612. }
  15613. }
  15614. // Handle options for floor, ceiling, softMin and softMax (#6359)
  15615. if (!isNumber(axis.userMin)) {
  15616. if (isNumber(options.softMin) && options.softMin < axis.min) {
  15617. axis.min = hardMin = options.softMin; // #6894
  15618. }
  15619. if (isNumber(options.floor)) {
  15620. axis.min = Math.max(axis.min, options.floor);
  15621. }
  15622. }
  15623. if (!isNumber(axis.userMax)) {
  15624. if (isNumber(options.softMax) && options.softMax > axis.max) {
  15625. axis.max = hardMax = options.softMax; // #6894
  15626. }
  15627. if (isNumber(options.ceiling)) {
  15628. axis.max = Math.min(axis.max, options.ceiling);
  15629. }
  15630. }
  15631. // When the threshold is soft, adjust the extreme value only if the data
  15632. // extreme and the padded extreme land on either side of the threshold.
  15633. // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
  15634. // for -1 because of the default minPadding and startOnTick options.
  15635. // This is prevented by the softThreshold option.
  15636. if (softThreshold && defined(axis.dataMin)) {
  15637. threshold = threshold || 0;
  15638. if (!defined(hardMin) &&
  15639. axis.min < threshold &&
  15640. axis.dataMin >= threshold) {
  15641. axis.min = axis.options.minRange ?
  15642. Math.min(threshold, axis.max -
  15643. axis.minRange) :
  15644. threshold;
  15645. }
  15646. else if (!defined(hardMax) &&
  15647. axis.max > threshold &&
  15648. axis.dataMax <= threshold) {
  15649. axis.max = axis.options.minRange ?
  15650. Math.max(threshold, axis.min +
  15651. axis.minRange) :
  15652. threshold;
  15653. }
  15654. }
  15655. // get tickInterval
  15656. if (axis.min === axis.max ||
  15657. typeof axis.min === 'undefined' ||
  15658. typeof axis.max === 'undefined') {
  15659. axis.tickInterval = 1;
  15660. }
  15661. else if (isLinked &&
  15662. !tickIntervalOption &&
  15663. tickPixelIntervalOption ===
  15664. axis.linkedParent.options.tickPixelInterval) {
  15665. axis.tickInterval = tickIntervalOption =
  15666. axis.linkedParent.tickInterval;
  15667. }
  15668. else {
  15669. axis.tickInterval = pick(tickIntervalOption, this.tickAmount ?
  15670. ((axis.max - axis.min) /
  15671. Math.max(this.tickAmount - 1, 1)) :
  15672. void 0,
  15673. // For categoried axis, 1 is default, for linear axis use
  15674. // tickPix
  15675. categories ?
  15676. 1 :
  15677. // don't let it be more than the data range
  15678. (axis.max - axis.min) *
  15679. tickPixelIntervalOption /
  15680. Math.max(axis.len, tickPixelIntervalOption));
  15681. }
  15682. // Now we're finished detecting min and max, crop and group series data.
  15683. // This is in turn needed in order to find tick positions in ordinal
  15684. // axes.
  15685. if (isXAxis && !secondPass) {
  15686. axis.series.forEach(function (series) {
  15687. series.processData(axis.min !== axis.oldMin || axis.max !== axis.oldMax);
  15688. });
  15689. }
  15690. // set the translation factor used in translate function
  15691. axis.setAxisTranslation(true);
  15692. // hook for ordinal axes and radial axes
  15693. fireEvent(this, 'initialAxisTranslation');
  15694. // In column-like charts, don't cramp in more ticks than there are
  15695. // points (#1943, #4184)
  15696. if (axis.pointRange && !tickIntervalOption) {
  15697. axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
  15698. }
  15699. // Before normalizing the tick interval, handle minimum tick interval.
  15700. // This applies only if tickInterval is not defined.
  15701. minTickInterval = pick(options.minTickInterval,
  15702. // In datetime axes, don't go below the data interval, except when
  15703. // there are scatter-like series involved (#13369).
  15704. axis.dateTime &&
  15705. !axis.series.some(function (s) { return s.noSharedTooltip; }) ?
  15706. axis.closestPointRange : 0);
  15707. if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
  15708. axis.tickInterval = minTickInterval;
  15709. }
  15710. // for linear axes, get magnitude and normalize the interval
  15711. if (!axis.dateTime && !axis.logarithmic && !tickIntervalOption) {
  15712. axis.tickInterval = normalizeTickInterval(axis.tickInterval, void 0, getMagnitude(axis.tickInterval), pick(options.allowDecimals,
  15713. // If the tick interval is greather than 0.5, avoid
  15714. // decimals, as linear axes are often used to render
  15715. // discrete values. #3363. If a tick amount is set, allow
  15716. // decimals by default, as it increases the chances for a
  15717. // good fit.
  15718. axis.tickInterval < 0.5 || this.tickAmount !== void 0), !!this.tickAmount);
  15719. }
  15720. // Prevent ticks from getting so close that we can't draw the labels
  15721. if (!this.tickAmount) {
  15722. axis.tickInterval = axis.unsquish();
  15723. }
  15724. this.setTickPositions();
  15725. };
  15726. /**
  15727. * Now we have computed the normalized tickInterval, get the tick positions.
  15728. *
  15729. * @private
  15730. * @function Highcharts.Axis#setTickPositions
  15731. *
  15732. * @fires Highcharts.Axis#event:afterSetTickPositions
  15733. */
  15734. Axis.prototype.setTickPositions = function () {
  15735. var axis = this,
  15736. options = this.options,
  15737. tickPositions,
  15738. tickPositionsOption = options.tickPositions,
  15739. minorTickIntervalOption = this.getMinorTickInterval(),
  15740. tickPositioner = options.tickPositioner,
  15741. hasVerticalPanning = this.hasVerticalPanning(),
  15742. isColorAxis = this.coll === 'colorAxis',
  15743. startOnTick = (isColorAxis || !hasVerticalPanning) && options.startOnTick,
  15744. endOnTick = (isColorAxis || !hasVerticalPanning) && options.endOnTick;
  15745. // Set the tickmarkOffset
  15746. this.tickmarkOffset = (this.categories &&
  15747. options.tickmarkPlacement === 'between' &&
  15748. this.tickInterval === 1) ? 0.5 : 0; // #3202
  15749. // get minorTickInterval
  15750. this.minorTickInterval =
  15751. minorTickIntervalOption === 'auto' &&
  15752. this.tickInterval ?
  15753. this.tickInterval / 5 :
  15754. minorTickIntervalOption;
  15755. // When there is only one point, or all points have the same value on
  15756. // this axis, then min and max are equal and tickPositions.length is 0
  15757. // or 1. In this case, add some padding in order to center the point,
  15758. // but leave it with one tick. #1337.
  15759. this.single =
  15760. this.min === this.max &&
  15761. defined(this.min) &&
  15762. !this.tickAmount &&
  15763. (
  15764. // Data is on integer (#6563)
  15765. parseInt(this.min, 10) === this.min ||
  15766. // Between integers and decimals are not allowed (#6274)
  15767. options.allowDecimals !== false);
  15768. /**
  15769. * Contains the current positions that are laid out on the axis. The
  15770. * positions are numbers in terms of axis values. In a category axis
  15771. * they are integers, in a datetime axis they are also integers, but
  15772. * designating milliseconds.
  15773. *
  15774. * This property is read only - for modifying the tick positions, use
  15775. * the `tickPositioner` callback or [axis.tickPositions(
  15776. * https://api.highcharts.com/highcharts/xAxis.tickPositions) option
  15777. * instead.
  15778. *
  15779. * @name Highcharts.Axis#tickPositions
  15780. * @type {Highcharts.AxisTickPositionsArray|undefined}
  15781. */
  15782. this.tickPositions =
  15783. // Find the tick positions. Work on a copy (#1565)
  15784. tickPositions =
  15785. (tickPositionsOption && tickPositionsOption.slice());
  15786. if (!tickPositions) {
  15787. // Too many ticks (#6405). Create a friendly warning and provide two
  15788. // ticks so at least we can show the data series.
  15789. if ((!axis.ordinal || !axis.ordinal.positions) &&
  15790. ((this.max - this.min) /
  15791. this.tickInterval >
  15792. Math.max(2 * this.len, 200))) {
  15793. tickPositions = [this.min, this.max];
  15794. error(19, false, this.chart);
  15795. }
  15796. else if (axis.dateTime) {
  15797. tickPositions = axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(this.tickInterval, options.units), this.min, this.max, options.startOfWeek, axis.ordinal && axis.ordinal.positions, this.closestPointRange, true);
  15798. }
  15799. else if (axis.logarithmic) {
  15800. tickPositions = axis.logarithmic.getLogTickPositions(this.tickInterval, this.min, this.max);
  15801. }
  15802. else {
  15803. tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
  15804. }
  15805. // Too dense ticks, keep only the first and last (#4477)
  15806. if (tickPositions.length > this.len) {
  15807. tickPositions = [tickPositions[0], tickPositions.pop()];
  15808. // Reduce doubled value (#7339)
  15809. if (tickPositions[0] === tickPositions[1]) {
  15810. tickPositions.length = 1;
  15811. }
  15812. }
  15813. this.tickPositions = tickPositions;
  15814. // Run the tick positioner callback, that allows modifying auto tick
  15815. // positions.
  15816. if (tickPositioner) {
  15817. tickPositioner = tickPositioner.apply(axis, [this.min, this.max]);
  15818. if (tickPositioner) {
  15819. this.tickPositions = tickPositions = tickPositioner;
  15820. }
  15821. }
  15822. }
  15823. // Reset min/max or remove extremes based on start/end on tick
  15824. this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
  15825. this.trimTicks(tickPositions, startOnTick, endOnTick);
  15826. if (!this.isLinked) {
  15827. // Substract half a unit (#2619, #2846, #2515, #3390),
  15828. // but not in case of multiple ticks (#6897)
  15829. if (this.single &&
  15830. tickPositions.length < 2 &&
  15831. !this.categories &&
  15832. !this.series.some(function (s) {
  15833. return (s.is('heatmap') && s.options.pointPlacement === 'between');
  15834. })) {
  15835. this.min -= 0.5;
  15836. this.max += 0.5;
  15837. }
  15838. if (!tickPositionsOption && !tickPositioner) {
  15839. this.adjustTickAmount();
  15840. }
  15841. }
  15842. fireEvent(this, 'afterSetTickPositions');
  15843. };
  15844. /**
  15845. * Handle startOnTick and endOnTick by either adapting to padding min/max or
  15846. * rounded min/max. Also handle single data points.
  15847. *
  15848. * @private
  15849. * @function Highcharts.Axis#trimTicks
  15850. *
  15851. * @param {Array<number>} tickPositions
  15852. * TO-DO: parameter description
  15853. *
  15854. * @param {boolean} [startOnTick]
  15855. * TO-DO: parameter description
  15856. *
  15857. * @param {boolean} [endOnTick]
  15858. * TO-DO: parameter description
  15859. */
  15860. Axis.prototype.trimTicks = function (tickPositions, startOnTick, endOnTick) {
  15861. var roundedMin = tickPositions[0],
  15862. roundedMax = tickPositions[tickPositions.length - 1],
  15863. minPointOffset = (!this.isOrdinal && this.minPointOffset) || 0; // (#12716)
  15864. fireEvent(this, 'trimTicks');
  15865. if (!this.isLinked) {
  15866. if (startOnTick && roundedMin !== -Infinity) { // #6502
  15867. this.min = roundedMin;
  15868. }
  15869. else {
  15870. while (this.min - minPointOffset > tickPositions[0]) {
  15871. tickPositions.shift();
  15872. }
  15873. }
  15874. if (endOnTick) {
  15875. this.max = roundedMax;
  15876. }
  15877. else {
  15878. while (this.max + minPointOffset <
  15879. tickPositions[tickPositions.length - 1]) {
  15880. tickPositions.pop();
  15881. }
  15882. }
  15883. // If no tick are left, set one tick in the middle (#3195)
  15884. if (tickPositions.length === 0 &&
  15885. defined(roundedMin) &&
  15886. !this.options.tickPositions) {
  15887. tickPositions.push((roundedMax + roundedMin) / 2);
  15888. }
  15889. }
  15890. };
  15891. /**
  15892. * Check if there are multiple axes in the same pane.
  15893. *
  15894. * @private
  15895. * @function Highcharts.Axis#alignToOthers
  15896. *
  15897. * @return {boolean|undefined}
  15898. * True if there are other axes.
  15899. */
  15900. Axis.prototype.alignToOthers = function () {
  15901. var axis = this,
  15902. others = // Whether there is another axis to pair with this one
  15903. {},
  15904. hasOther,
  15905. options = axis.options;
  15906. if (
  15907. // Only if alignTicks is true
  15908. this.chart.options.chart.alignTicks !== false &&
  15909. options.alignTicks !== false &&
  15910. // Disabled when startOnTick or endOnTick are false (#7604)
  15911. options.startOnTick !== false &&
  15912. options.endOnTick !== false &&
  15913. // Don't try to align ticks on a log axis, they are not evenly
  15914. // spaced (#6021)
  15915. !axis.logarithmic) {
  15916. this.chart[this.coll].forEach(function (axis) {
  15917. var otherOptions = axis.options, horiz = axis.horiz, key = [
  15918. horiz ? otherOptions.left : otherOptions.top,
  15919. otherOptions.width,
  15920. otherOptions.height,
  15921. otherOptions.pane
  15922. ].join(',');
  15923. if (axis.series.length) { // #4442
  15924. if (others[key]) {
  15925. hasOther = true; // #4201
  15926. }
  15927. else {
  15928. others[key] = 1;
  15929. }
  15930. }
  15931. });
  15932. }
  15933. return hasOther;
  15934. };
  15935. /**
  15936. * Find the max ticks of either the x and y axis collection, and record it
  15937. * in `this.tickAmount`.
  15938. *
  15939. * @private
  15940. * @function Highcharts.Axis#getTickAmount
  15941. */
  15942. Axis.prototype.getTickAmount = function () {
  15943. var axis = this,
  15944. options = this.options,
  15945. tickAmount = options.tickAmount,
  15946. tickPixelInterval = options.tickPixelInterval;
  15947. if (!defined(options.tickInterval) &&
  15948. !tickAmount && this.len < tickPixelInterval &&
  15949. !this.isRadial &&
  15950. !axis.logarithmic &&
  15951. options.startOnTick &&
  15952. options.endOnTick) {
  15953. tickAmount = 2;
  15954. }
  15955. if (!tickAmount && this.alignToOthers()) {
  15956. // Add 1 because 4 tick intervals require 5 ticks (including first
  15957. // and last)
  15958. tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
  15959. }
  15960. // For tick amounts of 2 and 3, compute five ticks and remove the
  15961. // intermediate ones. This prevents the axis from adding ticks that are
  15962. // too far away from the data extremes.
  15963. if (tickAmount < 4) {
  15964. this.finalTickAmt = tickAmount;
  15965. tickAmount = 5;
  15966. }
  15967. this.tickAmount = tickAmount;
  15968. };
  15969. /**
  15970. * When using multiple axes, adjust the number of ticks to match the highest
  15971. * number of ticks in that group.
  15972. *
  15973. * @private
  15974. * @function Highcharts.Axis#adjustTickAmount
  15975. */
  15976. Axis.prototype.adjustTickAmount = function () {
  15977. var axis = this,
  15978. axisOptions = axis.options,
  15979. tickInterval = axis.tickInterval,
  15980. tickPositions = axis.tickPositions,
  15981. tickAmount = axis.tickAmount,
  15982. finalTickAmt = axis.finalTickAmt,
  15983. currentTickAmount = tickPositions && tickPositions.length,
  15984. threshold = pick(axis.threshold,
  15985. axis.softThreshold ? 0 : null),
  15986. min,
  15987. len,
  15988. i;
  15989. if (axis.hasData()) {
  15990. if (currentTickAmount < tickAmount) {
  15991. min = axis.min;
  15992. while (tickPositions.length < tickAmount) {
  15993. // Extend evenly for both sides unless we're on the
  15994. // threshold (#3965)
  15995. if (tickPositions.length % 2 ||
  15996. min === threshold) {
  15997. // to the end
  15998. tickPositions.push(correctFloat(tickPositions[tickPositions.length - 1] +
  15999. tickInterval));
  16000. }
  16001. else {
  16002. // to the start
  16003. tickPositions.unshift(correctFloat(tickPositions[0] - tickInterval));
  16004. }
  16005. }
  16006. axis.transA *= (currentTickAmount - 1) / (tickAmount - 1);
  16007. // Do not crop when ticks are not extremes (#9841)
  16008. axis.min = axisOptions.startOnTick ?
  16009. tickPositions[0] :
  16010. Math.min(axis.min, tickPositions[0]);
  16011. axis.max = axisOptions.endOnTick ?
  16012. tickPositions[tickPositions.length - 1] :
  16013. Math.max(axis.max, tickPositions[tickPositions.length - 1]);
  16014. // We have too many ticks, run second pass to try to reduce ticks
  16015. }
  16016. else if (currentTickAmount > tickAmount) {
  16017. axis.tickInterval *= 2;
  16018. axis.setTickPositions();
  16019. }
  16020. // The finalTickAmt property is set in getTickAmount
  16021. if (defined(finalTickAmt)) {
  16022. i = len = tickPositions.length;
  16023. while (i--) {
  16024. if (
  16025. // Remove every other tick
  16026. (finalTickAmt === 3 && i % 2 === 1) ||
  16027. // Remove all but first and last
  16028. (finalTickAmt <= 2 && i > 0 && i < len - 1)) {
  16029. tickPositions.splice(i, 1);
  16030. }
  16031. }
  16032. axis.finalTickAmt = void 0;
  16033. }
  16034. }
  16035. };
  16036. /**
  16037. * Set the scale based on data min and max, user set min and max or options.
  16038. *
  16039. * @private
  16040. * @function Highcharts.Axis#setScale
  16041. *
  16042. * @fires Highcharts.Axis#event:afterSetScale
  16043. */
  16044. Axis.prototype.setScale = function () {
  16045. var axis = this,
  16046. isDirtyAxisLength,
  16047. isDirtyData = false,
  16048. isXAxisDirty = false;
  16049. axis.series.forEach(function (series) {
  16050. var _a;
  16051. isDirtyData = isDirtyData || series.isDirtyData || series.isDirty;
  16052. // When x axis is dirty, we need new data extremes for y as
  16053. // well:
  16054. isXAxisDirty = isXAxisDirty || ((_a = series.xAxis) === null || _a === void 0 ? void 0 : _a.isDirty) || false;
  16055. });
  16056. axis.oldMin = axis.min;
  16057. axis.oldMax = axis.max;
  16058. axis.oldAxisLength = axis.len;
  16059. // set the new axisLength
  16060. axis.setAxisSize();
  16061. isDirtyAxisLength = axis.len !== axis.oldAxisLength;
  16062. // do we really need to go through all this?
  16063. if (isDirtyAxisLength ||
  16064. isDirtyData ||
  16065. isXAxisDirty ||
  16066. axis.isLinked ||
  16067. axis.forceRedraw ||
  16068. axis.userMin !== axis.oldUserMin ||
  16069. axis.userMax !== axis.oldUserMax ||
  16070. axis.alignToOthers()) {
  16071. if (axis.stacking) {
  16072. axis.stacking.resetStacks();
  16073. }
  16074. axis.forceRedraw = false;
  16075. // get data extremes if needed
  16076. axis.getSeriesExtremes();
  16077. // get fixed positions based on tickInterval
  16078. axis.setTickInterval();
  16079. // record old values to decide whether a rescale is necessary later
  16080. // on (#540)
  16081. axis.oldUserMin = axis.userMin;
  16082. axis.oldUserMax = axis.userMax;
  16083. // Mark as dirty if it is not already set to dirty and extremes have
  16084. // changed. #595.
  16085. if (!axis.isDirty) {
  16086. axis.isDirty =
  16087. isDirtyAxisLength ||
  16088. axis.min !== axis.oldMin ||
  16089. axis.max !== axis.oldMax;
  16090. }
  16091. }
  16092. else if (axis.stacking) {
  16093. axis.stacking.cleanStacks();
  16094. }
  16095. // Recalculate panning state object, when the data
  16096. // has changed. It is required when vertical panning is enabled.
  16097. if (isDirtyData && axis.panningState) {
  16098. axis.panningState.isDirty = true;
  16099. }
  16100. fireEvent(this, 'afterSetScale');
  16101. };
  16102. /**
  16103. * Set the minimum and maximum of the axes after render time. If the
  16104. * `startOnTick` and `endOnTick` options are true, the minimum and maximum
  16105. * values are rounded off to the nearest tick. To prevent this, these
  16106. * options can be set to false before calling setExtremes. Also, setExtremes
  16107. * will not allow a range lower than the `minRange` option, which by default
  16108. * is the range of five points.
  16109. *
  16110. * @sample highcharts/members/axis-setextremes/
  16111. * Set extremes from a button
  16112. * @sample highcharts/members/axis-setextremes-datetime/
  16113. * Set extremes on a datetime axis
  16114. * @sample highcharts/members/axis-setextremes-off-ticks/
  16115. * Set extremes off ticks
  16116. * @sample stock/members/axis-setextremes/
  16117. * Set extremes in Highstock
  16118. * @sample maps/members/axis-setextremes/
  16119. * Set extremes in Highmaps
  16120. *
  16121. * @function Highcharts.Axis#setExtremes
  16122. *
  16123. * @param {number} [newMin]
  16124. * The new minimum value.
  16125. *
  16126. * @param {number} [newMax]
  16127. * The new maximum value.
  16128. *
  16129. * @param {boolean} [redraw=true]
  16130. * Whether to redraw the chart or wait for an explicit call to
  16131. * {@link Highcharts.Chart#redraw}
  16132. *
  16133. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  16134. * Enable or modify animations.
  16135. *
  16136. * @param {*} [eventArguments]
  16137. * Arguments to be accessed in event handler.
  16138. *
  16139. * @fires Highcharts.Axis#event:setExtremes
  16140. */
  16141. Axis.prototype.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  16142. var axis = this,
  16143. chart = axis.chart;
  16144. redraw = pick(redraw, true); // defaults to true
  16145. axis.series.forEach(function (serie) {
  16146. delete serie.kdTree;
  16147. });
  16148. // Extend the arguments with min and max
  16149. eventArguments = extend(eventArguments, {
  16150. min: newMin,
  16151. max: newMax
  16152. });
  16153. // Fire the event
  16154. fireEvent(axis, 'setExtremes', eventArguments, function () {
  16155. axis.userMin = newMin;
  16156. axis.userMax = newMax;
  16157. axis.eventArgs = eventArguments;
  16158. if (redraw) {
  16159. chart.redraw(animation);
  16160. }
  16161. });
  16162. };
  16163. /**
  16164. * Overridable method for zooming chart. Pulled out in a separate method to
  16165. * allow overriding in stock charts.
  16166. * @private
  16167. * @function Highcharts.Axis#zoom
  16168. *
  16169. * @param {number} newMin
  16170. * TO-DO: parameter description
  16171. *
  16172. * @param {number} newMax
  16173. * TO-DO: parameter description
  16174. *
  16175. * @return {boolean}
  16176. */
  16177. Axis.prototype.zoom = function (newMin, newMax) {
  16178. var axis = this,
  16179. dataMin = this.dataMin,
  16180. dataMax = this.dataMax,
  16181. options = this.options,
  16182. min = Math.min(dataMin,
  16183. pick(options.min,
  16184. dataMin)),
  16185. max = Math.max(dataMax,
  16186. pick(options.max,
  16187. dataMax)),
  16188. evt = {
  16189. newMin: newMin,
  16190. newMax: newMax
  16191. };
  16192. fireEvent(this, 'zoom', evt, function (e) {
  16193. // Use e.newMin and e.newMax - event handlers may have altered them
  16194. var newMin = e.newMin,
  16195. newMax = e.newMax;
  16196. if (newMin !== axis.min || newMax !== axis.max) { // #5790
  16197. // Prevent pinch zooming out of range. Check for defined is for
  16198. // #1946. #1734.
  16199. if (!axis.allowZoomOutside) {
  16200. // #6014, sometimes newMax will be smaller than min (or
  16201. // newMin will be larger than max).
  16202. if (defined(dataMin)) {
  16203. if (newMin < min) {
  16204. newMin = min;
  16205. }
  16206. if (newMin > max) {
  16207. newMin = max;
  16208. }
  16209. }
  16210. if (defined(dataMax)) {
  16211. if (newMax < min) {
  16212. newMax = min;
  16213. }
  16214. if (newMax > max) {
  16215. newMax = max;
  16216. }
  16217. }
  16218. }
  16219. // In full view, displaying the reset zoom button is not
  16220. // required
  16221. axis.displayBtn = (typeof newMin !== 'undefined' ||
  16222. typeof newMax !== 'undefined');
  16223. // Do it
  16224. axis.setExtremes(newMin, newMax, false, void 0, { trigger: 'zoom' });
  16225. }
  16226. e.zoomed = true;
  16227. });
  16228. return evt.zoomed;
  16229. };
  16230. /**
  16231. * Update the axis metrics.
  16232. *
  16233. * @private
  16234. * @function Highcharts.Axis#setAxisSize
  16235. */
  16236. Axis.prototype.setAxisSize = function () {
  16237. var chart = this.chart,
  16238. options = this.options,
  16239. // [top, right, bottom, left]
  16240. offsets = options.offsets || [0, 0, 0, 0],
  16241. horiz = this.horiz,
  16242. // Check for percentage based input values. Rounding fixes problems
  16243. // with column overflow and plot line filtering (#4898, #4899)
  16244. width = this.width = Math.round(relativeLength(pick(options.width,
  16245. chart.plotWidth - offsets[3] + offsets[1]),
  16246. chart.plotWidth)),
  16247. height = this.height = Math.round(relativeLength(pick(options.height,
  16248. chart.plotHeight - offsets[0] + offsets[2]),
  16249. chart.plotHeight)),
  16250. top = this.top = Math.round(relativeLength(pick(options.top,
  16251. chart.plotTop + offsets[0]),
  16252. chart.plotHeight,
  16253. chart.plotTop)),
  16254. left = this.left = Math.round(relativeLength(pick(options.left,
  16255. chart.plotLeft + offsets[3]),
  16256. chart.plotWidth,
  16257. chart.plotLeft));
  16258. // Expose basic values to use in Series object and navigator
  16259. this.bottom = chart.chartHeight - height - top;
  16260. this.right = chart.chartWidth - width - left;
  16261. // Direction agnostic properties
  16262. this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
  16263. this.pos = horiz ? left : top; // distance from SVG origin
  16264. };
  16265. /**
  16266. * Get the current extremes for the axis.
  16267. *
  16268. * @sample highcharts/members/axis-getextremes/
  16269. * Report extremes by click on a button
  16270. * @sample maps/members/axis-getextremes/
  16271. * Get extremes in Highmaps
  16272. *
  16273. * @function Highcharts.Axis#getExtremes
  16274. *
  16275. * @return {Highcharts.ExtremesObject}
  16276. * An object containing extremes information.
  16277. */
  16278. Axis.prototype.getExtremes = function () {
  16279. var axis = this;
  16280. var log = axis.logarithmic;
  16281. return {
  16282. min: log ?
  16283. correctFloat(log.lin2log(axis.min)) :
  16284. axis.min,
  16285. max: log ?
  16286. correctFloat(log.lin2log(axis.max)) :
  16287. axis.max,
  16288. dataMin: axis.dataMin,
  16289. dataMax: axis.dataMax,
  16290. userMin: axis.userMin,
  16291. userMax: axis.userMax
  16292. };
  16293. };
  16294. /**
  16295. * Get the zero plane either based on zero or on the min or max value.
  16296. * Used in bar and area plots.
  16297. *
  16298. * @function Highcharts.Axis#getThreshold
  16299. *
  16300. * @param {number} threshold
  16301. * The threshold in axis values.
  16302. *
  16303. * @return {number|undefined}
  16304. * The translated threshold position in terms of pixels, and corrected to
  16305. * stay within the axis bounds.
  16306. */
  16307. Axis.prototype.getThreshold = function (threshold) {
  16308. var axis = this,
  16309. log = axis.logarithmic,
  16310. realMin = log ? log.lin2log(axis.min) : axis.min,
  16311. realMax = log ? log.lin2log(axis.max) : axis.max;
  16312. if (threshold === null || threshold === -Infinity) {
  16313. threshold = realMin;
  16314. }
  16315. else if (threshold === Infinity) {
  16316. threshold = realMax;
  16317. }
  16318. else if (realMin > threshold) {
  16319. threshold = realMin;
  16320. }
  16321. else if (realMax < threshold) {
  16322. threshold = realMax;
  16323. }
  16324. return axis.translate(threshold, 0, 1, 0, 1);
  16325. };
  16326. /**
  16327. * Compute auto alignment for the axis label based on which side the axis is
  16328. * on and the given rotation for the label.
  16329. *
  16330. * @private
  16331. * @function Highcharts.Axis#autoLabelAlign
  16332. *
  16333. * @param {number} rotation
  16334. * The rotation in degrees as set by either the `rotation` or `autoRotation`
  16335. * options.
  16336. *
  16337. * @return {Highcharts.AlignValue}
  16338. * Can be `"center"`, `"left"` or `"right"`.
  16339. */
  16340. Axis.prototype.autoLabelAlign = function (rotation) {
  16341. var angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360,
  16342. evt = { align: 'center' };
  16343. fireEvent(this, 'autoLabelAlign', evt, function (e) {
  16344. if (angle > 15 && angle < 165) {
  16345. e.align = 'right';
  16346. }
  16347. else if (angle > 195 && angle < 345) {
  16348. e.align = 'left';
  16349. }
  16350. });
  16351. return evt.align;
  16352. };
  16353. /**
  16354. * Get the tick length and width for the axis based on axis options.
  16355. * @private
  16356. * @function Highcharts.Axis#tickSize
  16357. *
  16358. * @param {string} [prefix]
  16359. * 'tick' or 'minorTick'
  16360. *
  16361. * @return {Array<number,number>|undefined}
  16362. * An array of tickLength and tickWidth
  16363. */
  16364. Axis.prototype.tickSize = function (prefix) {
  16365. var options = this.options, tickLength = options[prefix === 'tick' ? 'tickLength' : 'minorTickLength'], tickWidth = pick(options[prefix === 'tick' ? 'tickWidth' : 'minorTickWidth'],
  16366. // Default to 1 on linear and datetime X axes
  16367. prefix === 'tick' && this.isXAxis && !this.categories ? 1 : 0), e, tickSize;
  16368. if (tickWidth && tickLength) {
  16369. // Negate the length
  16370. if (options[prefix + 'Position'] === 'inside') {
  16371. tickLength = -tickLength;
  16372. }
  16373. tickSize = [tickLength, tickWidth];
  16374. }
  16375. e = { tickSize: tickSize };
  16376. fireEvent(this, 'afterTickSize', e);
  16377. return e.tickSize;
  16378. };
  16379. /**
  16380. * Return the size of the labels.
  16381. *
  16382. * @private
  16383. * @function Highcharts.Axis#labelMetrics
  16384. *
  16385. * @return {Highcharts.FontMetricsObject}
  16386. */
  16387. Axis.prototype.labelMetrics = function () {
  16388. var index = this.tickPositions && this.tickPositions[0] || 0;
  16389. return this.chart.renderer.fontMetrics(this.options.labels.style &&
  16390. this.options.labels.style.fontSize, this.ticks[index] && this.ticks[index].label);
  16391. };
  16392. /**
  16393. * Prevent the ticks from getting so close we can't draw the labels. On a
  16394. * horizontal axis, this is handled by rotating the labels, removing ticks
  16395. * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
  16396. *
  16397. * @private
  16398. * @function Highcharts.Axis#unsquish
  16399. *
  16400. * @return {number}
  16401. */
  16402. Axis.prototype.unsquish = function () {
  16403. var labelOptions = this.options.labels,
  16404. horiz = this.horiz,
  16405. tickInterval = this.tickInterval,
  16406. newTickInterval = tickInterval,
  16407. slotSize = this.len / (((this.categories ? 1 : 0) +
  16408. this.max -
  16409. this.min) /
  16410. tickInterval),
  16411. rotation,
  16412. rotationOption = labelOptions.rotation,
  16413. labelMetrics = this.labelMetrics(),
  16414. step,
  16415. bestScore = Number.MAX_VALUE,
  16416. autoRotation,
  16417. range = this.max - this.min,
  16418. // Return the multiple of tickInterval that is needed to avoid
  16419. // collision
  16420. getStep = function (spaceNeeded) {
  16421. var step = spaceNeeded / (slotSize || 1);
  16422. step = step > 1 ? Math.ceil(step) : 1;
  16423. // Guard for very small or negative angles (#9835)
  16424. if (step * tickInterval > range &&
  16425. spaceNeeded !== Infinity &&
  16426. slotSize !== Infinity &&
  16427. range) {
  16428. step = Math.ceil(range / tickInterval);
  16429. }
  16430. return correctFloat(step * tickInterval);
  16431. };
  16432. if (horiz) {
  16433. autoRotation = !labelOptions.staggerLines &&
  16434. !labelOptions.step &&
  16435. ( // #3971
  16436. defined(rotationOption) ?
  16437. [rotationOption] :
  16438. slotSize < pick(labelOptions.autoRotationLimit, 80) && labelOptions.autoRotation);
  16439. if (autoRotation) {
  16440. // Loop over the given autoRotation options, and determine
  16441. // which gives the best score. The best score is that with
  16442. // the lowest number of steps and a rotation closest
  16443. // to horizontal.
  16444. autoRotation.forEach(function (rot) {
  16445. var score;
  16446. if (rot === rotationOption ||
  16447. (rot && rot >= -90 && rot <= 90)) { // #3891
  16448. step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
  16449. score = step + Math.abs(rot / 360);
  16450. if (score < bestScore) {
  16451. bestScore = score;
  16452. rotation = rot;
  16453. newTickInterval = step;
  16454. }
  16455. }
  16456. });
  16457. }
  16458. }
  16459. else if (!labelOptions.step) { // #4411
  16460. newTickInterval = getStep(labelMetrics.h);
  16461. }
  16462. this.autoRotation = autoRotation;
  16463. this.labelRotation = pick(rotation, rotationOption);
  16464. return newTickInterval;
  16465. };
  16466. /**
  16467. * Get the general slot width for labels/categories on this axis. This may
  16468. * change between the pre-render (from Axis.getOffset) and the final tick
  16469. * rendering and placement.
  16470. *
  16471. * @private
  16472. * @function Highcharts.Axis#getSlotWidth
  16473. *
  16474. * @param {Highcharts.Tick} [tick] Optionally, calculate the slot width
  16475. * basing on tick label. It is used in highcharts-3d module, where the slots
  16476. * has different widths depending on perspective angles.
  16477. *
  16478. * @return {number}
  16479. * The pixel width allocated to each axis label.
  16480. */
  16481. Axis.prototype.getSlotWidth = function (tick) {
  16482. var _a;
  16483. // #5086, #1580, #1931
  16484. var chart = this.chart,
  16485. horiz = this.horiz,
  16486. labelOptions = this.options.labels,
  16487. slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
  16488. marginLeft = chart.margin[3];
  16489. // Used by grid axis
  16490. if (tick && isNumber(tick.slotWidth)) { // #13221, can be 0
  16491. return tick.slotWidth;
  16492. }
  16493. if (horiz &&
  16494. labelOptions &&
  16495. (labelOptions.step || 0) < 2) {
  16496. if (labelOptions.rotation) { // #4415
  16497. return 0;
  16498. }
  16499. return ((this.staggerLines || 1) * this.len) / slotCount;
  16500. }
  16501. if (!horiz) {
  16502. // #7028
  16503. var cssWidth = (_a = labelOptions === null || labelOptions === void 0 ? void 0 : labelOptions.style) === null || _a === void 0 ? void 0 : _a.width;
  16504. if (cssWidth !== void 0) {
  16505. return parseInt(cssWidth, 10);
  16506. }
  16507. if (marginLeft) {
  16508. return marginLeft - chart.spacing[3];
  16509. }
  16510. }
  16511. // Last resort, a fraction of the available size
  16512. return chart.chartWidth * 0.33;
  16513. };
  16514. /**
  16515. * Render the axis labels and determine whether ellipsis or rotation need to
  16516. * be applied.
  16517. *
  16518. * @private
  16519. * @function Highcharts.Axis#renderUnsquish
  16520. */
  16521. Axis.prototype.renderUnsquish = function () {
  16522. var chart = this.chart,
  16523. renderer = chart.renderer,
  16524. tickPositions = this.tickPositions,
  16525. ticks = this.ticks,
  16526. labelOptions = this.options.labels,
  16527. labelStyleOptions = (labelOptions && labelOptions.style || {}),
  16528. horiz = this.horiz,
  16529. slotWidth = this.getSlotWidth(),
  16530. innerWidth = Math.max(1,
  16531. Math.round(slotWidth - 2 * (labelOptions.padding || 5))),
  16532. attr = {},
  16533. labelMetrics = this.labelMetrics(),
  16534. textOverflowOption = (labelOptions.style &&
  16535. labelOptions.style.textOverflow),
  16536. commonWidth,
  16537. commonTextOverflow,
  16538. maxLabelLength = 0,
  16539. label,
  16540. i,
  16541. pos;
  16542. // Set rotation option unless it is "auto", like in gauges
  16543. if (!isString(labelOptions.rotation)) {
  16544. // #4443:
  16545. attr.rotation = labelOptions.rotation || 0;
  16546. }
  16547. // Get the longest label length
  16548. tickPositions.forEach(function (tick) {
  16549. tick = ticks[tick];
  16550. // Replace label - sorting animation
  16551. if (tick.movedLabel) {
  16552. tick.replaceMovedLabel();
  16553. }
  16554. if (tick &&
  16555. tick.label &&
  16556. tick.label.textPxLength > maxLabelLength) {
  16557. maxLabelLength = tick.label.textPxLength;
  16558. }
  16559. });
  16560. this.maxLabelLength = maxLabelLength;
  16561. // Handle auto rotation on horizontal axis
  16562. if (this.autoRotation) {
  16563. // Apply rotation only if the label is too wide for the slot, and
  16564. // the label is wider than its height.
  16565. if (maxLabelLength > innerWidth &&
  16566. maxLabelLength > labelMetrics.h) {
  16567. attr.rotation = this.labelRotation;
  16568. }
  16569. else {
  16570. this.labelRotation = 0;
  16571. }
  16572. // Handle word-wrap or ellipsis on vertical axis
  16573. }
  16574. else if (slotWidth) {
  16575. // For word-wrap or ellipsis
  16576. commonWidth = innerWidth;
  16577. if (!textOverflowOption) {
  16578. commonTextOverflow = 'clip';
  16579. // On vertical axis, only allow word wrap if there is room
  16580. // for more lines.
  16581. i = tickPositions.length;
  16582. while (!horiz && i--) {
  16583. pos = tickPositions[i];
  16584. label = ticks[pos].label;
  16585. if (label) {
  16586. // Reset ellipsis in order to get the correct
  16587. // bounding box (#4070)
  16588. if (label.styles &&
  16589. label.styles.textOverflow === 'ellipsis') {
  16590. label.css({ textOverflow: 'clip' });
  16591. // Set the correct width in order to read
  16592. // the bounding box height (#4678, #5034)
  16593. }
  16594. else if (label.textPxLength > slotWidth) {
  16595. label.css({ width: slotWidth + 'px' });
  16596. }
  16597. if (label.getBBox().height > (this.len / tickPositions.length -
  16598. (labelMetrics.h - labelMetrics.f))) {
  16599. label.specificTextOverflow = 'ellipsis';
  16600. }
  16601. }
  16602. }
  16603. }
  16604. }
  16605. // Add ellipsis if the label length is significantly longer than ideal
  16606. if (attr.rotation) {
  16607. commonWidth = (maxLabelLength > chart.chartHeight * 0.5 ?
  16608. chart.chartHeight * 0.33 :
  16609. maxLabelLength);
  16610. if (!textOverflowOption) {
  16611. commonTextOverflow = 'ellipsis';
  16612. }
  16613. }
  16614. // Set the explicit or automatic label alignment
  16615. this.labelAlign = labelOptions.align ||
  16616. this.autoLabelAlign(this.labelRotation);
  16617. if (this.labelAlign) {
  16618. attr.align = this.labelAlign;
  16619. }
  16620. // Apply general and specific CSS
  16621. tickPositions.forEach(function (pos) {
  16622. var tick = ticks[pos],
  16623. label = tick && tick.label,
  16624. widthOption = labelStyleOptions.width,
  16625. css = {};
  16626. if (label) {
  16627. // This needs to go before the CSS in old IE (#4502)
  16628. label.attr(attr);
  16629. if (tick.shortenLabel) {
  16630. tick.shortenLabel();
  16631. }
  16632. else if (commonWidth &&
  16633. !widthOption &&
  16634. // Setting width in this case messes with the bounding box
  16635. // (#7975)
  16636. labelStyleOptions.whiteSpace !== 'nowrap' &&
  16637. (
  16638. // Speed optimizing, #7656
  16639. commonWidth < label.textPxLength ||
  16640. // Resetting CSS, #4928
  16641. label.element.tagName === 'SPAN')) {
  16642. css.width = commonWidth + 'px';
  16643. if (!textOverflowOption) {
  16644. css.textOverflow = (label.specificTextOverflow ||
  16645. commonTextOverflow);
  16646. }
  16647. label.css(css);
  16648. // Reset previously shortened label (#8210)
  16649. }
  16650. else if (label.styles &&
  16651. label.styles.width &&
  16652. !css.width &&
  16653. !widthOption) {
  16654. label.css({ width: null });
  16655. }
  16656. delete label.specificTextOverflow;
  16657. tick.rotation = attr.rotation;
  16658. }
  16659. }, this);
  16660. // Note: Why is this not part of getLabelPosition?
  16661. this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
  16662. };
  16663. /**
  16664. * Return true if the axis has associated data.
  16665. *
  16666. * @function Highcharts.Axis#hasData
  16667. *
  16668. * @return {boolean}
  16669. * True if the axis has associated visible series and those series have
  16670. * either valid data points or explicit `min` and `max` settings.
  16671. */
  16672. Axis.prototype.hasData = function () {
  16673. return this.series.some(function (s) {
  16674. return s.hasData();
  16675. }) ||
  16676. (this.options.showEmpty &&
  16677. defined(this.min) &&
  16678. defined(this.max));
  16679. };
  16680. /**
  16681. * Adds the title defined in axis.options.title.
  16682. *
  16683. * @function Highcharts.Axis#addTitle
  16684. *
  16685. * @param {boolean} [display]
  16686. * Whether or not to display the title.
  16687. */
  16688. Axis.prototype.addTitle = function (display) {
  16689. var axis = this,
  16690. renderer = axis.chart.renderer,
  16691. horiz = axis.horiz,
  16692. opposite = axis.opposite,
  16693. options = axis.options,
  16694. axisTitleOptions = options.title,
  16695. textAlign,
  16696. styledMode = axis.chart.styledMode;
  16697. if (!axis.axisTitle) {
  16698. textAlign = axisTitleOptions.textAlign;
  16699. if (!textAlign) {
  16700. textAlign = (horiz ? {
  16701. low: 'left',
  16702. middle: 'center',
  16703. high: 'right'
  16704. } : {
  16705. low: opposite ? 'right' : 'left',
  16706. middle: 'center',
  16707. high: opposite ? 'left' : 'right'
  16708. })[axisTitleOptions.align];
  16709. }
  16710. axis.axisTitle = renderer
  16711. .text(axisTitleOptions.text, 0, 0, axisTitleOptions.useHTML)
  16712. .attr({
  16713. zIndex: 7,
  16714. rotation: axisTitleOptions.rotation || 0,
  16715. align: textAlign
  16716. })
  16717. .addClass('highcharts-axis-title');
  16718. // #7814, don't mutate style option
  16719. if (!styledMode) {
  16720. axis.axisTitle.css(merge(axisTitleOptions.style));
  16721. }
  16722. axis.axisTitle.add(axis.axisGroup);
  16723. axis.axisTitle.isNew = true;
  16724. }
  16725. // Max width defaults to the length of the axis
  16726. if (!styledMode &&
  16727. !axisTitleOptions.style.width &&
  16728. !axis.isRadial) {
  16729. axis.axisTitle.css({
  16730. width: axis.len + 'px'
  16731. });
  16732. }
  16733. // hide or show the title depending on whether showEmpty is set
  16734. axis.axisTitle[display ? 'show' : 'hide'](display);
  16735. };
  16736. /**
  16737. * Generates a tick for initial positioning.
  16738. *
  16739. * @private
  16740. * @function Highcharts.Axis#generateTick
  16741. *
  16742. * @param {number} pos
  16743. * The tick position in axis values.
  16744. *
  16745. * @param {number} [i]
  16746. * The index of the tick in {@link Axis.tickPositions}.
  16747. */
  16748. Axis.prototype.generateTick = function (pos) {
  16749. var axis = this;
  16750. var ticks = axis.ticks;
  16751. if (!ticks[pos]) {
  16752. ticks[pos] = new Tick(axis, pos);
  16753. }
  16754. else {
  16755. ticks[pos].addLabel(); // update labels depending on tick interval
  16756. }
  16757. };
  16758. /**
  16759. * Render the tick labels to a preliminary position to get their sizes
  16760. *
  16761. * @private
  16762. * @function Highcharts.Axis#getOffset
  16763. *
  16764. * @fires Highcharts.Axis#event:afterGetOffset
  16765. */
  16766. Axis.prototype.getOffset = function () {
  16767. var axis = this,
  16768. chart = axis.chart,
  16769. renderer = chart.renderer,
  16770. options = axis.options,
  16771. tickPositions = axis.tickPositions,
  16772. ticks = axis.ticks,
  16773. horiz = axis.horiz,
  16774. side = axis.side,
  16775. invertedSide = chart.inverted &&
  16776. !axis.isZAxis ? [1, 0, 3, 2][side] : side,
  16777. hasData,
  16778. showAxis,
  16779. titleOffset = 0,
  16780. titleOffsetOption,
  16781. titleMargin = 0,
  16782. axisTitleOptions = options.title,
  16783. labelOptions = options.labels,
  16784. labelOffset = 0, // reset
  16785. labelOffsetPadded,
  16786. axisOffset = chart.axisOffset,
  16787. clipOffset = chart.clipOffset,
  16788. clip,
  16789. directionFactor = [-1, 1, 1, -1][side],
  16790. className = options.className,
  16791. axisParent = axis.axisParent, // Used in color axis
  16792. lineHeightCorrection;
  16793. // For reuse in Axis.render
  16794. hasData = axis.hasData();
  16795. axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);
  16796. // Set/reset staggerLines
  16797. axis.staggerLines = axis.horiz && labelOptions.staggerLines;
  16798. // Create the axisGroup and gridGroup elements on first iteration
  16799. if (!axis.axisGroup) {
  16800. axis.gridGroup = renderer.g('grid')
  16801. .attr({ zIndex: options.gridZIndex || 1 })
  16802. .addClass('highcharts-' + this.coll.toLowerCase() + '-grid ' +
  16803. (className || ''))
  16804. .add(axisParent);
  16805. axis.axisGroup = renderer.g('axis')
  16806. .attr({ zIndex: options.zIndex || 2 })
  16807. .addClass('highcharts-' + this.coll.toLowerCase() + ' ' +
  16808. (className || ''))
  16809. .add(axisParent);
  16810. axis.labelGroup = renderer.g('axis-labels')
  16811. .attr({ zIndex: labelOptions.zIndex || 7 })
  16812. .addClass('highcharts-' + axis.coll.toLowerCase() + '-labels ' +
  16813. (className || ''))
  16814. .add(axisParent);
  16815. }
  16816. if (hasData || axis.isLinked) {
  16817. // Generate ticks
  16818. tickPositions.forEach(function (pos, i) {
  16819. // i is not used here, but may be used in overrides
  16820. axis.generateTick(pos, i);
  16821. });
  16822. axis.renderUnsquish();
  16823. // Left side must be align: right and right side must
  16824. // have align: left for labels
  16825. axis.reserveSpaceDefault = (side === 0 ||
  16826. side === 2 ||
  16827. { 1: 'left', 3: 'right' }[side] === axis.labelAlign);
  16828. if (pick(labelOptions.reserveSpace, axis.labelAlign === 'center' ? true : null, axis.reserveSpaceDefault)) {
  16829. tickPositions.forEach(function (pos) {
  16830. // get the highest offset
  16831. labelOffset = Math.max(ticks[pos].getLabelSize(), labelOffset);
  16832. });
  16833. }
  16834. if (axis.staggerLines) {
  16835. labelOffset *= axis.staggerLines;
  16836. }
  16837. axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
  16838. }
  16839. else { // doesn't have data
  16840. objectEach(ticks, function (tick, n) {
  16841. tick.destroy();
  16842. delete ticks[n];
  16843. });
  16844. }
  16845. if (axisTitleOptions &&
  16846. axisTitleOptions.text &&
  16847. axisTitleOptions.enabled !== false) {
  16848. axis.addTitle(showAxis);
  16849. if (showAxis && axisTitleOptions.reserveSpace !== false) {
  16850. axis.titleOffset = titleOffset =
  16851. axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
  16852. titleOffsetOption = axisTitleOptions.offset;
  16853. titleMargin = defined(titleOffsetOption) ?
  16854. 0 :
  16855. pick(axisTitleOptions.margin, horiz ? 5 : 10);
  16856. }
  16857. }
  16858. // Render the axis line
  16859. axis.renderLine();
  16860. // handle automatic or user set offset
  16861. axis.offset = directionFactor * pick(options.offset, axisOffset[side] ? axisOffset[side] + (options.margin || 0) : 0);
  16862. axis.tickRotCorr = axis.tickRotCorr || { x: 0, y: 0 }; // polar
  16863. if (side === 0) {
  16864. lineHeightCorrection = -axis.labelMetrics().h;
  16865. }
  16866. else if (side === 2) {
  16867. lineHeightCorrection = axis.tickRotCorr.y;
  16868. }
  16869. else {
  16870. lineHeightCorrection = 0;
  16871. }
  16872. // Find the padded label offset
  16873. labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
  16874. if (labelOffset) {
  16875. labelOffsetPadded -= lineHeightCorrection;
  16876. labelOffsetPadded += directionFactor * (horiz ?
  16877. pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) :
  16878. labelOptions.x);
  16879. }
  16880. axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
  16881. if (axis.getMaxLabelDimensions) {
  16882. axis.maxLabelDimensions = axis.getMaxLabelDimensions(ticks, tickPositions);
  16883. }
  16884. // Due to GridAxis.tickSize, tickSize should be calculated after ticks
  16885. // has rendered.
  16886. var tickSize = this.tickSize('tick');
  16887. axisOffset[side] = Math.max(axisOffset[side], axis.axisTitleMargin + titleOffset +
  16888. directionFactor * axis.offset, labelOffsetPadded, // #3027
  16889. tickPositions && tickPositions.length && tickSize ?
  16890. tickSize[0] + directionFactor * axis.offset :
  16891. 0 // #4866
  16892. );
  16893. // Decide the clipping needed to keep the graph inside
  16894. // the plot area and axis lines
  16895. clip = options.offset ?
  16896. 0 :
  16897. // #4308, #4371:
  16898. Math.floor(axis.axisLine.strokeWidth() / 2) * 2;
  16899. clipOffset[invertedSide] =
  16900. Math.max(clipOffset[invertedSide], clip);
  16901. fireEvent(this, 'afterGetOffset');
  16902. };
  16903. /**
  16904. * Internal function to get the path for the axis line. Extended for polar
  16905. * charts.
  16906. *
  16907. * @function Highcharts.Axis#getLinePath
  16908. *
  16909. * @param {number} lineWidth
  16910. * The line width in pixels.
  16911. *
  16912. * @return {Highcharts.SVGPathArray}
  16913. * The SVG path definition in array form.
  16914. */
  16915. Axis.prototype.getLinePath = function (lineWidth) {
  16916. var chart = this.chart,
  16917. opposite = this.opposite,
  16918. offset = this.offset,
  16919. horiz = this.horiz,
  16920. lineLeft = this.left + (opposite ? this.width : 0) + offset,
  16921. lineTop = chart.chartHeight - this.bottom -
  16922. (opposite ? this.height : 0) + offset;
  16923. if (opposite) {
  16924. lineWidth *= -1; // crispify the other way - #1480, #1687
  16925. }
  16926. return chart.renderer
  16927. .crispLine([
  16928. [
  16929. 'M',
  16930. horiz ?
  16931. this.left :
  16932. lineLeft,
  16933. horiz ?
  16934. lineTop :
  16935. this.top
  16936. ],
  16937. [
  16938. 'L',
  16939. horiz ?
  16940. chart.chartWidth - this.right :
  16941. lineLeft,
  16942. horiz ?
  16943. lineTop :
  16944. chart.chartHeight - this.bottom
  16945. ]
  16946. ], lineWidth);
  16947. };
  16948. /**
  16949. * Render the axis line. Called internally when rendering and redrawing the
  16950. * axis.
  16951. *
  16952. * @function Highcharts.Axis#renderLine
  16953. */
  16954. Axis.prototype.renderLine = function () {
  16955. if (!this.axisLine) {
  16956. this.axisLine = this.chart.renderer.path()
  16957. .addClass('highcharts-axis-line')
  16958. .add(this.axisGroup);
  16959. if (!this.chart.styledMode) {
  16960. this.axisLine.attr({
  16961. stroke: this.options.lineColor,
  16962. 'stroke-width': this.options.lineWidth,
  16963. zIndex: 7
  16964. });
  16965. }
  16966. }
  16967. };
  16968. /**
  16969. * Position the axis title.
  16970. *
  16971. * @private
  16972. * @function Highcharts.Axis#getTitlePosition
  16973. *
  16974. * @return {Highcharts.PositionObject}
  16975. * X and Y positions for the title.
  16976. */
  16977. Axis.prototype.getTitlePosition = function () {
  16978. // compute anchor points for each of the title align options
  16979. var horiz = this.horiz,
  16980. axisLeft = this.left,
  16981. axisTop = this.top,
  16982. axisLength = this.len,
  16983. axisTitleOptions = this.options.title,
  16984. margin = horiz ? axisLeft : axisTop,
  16985. opposite = this.opposite,
  16986. offset = this.offset,
  16987. xOption = axisTitleOptions.x || 0,
  16988. yOption = axisTitleOptions.y || 0,
  16989. axisTitle = this.axisTitle,
  16990. fontMetrics = this.chart.renderer.fontMetrics(axisTitleOptions.style &&
  16991. axisTitleOptions.style.fontSize,
  16992. axisTitle),
  16993. // The part of a multiline text that is below the baseline of the
  16994. // first line. Subtract 1 to preserve pixel-perfectness from the
  16995. // old behaviour (v5.0.12), where only one line was allowed.
  16996. textHeightOvershoot = Math.max(axisTitle.getBBox(null, 0).height - fontMetrics.h - 1, 0),
  16997. // the position in the length direction of the axis
  16998. alongAxis = {
  16999. low: margin + (horiz ? 0 : axisLength),
  17000. middle: margin + axisLength / 2,
  17001. high: margin + (horiz ? axisLength : 0)
  17002. }[axisTitleOptions.align],
  17003. // the position in the perpendicular direction of the axis
  17004. offAxis = (horiz ? axisTop + this.height : axisLeft) +
  17005. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  17006. (opposite ? -1 : 1) * // so does opposite axes
  17007. this.axisTitleMargin +
  17008. [
  17009. -textHeightOvershoot,
  17010. textHeightOvershoot,
  17011. fontMetrics.f,
  17012. -textHeightOvershoot // left
  17013. ][this.side],
  17014. titlePosition = {
  17015. x: horiz ?
  17016. alongAxis + xOption :
  17017. offAxis + (opposite ? this.width : 0) + offset + xOption,
  17018. y: horiz ?
  17019. offAxis + yOption - (opposite ? this.height : 0) + offset :
  17020. alongAxis + yOption
  17021. };
  17022. fireEvent(this, 'afterGetTitlePosition', { titlePosition: titlePosition });
  17023. return titlePosition;
  17024. };
  17025. /**
  17026. * Render a minor tick into the given position. If a minor tick already
  17027. * exists in this position, move it.
  17028. *
  17029. * @function Highcharts.Axis#renderMinorTick
  17030. *
  17031. * @param {number} pos
  17032. * The position in axis values.
  17033. */
  17034. Axis.prototype.renderMinorTick = function (pos) {
  17035. var axis = this;
  17036. var slideInTicks = axis.chart.hasRendered && isNumber(axis.oldMin);
  17037. var minorTicks = axis.minorTicks;
  17038. if (!minorTicks[pos]) {
  17039. minorTicks[pos] = new Tick(axis, pos, 'minor');
  17040. }
  17041. // Render new ticks in old position
  17042. if (slideInTicks && minorTicks[pos].isNew) {
  17043. minorTicks[pos].render(null, true);
  17044. }
  17045. minorTicks[pos].render(null, false, 1);
  17046. };
  17047. /**
  17048. * Render a major tick into the given position. If a tick already exists
  17049. * in this position, move it.
  17050. *
  17051. * @function Highcharts.Axis#renderTick
  17052. *
  17053. * @param {number} pos
  17054. * The position in axis values.
  17055. *
  17056. * @param {number} i
  17057. * The tick index.
  17058. */
  17059. Axis.prototype.renderTick = function (pos, i) {
  17060. var axis = this;
  17061. var isLinked = axis.isLinked;
  17062. var ticks = axis.ticks;
  17063. var slideInTicks = axis.chart.hasRendered && isNumber(axis.oldMin);
  17064. // Linked axes need an extra check to find out if
  17065. if (!isLinked ||
  17066. (pos >= axis.min && pos <= axis.max)) {
  17067. if (!ticks[pos]) {
  17068. ticks[pos] = new Tick(axis, pos);
  17069. }
  17070. // NOTE this seems like overkill. Could be handled in tick.render by
  17071. // setting old position in attr, then set new position in animate.
  17072. // render new ticks in old position
  17073. if (slideInTicks && ticks[pos].isNew) {
  17074. // Start with negative opacity so that it is visible from
  17075. // halfway into the animation
  17076. ticks[pos].render(i, true, -1);
  17077. }
  17078. ticks[pos].render(i);
  17079. }
  17080. };
  17081. /**
  17082. * Render the axis.
  17083. *
  17084. * @private
  17085. * @function Highcharts.Axis#render
  17086. *
  17087. * @fires Highcharts.Axis#event:afterRender
  17088. */
  17089. Axis.prototype.render = function () {
  17090. var axis = this,
  17091. chart = axis.chart,
  17092. log = axis.logarithmic,
  17093. renderer = chart.renderer,
  17094. options = axis.options,
  17095. isLinked = axis.isLinked,
  17096. tickPositions = axis.tickPositions,
  17097. axisTitle = axis.axisTitle,
  17098. ticks = axis.ticks,
  17099. minorTicks = axis.minorTicks,
  17100. alternateBands = axis.alternateBands,
  17101. stackLabelOptions = options.stackLabels,
  17102. alternateGridColor = options.alternateGridColor,
  17103. tickmarkOffset = axis.tickmarkOffset,
  17104. axisLine = axis.axisLine,
  17105. showAxis = axis.showAxis,
  17106. animation = animObject(renderer.globalAnimation),
  17107. from,
  17108. to;
  17109. // Reset
  17110. axis.labelEdge.length = 0;
  17111. axis.overlap = false;
  17112. // Mark all elements inActive before we go over and mark the active ones
  17113. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17114. objectEach(coll, function (tick) {
  17115. tick.isActive = false;
  17116. });
  17117. });
  17118. // If the series has data draw the ticks. Else only the line and title
  17119. if (axis.hasData() || isLinked) {
  17120. // minor ticks
  17121. if (axis.minorTickInterval && !axis.categories) {
  17122. axis.getMinorTickPositions().forEach(function (pos) {
  17123. axis.renderMinorTick(pos);
  17124. });
  17125. }
  17126. // Major ticks. Pull out the first item and render it last so that
  17127. // we can get the position of the neighbour label. #808.
  17128. if (tickPositions.length) { // #1300
  17129. tickPositions.forEach(function (pos, i) {
  17130. axis.renderTick(pos, i);
  17131. });
  17132. // In a categorized axis, the tick marks are displayed
  17133. // between labels. So we need to add a tick mark and
  17134. // grid line at the left edge of the X axis.
  17135. if (tickmarkOffset && (axis.min === 0 || axis.single)) {
  17136. if (!ticks[-1]) {
  17137. ticks[-1] = new Tick(axis, -1, null, true);
  17138. }
  17139. ticks[-1].render(-1);
  17140. }
  17141. }
  17142. // alternate grid color
  17143. if (alternateGridColor) {
  17144. tickPositions.forEach(function (pos, i) {
  17145. to = typeof tickPositions[i + 1] !== 'undefined' ?
  17146. tickPositions[i + 1] + tickmarkOffset :
  17147. axis.max - tickmarkOffset;
  17148. if (i % 2 === 0 &&
  17149. pos < axis.max &&
  17150. to <= axis.max + (chart.polar ?
  17151. -tickmarkOffset :
  17152. tickmarkOffset)) { // #2248, #4660
  17153. if (!alternateBands[pos]) {
  17154. // Should be imported from PlotLineOrBand.js, but
  17155. // the dependency cycle with axis is a problem
  17156. alternateBands[pos] = new H.PlotLineOrBand(axis);
  17157. }
  17158. from = pos + tickmarkOffset; // #949
  17159. alternateBands[pos].options = {
  17160. from: log ? log.lin2log(from) : from,
  17161. to: log ? log.lin2log(to) : to,
  17162. color: alternateGridColor,
  17163. className: 'highcharts-alternate-grid'
  17164. };
  17165. alternateBands[pos].render();
  17166. alternateBands[pos].isActive = true;
  17167. }
  17168. });
  17169. }
  17170. // custom plot lines and bands
  17171. if (!axis._addedPlotLB) { // only first time
  17172. (options.plotLines || [])
  17173. .concat(options.plotBands || [])
  17174. .forEach(function (plotLineOptions) {
  17175. axis.addPlotBandOrLine(plotLineOptions);
  17176. });
  17177. axis._addedPlotLB = true;
  17178. }
  17179. } // end if hasData
  17180. // Remove inactive ticks
  17181. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17182. var i,
  17183. forDestruction = [],
  17184. delay = animation.duration,
  17185. destroyInactiveItems = function () {
  17186. i = forDestruction.length;
  17187. while (i--) {
  17188. // When resizing rapidly, the same items
  17189. // may be destroyed in different timeouts,
  17190. // or the may be reactivated
  17191. if (coll[forDestruction[i]] &&
  17192. !coll[forDestruction[i]].isActive) {
  17193. coll[forDestruction[i]].destroy();
  17194. delete coll[forDestruction[i]];
  17195. }
  17196. }
  17197. };
  17198. objectEach(coll, function (tick, pos) {
  17199. if (!tick.isActive) {
  17200. // Render to zero opacity
  17201. tick.render(pos, false, 0);
  17202. tick.isActive = false;
  17203. forDestruction.push(pos);
  17204. }
  17205. });
  17206. // When the objects are finished fading out, destroy them
  17207. syncTimeout(destroyInactiveItems, coll === alternateBands ||
  17208. !chart.hasRendered ||
  17209. !delay ?
  17210. 0 :
  17211. delay);
  17212. });
  17213. // Set the axis line path
  17214. if (axisLine) {
  17215. axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
  17216. d: this.getLinePath(axisLine.strokeWidth())
  17217. });
  17218. axisLine.isPlaced = true;
  17219. // Show or hide the line depending on options.showEmpty
  17220. axisLine[showAxis ? 'show' : 'hide'](showAxis);
  17221. }
  17222. if (axisTitle && showAxis) {
  17223. var titleXy = axis.getTitlePosition();
  17224. if (isNumber(titleXy.y)) {
  17225. axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
  17226. axisTitle.isNew = false;
  17227. }
  17228. else {
  17229. axisTitle.attr('y', -9999);
  17230. axisTitle.isNew = true;
  17231. }
  17232. }
  17233. // Stacked totals:
  17234. if (stackLabelOptions && stackLabelOptions.enabled && axis.stacking) {
  17235. axis.stacking.renderStackTotals();
  17236. }
  17237. // End stacked totals
  17238. axis.isDirty = false;
  17239. fireEvent(this, 'afterRender');
  17240. };
  17241. /**
  17242. * Redraw the axis to reflect changes in the data or axis extremes. Called
  17243. * internally from Highcharts.Chart#redraw.
  17244. *
  17245. * @private
  17246. * @function Highcharts.Axis#redraw
  17247. */
  17248. Axis.prototype.redraw = function () {
  17249. if (this.visible) {
  17250. // render the axis
  17251. this.render();
  17252. // move plot lines and bands
  17253. this.plotLinesAndBands.forEach(function (plotLine) {
  17254. plotLine.render();
  17255. });
  17256. }
  17257. // mark associated series as dirty and ready for redraw
  17258. this.series.forEach(function (series) {
  17259. series.isDirty = true;
  17260. });
  17261. };
  17262. /**
  17263. * Returns an array of axis properties, that should be untouched during
  17264. * reinitialization.
  17265. *
  17266. * @private
  17267. * @function Highcharts.Axis#getKeepProps
  17268. *
  17269. * @return {Array<string>}
  17270. */
  17271. Axis.prototype.getKeepProps = function () {
  17272. return (this.keepProps || Axis.keepProps);
  17273. };
  17274. /**
  17275. * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
  17276. * to fully remove the axis.
  17277. *
  17278. * @private
  17279. * @function Highcharts.Axis#destroy
  17280. *
  17281. * @param {boolean} [keepEvents]
  17282. * Whether to preserve events, used internally in Axis.update.
  17283. */
  17284. Axis.prototype.destroy = function (keepEvents) {
  17285. var axis = this,
  17286. plotLinesAndBands = axis.plotLinesAndBands,
  17287. plotGroup,
  17288. i;
  17289. fireEvent(this, 'destroy', { keepEvents: keepEvents });
  17290. // Remove the events
  17291. if (!keepEvents) {
  17292. removeEvent(axis);
  17293. }
  17294. // Destroy collections
  17295. [axis.ticks, axis.minorTicks, axis.alternateBands].forEach(function (coll) {
  17296. destroyObjectProperties(coll);
  17297. });
  17298. if (plotLinesAndBands) {
  17299. i = plotLinesAndBands.length;
  17300. while (i--) { // #1975
  17301. plotLinesAndBands[i].destroy();
  17302. }
  17303. }
  17304. // Destroy elements
  17305. ['axisLine', 'axisTitle', 'axisGroup',
  17306. 'gridGroup', 'labelGroup', 'cross', 'scrollbar'].forEach(function (prop) {
  17307. if (axis[prop]) {
  17308. axis[prop] = axis[prop].destroy();
  17309. }
  17310. });
  17311. // Destroy each generated group for plotlines and plotbands
  17312. for (plotGroup in axis.plotLinesAndBandsGroups) { // eslint-disable-line guard-for-in
  17313. axis.plotLinesAndBandsGroups[plotGroup] =
  17314. axis.plotLinesAndBandsGroups[plotGroup].destroy();
  17315. }
  17316. // Delete all properties and fall back to the prototype.
  17317. objectEach(axis, function (val, key) {
  17318. if (axis.getKeepProps().indexOf(key) === -1) {
  17319. delete axis[key];
  17320. }
  17321. });
  17322. };
  17323. /**
  17324. * Internal function to draw a crosshair.
  17325. *
  17326. * @function Highcharts.Axis#drawCrosshair
  17327. *
  17328. * @param {Highcharts.PointerEventObject} [e]
  17329. * The event arguments from the modified pointer event, extended with
  17330. * `chartX` and `chartY`
  17331. *
  17332. * @param {Highcharts.Point} [point]
  17333. * The Point object if the crosshair snaps to points.
  17334. *
  17335. * @fires Highcharts.Axis#event:afterDrawCrosshair
  17336. * @fires Highcharts.Axis#event:drawCrosshair
  17337. */
  17338. Axis.prototype.drawCrosshair = function (e, point) {
  17339. var path,
  17340. options = this.crosshair,
  17341. snap = pick(options.snap,
  17342. true),
  17343. pos,
  17344. categorized,
  17345. graphic = this.cross,
  17346. crossOptions,
  17347. chart = this.chart;
  17348. fireEvent(this, 'drawCrosshair', { e: e, point: point });
  17349. // Use last available event when updating non-snapped crosshairs without
  17350. // mouse interaction (#5287)
  17351. if (!e) {
  17352. e = this.cross && this.cross.e;
  17353. }
  17354. if (
  17355. // Disabled in options
  17356. !this.crosshair ||
  17357. // Snap
  17358. ((defined(point) || !snap) === false)) {
  17359. this.hideCrosshair();
  17360. }
  17361. else {
  17362. // Get the path
  17363. if (!snap) {
  17364. pos = e &&
  17365. (this.horiz ?
  17366. e.chartX - this.pos :
  17367. this.len - e.chartY + this.pos);
  17368. }
  17369. else if (defined(point)) {
  17370. // #3834
  17371. pos = pick(this.coll !== 'colorAxis' ?
  17372. point.crosshairPos : // 3D axis extension
  17373. null, this.isXAxis ?
  17374. point.plotX :
  17375. this.len - point.plotY);
  17376. }
  17377. if (defined(pos)) {
  17378. crossOptions = {
  17379. // value, only used on radial
  17380. value: point && (this.isXAxis ?
  17381. point.x :
  17382. pick(point.stackY, point.y)),
  17383. translatedValue: pos
  17384. };
  17385. if (chart.polar) {
  17386. // Additional information required for crosshairs in
  17387. // polar chart
  17388. extend(crossOptions, {
  17389. isCrosshair: true,
  17390. chartX: e && e.chartX,
  17391. chartY: e && e.chartY,
  17392. point: point
  17393. });
  17394. }
  17395. path = this.getPlotLinePath(crossOptions) ||
  17396. null; // #3189
  17397. }
  17398. if (!defined(path)) {
  17399. this.hideCrosshair();
  17400. return;
  17401. }
  17402. categorized = this.categories && !this.isRadial;
  17403. // Draw the cross
  17404. if (!graphic) {
  17405. this.cross = graphic = chart.renderer
  17406. .path()
  17407. .addClass('highcharts-crosshair highcharts-crosshair-' +
  17408. (categorized ? 'category ' : 'thin ') +
  17409. options.className)
  17410. .attr({
  17411. zIndex: pick(options.zIndex, 2)
  17412. })
  17413. .add();
  17414. // Presentational attributes
  17415. if (!chart.styledMode) {
  17416. graphic.attr({
  17417. stroke: options.color ||
  17418. (categorized ?
  17419. Color
  17420. .parse('#ccd6eb')
  17421. .setOpacity(0.25)
  17422. .get() :
  17423. '#cccccc'),
  17424. 'stroke-width': pick(options.width, 1)
  17425. }).css({
  17426. 'pointer-events': 'none'
  17427. });
  17428. if (options.dashStyle) {
  17429. graphic.attr({
  17430. dashstyle: options.dashStyle
  17431. });
  17432. }
  17433. }
  17434. }
  17435. graphic.show().attr({
  17436. d: path
  17437. });
  17438. if (categorized && !options.width) {
  17439. graphic.attr({
  17440. 'stroke-width': this.transA
  17441. });
  17442. }
  17443. this.cross.e = e;
  17444. }
  17445. fireEvent(this, 'afterDrawCrosshair', { e: e, point: point });
  17446. };
  17447. /**
  17448. * Hide the crosshair if visible.
  17449. *
  17450. * @function Highcharts.Axis#hideCrosshair
  17451. */
  17452. Axis.prototype.hideCrosshair = function () {
  17453. if (this.cross) {
  17454. this.cross.hide();
  17455. }
  17456. fireEvent(this, 'afterHideCrosshair');
  17457. };
  17458. /**
  17459. * Check whether the chart has vertical panning ('y' or 'xy' type).
  17460. *
  17461. * @private
  17462. * @function Highcharts.Axis#hasVerticalPanning
  17463. * @return {boolean}
  17464. *
  17465. */
  17466. Axis.prototype.hasVerticalPanning = function () {
  17467. var _a,
  17468. _b;
  17469. return /y/.test(((_b = (_a = this.chart.options.chart) === null || _a === void 0 ? void 0 : _a.panning) === null || _b === void 0 ? void 0 : _b.type) || '');
  17470. };
  17471. /**
  17472. * Check whether the given value is a positive valid axis value.
  17473. *
  17474. * @private
  17475. * @function Highcharts.Axis#validatePositiveValue
  17476. *
  17477. * @param {unknown} value
  17478. * The axis value
  17479. * @return {boolean}
  17480. *
  17481. */
  17482. Axis.prototype.validatePositiveValue = function (value) {
  17483. return isNumber(value) && value > 0;
  17484. };
  17485. /* *
  17486. *
  17487. * Static Properties
  17488. *
  17489. * */
  17490. /**
  17491. * The X axis or category axis. Normally this is the horizontal axis,
  17492. * though if the chart is inverted this is the vertical axis. In case of
  17493. * multiple axes, the xAxis node is an array of configuration objects.
  17494. *
  17495. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  17496. * access to the axis.
  17497. *
  17498. * @productdesc {highmaps}
  17499. * In Highmaps, the axis is hidden, but it is used behind the scenes to
  17500. * control features like zooming and panning. Zooming is in effect the same
  17501. * as setting the extremes of one of the exes.
  17502. *
  17503. * @type {*|Array<*>}
  17504. * @optionparent xAxis
  17505. *
  17506. * @private
  17507. */
  17508. Axis.defaultOptions = {
  17509. /**
  17510. * When using multiple axis, the ticks of two or more opposite axes
  17511. * will automatically be aligned by adding ticks to the axis or axes
  17512. * with the least ticks, as if `tickAmount` were specified.
  17513. *
  17514. * This can be prevented by setting `alignTicks` to false. If the grid
  17515. * lines look messy, it's a good idea to hide them for the secondary
  17516. * axis by setting `gridLineWidth` to 0.
  17517. *
  17518. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  17519. * then the `alignTicks ` will be disabled for the Axis.
  17520. *
  17521. * Disabled for logarithmic axes.
  17522. *
  17523. * @type {boolean}
  17524. * @default true
  17525. * @product highcharts highstock gantt
  17526. * @apioption xAxis.alignTicks
  17527. */
  17528. /**
  17529. * Whether to allow decimals in this axis' ticks. When counting
  17530. * integers, like persons or hits on a web page, decimals should
  17531. * be avoided in the labels.
  17532. *
  17533. * @see [minTickInterval](#xAxis.minTickInterval)
  17534. *
  17535. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-true/
  17536. * True by default
  17537. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-false/
  17538. * False
  17539. *
  17540. * @type {boolean}
  17541. * @default true
  17542. * @since 2.0
  17543. * @apioption xAxis.allowDecimals
  17544. */
  17545. /**
  17546. * When using an alternate grid color, a band is painted across the
  17547. * plot area between every other grid line.
  17548. *
  17549. * @sample {highcharts} highcharts/yaxis/alternategridcolor/
  17550. * Alternate grid color on the Y axis
  17551. * @sample {highstock} stock/xaxis/alternategridcolor/
  17552. * Alternate grid color on the Y axis
  17553. *
  17554. * @type {Highcharts.ColorType}
  17555. * @apioption xAxis.alternateGridColor
  17556. */
  17557. /**
  17558. * An array defining breaks in the axis, the sections defined will be
  17559. * left out and all the points shifted closer to each other.
  17560. *
  17561. * @productdesc {highcharts}
  17562. * Requires that the broken-axis.js module is loaded.
  17563. *
  17564. * @sample {highcharts} highcharts/axisbreak/break-simple/
  17565. * Simple break
  17566. * @sample {highcharts|highstock} highcharts/axisbreak/break-visualized/
  17567. * Advanced with callback
  17568. * @sample {highstock} stock/demo/intraday-breaks/
  17569. * Break on nights and weekends
  17570. *
  17571. * @type {Array<*>}
  17572. * @since 4.1.0
  17573. * @product highcharts highstock gantt
  17574. * @apioption xAxis.breaks
  17575. */
  17576. /**
  17577. * A number indicating how much space should be left between the start
  17578. * and the end of the break. The break size is given in axis units,
  17579. * so for instance on a `datetime` axis, a break size of 3600000 would
  17580. * indicate the equivalent of an hour.
  17581. *
  17582. * @type {number}
  17583. * @default 0
  17584. * @since 4.1.0
  17585. * @product highcharts highstock gantt
  17586. * @apioption xAxis.breaks.breakSize
  17587. */
  17588. /**
  17589. * The point where the break starts.
  17590. *
  17591. * @type {number}
  17592. * @since 4.1.0
  17593. * @product highcharts highstock gantt
  17594. * @apioption xAxis.breaks.from
  17595. */
  17596. /**
  17597. * Defines an interval after which the break appears again. By default
  17598. * the breaks do not repeat.
  17599. *
  17600. * @type {number}
  17601. * @default 0
  17602. * @since 4.1.0
  17603. * @product highcharts highstock gantt
  17604. * @apioption xAxis.breaks.repeat
  17605. */
  17606. /**
  17607. * The point where the break ends.
  17608. *
  17609. * @type {number}
  17610. * @since 4.1.0
  17611. * @product highcharts highstock gantt
  17612. * @apioption xAxis.breaks.to
  17613. */
  17614. /**
  17615. * If categories are present for the xAxis, names are used instead of
  17616. * numbers for that axis.
  17617. *
  17618. * Since Highcharts 3.0, categories can also
  17619. * be extracted by giving each point a [name](#series.data) and setting
  17620. * axis [type](#xAxis.type) to `category`. However, if you have multiple
  17621. * series, best practice remains defining the `categories` array.
  17622. *
  17623. * Example: `categories: ['Apples', 'Bananas', 'Oranges']`
  17624. *
  17625. * @sample {highcharts} highcharts/demo/line-labels/
  17626. * With
  17627. * @sample {highcharts} highcharts/xaxis/categories/
  17628. * Without
  17629. *
  17630. * @type {Array<string>}
  17631. * @product highcharts gantt
  17632. * @apioption xAxis.categories
  17633. */
  17634. /**
  17635. * The highest allowed value for automatically computed axis extremes.
  17636. *
  17637. * @see [floor](#xAxis.floor)
  17638. *
  17639. * @sample {highcharts|highstock} highcharts/yaxis/floor-ceiling/
  17640. * Floor and ceiling
  17641. *
  17642. * @type {number}
  17643. * @since 4.0
  17644. * @product highcharts highstock gantt
  17645. * @apioption xAxis.ceiling
  17646. */
  17647. /**
  17648. * A class name that opens for styling the axis by CSS, especially in
  17649. * Highcharts styled mode. The class name is applied to group elements
  17650. * for the grid, axis elements and labels.
  17651. *
  17652. * @sample {highcharts|highstock|highmaps} highcharts/css/axis/
  17653. * Multiple axes with separate styling
  17654. *
  17655. * @type {string}
  17656. * @since 5.0.0
  17657. * @apioption xAxis.className
  17658. */
  17659. /**
  17660. * Configure a crosshair that follows either the mouse pointer or the
  17661. * hovered point.
  17662. *
  17663. * In styled mode, the crosshairs are styled in the
  17664. * `.highcharts-crosshair`, `.highcharts-crosshair-thin` or
  17665. * `.highcharts-xaxis-category` classes.
  17666. *
  17667. * @productdesc {highstock}
  17668. * In Highstock, by default, the crosshair is enabled on the X axis and
  17669. * disabled on the Y axis.
  17670. *
  17671. * @sample {highcharts} highcharts/xaxis/crosshair-both/
  17672. * Crosshair on both axes
  17673. * @sample {highstock} stock/xaxis/crosshairs-xy/
  17674. * Crosshair on both axes
  17675. * @sample {highmaps} highcharts/xaxis/crosshair-both/
  17676. * Crosshair on both axes
  17677. *
  17678. * @declare Highcharts.AxisCrosshairOptions
  17679. * @type {boolean|*}
  17680. * @default false
  17681. * @since 4.1
  17682. * @apioption xAxis.crosshair
  17683. */
  17684. /**
  17685. * A class name for the crosshair, especially as a hook for styling.
  17686. *
  17687. * @type {string}
  17688. * @since 5.0.0
  17689. * @apioption xAxis.crosshair.className
  17690. */
  17691. /**
  17692. * The color of the crosshair. Defaults to `#cccccc` for numeric and
  17693. * datetime axes, and `rgba(204,214,235,0.25)` for category axes, where
  17694. * the crosshair by default highlights the whole category.
  17695. *
  17696. * @sample {highcharts|highstock|highmaps} highcharts/xaxis/crosshair-customized/
  17697. * Customized crosshairs
  17698. *
  17699. * @type {Highcharts.ColorType}
  17700. * @default #cccccc
  17701. * @since 4.1
  17702. * @apioption xAxis.crosshair.color
  17703. */
  17704. /**
  17705. * The dash style for the crosshair. See
  17706. * [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  17707. * for possible values.
  17708. *
  17709. * @sample {highcharts|highmaps} highcharts/xaxis/crosshair-dotted/
  17710. * Dotted crosshair
  17711. * @sample {highstock} stock/xaxis/crosshair-dashed/
  17712. * Dashed X axis crosshair
  17713. *
  17714. * @type {Highcharts.DashStyleValue}
  17715. * @default Solid
  17716. * @since 4.1
  17717. * @apioption xAxis.crosshair.dashStyle
  17718. */
  17719. /**
  17720. * A label on the axis next to the crosshair.
  17721. *
  17722. * In styled mode, the label is styled with the
  17723. * `.highcharts-crosshair-label` class.
  17724. *
  17725. * @sample {highstock} stock/xaxis/crosshair-label/
  17726. * Crosshair labels
  17727. * @sample {highstock} highcharts/css/crosshair-label/
  17728. * Style mode
  17729. *
  17730. * @declare Highcharts.AxisCrosshairLabelOptions
  17731. * @since 2.1
  17732. * @product highstock
  17733. * @apioption xAxis.crosshair.label
  17734. */
  17735. /**
  17736. * Alignment of the label compared to the axis. Defaults to `"left"` for
  17737. * right-side axes, `"right"` for left-side axes and `"center"` for
  17738. * horizontal axes.
  17739. *
  17740. * @type {Highcharts.AlignValue}
  17741. * @since 2.1
  17742. * @product highstock
  17743. * @apioption xAxis.crosshair.label.align
  17744. */
  17745. /**
  17746. * The background color for the label. Defaults to the related series
  17747. * color, or `#666666` if that is not available.
  17748. *
  17749. * @type {Highcharts.ColorType}
  17750. * @since 2.1
  17751. * @product highstock
  17752. * @apioption xAxis.crosshair.label.backgroundColor
  17753. */
  17754. /**
  17755. * The border color for the crosshair label
  17756. *
  17757. * @type {Highcharts.ColorType}
  17758. * @since 2.1
  17759. * @product highstock
  17760. * @apioption xAxis.crosshair.label.borderColor
  17761. */
  17762. /**
  17763. * The border corner radius of the crosshair label.
  17764. *
  17765. * @type {number}
  17766. * @default 3
  17767. * @since 2.1.10
  17768. * @product highstock
  17769. * @apioption xAxis.crosshair.label.borderRadius
  17770. */
  17771. /**
  17772. * The border width for the crosshair label.
  17773. *
  17774. * @type {number}
  17775. * @default 0
  17776. * @since 2.1
  17777. * @product highstock
  17778. * @apioption xAxis.crosshair.label.borderWidth
  17779. */
  17780. /**
  17781. * Flag to enable crosshair's label.
  17782. *
  17783. * @sample {highstock} stock/xaxis/crosshairs-xy/
  17784. * Enabled label for yAxis' crosshair
  17785. *
  17786. * @type {boolean}
  17787. * @default false
  17788. * @since 2.1
  17789. * @product highstock
  17790. * @apioption xAxis.crosshair.label.enabled
  17791. */
  17792. /**
  17793. * A format string for the crosshair label. Defaults to `{value}` for
  17794. * numeric axes and `{value:%b %d, %Y}` for datetime axes.
  17795. *
  17796. * @type {string}
  17797. * @since 2.1
  17798. * @product highstock
  17799. * @apioption xAxis.crosshair.label.format
  17800. */
  17801. /**
  17802. * Formatter function for the label text.
  17803. *
  17804. * @type {Highcharts.XAxisCrosshairLabelFormatterCallbackFunction}
  17805. * @since 2.1
  17806. * @product highstock
  17807. * @apioption xAxis.crosshair.label.formatter
  17808. */
  17809. /**
  17810. * Padding inside the crosshair label.
  17811. *
  17812. * @type {number}
  17813. * @default 8
  17814. * @since 2.1
  17815. * @product highstock
  17816. * @apioption xAxis.crosshair.label.padding
  17817. */
  17818. /**
  17819. * The shape to use for the label box.
  17820. *
  17821. * @type {string}
  17822. * @default callout
  17823. * @since 2.1
  17824. * @product highstock
  17825. * @apioption xAxis.crosshair.label.shape
  17826. */
  17827. /**
  17828. * Text styles for the crosshair label.
  17829. *
  17830. * @type {Highcharts.CSSObject}
  17831. * @default {"color": "white", "fontWeight": "normal", "fontSize": "11px", "textAlign": "center"}
  17832. * @since 2.1
  17833. * @product highstock
  17834. * @apioption xAxis.crosshair.label.style
  17835. */
  17836. /**
  17837. * Whether the crosshair should snap to the point or follow the pointer
  17838. * independent of points.
  17839. *
  17840. * @sample {highcharts|highstock} highcharts/xaxis/crosshair-snap-false/
  17841. * True by default
  17842. * @sample {highmaps} maps/demo/latlon-advanced/
  17843. * Snap is false
  17844. *
  17845. * @type {boolean}
  17846. * @default true
  17847. * @since 4.1
  17848. * @apioption xAxis.crosshair.snap
  17849. */
  17850. /**
  17851. * The pixel width of the crosshair. Defaults to 1 for numeric or
  17852. * datetime axes, and for one category width for category axes.
  17853. *
  17854. * @sample {highcharts} highcharts/xaxis/crosshair-customized/
  17855. * Customized crosshairs
  17856. * @sample {highstock} highcharts/xaxis/crosshair-customized/
  17857. * Customized crosshairs
  17858. * @sample {highmaps} highcharts/xaxis/crosshair-customized/
  17859. * Customized crosshairs
  17860. *
  17861. * @type {number}
  17862. * @default 1
  17863. * @since 4.1
  17864. * @apioption xAxis.crosshair.width
  17865. */
  17866. /**
  17867. * The Z index of the crosshair. Higher Z indices allow drawing the
  17868. * crosshair on top of the series or behind the grid lines.
  17869. *
  17870. * @type {number}
  17871. * @default 2
  17872. * @since 4.1
  17873. * @apioption xAxis.crosshair.zIndex
  17874. */
  17875. /**
  17876. * Whether to zoom axis. If `chart.zoomType` is set, the option allows
  17877. * to disable zooming on an individual axis.
  17878. *
  17879. * @sample {highcharts} highcharts/xaxis/zoomenabled/
  17880. * Zoom enabled is false
  17881. *
  17882. *
  17883. * @type {boolean}
  17884. * @default enabled
  17885. * @apioption xAxis.zoomEnabled
  17886. */
  17887. /**
  17888. * For a datetime axis, the scale will automatically adjust to the
  17889. * appropriate unit. This member gives the default string
  17890. * representations used for each unit. For intermediate values,
  17891. * different units may be used, for example the `day` unit can be used
  17892. * on midnight and `hour` unit be used for intermediate values on the
  17893. * same axis. For an overview of the replacement codes, see
  17894. * [dateFormat](/class-reference/Highcharts#dateFormat).
  17895. *
  17896. * Defaults to:
  17897. * ```js
  17898. * {
  17899. * millisecond: '%H:%M:%S.%L',
  17900. * second: '%H:%M:%S',
  17901. * minute: '%H:%M',
  17902. * hour: '%H:%M',
  17903. * day: '%e. %b',
  17904. * week: '%e. %b',
  17905. * month: '%b \'%y',
  17906. * year: '%Y'
  17907. * }
  17908. * ```
  17909. *
  17910. * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
  17911. * Different day format on X axis
  17912. * @sample {highstock} stock/xaxis/datetimelabelformats/
  17913. * More information in x axis labels
  17914. *
  17915. * @declare Highcharts.AxisDateTimeLabelFormatsOptions
  17916. * @product highcharts highstock
  17917. */
  17918. dateTimeLabelFormats: {
  17919. /**
  17920. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17921. * @type {string|*}
  17922. */
  17923. millisecond: {
  17924. main: '%H:%M:%S.%L',
  17925. range: false
  17926. },
  17927. /**
  17928. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17929. * @type {string|*}
  17930. */
  17931. second: {
  17932. main: '%H:%M:%S',
  17933. range: false
  17934. },
  17935. /**
  17936. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17937. * @type {string|*}
  17938. */
  17939. minute: {
  17940. main: '%H:%M',
  17941. range: false
  17942. },
  17943. /**
  17944. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17945. * @type {string|*}
  17946. */
  17947. hour: {
  17948. main: '%H:%M',
  17949. range: false
  17950. },
  17951. /**
  17952. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17953. * @type {string|*}
  17954. */
  17955. day: {
  17956. main: '%e. %b'
  17957. },
  17958. /**
  17959. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17960. * @type {string|*}
  17961. */
  17962. week: {
  17963. main: '%e. %b'
  17964. },
  17965. /**
  17966. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17967. * @type {string|*}
  17968. */
  17969. month: {
  17970. main: '%b \'%y'
  17971. },
  17972. /**
  17973. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17974. * @type {string|*}
  17975. */
  17976. year: {
  17977. main: '%Y'
  17978. }
  17979. },
  17980. /**
  17981. * Whether to force the axis to end on a tick. Use this option with
  17982. * the `maxPadding` option to control the axis end.
  17983. *
  17984. * @productdesc {highstock}
  17985. * In Highstock, `endOnTick` is always `false` when the navigator
  17986. * is enabled, to prevent jumpy scrolling.
  17987. *
  17988. * @sample {highcharts} highcharts/chart/reflow-true/
  17989. * True by default
  17990. * @sample {highcharts} highcharts/yaxis/endontick/
  17991. * False
  17992. * @sample {highstock} stock/demo/basic-line/
  17993. * True by default
  17994. * @sample {highstock} stock/xaxis/endontick/
  17995. * False
  17996. *
  17997. * @since 1.2.0
  17998. */
  17999. endOnTick: false,
  18000. /**
  18001. * Event handlers for the axis.
  18002. *
  18003. * @type {*}
  18004. * @apioption xAxis.events
  18005. */
  18006. /**
  18007. * An event fired after the breaks have rendered.
  18008. *
  18009. * @see [breaks](#xAxis.breaks)
  18010. *
  18011. * @sample {highcharts} highcharts/axisbreak/break-event/
  18012. * AfterBreak Event
  18013. *
  18014. * @type {Highcharts.AxisEventCallbackFunction}
  18015. * @since 4.1.0
  18016. * @product highcharts gantt
  18017. * @apioption xAxis.events.afterBreaks
  18018. */
  18019. /**
  18020. * As opposed to the `setExtremes` event, this event fires after the
  18021. * final min and max values are computed and corrected for `minRange`.
  18022. *
  18023. * Fires when the minimum and maximum is set for the axis, either by
  18024. * calling the `.setExtremes()` method or by selecting an area in the
  18025. * chart. One parameter, `event`, is passed to the function, containing
  18026. * common event information.
  18027. *
  18028. * The new user set minimum and maximum values can be found by
  18029. * `event.min` and `event.max`. These reflect the axis minimum and
  18030. * maximum in axis values. The actual data extremes are found in
  18031. * `event.dataMin` and `event.dataMax`.
  18032. *
  18033. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  18034. * @since 2.3
  18035. * @context Highcharts.Axis
  18036. * @apioption xAxis.events.afterSetExtremes
  18037. */
  18038. /**
  18039. * An event fired when a break from this axis occurs on a point.
  18040. *
  18041. * @see [breaks](#xAxis.breaks)
  18042. *
  18043. * @sample {highcharts} highcharts/axisbreak/break-visualized/
  18044. * Visualization of a Break
  18045. *
  18046. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18047. * @since 4.1.0
  18048. * @product highcharts gantt
  18049. * @context Highcharts.Axis
  18050. * @apioption xAxis.events.pointBreak
  18051. */
  18052. /**
  18053. * An event fired when a point falls inside a break from this axis.
  18054. *
  18055. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18056. * @product highcharts highstock gantt
  18057. * @context Highcharts.Axis
  18058. * @apioption xAxis.events.pointInBreak
  18059. */
  18060. /**
  18061. * Fires when the minimum and maximum is set for the axis, either by
  18062. * calling the `.setExtremes()` method or by selecting an area in the
  18063. * chart. One parameter, `event`, is passed to the function,
  18064. * containing common event information.
  18065. *
  18066. * The new user set minimum and maximum values can be found by
  18067. * `event.min` and `event.max`. These reflect the axis minimum and
  18068. * maximum in data values. When an axis is zoomed all the way out from
  18069. * the "Reset zoom" button, `event.min` and `event.max` are null, and
  18070. * the new extremes are set based on `this.dataMin` and `this.dataMax`.
  18071. *
  18072. * @sample {highstock} stock/xaxis/events-setextremes/
  18073. * Log new extremes on x axis
  18074. *
  18075. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  18076. * @since 1.2.0
  18077. * @context Highcharts.Axis
  18078. * @apioption xAxis.events.setExtremes
  18079. */
  18080. /**
  18081. * The lowest allowed value for automatically computed axis extremes.
  18082. *
  18083. * @see [ceiling](#yAxis.ceiling)
  18084. *
  18085. * @sample {highcharts} highcharts/yaxis/floor-ceiling/
  18086. * Floor and ceiling
  18087. * @sample {highstock} stock/demo/lazy-loading/
  18088. * Prevent negative stock price on Y axis
  18089. *
  18090. * @type {number}
  18091. * @since 4.0
  18092. * @product highcharts highstock gantt
  18093. * @apioption xAxis.floor
  18094. */
  18095. /**
  18096. * The dash or dot style of the grid lines. For possible values, see
  18097. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  18098. *
  18099. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  18100. * Long dashes
  18101. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  18102. * Long dashes
  18103. *
  18104. * @type {Highcharts.DashStyleValue}
  18105. * @default Solid
  18106. * @since 1.2
  18107. * @apioption xAxis.gridLineDashStyle
  18108. */
  18109. /**
  18110. * The Z index of the grid lines.
  18111. *
  18112. * @sample {highcharts|highstock} highcharts/xaxis/gridzindex/
  18113. * A Z index of 4 renders the grid above the graph
  18114. *
  18115. * @type {number}
  18116. * @default 1
  18117. * @product highcharts highstock gantt
  18118. * @apioption xAxis.gridZIndex
  18119. */
  18120. /**
  18121. * An id for the axis. This can be used after render time to get
  18122. * a pointer to the axis object through `chart.get()`.
  18123. *
  18124. * @sample {highcharts} highcharts/xaxis/id/
  18125. * Get the object
  18126. * @sample {highstock} stock/xaxis/id/
  18127. * Get the object
  18128. *
  18129. * @type {string}
  18130. * @since 1.2.0
  18131. * @apioption xAxis.id
  18132. */
  18133. /**
  18134. * The axis labels show the number or category for each tick.
  18135. *
  18136. * Since v8.0.0: Labels are animated in categorized x-axis with
  18137. * updating data if `tickInterval` and `step` is set to 1.
  18138. *
  18139. * @productdesc {highmaps}
  18140. * X and Y axis labels are by default disabled in Highmaps, but the
  18141. * functionality is inherited from Highcharts and used on `colorAxis`,
  18142. * and can be enabled on X and Y axes too.
  18143. */
  18144. labels: {
  18145. /**
  18146. * What part of the string the given position is anchored to.
  18147. * If `left`, the left side of the string is at the axis position.
  18148. * Can be one of `"left"`, `"center"` or `"right"`. Defaults to
  18149. * an intelligent guess based on which side of the chart the axis
  18150. * is on and the rotation of the label.
  18151. *
  18152. * @see [reserveSpace](#xAxis.labels.reserveSpace)
  18153. *
  18154. * @sample {highcharts} highcharts/xaxis/labels-align-left/
  18155. * Left
  18156. * @sample {highcharts} highcharts/xaxis/labels-align-right/
  18157. * Right
  18158. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  18159. * Left-aligned labels on a vertical category axis
  18160. *
  18161. * @type {Highcharts.AlignValue}
  18162. * @apioption xAxis.labels.align
  18163. */
  18164. /**
  18165. * For horizontal axes, the allowed degrees of label rotation
  18166. * to prevent overlapping labels. If there is enough space,
  18167. * labels are not rotated. As the chart gets narrower, it
  18168. * will start rotating the labels -45 degrees, then remove
  18169. * every second label and try again with rotations 0 and -45 etc.
  18170. * Set it to `false` to disable rotation, which will
  18171. * cause the labels to word-wrap if possible.
  18172. *
  18173. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-default/
  18174. * Default auto rotation of 0 or -45
  18175. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-0-90/
  18176. * Custom graded auto rotation
  18177. *
  18178. * @type {Array<number>|false}
  18179. * @default [-45]
  18180. * @since 4.1.0
  18181. * @product highcharts highstock gantt
  18182. * @apioption xAxis.labels.autoRotation
  18183. */
  18184. /**
  18185. * When each category width is more than this many pixels, we don't
  18186. * apply auto rotation. Instead, we lay out the axis label with word
  18187. * wrap. A lower limit makes sense when the label contains multiple
  18188. * short words that don't extend the available horizontal space for
  18189. * each label.
  18190. *
  18191. * @sample {highcharts} highcharts/xaxis/labels-autorotationlimit/
  18192. * Lower limit
  18193. *
  18194. * @type {number}
  18195. * @default 80
  18196. * @since 4.1.5
  18197. * @product highcharts gantt
  18198. * @apioption xAxis.labels.autoRotationLimit
  18199. */
  18200. /**
  18201. * Polar charts only. The label's pixel distance from the perimeter
  18202. * of the plot area.
  18203. *
  18204. * @type {number}
  18205. * @default 15
  18206. * @product highcharts gantt
  18207. * @apioption xAxis.labels.distance
  18208. */
  18209. /**
  18210. * Enable or disable the axis labels.
  18211. *
  18212. * @sample {highcharts} highcharts/xaxis/labels-enabled/
  18213. * X axis labels disabled
  18214. * @sample {highstock} stock/xaxis/labels-enabled/
  18215. * X axis labels disabled
  18216. *
  18217. * @default {highcharts|highstock|gantt} true
  18218. * @default {highmaps} false
  18219. */
  18220. enabled: true,
  18221. /**
  18222. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  18223. * for the axis label.
  18224. *
  18225. * @sample {highcharts|highstock} highcharts/yaxis/labels-format/
  18226. * Add units to Y axis label
  18227. *
  18228. * @type {string}
  18229. * @default {value}
  18230. * @since 3.0
  18231. * @apioption xAxis.labels.format
  18232. */
  18233. /**
  18234. * Callback JavaScript function to format the label. The value
  18235. * is given by `this.value`. Additional properties for `this` are
  18236. * `axis`, `chart`, `isFirst` and `isLast`. The value of the default
  18237. * label formatter can be retrieved by calling
  18238. * `this.axis.defaultLabelFormatter.call(this)` within the function.
  18239. *
  18240. * Defaults to:
  18241. * ```js
  18242. * function() {
  18243. * return this.value;
  18244. * }
  18245. * ```
  18246. *
  18247. * @sample {highcharts} highcharts/xaxis/labels-formatter-linked/
  18248. * Linked category names
  18249. * @sample {highcharts} highcharts/xaxis/labels-formatter-extended/
  18250. * Modified numeric labels
  18251. * @sample {highstock} stock/xaxis/labels-formatter/
  18252. * Added units on Y axis
  18253. *
  18254. * @type {Highcharts.AxisLabelsFormatterCallbackFunction}
  18255. * @apioption xAxis.labels.formatter
  18256. */
  18257. /**
  18258. * The number of pixels to indent the labels per level in a treegrid
  18259. * axis.
  18260. *
  18261. * @sample gantt/treegrid-axis/demo
  18262. * Indentation 10px by default.
  18263. * @sample gantt/treegrid-axis/indentation-0px
  18264. * Indentation set to 0px.
  18265. *
  18266. * @product gantt
  18267. */
  18268. indentation: 10,
  18269. /**
  18270. * Horizontal axis only. When `staggerLines` is not set,
  18271. * `maxStaggerLines` defines how many lines the axis is allowed to
  18272. * add to automatically avoid overlapping X labels. Set to `1` to
  18273. * disable overlap detection.
  18274. *
  18275. * @deprecated
  18276. * @type {number}
  18277. * @default 5
  18278. * @since 1.3.3
  18279. * @apioption xAxis.labels.maxStaggerLines
  18280. */
  18281. /**
  18282. * How to handle overflowing labels on horizontal axis. If set to
  18283. * `"allow"`, it will not be aligned at all. By default it
  18284. * `"justify"` labels inside the chart area. If there is room to
  18285. * move it, it will be aligned to the edge, else it will be removed.
  18286. *
  18287. * @type {string}
  18288. * @default justify
  18289. * @since 2.2.5
  18290. * @validvalue ["allow", "justify"]
  18291. * @apioption xAxis.labels.overflow
  18292. */
  18293. /**
  18294. * The pixel padding for axis labels, to ensure white space between
  18295. * them.
  18296. *
  18297. * @type {number}
  18298. * @default 5
  18299. * @product highcharts gantt
  18300. * @apioption xAxis.labels.padding
  18301. */
  18302. /**
  18303. * Whether to reserve space for the labels. By default, space is
  18304. * reserved for the labels in these cases:
  18305. *
  18306. * * On all horizontal axes.
  18307. * * On vertical axes if `label.align` is `right` on a left-side
  18308. * axis or `left` on a right-side axis.
  18309. * * On vertical axes if `label.align` is `center`.
  18310. *
  18311. * This can be turned off when for example the labels are rendered
  18312. * inside the plot area instead of outside.
  18313. *
  18314. * @see [labels.align](#xAxis.labels.align)
  18315. *
  18316. * @sample {highcharts} highcharts/xaxis/labels-reservespace/
  18317. * No reserved space, labels inside plot
  18318. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  18319. * Left-aligned labels on a vertical category axis
  18320. *
  18321. * @type {boolean}
  18322. * @since 4.1.10
  18323. * @product highcharts gantt
  18324. * @apioption xAxis.labels.reserveSpace
  18325. */
  18326. /**
  18327. * Rotation of the labels in degrees.
  18328. *
  18329. * @sample {highcharts} highcharts/xaxis/labels-rotation/
  18330. * X axis labels rotated 90°
  18331. *
  18332. * @type {number}
  18333. * @default 0
  18334. * @apioption xAxis.labels.rotation
  18335. */
  18336. /**
  18337. * Horizontal axes only. The number of lines to spread the labels
  18338. * over to make room or tighter labels.
  18339. *
  18340. * @sample {highcharts} highcharts/xaxis/labels-staggerlines/
  18341. * Show labels over two lines
  18342. * @sample {highstock} stock/xaxis/labels-staggerlines/
  18343. * Show labels over two lines
  18344. *
  18345. * @type {number}
  18346. * @since 2.1
  18347. * @apioption xAxis.labels.staggerLines
  18348. */
  18349. /**
  18350. * To show only every _n_'th label on the axis, set the step to _n_.
  18351. * Setting the step to 2 shows every other label.
  18352. *
  18353. * By default, the step is calculated automatically to avoid
  18354. * overlap. To prevent this, set it to 1\. This usually only
  18355. * happens on a category axis, and is often a sign that you have
  18356. * chosen the wrong axis type.
  18357. *
  18358. * Read more at
  18359. * [Axis docs](https://www.highcharts.com/docs/chart-concepts/axes)
  18360. * => What axis should I use?
  18361. *
  18362. * @sample {highcharts} highcharts/xaxis/labels-step/
  18363. * Showing only every other axis label on a categorized
  18364. * x-axis
  18365. * @sample {highcharts} highcharts/xaxis/labels-step-auto/
  18366. * Auto steps on a category axis
  18367. *
  18368. * @type {number}
  18369. * @since 2.1
  18370. * @apioption xAxis.labels.step
  18371. */
  18372. /**
  18373. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  18374. * to render the labels.
  18375. *
  18376. * @type {boolean}
  18377. * @default false
  18378. * @apioption xAxis.labels.useHTML
  18379. */
  18380. /**
  18381. * The x position offset of all labels relative to the tick
  18382. * positions on the axis.
  18383. *
  18384. * @sample {highcharts} highcharts/xaxis/labels-x/
  18385. * Y axis labels placed on grid lines
  18386. */
  18387. x: 0,
  18388. /**
  18389. * The y position offset of all labels relative to the tick
  18390. * positions on the axis. The default makes it adapt to the font
  18391. * size of the bottom axis.
  18392. *
  18393. * @sample {highcharts} highcharts/xaxis/labels-x/
  18394. * Y axis labels placed on grid lines
  18395. *
  18396. * @type {number}
  18397. * @apioption xAxis.labels.y
  18398. */
  18399. /**
  18400. * The Z index for the axis labels.
  18401. *
  18402. * @type {number}
  18403. * @default 7
  18404. * @apioption xAxis.labels.zIndex
  18405. */
  18406. /**
  18407. * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
  18408. * wrapping of category labels. Use `textOverflow: 'none'` to
  18409. * prevent ellipsis (dots).
  18410. *
  18411. * In styled mode, the labels are styled with the
  18412. * `.highcharts-axis-labels` class.
  18413. *
  18414. * @sample {highcharts} highcharts/xaxis/labels-style/
  18415. * Red X axis labels
  18416. *
  18417. * @type {Highcharts.CSSObject}
  18418. */
  18419. style: {
  18420. /** @internal */
  18421. color: '#666666',
  18422. /** @internal */
  18423. cursor: 'default',
  18424. /** @internal */
  18425. fontSize: '11px'
  18426. }
  18427. },
  18428. /**
  18429. * The left position as the horizontal axis. If it's a number, it is
  18430. * interpreted as pixel position relative to the chart.
  18431. *
  18432. * Since Highcharts v5.0.13: If it's a percentage string, it is
  18433. * interpreted as percentages of the plot width, offset from plot area
  18434. * left.
  18435. *
  18436. * @type {number|string}
  18437. * @product highcharts highstock
  18438. * @apioption xAxis.left
  18439. */
  18440. /**
  18441. * The top position as the vertical axis. If it's a number, it is
  18442. * interpreted as pixel position relative to the chart.
  18443. *
  18444. * Since Highcharts 2: If it's a percentage string, it is interpreted
  18445. * as percentages of the plot height, offset from plot area top.
  18446. *
  18447. * @type {number|string}
  18448. * @product highcharts highstock
  18449. * @apioption xAxis.top
  18450. */
  18451. /**
  18452. * Index of another axis that this axis is linked to. When an axis is
  18453. * linked to a master axis, it will take the same extremes as
  18454. * the master, but as assigned by min or max or by setExtremes.
  18455. * It can be used to show additional info, or to ease reading the
  18456. * chart by duplicating the scales.
  18457. *
  18458. * @sample {highcharts} highcharts/xaxis/linkedto/
  18459. * Different string formats of the same date
  18460. * @sample {highcharts} highcharts/yaxis/linkedto/
  18461. * Y values on both sides
  18462. *
  18463. * @type {number}
  18464. * @since 2.0.2
  18465. * @product highcharts highstock gantt
  18466. * @apioption xAxis.linkedTo
  18467. */
  18468. /**
  18469. * The maximum value of the axis. If `null`, the max value is
  18470. * automatically calculated.
  18471. *
  18472. * If the [endOnTick](#yAxis.endOnTick) option is true, the `max` value
  18473. * might be rounded up.
  18474. *
  18475. * If a [tickAmount](#yAxis.tickAmount) is set, the axis may be extended
  18476. * beyond the set max in order to reach the given number of ticks. The
  18477. * same may happen in a chart with multiple axes, determined by [chart.
  18478. * alignTicks](#chart), where a `tickAmount` is applied internally.
  18479. *
  18480. * @sample {highcharts} highcharts/yaxis/max-200/
  18481. * Y axis max of 200
  18482. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  18483. * Y axis max on logarithmic axis
  18484. * @sample {highstock} stock/xaxis/min-max/
  18485. * Fixed min and max on X axis
  18486. * @sample {highmaps} maps/axis/min-max/
  18487. * Pre-zoomed to a specific area
  18488. *
  18489. * @type {number|null}
  18490. * @apioption xAxis.max
  18491. */
  18492. /**
  18493. * Padding of the max value relative to the length of the axis. A
  18494. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  18495. * when you don't want the highest data value to appear on the edge
  18496. * of the plot area. When the axis' `max` option is set or a max extreme
  18497. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  18498. *
  18499. * @sample {highcharts} highcharts/yaxis/maxpadding/
  18500. * Max padding of 0.25 on y axis
  18501. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  18502. * Greater min- and maxPadding
  18503. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  18504. * Add some padding
  18505. *
  18506. * @default {highcharts} 0.01
  18507. * @default {highstock|highmaps} 0
  18508. * @since 1.2.0
  18509. */
  18510. maxPadding: 0.01,
  18511. /**
  18512. * Deprecated. Use `minRange` instead.
  18513. *
  18514. * @deprecated
  18515. * @type {number}
  18516. * @product highcharts highstock
  18517. * @apioption xAxis.maxZoom
  18518. */
  18519. /**
  18520. * The minimum value of the axis. If `null` the min value is
  18521. * automatically calculated.
  18522. *
  18523. * If the [startOnTick](#yAxis.startOnTick) option is true (default),
  18524. * the `min` value might be rounded down.
  18525. *
  18526. * The automatically calculated minimum value is also affected by
  18527. * [floor](#yAxis.floor), [softMin](#yAxis.softMin),
  18528. * [minPadding](#yAxis.minPadding), [minRange](#yAxis.minRange)
  18529. * as well as [series.threshold](#plotOptions.series.threshold)
  18530. * and [series.softThreshold](#plotOptions.series.softThreshold).
  18531. *
  18532. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  18533. * -50 with startOnTick to false
  18534. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  18535. * -50 with startOnTick true by default
  18536. * @sample {highstock} stock/xaxis/min-max/
  18537. * Set min and max on X axis
  18538. * @sample {highmaps} maps/axis/min-max/
  18539. * Pre-zoomed to a specific area
  18540. *
  18541. * @type {number|null}
  18542. * @apioption xAxis.min
  18543. */
  18544. /**
  18545. * The dash or dot style of the minor grid lines. For possible values,
  18546. * see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  18547. *
  18548. * @sample {highcharts} highcharts/yaxis/minorgridlinedashstyle/
  18549. * Long dashes on minor grid lines
  18550. * @sample {highstock} stock/xaxis/minorgridlinedashstyle/
  18551. * Long dashes on minor grid lines
  18552. *
  18553. * @type {Highcharts.DashStyleValue}
  18554. * @default Solid
  18555. * @since 1.2
  18556. * @apioption xAxis.minorGridLineDashStyle
  18557. */
  18558. /**
  18559. * Specific tick interval in axis units for the minor ticks. On a linear
  18560. * axis, if `"auto"`, the minor tick interval is calculated as a fifth
  18561. * of the tickInterval. If `null` or `undefined`, minor ticks are not
  18562. * shown.
  18563. *
  18564. * On logarithmic axes, the unit is the power of the value. For example,
  18565. * setting the minorTickInterval to 1 puts one tick on each of 0.1, 1,
  18566. * 10, 100 etc. Setting the minorTickInterval to 0.1 produces 9 ticks
  18567. * between 1 and 10, 10 and 100 etc.
  18568. *
  18569. * If user settings dictate minor ticks to become too dense, they don't
  18570. * make sense, and will be ignored to prevent performance problems.
  18571. *
  18572. * @sample {highcharts} highcharts/yaxis/minortickinterval-null/
  18573. * Null by default
  18574. * @sample {highcharts} highcharts/yaxis/minortickinterval-5/
  18575. * 5 units
  18576. * @sample {highcharts} highcharts/yaxis/minortickinterval-log-auto/
  18577. * "auto"
  18578. * @sample {highcharts} highcharts/yaxis/minortickinterval-log/
  18579. * 0.1
  18580. * @sample {highstock} stock/demo/basic-line/
  18581. * Null by default
  18582. * @sample {highstock} stock/xaxis/minortickinterval-auto/
  18583. * "auto"
  18584. *
  18585. * @type {number|string|null}
  18586. * @apioption xAxis.minorTickInterval
  18587. */
  18588. /**
  18589. * The pixel length of the minor tick marks.
  18590. *
  18591. * @sample {highcharts} highcharts/yaxis/minorticklength/
  18592. * 10px on Y axis
  18593. * @sample {highstock} stock/xaxis/minorticks/
  18594. * 10px on Y axis
  18595. */
  18596. minorTickLength: 2,
  18597. /**
  18598. * The position of the minor tick marks relative to the axis line.
  18599. * Can be one of `inside` and `outside`.
  18600. *
  18601. * @sample {highcharts} highcharts/yaxis/minortickposition-outside/
  18602. * Outside by default
  18603. * @sample {highcharts} highcharts/yaxis/minortickposition-inside/
  18604. * Inside
  18605. * @sample {highstock} stock/xaxis/minorticks/
  18606. * Inside
  18607. *
  18608. * @validvalue ["inside", "outside"]
  18609. */
  18610. minorTickPosition: 'outside',
  18611. /**
  18612. * Enable or disable minor ticks. Unless
  18613. * [minorTickInterval](#xAxis.minorTickInterval) is set, the tick
  18614. * interval is calculated as a fifth of the `tickInterval`.
  18615. *
  18616. * On a logarithmic axis, minor ticks are laid out based on a best
  18617. * guess, attempting to enter approximately 5 minor ticks between
  18618. * each major tick.
  18619. *
  18620. * Prior to v6.0.0, ticks were unabled in auto layout by setting
  18621. * `minorTickInterval` to `"auto"`.
  18622. *
  18623. * @productdesc {highcharts}
  18624. * On axes using [categories](#xAxis.categories), minor ticks are not
  18625. * supported.
  18626. *
  18627. * @sample {highcharts} highcharts/yaxis/minorticks-true/
  18628. * Enabled on linear Y axis
  18629. *
  18630. * @type {boolean}
  18631. * @default false
  18632. * @since 6.0.0
  18633. * @apioption xAxis.minorTicks
  18634. */
  18635. /**
  18636. * The pixel width of the minor tick mark.
  18637. *
  18638. * @sample {highcharts} highcharts/yaxis/minortickwidth/
  18639. * 3px width
  18640. * @sample {highstock} stock/xaxis/minorticks/
  18641. * 1px width
  18642. *
  18643. * @type {number}
  18644. * @default 0
  18645. * @apioption xAxis.minorTickWidth
  18646. */
  18647. /**
  18648. * Padding of the min value relative to the length of the axis. A
  18649. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  18650. * when you don't want the lowest data value to appear on the edge
  18651. * of the plot area. When the axis' `min` option is set or a min extreme
  18652. * is set using `axis.setExtremes()`, the minPadding will be ignored.
  18653. *
  18654. * @sample {highcharts} highcharts/yaxis/minpadding/
  18655. * Min padding of 0.2
  18656. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  18657. * Greater min- and maxPadding
  18658. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  18659. * Add some padding
  18660. *
  18661. * @default {highcharts} 0.01
  18662. * @default {highstock|highmaps} 0
  18663. * @since 1.2.0
  18664. * @product highcharts highstock gantt
  18665. */
  18666. minPadding: 0.01,
  18667. /**
  18668. * The minimum range to display on this axis. The entire axis will not
  18669. * be allowed to span over a smaller interval than this. For example,
  18670. * for a datetime axis the main unit is milliseconds. If minRange is
  18671. * set to 3600000, you can't zoom in more than to one hour.
  18672. *
  18673. * The default minRange for the x axis is five times the smallest
  18674. * interval between any of the data points.
  18675. *
  18676. * On a logarithmic axis, the unit for the minimum range is the power.
  18677. * So a minRange of 1 means that the axis can be zoomed to 10-100,
  18678. * 100-1000, 1000-10000 etc.
  18679. *
  18680. * **Note**: The `minPadding`, `maxPadding`, `startOnTick` and
  18681. * `endOnTick` settings also affect how the extremes of the axis
  18682. * are computed.
  18683. *
  18684. * @sample {highcharts} highcharts/xaxis/minrange/
  18685. * Minimum range of 5
  18686. * @sample {highstock} stock/xaxis/minrange/
  18687. * Max zoom of 6 months overrides user selections
  18688. * @sample {highmaps} maps/axis/minrange/
  18689. * Minimum range of 1000
  18690. *
  18691. * @type {number}
  18692. * @apioption xAxis.minRange
  18693. */
  18694. /**
  18695. * The minimum tick interval allowed in axis values. For example on
  18696. * zooming in on an axis with daily data, this can be used to prevent
  18697. * the axis from showing hours. Defaults to the closest distance between
  18698. * two points on the axis.
  18699. *
  18700. * @type {number}
  18701. * @since 2.3.0
  18702. * @apioption xAxis.minTickInterval
  18703. */
  18704. /**
  18705. * The distance in pixels from the plot area to the axis line.
  18706. * A positive offset moves the axis with it's line, labels and ticks
  18707. * away from the plot area. This is typically used when two or more
  18708. * axes are displayed on the same side of the plot. With multiple
  18709. * axes the offset is dynamically adjusted to avoid collision, this
  18710. * can be overridden by setting offset explicitly.
  18711. *
  18712. * @sample {highcharts} highcharts/yaxis/offset/
  18713. * Y axis offset of 70
  18714. * @sample {highcharts} highcharts/yaxis/offset-centered/
  18715. * Axes positioned in the center of the plot
  18716. * @sample {highstock} stock/xaxis/offset/
  18717. * Y axis offset by 70 px
  18718. *
  18719. * @type {number}
  18720. * @default 0
  18721. * @apioption xAxis.offset
  18722. */
  18723. /**
  18724. * Whether to display the axis on the opposite side of the normal. The
  18725. * normal is on the left side for vertical axes and bottom for
  18726. * horizontal, so the opposite sides will be right and top respectively.
  18727. * This is typically used with dual or multiple axes.
  18728. *
  18729. * @sample {highcharts} highcharts/yaxis/opposite/
  18730. * Secondary Y axis opposite
  18731. * @sample {highstock} stock/xaxis/opposite/
  18732. * Y axis on left side
  18733. *
  18734. * @type {boolean}
  18735. * @default false
  18736. * @apioption xAxis.opposite
  18737. */
  18738. /**
  18739. * In an ordinal axis, the points are equally spaced in the chart
  18740. * regardless of the actual time or x distance between them. This means
  18741. * that missing data periods (e.g. nights or weekends for a stock chart)
  18742. * will not take up space in the chart.
  18743. * Having `ordinal: false` will show any gaps created by the `gapSize`
  18744. * setting proportionate to their duration.
  18745. *
  18746. * In stock charts the X axis is ordinal by default, unless
  18747. * the boost module is used and at least one of the series' data length
  18748. * exceeds the [boostThreshold](#series.line.boostThreshold).
  18749. *
  18750. * @sample {highstock} stock/xaxis/ordinal-true/
  18751. * True by default
  18752. * @sample {highstock} stock/xaxis/ordinal-false/
  18753. * False
  18754. *
  18755. * @type {boolean}
  18756. * @default true
  18757. * @since 1.1
  18758. * @product highstock
  18759. * @apioption xAxis.ordinal
  18760. */
  18761. /**
  18762. * Additional range on the right side of the xAxis. Works similar to
  18763. * `xAxis.maxPadding`, but value is set in milliseconds. Can be set for
  18764. * both main `xAxis` and the navigator's `xAxis`.
  18765. *
  18766. * @sample {highstock} stock/xaxis/overscroll/
  18767. * One minute overscroll with live data
  18768. *
  18769. * @type {number}
  18770. * @default 0
  18771. * @since 6.0.0
  18772. * @product highstock
  18773. * @apioption xAxis.overscroll
  18774. */
  18775. /**
  18776. * Refers to the index in the [panes](#panes) array. Used for circular
  18777. * gauges and polar charts. When the option is not set then first pane
  18778. * will be used.
  18779. *
  18780. * @sample highcharts/demo/gauge-vu-meter
  18781. * Two gauges with different center
  18782. *
  18783. * @type {number}
  18784. * @product highcharts
  18785. * @apioption xAxis.pane
  18786. */
  18787. /**
  18788. * The zoomed range to display when only defining one or none of `min`
  18789. * or `max`. For example, to show the latest month, a range of one month
  18790. * can be set.
  18791. *
  18792. * @sample {highstock} stock/xaxis/range/
  18793. * Setting a zoomed range when the rangeSelector is disabled
  18794. *
  18795. * @type {number}
  18796. * @product highstock
  18797. * @apioption xAxis.range
  18798. */
  18799. /**
  18800. * Whether to reverse the axis so that the highest number is closest
  18801. * to the origin. If the chart is inverted, the x axis is reversed by
  18802. * default.
  18803. *
  18804. * @sample {highcharts} highcharts/yaxis/reversed/
  18805. * Reversed Y axis
  18806. * @sample {highstock} stock/xaxis/reversed/
  18807. * Reversed Y axis
  18808. *
  18809. * @type {boolean}
  18810. * @default false
  18811. * @apioption xAxis.reversed
  18812. */
  18813. // reversed: false,
  18814. /**
  18815. * This option determines how stacks should be ordered within a group.
  18816. * For example reversed xAxis also reverses stacks, so first series
  18817. * comes last in a group. To keep order like for non-reversed xAxis
  18818. * enable this option.
  18819. *
  18820. * @sample {highcharts} highcharts/xaxis/reversedstacks/
  18821. * Reversed stacks comparison
  18822. * @sample {highstock} highcharts/xaxis/reversedstacks/
  18823. * Reversed stacks comparison
  18824. *
  18825. * @type {boolean}
  18826. * @default false
  18827. * @since 6.1.1
  18828. * @product highcharts highstock
  18829. * @apioption xAxis.reversedStacks
  18830. */
  18831. /**
  18832. * An optional scrollbar to display on the X axis in response to
  18833. * limiting the minimum and maximum of the axis values.
  18834. *
  18835. * In styled mode, all the presentational options for the scrollbar are
  18836. * replaced by the classes `.highcharts-scrollbar-thumb`,
  18837. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  18838. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  18839. *
  18840. * @sample {highstock} stock/yaxis/heatmap-scrollbars/
  18841. * Heatmap with both scrollbars
  18842. *
  18843. * @extends scrollbar
  18844. * @since 4.2.6
  18845. * @product highstock
  18846. * @apioption xAxis.scrollbar
  18847. */
  18848. /**
  18849. * Whether to show the axis line and title when the axis has no data.
  18850. *
  18851. * @sample {highcharts} highcharts/yaxis/showempty/
  18852. * When clicking the legend to hide series, one axis preserves
  18853. * line and title, the other doesn't
  18854. * @sample {highstock} highcharts/yaxis/showempty/
  18855. * When clicking the legend to hide series, one axis preserves
  18856. * line and title, the other doesn't
  18857. *
  18858. * @since 1.1
  18859. */
  18860. showEmpty: true,
  18861. /**
  18862. * Whether to show the first tick label.
  18863. *
  18864. * @sample {highcharts} highcharts/xaxis/showfirstlabel-false/
  18865. * Set to false on X axis
  18866. * @sample {highstock} stock/xaxis/showfirstlabel/
  18867. * Labels below plot lines on Y axis
  18868. *
  18869. * @type {boolean}
  18870. * @default true
  18871. * @apioption xAxis.showFirstLabel
  18872. */
  18873. /**
  18874. * Whether to show the last tick label. Defaults to `true` on cartesian
  18875. * charts, and `false` on polar charts.
  18876. *
  18877. * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
  18878. * Set to true on X axis
  18879. * @sample {highstock} stock/xaxis/showfirstlabel/
  18880. * Labels below plot lines on Y axis
  18881. *
  18882. * @type {boolean}
  18883. * @default true
  18884. * @product highcharts highstock gantt
  18885. * @apioption xAxis.showLastLabel
  18886. */
  18887. /**
  18888. * A soft maximum for the axis. If the series data maximum is less than
  18889. * this, the axis will stay at this maximum, but if the series data
  18890. * maximum is higher, the axis will flex to show all data.
  18891. *
  18892. * @sample highcharts/yaxis/softmin-softmax/
  18893. * Soft min and max
  18894. *
  18895. * @type {number}
  18896. * @since 5.0.1
  18897. * @product highcharts highstock gantt
  18898. * @apioption xAxis.softMax
  18899. */
  18900. /**
  18901. * A soft minimum for the axis. If the series data minimum is greater
  18902. * than this, the axis will stay at this minimum, but if the series
  18903. * data minimum is lower, the axis will flex to show all data.
  18904. *
  18905. * @sample highcharts/yaxis/softmin-softmax/
  18906. * Soft min and max
  18907. *
  18908. * @type {number}
  18909. * @since 5.0.1
  18910. * @product highcharts highstock gantt
  18911. * @apioption xAxis.softMin
  18912. */
  18913. /**
  18914. * For datetime axes, this decides where to put the tick between weeks.
  18915. * 0 = Sunday, 1 = Monday.
  18916. *
  18917. * @sample {highcharts} highcharts/xaxis/startofweek-monday/
  18918. * Monday by default
  18919. * @sample {highcharts} highcharts/xaxis/startofweek-sunday/
  18920. * Sunday
  18921. * @sample {highstock} stock/xaxis/startofweek-1
  18922. * Monday by default
  18923. * @sample {highstock} stock/xaxis/startofweek-0
  18924. * Sunday
  18925. *
  18926. * @product highcharts highstock gantt
  18927. */
  18928. startOfWeek: 1,
  18929. /**
  18930. * Whether to force the axis to start on a tick. Use this option with
  18931. * the `minPadding` option to control the axis start.
  18932. *
  18933. * @productdesc {highstock}
  18934. * In Highstock, `startOnTick` is always `false` when the navigator
  18935. * is enabled, to prevent jumpy scrolling.
  18936. *
  18937. * @sample {highcharts} highcharts/xaxis/startontick-false/
  18938. * False by default
  18939. * @sample {highcharts} highcharts/xaxis/startontick-true/
  18940. * True
  18941. *
  18942. * @since 1.2.0
  18943. */
  18944. startOnTick: false,
  18945. /**
  18946. * The amount of ticks to draw on the axis. This opens up for aligning
  18947. * the ticks of multiple charts or panes within a chart. This option
  18948. * overrides the `tickPixelInterval` option.
  18949. *
  18950. * This option only has an effect on linear axes. Datetime, logarithmic
  18951. * or category axes are not affected.
  18952. *
  18953. * @sample {highcharts} highcharts/yaxis/tickamount/
  18954. * 8 ticks on Y axis
  18955. * @sample {highstock} highcharts/yaxis/tickamount/
  18956. * 8 ticks on Y axis
  18957. *
  18958. * @type {number}
  18959. * @since 4.1.0
  18960. * @product highcharts highstock gantt
  18961. * @apioption xAxis.tickAmount
  18962. */
  18963. /**
  18964. * The interval of the tick marks in axis units. When `undefined`, the
  18965. * tick interval is computed to approximately follow the
  18966. * [tickPixelInterval](#xAxis.tickPixelInterval) on linear and datetime
  18967. * axes. On categorized axes, a `undefined` tickInterval will default to
  18968. * 1, one category. Note that datetime axes are based on milliseconds,
  18969. * so for example an interval of one day is expressed as
  18970. * `24 * 3600 * 1000`.
  18971. *
  18972. * On logarithmic axes, the tickInterval is based on powers, so a
  18973. * tickInterval of 1 means one tick on each of 0.1, 1, 10, 100 etc. A
  18974. * tickInterval of 2 means a tick of 0.1, 10, 1000 etc. A tickInterval
  18975. * of 0.2 puts a tick on 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20,
  18976. * 40 etc.
  18977. *
  18978. *
  18979. * If the tickInterval is too dense for labels to be drawn, Highcharts
  18980. * may remove ticks.
  18981. *
  18982. * If the chart has multiple axes, the [alignTicks](#chart.alignTicks)
  18983. * option may interfere with the `tickInterval` setting.
  18984. *
  18985. * @see [tickPixelInterval](#xAxis.tickPixelInterval)
  18986. * @see [tickPositions](#xAxis.tickPositions)
  18987. * @see [tickPositioner](#xAxis.tickPositioner)
  18988. *
  18989. * @sample {highcharts} highcharts/xaxis/tickinterval-5/
  18990. * Tick interval of 5 on a linear axis
  18991. * @sample {highstock} stock/xaxis/tickinterval/
  18992. * Tick interval of 0.01 on Y axis
  18993. *
  18994. * @type {number}
  18995. * @apioption xAxis.tickInterval
  18996. */
  18997. /**
  18998. * The pixel length of the main tick marks.
  18999. *
  19000. * @sample {highcharts} highcharts/xaxis/ticklength/
  19001. * 20 px tick length on the X axis
  19002. * @sample {highstock} stock/xaxis/ticks/
  19003. * Formatted ticks on X axis
  19004. */
  19005. tickLength: 10,
  19006. /**
  19007. * If tickInterval is `null` this option sets the approximate pixel
  19008. * interval of the tick marks. Not applicable to categorized axis.
  19009. *
  19010. * The tick interval is also influenced by the [minTickInterval](
  19011. * #xAxis.minTickInterval) option, that, by default prevents ticks from
  19012. * being denser than the data points.
  19013. *
  19014. * @see [tickInterval](#xAxis.tickInterval)
  19015. * @see [tickPositioner](#xAxis.tickPositioner)
  19016. * @see [tickPositions](#xAxis.tickPositions)
  19017. *
  19018. * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
  19019. * 50 px on X axis
  19020. * @sample {highstock} stock/xaxis/tickpixelinterval/
  19021. * 200 px on X axis
  19022. */
  19023. tickPixelInterval: 100,
  19024. /**
  19025. * For categorized axes only. If `on` the tick mark is placed in the
  19026. * center of the category, if `between` the tick mark is placed between
  19027. * categories. The default is `between` if the `tickInterval` is 1, else
  19028. * `on`.
  19029. *
  19030. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
  19031. * "between" by default
  19032. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
  19033. * "on"
  19034. *
  19035. * @product highcharts gantt
  19036. * @validvalue ["on", "between"]
  19037. */
  19038. tickmarkPlacement: 'between',
  19039. /**
  19040. * The position of the major tick marks relative to the axis line.
  19041. * Can be one of `inside` and `outside`.
  19042. *
  19043. * @sample {highcharts} highcharts/xaxis/tickposition-outside/
  19044. * "outside" by default
  19045. * @sample {highcharts} highcharts/xaxis/tickposition-inside/
  19046. * "inside"
  19047. * @sample {highstock} stock/xaxis/ticks/
  19048. * Formatted ticks on X axis
  19049. *
  19050. * @validvalue ["inside", "outside"]
  19051. */
  19052. tickPosition: 'outside',
  19053. /**
  19054. * A callback function returning array defining where the ticks are
  19055. * laid out on the axis. This overrides the default behaviour of
  19056. * [tickPixelInterval](#xAxis.tickPixelInterval) and [tickInterval](
  19057. * #xAxis.tickInterval). The automatic tick positions are accessible
  19058. * through `this.tickPositions` and can be modified by the callback.
  19059. *
  19060. * @see [tickPositions](#xAxis.tickPositions)
  19061. *
  19062. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  19063. * Demo of tickPositions and tickPositioner
  19064. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  19065. * Demo of tickPositions and tickPositioner
  19066. *
  19067. * @type {Highcharts.AxisTickPositionerCallbackFunction}
  19068. * @apioption xAxis.tickPositioner
  19069. */
  19070. /**
  19071. * An array defining where the ticks are laid out on the axis. This
  19072. * overrides the default behaviour of [tickPixelInterval](
  19073. * #xAxis.tickPixelInterval) and [tickInterval](#xAxis.tickInterval).
  19074. *
  19075. * @see [tickPositioner](#xAxis.tickPositioner)
  19076. *
  19077. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  19078. * Demo of tickPositions and tickPositioner
  19079. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  19080. * Demo of tickPositions and tickPositioner
  19081. *
  19082. * @type {Array<number>}
  19083. * @apioption xAxis.tickPositions
  19084. */
  19085. /**
  19086. * The pixel width of the major tick marks. Defaults to 0 on category
  19087. * axes, otherwise 1.
  19088. *
  19089. * In styled mode, the stroke width is given in the `.highcharts-tick`
  19090. * class, but in order for the element to be generated on category axes,
  19091. * the option must be explicitly set to 1.
  19092. *
  19093. * @sample {highcharts} highcharts/xaxis/tickwidth/
  19094. * 10 px width
  19095. * @sample {highcharts} highcharts/css/axis-grid/
  19096. * Styled mode
  19097. * @sample {highstock} stock/xaxis/ticks/
  19098. * Formatted ticks on X axis
  19099. * @sample {highstock} highcharts/css/axis-grid/
  19100. * Styled mode
  19101. *
  19102. * @type {undefined|number}
  19103. * @default {highstock} 1
  19104. * @default {highmaps} 0
  19105. * @apioption xAxis.tickWidth
  19106. */
  19107. /**
  19108. * The axis title, showing next to the axis line.
  19109. *
  19110. * @productdesc {highmaps}
  19111. * In Highmaps, the axis is hidden by default, but adding an axis title
  19112. * is still possible. X axis and Y axis titles will appear at the bottom
  19113. * and left by default.
  19114. */
  19115. title: {
  19116. /**
  19117. * Deprecated. Set the `text` to `null` to disable the title.
  19118. *
  19119. * @deprecated
  19120. * @type {boolean}
  19121. * @product highcharts
  19122. * @apioption xAxis.title.enabled
  19123. */
  19124. /**
  19125. * The pixel distance between the axis labels or line and the title.
  19126. * Defaults to 0 for horizontal axes, 10 for vertical
  19127. *
  19128. * @sample {highcharts} highcharts/xaxis/title-margin/
  19129. * Y axis title margin of 60
  19130. *
  19131. * @type {number}
  19132. * @apioption xAxis.title.margin
  19133. */
  19134. /**
  19135. * The distance of the axis title from the axis line. By default,
  19136. * this distance is computed from the offset width of the labels,
  19137. * the labels' distance from the axis and the title's margin.
  19138. * However when the offset option is set, it overrides all this.
  19139. *
  19140. * @sample {highcharts} highcharts/yaxis/title-offset/
  19141. * Place the axis title on top of the axis
  19142. * @sample {highstock} highcharts/yaxis/title-offset/
  19143. * Place the axis title on top of the Y axis
  19144. *
  19145. * @type {number}
  19146. * @since 2.2.0
  19147. * @apioption xAxis.title.offset
  19148. */
  19149. /**
  19150. * Whether to reserve space for the title when laying out the axis.
  19151. *
  19152. * @type {boolean}
  19153. * @default true
  19154. * @since 5.0.11
  19155. * @product highcharts highstock gantt
  19156. * @apioption xAxis.title.reserveSpace
  19157. */
  19158. /**
  19159. * The rotation of the text in degrees. 0 is horizontal, 270 is
  19160. * vertical reading from bottom to top.
  19161. *
  19162. * @sample {highcharts} highcharts/yaxis/title-offset/
  19163. * Horizontal
  19164. *
  19165. * @type {number}
  19166. * @default 0
  19167. * @apioption xAxis.title.rotation
  19168. */
  19169. /**
  19170. * The actual text of the axis title. It can contain basic HTML tags
  19171. * like `b`, `i` and `span` with style.
  19172. *
  19173. * @sample {highcharts} highcharts/xaxis/title-text/
  19174. * Custom HTML
  19175. * @sample {highstock} stock/xaxis/title-text/
  19176. * Titles for both axes
  19177. *
  19178. * @type {string|null}
  19179. * @apioption xAxis.title.text
  19180. */
  19181. /**
  19182. * Alignment of the text, can be `"left"`, `"right"` or `"center"`.
  19183. * Default alignment depends on the
  19184. * [title.align](xAxis.title.align):
  19185. *
  19186. * Horizontal axes:
  19187. * - for `align` = `"low"`, `textAlign` is set to `left`
  19188. * - for `align` = `"middle"`, `textAlign` is set to `center`
  19189. * - for `align` = `"high"`, `textAlign` is set to `right`
  19190. *
  19191. * Vertical axes:
  19192. * - for `align` = `"low"` and `opposite` = `true`, `textAlign` is
  19193. * set to `right`
  19194. * - for `align` = `"low"` and `opposite` = `false`, `textAlign` is
  19195. * set to `left`
  19196. * - for `align` = `"middle"`, `textAlign` is set to `center`
  19197. * - for `align` = `"high"` and `opposite` = `true` `textAlign` is
  19198. * set to `left`
  19199. * - for `align` = `"high"` and `opposite` = `false` `textAlign` is
  19200. * set to `right`
  19201. *
  19202. * @type {Highcharts.AlignValue}
  19203. * @apioption xAxis.title.textAlign
  19204. */
  19205. /**
  19206. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  19207. * to render the axis title.
  19208. *
  19209. * @type {boolean}
  19210. * @default false
  19211. * @product highcharts highstock gantt
  19212. * @apioption xAxis.title.useHTML
  19213. */
  19214. /**
  19215. * Horizontal pixel offset of the title position.
  19216. *
  19217. * @type {number}
  19218. * @default 0
  19219. * @since 4.1.6
  19220. * @product highcharts highstock gantt
  19221. * @apioption xAxis.title.x
  19222. */
  19223. /**
  19224. * Vertical pixel offset of the title position.
  19225. *
  19226. * @type {number}
  19227. * @product highcharts highstock gantt
  19228. * @apioption xAxis.title.y
  19229. */
  19230. /**
  19231. * Alignment of the title relative to the axis values. Possible
  19232. * values are "low", "middle" or "high".
  19233. *
  19234. * @sample {highcharts} highcharts/xaxis/title-align-low/
  19235. * "low"
  19236. * @sample {highcharts} highcharts/xaxis/title-align-center/
  19237. * "middle" by default
  19238. * @sample {highcharts} highcharts/xaxis/title-align-high/
  19239. * "high"
  19240. * @sample {highcharts} highcharts/yaxis/title-offset/
  19241. * Place the Y axis title on top of the axis
  19242. * @sample {highstock} stock/xaxis/title-align/
  19243. * Aligned to "high" value
  19244. *
  19245. * @type {Highcharts.AxisTitleAlignValue}
  19246. */
  19247. align: 'middle',
  19248. /**
  19249. * CSS styles for the title. If the title text is longer than the
  19250. * axis length, it will wrap to multiple lines by default. This can
  19251. * be customized by setting `textOverflow: 'ellipsis'`, by
  19252. * setting a specific `width` or by setting `whiteSpace: 'nowrap'`.
  19253. *
  19254. * In styled mode, the stroke width is given in the
  19255. * `.highcharts-axis-title` class.
  19256. *
  19257. * @sample {highcharts} highcharts/xaxis/title-style/
  19258. * Red
  19259. * @sample {highcharts} highcharts/css/axis/
  19260. * Styled mode
  19261. *
  19262. * @type {Highcharts.CSSObject}
  19263. */
  19264. style: {
  19265. /** @internal */
  19266. color: '#666666'
  19267. }
  19268. },
  19269. /**
  19270. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
  19271. * or `category`. In a datetime axis, the numbers are given in
  19272. * milliseconds, and tick marks are placed on appropriate values like
  19273. * full hours or days. In a category axis, the
  19274. * [point names](#series.line.data.name) of the chart's series are used
  19275. * for categories, if not a [categories](#xAxis.categories) array is
  19276. * defined.
  19277. *
  19278. * @sample {highcharts} highcharts/xaxis/type-linear/
  19279. * Linear
  19280. * @sample {highcharts} highcharts/yaxis/type-log/
  19281. * Logarithmic
  19282. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  19283. * Logarithmic with minor grid lines
  19284. * @sample {highcharts} highcharts/xaxis/type-log-both/
  19285. * Logarithmic on two axes
  19286. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  19287. * Logarithmic with extension to emulate negative values
  19288. *
  19289. * @type {Highcharts.AxisTypeValue}
  19290. * @product highcharts gantt
  19291. */
  19292. type: 'linear',
  19293. /**
  19294. * If there are multiple axes on the same side of the chart, the pixel
  19295. * margin between the axes. Defaults to 0 on vertical axes, 15 on
  19296. * horizontal axes.
  19297. *
  19298. * @type {number}
  19299. * @since 7.0.3
  19300. * @apioption xAxis.margin
  19301. */
  19302. /**
  19303. * Applies only when the axis `type` is `category`. When `uniqueNames`
  19304. * is true, points are placed on the X axis according to their names.
  19305. * If the same point name is repeated in the same or another series,
  19306. * the point is placed on the same X position as other points of the
  19307. * same name. When `uniqueNames` is false, the points are laid out in
  19308. * increasing X positions regardless of their names, and the X axis
  19309. * category will take the name of the last point in each position.
  19310. *
  19311. * @sample {highcharts} highcharts/xaxis/uniquenames-true/
  19312. * True by default
  19313. * @sample {highcharts} highcharts/xaxis/uniquenames-false/
  19314. * False
  19315. *
  19316. * @type {boolean}
  19317. * @default true
  19318. * @since 4.2.7
  19319. * @product highcharts gantt
  19320. * @apioption xAxis.uniqueNames
  19321. */
  19322. /**
  19323. * Datetime axis only. An array determining what time intervals the
  19324. * ticks are allowed to fall on. Each array item is an array where the
  19325. * first value is the time unit and the second value another array of
  19326. * allowed multiples.
  19327. *
  19328. * Defaults to:
  19329. * ```js
  19330. * units: [[
  19331. * 'millisecond', // unit name
  19332. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  19333. * ], [
  19334. * 'second',
  19335. * [1, 2, 5, 10, 15, 30]
  19336. * ], [
  19337. * 'minute',
  19338. * [1, 2, 5, 10, 15, 30]
  19339. * ], [
  19340. * 'hour',
  19341. * [1, 2, 3, 4, 6, 8, 12]
  19342. * ], [
  19343. * 'day',
  19344. * [1]
  19345. * ], [
  19346. * 'week',
  19347. * [1]
  19348. * ], [
  19349. * 'month',
  19350. * [1, 3, 6]
  19351. * ], [
  19352. * 'year',
  19353. * null
  19354. * ]]
  19355. * ```
  19356. *
  19357. * @type {Array<Array<string,(Array<number>|null)>>}
  19358. * @product highcharts highstock gantt
  19359. * @apioption xAxis.units
  19360. */
  19361. /**
  19362. * Whether axis, including axis title, line, ticks and labels, should
  19363. * be visible.
  19364. *
  19365. * @type {boolean}
  19366. * @default true
  19367. * @since 4.1.9
  19368. * @product highcharts highstock gantt
  19369. * @apioption xAxis.visible
  19370. */
  19371. /**
  19372. * Color of the minor, secondary grid lines.
  19373. *
  19374. * In styled mode, the stroke width is given in the
  19375. * `.highcharts-minor-grid-line` class.
  19376. *
  19377. * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
  19378. * Bright grey lines from Y axis
  19379. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19380. * Styled mode
  19381. * @sample {highstock} stock/xaxis/minorgridlinecolor/
  19382. * Bright grey lines from Y axis
  19383. *
  19384. * @type {Highcharts.ColorType}
  19385. * @default #f2f2f2
  19386. */
  19387. minorGridLineColor: '#f2f2f2',
  19388. /**
  19389. * Width of the minor, secondary grid lines.
  19390. *
  19391. * In styled mode, the stroke width is given in the
  19392. * `.highcharts-grid-line` class.
  19393. *
  19394. * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
  19395. * 2px lines from Y axis
  19396. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19397. * Styled mode
  19398. * @sample {highstock} stock/xaxis/minorgridlinewidth/
  19399. * 2px lines from Y axis
  19400. */
  19401. minorGridLineWidth: 1,
  19402. /**
  19403. * Color for the minor tick marks.
  19404. *
  19405. * @sample {highcharts} highcharts/yaxis/minortickcolor/
  19406. * Black tick marks on Y axis
  19407. * @sample {highstock} stock/xaxis/minorticks/
  19408. * Black tick marks on Y axis
  19409. *
  19410. * @type {Highcharts.ColorType}
  19411. * @default #999999
  19412. */
  19413. minorTickColor: '#999999',
  19414. /**
  19415. * The color of the line marking the axis itself.
  19416. *
  19417. * In styled mode, the line stroke is given in the
  19418. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  19419. *
  19420. * @productdesc {highmaps}
  19421. * In Highmaps, the axis line is hidden by default, because the axis is
  19422. * not visible by default.
  19423. *
  19424. * @sample {highcharts} highcharts/yaxis/linecolor/
  19425. * A red line on Y axis
  19426. * @sample {highcharts|highstock} highcharts/css/axis/
  19427. * Axes in styled mode
  19428. * @sample {highstock} stock/xaxis/linecolor/
  19429. * A red line on X axis
  19430. *
  19431. * @type {Highcharts.ColorType}
  19432. * @default #ccd6eb
  19433. */
  19434. lineColor: '#ccd6eb',
  19435. /**
  19436. * The width of the line marking the axis itself.
  19437. *
  19438. * In styled mode, the stroke width is given in the
  19439. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  19440. *
  19441. * @sample {highcharts} highcharts/yaxis/linecolor/
  19442. * A 1px line on Y axis
  19443. * @sample {highcharts|highstock} highcharts/css/axis/
  19444. * Axes in styled mode
  19445. * @sample {highstock} stock/xaxis/linewidth/
  19446. * A 2px line on X axis
  19447. *
  19448. * @default {highcharts|highstock} 1
  19449. * @default {highmaps} 0
  19450. */
  19451. lineWidth: 1,
  19452. /**
  19453. * Color of the grid lines extending the ticks across the plot area.
  19454. *
  19455. * In styled mode, the stroke is given in the `.highcharts-grid-line`
  19456. * class.
  19457. *
  19458. * @productdesc {highmaps}
  19459. * In Highmaps, the grid lines are hidden by default.
  19460. *
  19461. * @sample {highcharts} highcharts/yaxis/gridlinecolor/
  19462. * Green lines
  19463. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19464. * Styled mode
  19465. * @sample {highstock} stock/xaxis/gridlinecolor/
  19466. * Green lines
  19467. *
  19468. * @type {Highcharts.ColorType}
  19469. * @default #e6e6e6
  19470. */
  19471. gridLineColor: '#e6e6e6',
  19472. // gridLineDashStyle: 'solid',
  19473. /**
  19474. * The width of the grid lines extending the ticks across the plot area.
  19475. *
  19476. * In styled mode, the stroke width is given in the
  19477. * `.highcharts-grid-line` class.
  19478. *
  19479. * @sample {highcharts} highcharts/yaxis/gridlinewidth/
  19480. * 2px lines
  19481. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19482. * Styled mode
  19483. * @sample {highstock} stock/xaxis/gridlinewidth/
  19484. * 2px lines
  19485. *
  19486. * @type {number}
  19487. * @default 0
  19488. * @apioption xAxis.gridLineWidth
  19489. */
  19490. // gridLineWidth: 0,
  19491. /**
  19492. * The height as the vertical axis. If it's a number, it is
  19493. * interpreted as pixels.
  19494. *
  19495. * Since Highcharts 2: If it's a percentage string, it is interpreted
  19496. * as percentages of the total plot height.
  19497. *
  19498. * @type {number|string}
  19499. * @product highcharts highstock
  19500. * @apioption xAxis.height
  19501. */
  19502. /**
  19503. * The width as the horizontal axis. If it's a number, it is interpreted
  19504. * as pixels.
  19505. *
  19506. * Since Highcharts v5.0.13: If it's a percentage string, it is
  19507. * interpreted as percentages of the total plot width.
  19508. *
  19509. * @type {number|string}
  19510. * @product highcharts highstock
  19511. * @apioption xAxis.width
  19512. */
  19513. /**
  19514. * Color for the main tick marks.
  19515. *
  19516. * In styled mode, the stroke is given in the `.highcharts-tick`
  19517. * class.
  19518. *
  19519. * @sample {highcharts} highcharts/xaxis/tickcolor/
  19520. * Red ticks on X axis
  19521. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19522. * Styled mode
  19523. * @sample {highstock} stock/xaxis/ticks/
  19524. * Formatted ticks on X axis
  19525. *
  19526. * @type {Highcharts.ColorType}
  19527. * @default #ccd6eb
  19528. */
  19529. tickColor: '#ccd6eb'
  19530. // tickWidth: 1
  19531. };
  19532. /**
  19533. * The Y axis or value axis. Normally this is the vertical axis,
  19534. * though if the chart is inverted this is the horizontal axis.
  19535. * In case of multiple axes, the yAxis node is an array of
  19536. * configuration objects.
  19537. *
  19538. * See [the Axis object](/class-reference/Highcharts.Axis) for programmatic
  19539. * access to the axis.
  19540. *
  19541. * @type {*|Array<*>}
  19542. * @extends xAxis
  19543. * @excluding currentDateIndicator,ordinal,overscroll
  19544. * @optionparent yAxis
  19545. *
  19546. * @private
  19547. */
  19548. Axis.defaultYAxisOptions = {
  19549. /**
  19550. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`,
  19551. * `category` or `treegrid`. Defaults to `treegrid` for Gantt charts,
  19552. * `linear` for other chart types.
  19553. *
  19554. * In a datetime axis, the numbers are given in milliseconds, and tick
  19555. * marks are placed on appropriate values, like full hours or days. In a
  19556. * category or treegrid axis, the [point names](#series.line.data.name)
  19557. * of the chart's series are used for categories, if a
  19558. * [categories](#xAxis.categories) array is not defined.
  19559. *
  19560. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  19561. * Logarithmic with minor grid lines
  19562. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  19563. * Logarithmic with extension to emulate negative values
  19564. * @sample {gantt} gantt/treegrid-axis/demo
  19565. * Treegrid axis
  19566. *
  19567. * @type {Highcharts.AxisTypeValue}
  19568. * @default {highcharts} linear
  19569. * @default {gantt} treegrid
  19570. * @product highcharts gantt
  19571. * @apioption yAxis.type
  19572. */
  19573. /**
  19574. * The height of the Y axis. If it's a number, it is interpreted as
  19575. * pixels.
  19576. *
  19577. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  19578. * percentages of the total plot height.
  19579. *
  19580. * @see [yAxis.top](#yAxis.top)
  19581. *
  19582. * @sample {highstock} stock/demo/candlestick-and-volume/
  19583. * Percentage height panes
  19584. *
  19585. * @type {number|string}
  19586. * @product highcharts highstock
  19587. * @apioption yAxis.height
  19588. */
  19589. /**
  19590. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  19591. * to represent the maximum value of the Y axis.
  19592. *
  19593. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  19594. * Min and max colors
  19595. *
  19596. * @type {Highcharts.ColorType}
  19597. * @default #003399
  19598. * @since 4.0
  19599. * @product highcharts
  19600. * @apioption yAxis.maxColor
  19601. */
  19602. /**
  19603. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  19604. * to represent the minimum value of the Y axis.
  19605. *
  19606. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  19607. * Min and max color
  19608. *
  19609. * @type {Highcharts.ColorType}
  19610. * @default #e6ebf5
  19611. * @since 4.0
  19612. * @product highcharts
  19613. * @apioption yAxis.minColor
  19614. */
  19615. /**
  19616. * Whether to reverse the axis so that the highest number is closest
  19617. * to the origin.
  19618. *
  19619. * @sample {highcharts} highcharts/yaxis/reversed/
  19620. * Reversed Y axis
  19621. * @sample {highstock} stock/xaxis/reversed/
  19622. * Reversed Y axis
  19623. *
  19624. * @type {boolean}
  19625. * @default {highcharts} false
  19626. * @default {highstock} false
  19627. * @default {highmaps} true
  19628. * @default {gantt} true
  19629. * @apioption yAxis.reversed
  19630. */
  19631. /**
  19632. * If `true`, the first series in a stack will be drawn on top in a
  19633. * positive, non-reversed Y axis. If `false`, the first series is in
  19634. * the base of the stack.
  19635. *
  19636. * @sample {highcharts} highcharts/yaxis/reversedstacks-false/
  19637. * Non-reversed stacks
  19638. * @sample {highstock} highcharts/yaxis/reversedstacks-false/
  19639. * Non-reversed stacks
  19640. *
  19641. * @type {boolean}
  19642. * @default true
  19643. * @since 3.0.10
  19644. * @product highcharts highstock
  19645. * @apioption yAxis.reversedStacks
  19646. */
  19647. /**
  19648. * Solid gauge series only. Color stops for the solid gauge. Use this
  19649. * in cases where a linear gradient between a `minColor` and `maxColor`
  19650. * is not sufficient. The stops is an array of tuples, where the first
  19651. * item is a float between 0 and 1 assigning the relative position in
  19652. * the gradient, and the second item is the color.
  19653. *
  19654. * For solid gauges, the Y axis also inherits the concept of
  19655. * [data classes](https://api.highcharts.com/highmaps#colorAxis.dataClasses)
  19656. * from the Highmaps color axis.
  19657. *
  19658. * @see [minColor](#yAxis.minColor)
  19659. * @see [maxColor](#yAxis.maxColor)
  19660. *
  19661. * @sample {highcharts} highcharts/demo/gauge-solid/
  19662. * True by default
  19663. *
  19664. * @type {Array<Array<number,Highcharts.ColorType>>}
  19665. * @since 4.0
  19666. * @product highcharts
  19667. * @apioption yAxis.stops
  19668. */
  19669. /**
  19670. * The pixel width of the major tick marks.
  19671. *
  19672. * @sample {highcharts} highcharts/xaxis/tickwidth/ 10 px width
  19673. * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
  19674. *
  19675. * @type {number}
  19676. * @default 0
  19677. * @product highcharts highstock gantt
  19678. * @apioption yAxis.tickWidth
  19679. */
  19680. /**
  19681. * Whether to force the axis to end on a tick. Use this option with
  19682. * the `maxPadding` option to control the axis end.
  19683. *
  19684. * This option is always disabled, when panning type is
  19685. * either `y` or `xy`.
  19686. *
  19687. * @see [type](#chart.panning.type)
  19688. *
  19689. *
  19690. * @sample {highcharts} highcharts/chart/reflow-true/
  19691. * True by default
  19692. * @sample {highcharts} highcharts/yaxis/endontick/
  19693. * False
  19694. * @sample {highstock} stock/demo/basic-line/
  19695. * True by default
  19696. * @sample {highstock} stock/xaxis/endontick/
  19697. * False for Y axis
  19698. *
  19699. * @since 1.2.0
  19700. */
  19701. endOnTick: true,
  19702. /**
  19703. * Padding of the max value relative to the length of the axis. A
  19704. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19705. * when you don't want the highest data value to appear on the edge
  19706. * of the plot area. When the axis' `max` option is set or a max extreme
  19707. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  19708. *
  19709. * Also the `softThreshold` option takes precedence over `maxPadding`,
  19710. * so if the data is tangent to the threshold, `maxPadding` may not
  19711. * apply unless `softThreshold` is set to false.
  19712. *
  19713. * @sample {highcharts} highcharts/yaxis/maxpadding-02/
  19714. * Max padding of 0.2
  19715. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19716. * Greater min- and maxPadding
  19717. *
  19718. * @since 1.2.0
  19719. * @product highcharts highstock gantt
  19720. */
  19721. maxPadding: 0.05,
  19722. /**
  19723. * Padding of the min value relative to the length of the axis. A
  19724. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19725. * when you don't want the lowest data value to appear on the edge
  19726. * of the plot area. When the axis' `min` option is set or a max extreme
  19727. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  19728. *
  19729. * Also the `softThreshold` option takes precedence over `minPadding`,
  19730. * so if the data is tangent to the threshold, `minPadding` may not
  19731. * apply unless `softThreshold` is set to false.
  19732. *
  19733. * @sample {highcharts} highcharts/yaxis/minpadding/
  19734. * Min padding of 0.2
  19735. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19736. * Greater min- and maxPadding
  19737. *
  19738. * @since 1.2.0
  19739. * @product highcharts highstock gantt
  19740. */
  19741. minPadding: 0.05,
  19742. /**
  19743. * @productdesc {highstock}
  19744. * In Highstock 1.x, the Y axis was placed on the left side by default.
  19745. *
  19746. * @sample {highcharts} highcharts/yaxis/opposite/
  19747. * Secondary Y axis opposite
  19748. * @sample {highstock} stock/xaxis/opposite/
  19749. * Y axis on left side
  19750. *
  19751. * @type {boolean}
  19752. * @default {highstock} true
  19753. * @default {highcharts} false
  19754. * @product highstock highcharts gantt
  19755. * @apioption yAxis.opposite
  19756. */
  19757. /**
  19758. * @see [tickInterval](#xAxis.tickInterval)
  19759. * @see [tickPositioner](#xAxis.tickPositioner)
  19760. * @see [tickPositions](#xAxis.tickPositions)
  19761. */
  19762. tickPixelInterval: 72,
  19763. showLastLabel: true,
  19764. /**
  19765. * @extends xAxis.labels
  19766. */
  19767. labels: {
  19768. /**
  19769. * Angular gauges and solid gauges only.
  19770. * The label's pixel distance from the perimeter of the plot area.
  19771. *
  19772. * Since v7.1.2: If it's a percentage string, it is interpreted the
  19773. * same as [series.radius](#plotOptions.gauge.radius), so label can be
  19774. * aligned under the gauge's shape.
  19775. *
  19776. * @sample {highcharts} highcharts/yaxis/labels-distance/
  19777. * Labels centered under the arc
  19778. *
  19779. * @type {number|string}
  19780. * @default -25
  19781. * @product highcharts
  19782. * @apioption yAxis.labels.distance
  19783. */
  19784. /**
  19785. * The y position offset of all labels relative to the tick
  19786. * positions on the axis. For polar and radial axis consider the use
  19787. * of the [distance](#yAxis.labels.distance) option.
  19788. *
  19789. * @sample {highcharts} highcharts/xaxis/labels-x/
  19790. * Y axis labels placed on grid lines
  19791. *
  19792. * @type {number}
  19793. * @default {highcharts} 3
  19794. * @default {highstock} -2
  19795. * @default {highmaps} 3
  19796. * @apioption yAxis.labels.y
  19797. */
  19798. /**
  19799. * What part of the string the given position is anchored to. Can
  19800. * be one of `"left"`, `"center"` or `"right"`. The exact position
  19801. * also depends on the `labels.x` setting.
  19802. *
  19803. * Angular gauges and solid gauges defaults to `"center"`.
  19804. * Solid gauges with two labels have additional option `"auto"`
  19805. * for automatic horizontal and vertical alignment.
  19806. *
  19807. * @see [yAxis.labels.distance](#yAxis.labels.distance)
  19808. *
  19809. * @sample {highcharts} highcharts/yaxis/labels-align-left/
  19810. * Left
  19811. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  19812. * Solid gauge labels auto aligned
  19813. *
  19814. * @type {Highcharts.AlignValue}
  19815. * @default {highcharts|highmaps} right
  19816. * @default {highstock} left
  19817. * @apioption yAxis.labels.align
  19818. */
  19819. /**
  19820. * The x position offset of all labels relative to the tick
  19821. * positions on the axis. Defaults to -15 for left axis, 15 for
  19822. * right axis.
  19823. *
  19824. * @sample {highcharts} highcharts/xaxis/labels-x/
  19825. * Y axis labels placed on grid lines
  19826. */
  19827. x: -8
  19828. },
  19829. /**
  19830. * @productdesc {highmaps}
  19831. * In Highmaps, the axis line is hidden by default, because the axis is
  19832. * not visible by default.
  19833. *
  19834. * @type {Highcharts.ColorType}
  19835. * @apioption yAxis.lineColor
  19836. */
  19837. /**
  19838. * @sample {highcharts} highcharts/yaxis/max-200/
  19839. * Y axis max of 200
  19840. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  19841. * Y axis max on logarithmic axis
  19842. * @sample {highstock} stock/yaxis/min-max/
  19843. * Fixed min and max on Y axis
  19844. * @sample {highmaps} maps/axis/min-max/
  19845. * Pre-zoomed to a specific area
  19846. *
  19847. * @apioption yAxis.max
  19848. */
  19849. /**
  19850. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  19851. * -50 with startOnTick to false
  19852. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  19853. * -50 with startOnTick true by default
  19854. * @sample {highstock} stock/yaxis/min-max/
  19855. * Fixed min and max on Y axis
  19856. * @sample {highmaps} maps/axis/min-max/
  19857. * Pre-zoomed to a specific area
  19858. *
  19859. * @apioption yAxis.min
  19860. */
  19861. /**
  19862. * An optional scrollbar to display on the Y axis in response to
  19863. * limiting the minimum an maximum of the axis values.
  19864. *
  19865. * In styled mode, all the presentational options for the scrollbar
  19866. * are replaced by the classes `.highcharts-scrollbar-thumb`,
  19867. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  19868. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  19869. *
  19870. * @sample {highstock} stock/yaxis/scrollbar/
  19871. * Scrollbar on the Y axis
  19872. *
  19873. * @extends scrollbar
  19874. * @since 4.2.6
  19875. * @product highstock
  19876. * @excluding height
  19877. * @apioption yAxis.scrollbar
  19878. */
  19879. /**
  19880. * Enable the scrollbar on the Y axis.
  19881. *
  19882. * @sample {highstock} stock/yaxis/scrollbar/
  19883. * Enabled on Y axis
  19884. *
  19885. * @type {boolean}
  19886. * @default false
  19887. * @since 4.2.6
  19888. * @product highstock
  19889. * @apioption yAxis.scrollbar.enabled
  19890. */
  19891. /**
  19892. * Pixel margin between the scrollbar and the axis elements.
  19893. *
  19894. * @type {number}
  19895. * @default 10
  19896. * @since 4.2.6
  19897. * @product highstock
  19898. * @apioption yAxis.scrollbar.margin
  19899. */
  19900. /**
  19901. * Whether to show the scrollbar when it is fully zoomed out at max
  19902. * range. Setting it to `false` on the Y axis makes the scrollbar stay
  19903. * hidden until the user zooms in, like common in browsers.
  19904. *
  19905. * @type {boolean}
  19906. * @default true
  19907. * @since 4.2.6
  19908. * @product highstock
  19909. * @apioption yAxis.scrollbar.showFull
  19910. */
  19911. /**
  19912. * The width of a vertical scrollbar or height of a horizontal
  19913. * scrollbar. Defaults to 20 on touch devices.
  19914. *
  19915. * @type {number}
  19916. * @default 14
  19917. * @since 4.2.6
  19918. * @product highstock
  19919. * @apioption yAxis.scrollbar.size
  19920. */
  19921. /**
  19922. * Z index of the scrollbar elements.
  19923. *
  19924. * @type {number}
  19925. * @default 3
  19926. * @since 4.2.6
  19927. * @product highstock
  19928. * @apioption yAxis.scrollbar.zIndex
  19929. */
  19930. /**
  19931. * A soft maximum for the axis. If the series data maximum is less
  19932. * than this, the axis will stay at this maximum, but if the series
  19933. * data maximum is higher, the axis will flex to show all data.
  19934. *
  19935. * **Note**: The [series.softThreshold](
  19936. * #plotOptions.series.softThreshold) option takes precedence over this
  19937. * option.
  19938. *
  19939. * @sample highcharts/yaxis/softmin-softmax/
  19940. * Soft min and max
  19941. *
  19942. * @type {number}
  19943. * @since 5.0.1
  19944. * @product highcharts highstock gantt
  19945. * @apioption yAxis.softMax
  19946. */
  19947. /**
  19948. * A soft minimum for the axis. If the series data minimum is greater
  19949. * than this, the axis will stay at this minimum, but if the series
  19950. * data minimum is lower, the axis will flex to show all data.
  19951. *
  19952. * **Note**: The [series.softThreshold](
  19953. * #plotOptions.series.softThreshold) option takes precedence over this
  19954. * option.
  19955. *
  19956. * @sample highcharts/yaxis/softmin-softmax/
  19957. * Soft min and max
  19958. *
  19959. * @type {number}
  19960. * @since 5.0.1
  19961. * @product highcharts highstock gantt
  19962. * @apioption yAxis.softMin
  19963. */
  19964. /**
  19965. * Defines the horizontal alignment of the stack total label. Can be one
  19966. * of `"left"`, `"center"` or `"right"`. The default value is calculated
  19967. * at runtime and depends on orientation and whether the stack is
  19968. * positive or negative.
  19969. *
  19970. * @sample {highcharts} highcharts/yaxis/stacklabels-align-left/
  19971. * Aligned to the left
  19972. * @sample {highcharts} highcharts/yaxis/stacklabels-align-center/
  19973. * Aligned in center
  19974. * @sample {highcharts} highcharts/yaxis/stacklabels-align-right/
  19975. * Aligned to the right
  19976. *
  19977. * @type {Highcharts.AlignValue}
  19978. * @since 2.1.5
  19979. * @product highcharts
  19980. * @apioption yAxis.stackLabels.align
  19981. */
  19982. /**
  19983. * A format string for the data label. Available variables are the same
  19984. * as for `formatter`.
  19985. *
  19986. * @type {string}
  19987. * @default {total}
  19988. * @since 3.0.2
  19989. * @product highcharts highstock
  19990. * @apioption yAxis.stackLabels.format
  19991. */
  19992. /**
  19993. * Rotation of the labels in degrees.
  19994. *
  19995. * @sample {highcharts} highcharts/yaxis/stacklabels-rotation/
  19996. * Labels rotated 45°
  19997. *
  19998. * @type {number}
  19999. * @default 0
  20000. * @since 2.1.5
  20001. * @product highcharts
  20002. * @apioption yAxis.stackLabels.rotation
  20003. */
  20004. /**
  20005. * The text alignment for the label. While `align` determines where the
  20006. * texts anchor point is placed with regards to the stack, `textAlign`
  20007. * determines how the text is aligned against its anchor point. Possible
  20008. * values are `"left"`, `"center"` and `"right"`. The default value is
  20009. * calculated at runtime and depends on orientation and whether the
  20010. * stack is positive or negative.
  20011. *
  20012. * @sample {highcharts} highcharts/yaxis/stacklabels-textalign-left/
  20013. * Label in center position but text-aligned left
  20014. *
  20015. * @type {Highcharts.AlignValue}
  20016. * @since 2.1.5
  20017. * @product highcharts
  20018. * @apioption yAxis.stackLabels.textAlign
  20019. */
  20020. /**
  20021. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20022. * to render the labels.
  20023. *
  20024. * @type {boolean}
  20025. * @default false
  20026. * @since 3.0
  20027. * @product highcharts highstock
  20028. * @apioption yAxis.stackLabels.useHTML
  20029. */
  20030. /**
  20031. * Defines the vertical alignment of the stack total label. Can be one
  20032. * of `"top"`, `"middle"` or `"bottom"`. The default value is calculated
  20033. * at runtime and depends on orientation and whether the stack is
  20034. * positive or negative.
  20035. *
  20036. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-top/
  20037. * Vertically aligned top
  20038. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-middle/
  20039. * Vertically aligned middle
  20040. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-bottom/
  20041. * Vertically aligned bottom
  20042. *
  20043. * @type {Highcharts.VerticalAlignValue}
  20044. * @since 2.1.5
  20045. * @product highcharts
  20046. * @apioption yAxis.stackLabels.verticalAlign
  20047. */
  20048. /**
  20049. * The x position offset of the label relative to the left of the
  20050. * stacked bar. The default value is calculated at runtime and depends
  20051. * on orientation and whether the stack is positive or negative.
  20052. *
  20053. * @sample {highcharts} highcharts/yaxis/stacklabels-x/
  20054. * Stack total labels with x offset
  20055. *
  20056. * @type {number}
  20057. * @since 2.1.5
  20058. * @product highcharts
  20059. * @apioption yAxis.stackLabels.x
  20060. */
  20061. /**
  20062. * The y position offset of the label relative to the tick position
  20063. * on the axis. The default value is calculated at runtime and depends
  20064. * on orientation and whether the stack is positive or negative.
  20065. *
  20066. * @sample {highcharts} highcharts/yaxis/stacklabels-y/
  20067. * Stack total labels with y offset
  20068. *
  20069. * @type {number}
  20070. * @since 2.1.5
  20071. * @product highcharts
  20072. * @apioption yAxis.stackLabels.y
  20073. */
  20074. /**
  20075. * Whether to force the axis to start on a tick. Use this option with
  20076. * the `maxPadding` option to control the axis start.
  20077. *
  20078. * This option is always disabled, when panning type is
  20079. * either `y` or `xy`.
  20080. *
  20081. * @see [type](#chart.panning.type)
  20082. *
  20083. * @sample {highcharts} highcharts/xaxis/startontick-false/
  20084. * False by default
  20085. * @sample {highcharts} highcharts/xaxis/startontick-true/
  20086. * True
  20087. * @sample {highstock} stock/xaxis/endontick/
  20088. * False for Y axis
  20089. *
  20090. * @since 1.2.0
  20091. * @product highcharts highstock gantt
  20092. */
  20093. startOnTick: true,
  20094. title: {
  20095. /**
  20096. * The pixel distance between the axis labels and the title.
  20097. * Positive values are outside the axis line, negative are inside.
  20098. *
  20099. * @sample {highcharts} highcharts/xaxis/title-margin/
  20100. * Y axis title margin of 60
  20101. *
  20102. * @type {number}
  20103. * @default 40
  20104. * @apioption yAxis.title.margin
  20105. */
  20106. /**
  20107. * The rotation of the text in degrees. 0 is horizontal, 270 is
  20108. * vertical reading from bottom to top.
  20109. *
  20110. * @sample {highcharts} highcharts/yaxis/title-offset/
  20111. * Horizontal
  20112. */
  20113. rotation: 270,
  20114. /**
  20115. * The actual text of the axis title. Horizontal texts can contain
  20116. * HTML, but rotated texts are painted using vector techniques and
  20117. * must be clean text. The Y axis title is disabled by setting the
  20118. * `text` option to `undefined`.
  20119. *
  20120. * @sample {highcharts} highcharts/xaxis/title-text/
  20121. * Custom HTML
  20122. *
  20123. * @type {string|null}
  20124. * @default {highcharts} Values
  20125. * @default {highstock} undefined
  20126. * @product highcharts highstock gantt
  20127. */
  20128. text: 'Values'
  20129. },
  20130. /**
  20131. * The top position of the Y axis. If it's a number, it is interpreted
  20132. * as pixel position relative to the chart.
  20133. *
  20134. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  20135. * percentages of the plot height, offset from plot area top.
  20136. *
  20137. * @see [yAxis.height](#yAxis.height)
  20138. *
  20139. * @sample {highstock} stock/demo/candlestick-and-volume/
  20140. * Percentage height panes
  20141. *
  20142. * @type {number|string}
  20143. * @product highcharts highstock
  20144. * @apioption yAxis.top
  20145. */
  20146. /**
  20147. * The stack labels show the total value for each bar in a stacked
  20148. * column or bar chart. The label will be placed on top of positive
  20149. * columns and below negative columns. In case of an inverted column
  20150. * chart or a bar chart the label is placed to the right of positive
  20151. * bars and to the left of negative bars.
  20152. *
  20153. * @product highcharts
  20154. */
  20155. stackLabels: {
  20156. /**
  20157. * Enable or disable the initial animation when a series is
  20158. * displayed for the `stackLabels`. The animation can also be set as
  20159. * a configuration object. Please note that this option only
  20160. * applies to the initial animation.
  20161. * For other animations, see [chart.animation](#chart.animation)
  20162. * and the animation parameter under the API methods.
  20163. * The following properties are supported:
  20164. *
  20165. * - `defer`: The animation delay time in milliseconds.
  20166. *
  20167. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  20168. * Animation defer settings
  20169. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  20170. * @since 8.2.0
  20171. * @apioption yAxis.stackLabels.animation
  20172. */
  20173. animation: {},
  20174. /**
  20175. * The animation delay time in milliseconds.
  20176. * Set to `0` renders stackLabel immediately.
  20177. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  20178. *
  20179. * @type {number}
  20180. * @since 8.2.0
  20181. * @apioption yAxis.stackLabels.animation.defer
  20182. */
  20183. /**
  20184. * Allow the stack labels to overlap.
  20185. *
  20186. * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
  20187. * Default false
  20188. *
  20189. * @since 5.0.13
  20190. * @product highcharts
  20191. */
  20192. allowOverlap: false,
  20193. /**
  20194. * The background color or gradient for the stack label.
  20195. *
  20196. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  20197. * Stack labels box options
  20198. * @type {Highcharts.ColorType}
  20199. * @since 8.1.0
  20200. * @apioption yAxis.stackLabels.backgroundColor
  20201. */
  20202. /**
  20203. * The border color for the stack label. Defaults to `undefined`.
  20204. *
  20205. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  20206. * Stack labels box options
  20207. * @type {Highcharts.ColorType}
  20208. * @since 8.1.0
  20209. * @apioption yAxis.stackLabels.borderColor
  20210. */
  20211. /**
  20212. * The border radius in pixels for the stack label.
  20213. *
  20214. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  20215. * Stack labels box options
  20216. * @type {number}
  20217. * @default 0
  20218. * @since 8.1.0
  20219. * @apioption yAxis.stackLabels.borderRadius
  20220. */
  20221. /**
  20222. * The border width in pixels for the stack label.
  20223. *
  20224. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  20225. * Stack labels box options
  20226. * @type {number}
  20227. * @default 0
  20228. * @since 8.1.0
  20229. * @apioption yAxis.stackLabels.borderWidth
  20230. */
  20231. /**
  20232. * Enable or disable the stack total labels.
  20233. *
  20234. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
  20235. * Enabled stack total labels
  20236. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled-waterfall/
  20237. * Enabled stack labels in waterfall chart
  20238. *
  20239. * @since 2.1.5
  20240. * @product highcharts
  20241. */
  20242. enabled: false,
  20243. /**
  20244. * Whether to hide stack labels that are outside the plot area.
  20245. * By default, the stack label is moved
  20246. * inside the plot area according to the
  20247. * [overflow](/highcharts/#yAxis/stackLabels/overflow)
  20248. * option.
  20249. *
  20250. * @type {boolean}
  20251. * @since 7.1.3
  20252. */
  20253. crop: true,
  20254. /**
  20255. * How to handle stack total labels that flow outside the plot area.
  20256. * The default is set to `"justify"`,
  20257. * which aligns them inside the plot area.
  20258. * For columns and bars, this means it will be moved inside the bar.
  20259. * To display stack labels outside the plot area,
  20260. * set `crop` to `false` and `overflow` to `"allow"`.
  20261. *
  20262. * @sample highcharts/yaxis/stacklabels-overflow/
  20263. * Stack labels flows outside the plot area.
  20264. *
  20265. * @type {Highcharts.DataLabelsOverflowValue}
  20266. * @since 7.1.3
  20267. */
  20268. overflow: 'justify',
  20269. /* eslint-disable valid-jsdoc */
  20270. /**
  20271. * Callback JavaScript function to format the label. The value is
  20272. * given by `this.total`.
  20273. *
  20274. * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
  20275. * Added units to stack total value
  20276. *
  20277. * @type {Highcharts.FormatterCallbackFunction<Highcharts.StackItemObject>}
  20278. * @since 2.1.5
  20279. * @product highcharts
  20280. */
  20281. formatter: function () {
  20282. var numberFormatter = this.axis.chart.numberFormatter;
  20283. /* eslint-enable valid-jsdoc */
  20284. return numberFormatter(this.total, -1);
  20285. },
  20286. /**
  20287. * CSS styles for the label.
  20288. *
  20289. * In styled mode, the styles are set in the
  20290. * `.highcharts-stack-label` class.
  20291. *
  20292. * @sample {highcharts} highcharts/yaxis/stacklabels-style/
  20293. * Red stack total labels
  20294. *
  20295. * @type {Highcharts.CSSObject}
  20296. * @since 2.1.5
  20297. * @product highcharts
  20298. */
  20299. style: {
  20300. /** @internal */
  20301. color: '#000000',
  20302. /** @internal */
  20303. fontSize: '11px',
  20304. /** @internal */
  20305. fontWeight: 'bold',
  20306. /** @internal */
  20307. textOutline: '1px contrast'
  20308. }
  20309. },
  20310. gridLineWidth: 1,
  20311. lineWidth: 0
  20312. // tickWidth: 0
  20313. };
  20314. /**
  20315. * The Z axis or depth axis for 3D plots.
  20316. *
  20317. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  20318. * access to the axis.
  20319. *
  20320. * @sample {highcharts} highcharts/3d/scatter-zaxis-categories/
  20321. * Z-Axis with Categories
  20322. * @sample {highcharts} highcharts/3d/scatter-zaxis-grid/
  20323. * Z-Axis with styling
  20324. *
  20325. * @type {*|Array<*>}
  20326. * @extends xAxis
  20327. * @since 5.0.0
  20328. * @product highcharts
  20329. * @excluding breaks, crosshair, height, left, lineColor, lineWidth,
  20330. * nameToX, showEmpty, top, width
  20331. * @apioption zAxis
  20332. *
  20333. * @private
  20334. */
  20335. // This variable extends the defaultOptions for left axes.
  20336. Axis.defaultLeftAxisOptions = {
  20337. labels: {
  20338. x: -15
  20339. },
  20340. title: {
  20341. rotation: 270
  20342. }
  20343. };
  20344. // This variable extends the defaultOptions for right axes.
  20345. Axis.defaultRightAxisOptions = {
  20346. labels: {
  20347. x: 15
  20348. },
  20349. title: {
  20350. rotation: 90
  20351. }
  20352. };
  20353. // This variable extends the defaultOptions for bottom axes.
  20354. Axis.defaultBottomAxisOptions = {
  20355. labels: {
  20356. autoRotation: [-45],
  20357. x: 0
  20358. // overflow: undefined,
  20359. // staggerLines: null
  20360. },
  20361. margin: 15,
  20362. title: {
  20363. rotation: 0
  20364. }
  20365. };
  20366. // This variable extends the defaultOptions for top axes.
  20367. Axis.defaultTopAxisOptions = {
  20368. labels: {
  20369. autoRotation: [-45],
  20370. x: 0
  20371. // overflow: undefined
  20372. // staggerLines: null
  20373. },
  20374. margin: 15,
  20375. title: {
  20376. rotation: 0
  20377. }
  20378. };
  20379. // Properties to survive after destroy, needed for Axis.update (#4317,
  20380. // #5773, #5881).
  20381. Axis.keepProps = ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'];
  20382. return Axis;
  20383. }());
  20384. H.Axis = Axis;
  20385. return H.Axis;
  20386. });
  20387. _registerModule(_modules, 'Core/Axis/DateTimeAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  20388. /* *
  20389. *
  20390. * (c) 2010-2020 Torstein Honsi
  20391. *
  20392. * License: www.highcharts.com/license
  20393. *
  20394. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  20395. *
  20396. * */
  20397. var addEvent = U.addEvent,
  20398. getMagnitude = U.getMagnitude,
  20399. normalizeTickInterval = U.normalizeTickInterval,
  20400. timeUnits = U.timeUnits;
  20401. /* eslint-disable valid-jsdoc */
  20402. var DateTimeAxisAdditions = /** @class */ (function () {
  20403. /* *
  20404. *
  20405. * Constructors
  20406. *
  20407. * */
  20408. function DateTimeAxisAdditions(axis) {
  20409. this.axis = axis;
  20410. }
  20411. /* *
  20412. *
  20413. * Functions
  20414. *
  20415. * */
  20416. /**
  20417. * Get a normalized tick interval for dates. Returns a configuration object
  20418. * with unit range (interval), count and name. Used to prepare data for
  20419. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  20420. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  20421. * logic was extracted in order to prevent it for running over again for
  20422. * each segment having the same interval. #662, #697.
  20423. * @private
  20424. */
  20425. /**
  20426. * Get a normalized tick interval for dates. Returns a configuration object
  20427. * with unit range (interval), count and name. Used to prepare data for
  20428. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  20429. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  20430. * logic was extracted in order to prevent it for running over again for
  20431. * each segment having the same interval. #662, #697.
  20432. * @private
  20433. */
  20434. DateTimeAxisAdditions.prototype.normalizeTimeTickInterval = function (tickInterval, unitsOption) {
  20435. var units = unitsOption || [[
  20436. 'millisecond',
  20437. [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  20438. ],
  20439. [
  20440. 'second',
  20441. [1, 2, 5, 10, 15, 30]
  20442. ],
  20443. [
  20444. 'minute',
  20445. [1, 2, 5, 10, 15, 30]
  20446. ],
  20447. [
  20448. 'hour',
  20449. [1, 2, 3, 4, 6, 8, 12]
  20450. ],
  20451. [
  20452. 'day',
  20453. [1, 2]
  20454. ],
  20455. [
  20456. 'week',
  20457. [1, 2]
  20458. ],
  20459. [
  20460. 'month',
  20461. [1, 2, 3, 4, 6]
  20462. ],
  20463. [
  20464. 'year',
  20465. null
  20466. ]],
  20467. unit = units[units.length - 1], // default unit is years
  20468. interval = timeUnits[unit[0]],
  20469. multiples = unit[1],
  20470. count,
  20471. i;
  20472. // loop through the units to find the one that best fits the
  20473. // tickInterval
  20474. for (i = 0; i < units.length; i++) {
  20475. unit = units[i];
  20476. interval = timeUnits[unit[0]];
  20477. multiples = unit[1];
  20478. if (units[i + 1]) {
  20479. // lessThan is in the middle between the highest multiple and
  20480. // the next unit.
  20481. var lessThan = (interval *
  20482. multiples[multiples.length - 1] +
  20483. timeUnits[units[i + 1][0]]) / 2;
  20484. // break and keep the current unit
  20485. if (tickInterval <= lessThan) {
  20486. break;
  20487. }
  20488. }
  20489. }
  20490. // prevent 2.5 years intervals, though 25, 250 etc. are allowed
  20491. if (interval === timeUnits.year && tickInterval < 5 * interval) {
  20492. multiples = [1, 2, 5];
  20493. }
  20494. // get the count
  20495. count = normalizeTickInterval(tickInterval / interval, multiples, unit[0] === 'year' ? // #1913, #2360
  20496. Math.max(getMagnitude(tickInterval / interval), 1) :
  20497. 1);
  20498. return {
  20499. unitRange: interval,
  20500. count: count,
  20501. unitName: unit[0]
  20502. };
  20503. };
  20504. return DateTimeAxisAdditions;
  20505. }());
  20506. /**
  20507. * Date and time support for axes.
  20508. *
  20509. * @private
  20510. * @class
  20511. */
  20512. var DateTimeAxis = /** @class */ (function () {
  20513. function DateTimeAxis() {
  20514. }
  20515. /* *
  20516. *
  20517. * Static Functions
  20518. *
  20519. * */
  20520. /**
  20521. * Extends axis class with date and time support.
  20522. * @private
  20523. */
  20524. DateTimeAxis.compose = function (AxisClass) {
  20525. AxisClass.keepProps.push('dateTime');
  20526. var axisProto = AxisClass.prototype;
  20527. /**
  20528. * Set the tick positions to a time unit that makes sense, for example
  20529. * on the first of each month or on every Monday. Return an array with
  20530. * the time positions. Used in datetime axes as well as for grouping
  20531. * data on a datetime axis.
  20532. *
  20533. * @private
  20534. * @function Highcharts.Axis#getTimeTicks
  20535. *
  20536. * @param {Highcharts.TimeNormalizeObject} normalizedInterval
  20537. * The interval in axis values (ms) and thecount.
  20538. *
  20539. * @param {number} min
  20540. * The minimum in axis values.
  20541. *
  20542. * @param {number} max
  20543. * The maximum in axis values.
  20544. *
  20545. * @param {number} startOfWeek
  20546. *
  20547. * @return {Highcharts.AxisTickPositionsArray}
  20548. */
  20549. axisProto.getTimeTicks = function () {
  20550. return this.chart.time.getTimeTicks.apply(this.chart.time, arguments);
  20551. };
  20552. /* eslint-disable no-invalid-this */
  20553. addEvent(AxisClass, 'init', function (e) {
  20554. var axis = this;
  20555. var options = e.userOptions;
  20556. if (options.type !== 'datetime') {
  20557. axis.dateTime = void 0;
  20558. return;
  20559. }
  20560. if (!axis.dateTime) {
  20561. axis.dateTime = new DateTimeAxisAdditions(axis);
  20562. }
  20563. });
  20564. /* eslint-enable no-invalid-this */
  20565. };
  20566. /* *
  20567. *
  20568. * Static Properties
  20569. *
  20570. * */
  20571. DateTimeAxis.AdditionsClass = DateTimeAxisAdditions;
  20572. return DateTimeAxis;
  20573. }());
  20574. DateTimeAxis.compose(Axis);
  20575. return DateTimeAxis;
  20576. });
  20577. _registerModule(_modules, 'Core/Axis/LogarithmicAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  20578. /* *
  20579. *
  20580. * (c) 2010-2020 Torstein Honsi
  20581. *
  20582. * License: www.highcharts.com/license
  20583. *
  20584. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  20585. *
  20586. * */
  20587. var addEvent = U.addEvent,
  20588. getMagnitude = U.getMagnitude,
  20589. normalizeTickInterval = U.normalizeTickInterval,
  20590. pick = U.pick;
  20591. /* eslint-disable valid-jsdoc */
  20592. /**
  20593. * Provides logarithmic support for axes.
  20594. *
  20595. * @private
  20596. * @class
  20597. */
  20598. var LogarithmicAxisAdditions = /** @class */ (function () {
  20599. /* *
  20600. *
  20601. * Constructors
  20602. *
  20603. * */
  20604. function LogarithmicAxisAdditions(axis) {
  20605. this.axis = axis;
  20606. }
  20607. /* *
  20608. *
  20609. * Functions
  20610. *
  20611. * */
  20612. /**
  20613. * Set the tick positions of a logarithmic axis.
  20614. */
  20615. LogarithmicAxisAdditions.prototype.getLogTickPositions = function (interval, min, max, minor) {
  20616. var log = this;
  20617. var axis = log.axis;
  20618. var axisLength = axis.len;
  20619. var options = axis.options;
  20620. // Since we use this method for both major and minor ticks,
  20621. // use a local variable and return the result
  20622. var positions = [];
  20623. // Reset
  20624. if (!minor) {
  20625. log.minorAutoInterval = void 0;
  20626. }
  20627. // First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
  20628. if (interval >= 0.5) {
  20629. interval = Math.round(interval);
  20630. positions = axis.getLinearTickPositions(interval, min, max);
  20631. // Second case: We need intermediary ticks. For example
  20632. // 1, 2, 4, 6, 8, 10, 20, 40 etc.
  20633. }
  20634. else if (interval >= 0.08) {
  20635. var roundedMin = Math.floor(min),
  20636. intermediate,
  20637. i,
  20638. j,
  20639. len,
  20640. pos,
  20641. lastPos,
  20642. break2;
  20643. if (interval > 0.3) {
  20644. intermediate = [1, 2, 4];
  20645. // 0.2 equals five minor ticks per 1, 10, 100 etc
  20646. }
  20647. else if (interval > 0.15) {
  20648. intermediate = [1, 2, 4, 6, 8];
  20649. }
  20650. else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
  20651. intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  20652. }
  20653. for (i = roundedMin; i < max + 1 && !break2; i++) {
  20654. len = intermediate.length;
  20655. for (j = 0; j < len && !break2; j++) {
  20656. pos = log.log2lin(log.lin2log(i) * intermediate[j]);
  20657. // #1670, lastPos is #3113
  20658. if (pos > min &&
  20659. (!minor || lastPos <= max) &&
  20660. typeof lastPos !== 'undefined') {
  20661. positions.push(lastPos);
  20662. }
  20663. if (lastPos > max) {
  20664. break2 = true;
  20665. }
  20666. lastPos = pos;
  20667. }
  20668. }
  20669. // Third case: We are so deep in between whole logarithmic values that
  20670. // we might as well handle the tick positions like a linear axis. For
  20671. // example 1.01, 1.02, 1.03, 1.04.
  20672. }
  20673. else {
  20674. var realMin = log.lin2log(min),
  20675. realMax = log.lin2log(max),
  20676. tickIntervalOption = minor ?
  20677. axis.getMinorTickInterval() :
  20678. options.tickInterval,
  20679. filteredTickIntervalOption = tickIntervalOption === 'auto' ?
  20680. null :
  20681. tickIntervalOption,
  20682. tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
  20683. totalPixelLength = minor ?
  20684. axisLength / axis.tickPositions.length :
  20685. axisLength;
  20686. interval = pick(filteredTickIntervalOption, log.minorAutoInterval, (realMax - realMin) *
  20687. tickPixelIntervalOption / (totalPixelLength || 1));
  20688. interval = normalizeTickInterval(interval, void 0, getMagnitude(interval));
  20689. positions = axis.getLinearTickPositions(interval, realMin, realMax).map(log.log2lin);
  20690. if (!minor) {
  20691. log.minorAutoInterval = interval / 5;
  20692. }
  20693. }
  20694. // Set the axis-level tickInterval variable
  20695. if (!minor) {
  20696. axis.tickInterval = interval;
  20697. }
  20698. return positions;
  20699. };
  20700. LogarithmicAxisAdditions.prototype.lin2log = function (num) {
  20701. return Math.pow(10, num);
  20702. };
  20703. LogarithmicAxisAdditions.prototype.log2lin = function (num) {
  20704. return Math.log(num) / Math.LN10;
  20705. };
  20706. return LogarithmicAxisAdditions;
  20707. }());
  20708. var LogarithmicAxis = /** @class */ (function () {
  20709. function LogarithmicAxis() {
  20710. }
  20711. /**
  20712. * Provides logarithmic support for axes.
  20713. *
  20714. * @private
  20715. */
  20716. LogarithmicAxis.compose = function (AxisClass) {
  20717. AxisClass.keepProps.push('logarithmic');
  20718. // HC <= 8 backwards compatibility, allow wrapping
  20719. // Axis.prototype.lin2log and log2lin
  20720. // @todo Remove this in next major
  20721. var axisProto = AxisClass.prototype;
  20722. var logAxisProto = LogarithmicAxisAdditions.prototype;
  20723. axisProto.log2lin = logAxisProto.log2lin;
  20724. axisProto.lin2log = logAxisProto.lin2log;
  20725. /* eslint-disable no-invalid-this */
  20726. addEvent(AxisClass, 'init', function (e) {
  20727. var axis = this;
  20728. var options = e.userOptions;
  20729. var logarithmic = axis.logarithmic;
  20730. if (options.type !== 'logarithmic') {
  20731. axis.logarithmic = void 0;
  20732. }
  20733. else {
  20734. if (!logarithmic) {
  20735. logarithmic = axis.logarithmic = new LogarithmicAxisAdditions(axis);
  20736. }
  20737. // HC <= 8 backwards compatibility, allow wrapping
  20738. // Axis.prototype.lin2log and log2lin
  20739. // @todo Remove this in next major
  20740. if (axis.log2lin !== logarithmic.log2lin) {
  20741. logarithmic.log2lin = axis.log2lin.bind(axis);
  20742. }
  20743. if (axis.lin2log !== logarithmic.lin2log) {
  20744. logarithmic.lin2log = axis.lin2log.bind(axis);
  20745. }
  20746. }
  20747. });
  20748. addEvent(AxisClass, 'afterInit', function () {
  20749. var axis = this;
  20750. var log = axis.logarithmic;
  20751. // extend logarithmic axis
  20752. if (log) {
  20753. axis.lin2val = function (num) {
  20754. return log.lin2log(num);
  20755. };
  20756. axis.val2lin = function (num) {
  20757. return log.log2lin(num);
  20758. };
  20759. }
  20760. });
  20761. };
  20762. return LogarithmicAxis;
  20763. }());
  20764. LogarithmicAxis.compose(Axis); // @todo move to factory functions
  20765. return LogarithmicAxis;
  20766. });
  20767. _registerModule(_modules, 'Core/Axis/PlotLineOrBand.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Axis, H, U) {
  20768. /* *
  20769. *
  20770. * (c) 2010-2020 Torstein Honsi
  20771. *
  20772. * License: www.highcharts.com/license
  20773. *
  20774. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  20775. *
  20776. * */
  20777. /**
  20778. * Options for plot bands on axes.
  20779. *
  20780. * @typedef {Highcharts.XAxisPlotBandsOptions|Highcharts.YAxisPlotBandsOptions|Highcharts.ZAxisPlotBandsOptions} Highcharts.AxisPlotBandsOptions
  20781. */
  20782. /**
  20783. * Options for plot band labels on axes.
  20784. *
  20785. * @typedef {Highcharts.XAxisPlotBandsLabelOptions|Highcharts.YAxisPlotBandsLabelOptions|Highcharts.ZAxisPlotBandsLabelOptions} Highcharts.AxisPlotBandsLabelOptions
  20786. */
  20787. /**
  20788. * Options for plot lines on axes.
  20789. *
  20790. * @typedef {Highcharts.XAxisPlotLinesOptions|Highcharts.YAxisPlotLinesOptions|Highcharts.ZAxisPlotLinesOptions} Highcharts.AxisPlotLinesOptions
  20791. */
  20792. /**
  20793. * Options for plot line labels on axes.
  20794. *
  20795. * @typedef {Highcharts.XAxisPlotLinesLabelOptions|Highcharts.YAxisPlotLinesLabelOptions|Highcharts.ZAxisPlotLinesLabelOptions} Highcharts.AxisPlotLinesLabelOptions
  20796. */
  20797. var arrayMax = U.arrayMax,
  20798. arrayMin = U.arrayMin,
  20799. defined = U.defined,
  20800. destroyObjectProperties = U.destroyObjectProperties,
  20801. erase = U.erase,
  20802. extend = U.extend,
  20803. merge = U.merge,
  20804. objectEach = U.objectEach,
  20805. pick = U.pick;
  20806. /* eslint-disable no-invalid-this, valid-jsdoc */
  20807. /**
  20808. * The object wrapper for plot lines and plot bands
  20809. *
  20810. * @class
  20811. * @name Highcharts.PlotLineOrBand
  20812. *
  20813. * @param {Highcharts.Axis} axis
  20814. *
  20815. * @param {Highcharts.AxisPlotLinesOptions|Highcharts.AxisPlotBandsOptions} [options]
  20816. */
  20817. var PlotLineOrBand = /** @class */ (function () {
  20818. function PlotLineOrBand(axis, options) {
  20819. this.axis = axis;
  20820. if (options) {
  20821. this.options = options;
  20822. this.id = options.id;
  20823. }
  20824. }
  20825. /**
  20826. * Render the plot line or plot band. If it is already existing,
  20827. * move it.
  20828. *
  20829. * @private
  20830. * @function Highcharts.PlotLineOrBand#render
  20831. * @return {Highcharts.PlotLineOrBand|undefined}
  20832. */
  20833. PlotLineOrBand.prototype.render = function () {
  20834. H.fireEvent(this, 'render');
  20835. var plotLine = this,
  20836. axis = plotLine.axis,
  20837. horiz = axis.horiz,
  20838. log = axis.logarithmic,
  20839. options = plotLine.options,
  20840. optionsLabel = options.label,
  20841. label = plotLine.label,
  20842. to = options.to,
  20843. from = options.from,
  20844. value = options.value,
  20845. isBand = defined(from) && defined(to),
  20846. isLine = defined(value),
  20847. svgElem = plotLine.svgElem,
  20848. isNew = !svgElem,
  20849. path = [],
  20850. color = options.color,
  20851. zIndex = pick(options.zIndex, 0),
  20852. events = options.events,
  20853. attribs = {
  20854. 'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') +
  20855. (options.className || '')
  20856. },
  20857. groupAttribs = {},
  20858. renderer = axis.chart.renderer,
  20859. groupName = isBand ? 'bands' : 'lines',
  20860. group;
  20861. // logarithmic conversion
  20862. if (log) {
  20863. from = log.log2lin(from);
  20864. to = log.log2lin(to);
  20865. value = log.log2lin(value);
  20866. }
  20867. // Set the presentational attributes
  20868. if (!axis.chart.styledMode) {
  20869. if (isLine) {
  20870. attribs.stroke = color || '#999999';
  20871. attribs['stroke-width'] = pick(options.width, 1);
  20872. if (options.dashStyle) {
  20873. attribs.dashstyle =
  20874. options.dashStyle;
  20875. }
  20876. }
  20877. else if (isBand) { // plot band
  20878. attribs.fill = color || '#e6ebf5';
  20879. if (options.borderWidth) {
  20880. attribs.stroke = options.borderColor;
  20881. attribs['stroke-width'] = options.borderWidth;
  20882. }
  20883. }
  20884. }
  20885. // Grouping and zIndex
  20886. groupAttribs.zIndex = zIndex;
  20887. groupName += '-' + zIndex;
  20888. group = axis.plotLinesAndBandsGroups[groupName];
  20889. if (!group) {
  20890. axis.plotLinesAndBandsGroups[groupName] = group =
  20891. renderer.g('plot-' + groupName)
  20892. .attr(groupAttribs).add();
  20893. }
  20894. // Create the path
  20895. if (isNew) {
  20896. /**
  20897. * SVG element of the plot line or band.
  20898. *
  20899. * @name Highcharts.PlotLineOrBand#svgElement
  20900. * @type {Highcharts.SVGElement}
  20901. */
  20902. plotLine.svgElem = svgElem = renderer
  20903. .path()
  20904. .attr(attribs)
  20905. .add(group);
  20906. }
  20907. // Set the path or return
  20908. if (isLine) {
  20909. path = axis.getPlotLinePath({
  20910. value: value,
  20911. lineWidth: svgElem.strokeWidth(),
  20912. acrossPanes: options.acrossPanes
  20913. });
  20914. }
  20915. else if (isBand) { // plot band
  20916. path = axis.getPlotBandPath(from, to, options);
  20917. }
  20918. else {
  20919. return;
  20920. }
  20921. // common for lines and bands
  20922. // Add events only if they were not added before.
  20923. if (!plotLine.eventsAdded && events) {
  20924. objectEach(events, function (event, eventType) {
  20925. svgElem.on(eventType, function (e) {
  20926. events[eventType].apply(plotLine, [e]);
  20927. });
  20928. });
  20929. plotLine.eventsAdded = true;
  20930. }
  20931. if ((isNew || !svgElem.d) && path && path.length) {
  20932. svgElem.attr({ d: path });
  20933. }
  20934. else if (svgElem) {
  20935. if (path) {
  20936. svgElem.show(true);
  20937. svgElem.animate({ d: path });
  20938. }
  20939. else if (svgElem.d) {
  20940. svgElem.hide();
  20941. if (label) {
  20942. plotLine.label = label = label.destroy();
  20943. }
  20944. }
  20945. }
  20946. // the plot band/line label
  20947. if (optionsLabel &&
  20948. (defined(optionsLabel.text) || defined(optionsLabel.formatter)) &&
  20949. path &&
  20950. path.length &&
  20951. axis.width > 0 &&
  20952. axis.height > 0 &&
  20953. !path.isFlat) {
  20954. // apply defaults
  20955. optionsLabel = merge({
  20956. align: horiz && isBand && 'center',
  20957. x: horiz ? !isBand && 4 : 10,
  20958. verticalAlign: !horiz && isBand && 'middle',
  20959. y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
  20960. rotation: horiz && !isBand && 90
  20961. }, optionsLabel);
  20962. this.renderLabel(optionsLabel, path, isBand, zIndex);
  20963. }
  20964. else if (label) { // move out of sight
  20965. label.hide();
  20966. }
  20967. // chainable
  20968. return plotLine;
  20969. };
  20970. /**
  20971. * Render and align label for plot line or band.
  20972. *
  20973. * @private
  20974. * @function Highcharts.PlotLineOrBand#renderLabel
  20975. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  20976. * @param {Highcharts.SVGPathArray} path
  20977. * @param {boolean} [isBand]
  20978. * @param {number} [zIndex]
  20979. * @return {void}
  20980. */
  20981. PlotLineOrBand.prototype.renderLabel = function (optionsLabel, path, isBand, zIndex) {
  20982. var plotLine = this,
  20983. label = plotLine.label,
  20984. renderer = plotLine.axis.chart.renderer,
  20985. attribs,
  20986. xBounds,
  20987. yBounds,
  20988. x,
  20989. y,
  20990. labelText;
  20991. // add the SVG element
  20992. if (!label) {
  20993. attribs = {
  20994. align: optionsLabel.textAlign || optionsLabel.align,
  20995. rotation: optionsLabel.rotation,
  20996. 'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') +
  20997. '-label ' + (optionsLabel.className || '')
  20998. };
  20999. attribs.zIndex = zIndex;
  21000. labelText = this.getLabelText(optionsLabel);
  21001. /**
  21002. * SVG element of the label.
  21003. *
  21004. * @name Highcharts.PlotLineOrBand#label
  21005. * @type {Highcharts.SVGElement}
  21006. */
  21007. plotLine.label = label = renderer
  21008. .text(labelText, 0, 0, optionsLabel.useHTML)
  21009. .attr(attribs)
  21010. .add();
  21011. if (!this.axis.chart.styledMode) {
  21012. label.css(optionsLabel.style);
  21013. }
  21014. }
  21015. // get the bounding box and align the label
  21016. // #3000 changed to better handle choice between plotband or plotline
  21017. xBounds = path.xBounds ||
  21018. [path[0][1], path[1][1], (isBand ? path[2][1] : path[0][1])];
  21019. yBounds = path.yBounds ||
  21020. [path[0][2], path[1][2], (isBand ? path[2][2] : path[0][2])];
  21021. x = arrayMin(xBounds);
  21022. y = arrayMin(yBounds);
  21023. label.align(optionsLabel, false, {
  21024. x: x,
  21025. y: y,
  21026. width: arrayMax(xBounds) - x,
  21027. height: arrayMax(yBounds) - y
  21028. });
  21029. label.show(true);
  21030. };
  21031. /**
  21032. * Get label's text content.
  21033. *
  21034. * @private
  21035. * @function Highcharts.PlotLineOrBand#getLabelText
  21036. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  21037. * @return {string}
  21038. */
  21039. PlotLineOrBand.prototype.getLabelText = function (optionsLabel) {
  21040. return defined(optionsLabel.formatter) ?
  21041. optionsLabel.formatter
  21042. .call(this) :
  21043. optionsLabel.text;
  21044. };
  21045. /**
  21046. * Remove the plot line or band.
  21047. *
  21048. * @function Highcharts.PlotLineOrBand#destroy
  21049. * @return {void}
  21050. */
  21051. PlotLineOrBand.prototype.destroy = function () {
  21052. // remove it from the lookup
  21053. erase(this.axis.plotLinesAndBands, this);
  21054. delete this.axis;
  21055. destroyObjectProperties(this);
  21056. };
  21057. return PlotLineOrBand;
  21058. }());
  21059. /* eslint-enable no-invalid-this, valid-jsdoc */
  21060. // Object with members for extending the Axis prototype
  21061. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  21062. /**
  21063. * An array of colored bands stretching across the plot area marking an
  21064. * interval on the axis.
  21065. *
  21066. * In styled mode, the plot bands are styled by the `.highcharts-plot-band`
  21067. * class in addition to the `className` option.
  21068. *
  21069. * @productdesc {highcharts}
  21070. * In a gauge, a plot band on the Y axis (value axis) will stretch along the
  21071. * perimeter of the gauge.
  21072. *
  21073. * @type {Array<*>}
  21074. * @product highcharts highstock gantt
  21075. * @apioption xAxis.plotBands
  21076. */
  21077. /**
  21078. * Flag to decide if plotBand should be rendered across all panes.
  21079. *
  21080. * @since 7.1.2
  21081. * @product highstock
  21082. * @type {boolean}
  21083. * @default true
  21084. * @apioption xAxis.plotBands.acrossPanes
  21085. */
  21086. /**
  21087. * Border color for the plot band. Also requires `borderWidth` to be set.
  21088. *
  21089. * @type {Highcharts.ColorString}
  21090. * @apioption xAxis.plotBands.borderColor
  21091. */
  21092. /**
  21093. * Border width for the plot band. Also requires `borderColor` to be set.
  21094. *
  21095. * @type {number}
  21096. * @default 0
  21097. * @apioption xAxis.plotBands.borderWidth
  21098. */
  21099. /**
  21100. * A custom class name, in addition to the default `highcharts-plot-band`,
  21101. * to apply to each individual band.
  21102. *
  21103. * @type {string}
  21104. * @since 5.0.0
  21105. * @apioption xAxis.plotBands.className
  21106. */
  21107. /**
  21108. * The color of the plot band.
  21109. *
  21110. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  21111. * Color band
  21112. * @sample {highstock} stock/xaxis/plotbands/
  21113. * Plot band on Y axis
  21114. *
  21115. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  21116. * @default #e6ebf5
  21117. * @apioption xAxis.plotBands.color
  21118. */
  21119. /**
  21120. * An object defining mouse events for the plot band. Supported properties
  21121. * are `click`, `mouseover`, `mouseout`, `mousemove`.
  21122. *
  21123. * @sample {highcharts} highcharts/xaxis/plotbands-events/
  21124. * Mouse events demonstrated
  21125. *
  21126. * @since 1.2
  21127. * @apioption xAxis.plotBands.events
  21128. */
  21129. /**
  21130. * Click event on a plot band.
  21131. *
  21132. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21133. * @apioption xAxis.plotBands.events.click
  21134. */
  21135. /**
  21136. * Mouse move event on a plot band.
  21137. *
  21138. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21139. * @apioption xAxis.plotBands.events.mousemove
  21140. */
  21141. /**
  21142. * Mouse out event on the corner of a plot band.
  21143. *
  21144. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21145. * @apioption xAxis.plotBands.events.mouseout
  21146. */
  21147. /**
  21148. * Mouse over event on a plot band.
  21149. *
  21150. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21151. * @apioption xAxis.plotBands.events.mouseover
  21152. */
  21153. /**
  21154. * The start position of the plot band in axis units.
  21155. *
  21156. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  21157. * Datetime axis
  21158. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  21159. * Categorized axis
  21160. * @sample {highstock} stock/xaxis/plotbands/
  21161. * Plot band on Y axis
  21162. *
  21163. * @type {number}
  21164. * @apioption xAxis.plotBands.from
  21165. */
  21166. /**
  21167. * An id used for identifying the plot band in Axis.removePlotBand.
  21168. *
  21169. * @sample {highcharts} highcharts/xaxis/plotbands-id/
  21170. * Remove plot band by id
  21171. * @sample {highstock} highcharts/xaxis/plotbands-id/
  21172. * Remove plot band by id
  21173. *
  21174. * @type {string}
  21175. * @apioption xAxis.plotBands.id
  21176. */
  21177. /**
  21178. * The end position of the plot band in axis units.
  21179. *
  21180. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  21181. * Datetime axis
  21182. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  21183. * Categorized axis
  21184. * @sample {highstock} stock/xaxis/plotbands/
  21185. * Plot band on Y axis
  21186. *
  21187. * @type {number}
  21188. * @apioption xAxis.plotBands.to
  21189. */
  21190. /**
  21191. * The z index of the plot band within the chart, relative to other
  21192. * elements. Using the same z index as another element may give
  21193. * unpredictable results, as the last rendered element will be on top.
  21194. * Values from 0 to 20 make sense.
  21195. *
  21196. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  21197. * Behind plot lines by default
  21198. * @sample {highcharts} highcharts/xaxis/plotbands-zindex/
  21199. * Above plot lines
  21200. * @sample {highcharts} highcharts/xaxis/plotbands-zindex-above-series/
  21201. * Above plot lines and series
  21202. *
  21203. * @type {number}
  21204. * @since 1.2
  21205. * @apioption xAxis.plotBands.zIndex
  21206. */
  21207. /**
  21208. * Text labels for the plot bands
  21209. *
  21210. * @product highcharts highstock gantt
  21211. * @apioption xAxis.plotBands.label
  21212. */
  21213. /**
  21214. * Horizontal alignment of the label. Can be one of "left", "center" or
  21215. * "right".
  21216. *
  21217. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  21218. * Aligned to the right
  21219. * @sample {highstock} stock/xaxis/plotbands-label/
  21220. * Plot band with labels
  21221. *
  21222. * @type {Highcharts.AlignValue}
  21223. * @default center
  21224. * @since 2.1
  21225. * @apioption xAxis.plotBands.label.align
  21226. */
  21227. /**
  21228. * Rotation of the text label in degrees .
  21229. *
  21230. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  21231. * Vertical text
  21232. *
  21233. * @type {number}
  21234. * @default 0
  21235. * @since 2.1
  21236. * @apioption xAxis.plotBands.label.rotation
  21237. */
  21238. /**
  21239. * CSS styles for the text label.
  21240. *
  21241. * In styled mode, the labels are styled by the
  21242. * `.highcharts-plot-band-label` class.
  21243. *
  21244. * @sample {highcharts} highcharts/xaxis/plotbands-label-style/
  21245. * Blue and bold label
  21246. *
  21247. * @type {Highcharts.CSSObject}
  21248. * @since 2.1
  21249. * @apioption xAxis.plotBands.label.style
  21250. */
  21251. /**
  21252. * The string text itself. A subset of HTML is supported.
  21253. *
  21254. * @type {string}
  21255. * @since 2.1
  21256. * @apioption xAxis.plotBands.label.text
  21257. */
  21258. /**
  21259. * The text alignment for the label. While `align` determines where the
  21260. * texts anchor point is placed within the plot band, `textAlign` determines
  21261. * how the text is aligned against its anchor point. Possible values are
  21262. * "left", "center" and "right". Defaults to the same as the `align` option.
  21263. *
  21264. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  21265. * Vertical text in center position but text-aligned left
  21266. *
  21267. * @type {Highcharts.AlignValue}
  21268. * @since 2.1
  21269. * @apioption xAxis.plotBands.label.textAlign
  21270. */
  21271. /**
  21272. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  21273. * to render the labels.
  21274. *
  21275. * @type {boolean}
  21276. * @default false
  21277. * @since 3.0.3
  21278. * @apioption xAxis.plotBands.label.useHTML
  21279. */
  21280. /**
  21281. * Vertical alignment of the label relative to the plot band. Can be one of
  21282. * "top", "middle" or "bottom".
  21283. *
  21284. * @sample {highcharts} highcharts/xaxis/plotbands-label-verticalalign/
  21285. * Vertically centered label
  21286. * @sample {highstock} stock/xaxis/plotbands-label/
  21287. * Plot band with labels
  21288. *
  21289. * @type {Highcharts.VerticalAlignValue}
  21290. * @default top
  21291. * @since 2.1
  21292. * @apioption xAxis.plotBands.label.verticalAlign
  21293. */
  21294. /**
  21295. * Horizontal position relative the alignment. Default varies by
  21296. * orientation.
  21297. *
  21298. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  21299. * Aligned 10px from the right edge
  21300. * @sample {highstock} stock/xaxis/plotbands-label/
  21301. * Plot band with labels
  21302. *
  21303. * @type {number}
  21304. * @since 2.1
  21305. * @apioption xAxis.plotBands.label.x
  21306. */
  21307. /**
  21308. * Vertical position of the text baseline relative to the alignment. Default
  21309. * varies by orientation.
  21310. *
  21311. * @sample {highcharts} highcharts/xaxis/plotbands-label-y/
  21312. * Label on x axis
  21313. * @sample {highstock} stock/xaxis/plotbands-label/
  21314. * Plot band with labels
  21315. *
  21316. * @type {number}
  21317. * @since 2.1
  21318. * @apioption xAxis.plotBands.label.y
  21319. */
  21320. /**
  21321. * An array of lines stretching across the plot area, marking a specific
  21322. * value on one of the axes.
  21323. *
  21324. * In styled mode, the plot lines are styled by the
  21325. * `.highcharts-plot-line` class in addition to the `className` option.
  21326. *
  21327. * @type {Array<*>}
  21328. * @product highcharts highstock gantt
  21329. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  21330. * Basic plot line
  21331. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  21332. * Solid gauge plot line
  21333. * @apioption xAxis.plotLines
  21334. */
  21335. /**
  21336. * Flag to decide if plotLine should be rendered across all panes.
  21337. *
  21338. * @sample {highstock} stock/xaxis/plotlines-acrosspanes/
  21339. * Plot lines on different panes
  21340. *
  21341. * @since 7.1.2
  21342. * @product highstock
  21343. * @type {boolean}
  21344. * @default true
  21345. * @apioption xAxis.plotLines.acrossPanes
  21346. */
  21347. /**
  21348. * A custom class name, in addition to the default `highcharts-plot-line`,
  21349. * to apply to each individual line.
  21350. *
  21351. * @type {string}
  21352. * @since 5.0.0
  21353. * @apioption xAxis.plotLines.className
  21354. */
  21355. /**
  21356. * The color of the line.
  21357. *
  21358. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  21359. * A red line from X axis
  21360. * @sample {highstock} stock/xaxis/plotlines/
  21361. * Plot line on Y axis
  21362. *
  21363. * @type {Highcharts.ColorString}
  21364. * @default #999999
  21365. * @apioption xAxis.plotLines.color
  21366. */
  21367. /**
  21368. * The dashing or dot style for the plot line. For possible values see
  21369. * [this overview](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  21370. *
  21371. * @sample {highcharts} highcharts/xaxis/plotlines-dashstyle/
  21372. * Dash and dot pattern
  21373. * @sample {highstock} stock/xaxis/plotlines/
  21374. * Plot line on Y axis
  21375. *
  21376. * @type {Highcharts.DashStyleValue}
  21377. * @default Solid
  21378. * @since 1.2
  21379. * @apioption xAxis.plotLines.dashStyle
  21380. */
  21381. /**
  21382. * An object defining mouse events for the plot line. Supported
  21383. * properties are `click`, `mouseover`, `mouseout`, `mousemove`.
  21384. *
  21385. * @sample {highcharts} highcharts/xaxis/plotlines-events/
  21386. * Mouse events demonstrated
  21387. *
  21388. * @since 1.2
  21389. * @apioption xAxis.plotLines.events
  21390. */
  21391. /**
  21392. * Click event on a plot band.
  21393. *
  21394. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21395. * @apioption xAxis.plotLines.events.click
  21396. */
  21397. /**
  21398. * Mouse move event on a plot band.
  21399. *
  21400. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21401. * @apioption xAxis.plotLines.events.mousemove
  21402. */
  21403. /**
  21404. * Mouse out event on the corner of a plot band.
  21405. *
  21406. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21407. * @apioption xAxis.plotLines.events.mouseout
  21408. */
  21409. /**
  21410. * Mouse over event on a plot band.
  21411. *
  21412. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21413. * @apioption xAxis.plotLines.events.mouseover
  21414. */
  21415. /**
  21416. * An id used for identifying the plot line in Axis.removePlotLine.
  21417. *
  21418. * @sample {highcharts} highcharts/xaxis/plotlines-id/
  21419. * Remove plot line by id
  21420. *
  21421. * @type {string}
  21422. * @apioption xAxis.plotLines.id
  21423. */
  21424. /**
  21425. * The position of the line in axis units.
  21426. *
  21427. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  21428. * Between two categories on X axis
  21429. * @sample {highstock} stock/xaxis/plotlines/
  21430. * Plot line on Y axis
  21431. *
  21432. * @type {number}
  21433. * @apioption xAxis.plotLines.value
  21434. */
  21435. /**
  21436. * The width or thickness of the plot line.
  21437. *
  21438. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  21439. * 2px wide line from X axis
  21440. * @sample {highstock} stock/xaxis/plotlines/
  21441. * Plot line on Y axis
  21442. *
  21443. * @type {number}
  21444. * @default 2
  21445. * @apioption xAxis.plotLines.width
  21446. */
  21447. /**
  21448. * The z index of the plot line within the chart.
  21449. *
  21450. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-behind/
  21451. * Behind plot lines by default
  21452. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above/
  21453. * Above plot lines
  21454. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above-all/
  21455. * Above plot lines and series
  21456. *
  21457. * @type {number}
  21458. * @since 1.2
  21459. * @apioption xAxis.plotLines.zIndex
  21460. */
  21461. /**
  21462. * Text labels for the plot bands
  21463. *
  21464. * @apioption xAxis.plotLines.label
  21465. */
  21466. /**
  21467. * Horizontal alignment of the label. Can be one of "left", "center" or
  21468. * "right".
  21469. *
  21470. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  21471. * Aligned to the right
  21472. * @sample {highstock} stock/xaxis/plotlines/
  21473. * Plot line on Y axis
  21474. *
  21475. * @type {Highcharts.AlignValue}
  21476. * @default left
  21477. * @since 2.1
  21478. * @apioption xAxis.plotLines.label.align
  21479. */
  21480. /**
  21481. * Callback JavaScript function to format the label. Useful properties like
  21482. * the value of plot line or the range of plot band (`from` & `to`
  21483. * properties) can be found in `this.options` object.
  21484. *
  21485. * @sample {highcharts} highcharts/xaxis/plotlines-plotbands-label-formatter
  21486. * Label formatters for plot line and plot band.
  21487. * @type {Highcharts.FormatterCallbackFunction<Highcharts.PlotLineOrBand>}
  21488. * @apioption xAxis.plotLines.label.formatter
  21489. */
  21490. /**
  21491. * Rotation of the text label in degrees. Defaults to 0 for horizontal plot
  21492. * lines and 90 for vertical lines.
  21493. *
  21494. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  21495. * Slanted text
  21496. *
  21497. * @type {number}
  21498. * @since 2.1
  21499. * @apioption xAxis.plotLines.label.rotation
  21500. */
  21501. /**
  21502. * CSS styles for the text label.
  21503. *
  21504. * In styled mode, the labels are styled by the
  21505. * `.highcharts-plot-line-label` class.
  21506. *
  21507. * @sample {highcharts} highcharts/xaxis/plotlines-label-style/
  21508. * Blue and bold label
  21509. *
  21510. * @type {Highcharts.CSSObject}
  21511. * @since 2.1
  21512. * @apioption xAxis.plotLines.label.style
  21513. */
  21514. /**
  21515. * The text itself. A subset of HTML is supported.
  21516. *
  21517. * @type {string}
  21518. * @since 2.1
  21519. * @apioption xAxis.plotLines.label.text
  21520. */
  21521. /**
  21522. * The text alignment for the label. While `align` determines where the
  21523. * texts anchor point is placed within the plot band, `textAlign` determines
  21524. * how the text is aligned against its anchor point. Possible values are
  21525. * "left", "center" and "right". Defaults to the same as the `align` option.
  21526. *
  21527. * @sample {highcharts} highcharts/xaxis/plotlines-label-textalign/
  21528. * Text label in bottom position
  21529. *
  21530. * @type {Highcharts.AlignValue}
  21531. * @since 2.1
  21532. * @apioption xAxis.plotLines.label.textAlign
  21533. */
  21534. /**
  21535. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  21536. * to render the labels.
  21537. *
  21538. * @type {boolean}
  21539. * @default false
  21540. * @since 3.0.3
  21541. * @apioption xAxis.plotLines.label.useHTML
  21542. */
  21543. /**
  21544. * Vertical alignment of the label relative to the plot line. Can be
  21545. * one of "top", "middle" or "bottom".
  21546. *
  21547. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  21548. * Vertically centered label
  21549. *
  21550. * @type {Highcharts.VerticalAlignValue}
  21551. * @default {highcharts} top
  21552. * @default {highstock} top
  21553. * @since 2.1
  21554. * @apioption xAxis.plotLines.label.verticalAlign
  21555. */
  21556. /**
  21557. * Horizontal position relative the alignment. Default varies by
  21558. * orientation.
  21559. *
  21560. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  21561. * Aligned 10px from the right edge
  21562. * @sample {highstock} stock/xaxis/plotlines/
  21563. * Plot line on Y axis
  21564. *
  21565. * @type {number}
  21566. * @since 2.1
  21567. * @apioption xAxis.plotLines.label.x
  21568. */
  21569. /**
  21570. * Vertical position of the text baseline relative to the alignment. Default
  21571. * varies by orientation.
  21572. *
  21573. * @sample {highcharts} highcharts/xaxis/plotlines-label-y/
  21574. * Label below the plot line
  21575. * @sample {highstock} stock/xaxis/plotlines/
  21576. * Plot line on Y axis
  21577. *
  21578. * @type {number}
  21579. * @since 2.1
  21580. * @apioption xAxis.plotLines.label.y
  21581. */
  21582. /**
  21583. *
  21584. * @type {Array<*>}
  21585. * @extends xAxis.plotBands
  21586. * @apioption yAxis.plotBands
  21587. */
  21588. /**
  21589. * In a gauge chart, this option determines the inner radius of the
  21590. * plot band that stretches along the perimeter. It can be given as
  21591. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  21592. * By default, the inner radius is controlled by the [thickness](
  21593. * #yAxis.plotBands.thickness) option.
  21594. *
  21595. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  21596. * Gauge plot band
  21597. *
  21598. * @type {number|string}
  21599. * @since 2.3
  21600. * @product highcharts
  21601. * @apioption yAxis.plotBands.innerRadius
  21602. */
  21603. /**
  21604. * In a gauge chart, this option determines the outer radius of the
  21605. * plot band that stretches along the perimeter. It can be given as
  21606. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  21607. *
  21608. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  21609. * Gauge plot band
  21610. *
  21611. * @type {number|string}
  21612. * @default 100%
  21613. * @since 2.3
  21614. * @product highcharts
  21615. * @apioption yAxis.plotBands.outerRadius
  21616. */
  21617. /**
  21618. * In a gauge chart, this option sets the width of the plot band
  21619. * stretching along the perimeter. It can be given as a percentage
  21620. * string, like `"10%"`, or as a pixel number, like `10`. The default
  21621. * value 10 is the same as the default [tickLength](#yAxis.tickLength),
  21622. * thus making the plot band act as a background for the tick markers.
  21623. *
  21624. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  21625. * Gauge plot band
  21626. *
  21627. * @type {number|string}
  21628. * @default 10
  21629. * @since 2.3
  21630. * @product highcharts
  21631. * @apioption yAxis.plotBands.thickness
  21632. */
  21633. /**
  21634. * @type {Array<*>}
  21635. * @extends xAxis.plotLines
  21636. * @apioption yAxis.plotLines
  21637. */
  21638. /* eslint-disable no-invalid-this, valid-jsdoc */
  21639. /**
  21640. * Internal function to create the SVG path definition for a plot band.
  21641. *
  21642. * @function Highcharts.Axis#getPlotBandPath
  21643. *
  21644. * @param {number} from
  21645. * The axis value to start from.
  21646. *
  21647. * @param {number} to
  21648. * The axis value to end on.
  21649. *
  21650. * @return {Highcharts.SVGPathArray}
  21651. * The SVG path definition in array form.
  21652. */
  21653. getPlotBandPath: function (from, to) {
  21654. var toPath = this.getPlotLinePath({
  21655. value: to,
  21656. force: true,
  21657. acrossPanes: this.options.acrossPanes
  21658. }),
  21659. path = this.getPlotLinePath({
  21660. value: from,
  21661. force: true,
  21662. acrossPanes: this.options.acrossPanes
  21663. }),
  21664. result = [],
  21665. i,
  21666. // #4964 check if chart is inverted or plotband is on yAxis
  21667. horiz = this.horiz,
  21668. plus = 1,
  21669. isFlat,
  21670. outside = (from < this.min && to < this.min) ||
  21671. (from > this.max && to > this.max);
  21672. if (path && toPath) {
  21673. // Flat paths don't need labels (#3836)
  21674. if (outside) {
  21675. isFlat = path.toString() === toPath.toString();
  21676. plus = 0;
  21677. }
  21678. // Go over each subpath - for panes in Highstock
  21679. for (i = 0; i < path.length; i += 2) {
  21680. var pathStart = path[i],
  21681. pathEnd = path[i + 1],
  21682. toPathStart = toPath[i],
  21683. toPathEnd = toPath[i + 1];
  21684. // Type checking all affected path segments. Consider something
  21685. // smarter.
  21686. if ((pathStart[0] === 'M' || pathStart[0] === 'L') &&
  21687. (pathEnd[0] === 'M' || pathEnd[0] === 'L') &&
  21688. (toPathStart[0] === 'M' || toPathStart[0] === 'L') &&
  21689. (toPathEnd[0] === 'M' || toPathEnd[0] === 'L')) {
  21690. // Add 1 pixel when coordinates are the same
  21691. if (horiz && toPathStart[1] === pathStart[1]) {
  21692. toPathStart[1] += plus;
  21693. toPathEnd[1] += plus;
  21694. }
  21695. else if (!horiz && toPathStart[2] === pathStart[2]) {
  21696. toPathStart[2] += plus;
  21697. toPathEnd[2] += plus;
  21698. }
  21699. result.push(['M', pathStart[1], pathStart[2]], ['L', pathEnd[1], pathEnd[2]], ['L', toPathEnd[1], toPathEnd[2]], ['L', toPathStart[1], toPathStart[2]], ['Z']);
  21700. }
  21701. result.isFlat = isFlat;
  21702. }
  21703. }
  21704. else { // outside the axis area
  21705. path = null;
  21706. }
  21707. return result;
  21708. },
  21709. /**
  21710. * Add a plot band after render time.
  21711. *
  21712. * @sample highcharts/members/axis-addplotband/
  21713. * Toggle the plot band from a button
  21714. *
  21715. * @function Highcharts.Axis#addPlotBand
  21716. *
  21717. * @param {Highcharts.AxisPlotBandsOptions} options
  21718. * A configuration object for the plot band, as defined in
  21719. * [xAxis.plotBands](https://api.highcharts.com/highcharts/xAxis.plotBands).
  21720. *
  21721. * @return {Highcharts.PlotLineOrBand|undefined}
  21722. * The added plot band.
  21723. */
  21724. addPlotBand: function (options) {
  21725. return this.addPlotBandOrLine(options, 'plotBands');
  21726. },
  21727. /**
  21728. * Add a plot line after render time.
  21729. *
  21730. * @sample highcharts/members/axis-addplotline/
  21731. * Toggle the plot line from a button
  21732. *
  21733. * @function Highcharts.Axis#addPlotLine
  21734. *
  21735. * @param {Highcharts.AxisPlotLinesOptions} options
  21736. * A configuration object for the plot line, as defined in
  21737. * [xAxis.plotLines](https://api.highcharts.com/highcharts/xAxis.plotLines).
  21738. *
  21739. * @return {Highcharts.PlotLineOrBand|undefined}
  21740. * The added plot line.
  21741. */
  21742. addPlotLine: function (options) {
  21743. return this.addPlotBandOrLine(options, 'plotLines');
  21744. },
  21745. /**
  21746. * Add a plot band or plot line after render time. Called from addPlotBand
  21747. * and addPlotLine internally.
  21748. *
  21749. * @private
  21750. * @function Highcharts.Axis#addPlotBandOrLine
  21751. *
  21752. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  21753. * The plotBand or plotLine configuration object.
  21754. *
  21755. * @param {"plotBands"|"plotLines"} [coll]
  21756. *
  21757. * @return {Highcharts.PlotLineOrBand|undefined}
  21758. */
  21759. addPlotBandOrLine: function (options, coll) {
  21760. var obj = new PlotLineOrBand(this,
  21761. options).render(),
  21762. userOptions = this.userOptions;
  21763. if (obj) { // #2189
  21764. // Add it to the user options for exporting and Axis.update
  21765. if (coll) {
  21766. // Workaround Microsoft/TypeScript issue #32693
  21767. var updatedOptions = (userOptions[coll] || []);
  21768. updatedOptions.push(options);
  21769. userOptions[coll] = updatedOptions;
  21770. }
  21771. this.plotLinesAndBands.push(obj);
  21772. this._addedPlotLB = true;
  21773. }
  21774. return obj;
  21775. },
  21776. /**
  21777. * Remove a plot band or plot line from the chart by id. Called internally
  21778. * from `removePlotBand` and `removePlotLine`.
  21779. *
  21780. * @private
  21781. * @function Highcharts.Axis#removePlotBandOrLine
  21782. * @param {string} id
  21783. * @return {void}
  21784. */
  21785. removePlotBandOrLine: function (id) {
  21786. var plotLinesAndBands = this.plotLinesAndBands,
  21787. options = this.options,
  21788. userOptions = this.userOptions,
  21789. i = plotLinesAndBands.length;
  21790. while (i--) {
  21791. if (plotLinesAndBands[i].id === id) {
  21792. plotLinesAndBands[i].destroy();
  21793. }
  21794. }
  21795. ([
  21796. options.plotLines || [],
  21797. userOptions.plotLines || [],
  21798. options.plotBands || [],
  21799. userOptions.plotBands || []
  21800. ]).forEach(function (arr) {
  21801. i = arr.length;
  21802. while (i--) {
  21803. if ((arr[i] || {}).id === id) {
  21804. erase(arr, arr[i]);
  21805. }
  21806. }
  21807. });
  21808. },
  21809. /**
  21810. * Remove a plot band by its id.
  21811. *
  21812. * @sample highcharts/members/axis-removeplotband/
  21813. * Remove plot band by id
  21814. * @sample highcharts/members/axis-addplotband/
  21815. * Toggle the plot band from a button
  21816. *
  21817. * @function Highcharts.Axis#removePlotBand
  21818. *
  21819. * @param {string} id
  21820. * The plot band's `id` as given in the original configuration
  21821. * object or in the `addPlotBand` option.
  21822. *
  21823. * @return {void}
  21824. */
  21825. removePlotBand: function (id) {
  21826. this.removePlotBandOrLine(id);
  21827. },
  21828. /**
  21829. * Remove a plot line by its id.
  21830. *
  21831. * @sample highcharts/xaxis/plotlines-id/
  21832. * Remove plot line by id
  21833. * @sample highcharts/members/axis-addplotline/
  21834. * Toggle the plot line from a button
  21835. *
  21836. * @function Highcharts.Axis#removePlotLine
  21837. *
  21838. * @param {string} id
  21839. * The plot line's `id` as given in the original configuration
  21840. * object or in the `addPlotLine` option.
  21841. */
  21842. removePlotLine: function (id) {
  21843. this.removePlotBandOrLine(id);
  21844. }
  21845. });
  21846. H.PlotLineOrBand = PlotLineOrBand;
  21847. return H.PlotLineOrBand;
  21848. });
  21849. _registerModule(_modules, 'Core/Tooltip.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  21850. /* *
  21851. *
  21852. * (c) 2010-2020 Torstein Honsi
  21853. *
  21854. * License: www.highcharts.com/license
  21855. *
  21856. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21857. *
  21858. * */
  21859. var doc = H.doc;
  21860. var clamp = U.clamp,
  21861. css = U.css,
  21862. defined = U.defined,
  21863. discardElement = U.discardElement,
  21864. extend = U.extend,
  21865. fireEvent = U.fireEvent,
  21866. format = U.format,
  21867. isNumber = U.isNumber,
  21868. isString = U.isString,
  21869. merge = U.merge,
  21870. pick = U.pick,
  21871. splat = U.splat,
  21872. syncTimeout = U.syncTimeout,
  21873. timeUnits = U.timeUnits;
  21874. /**
  21875. * Callback function to format the text of the tooltip from scratch.
  21876. *
  21877. * In case of single or shared tooltips, a string should be be returned. In case
  21878. * of splitted tooltips, it should return an array where the first item is the
  21879. * header, and subsequent items are mapped to the points. Return `false` to
  21880. * disable tooltip for a specific point on series.
  21881. *
  21882. * @callback Highcharts.TooltipFormatterCallbackFunction
  21883. *
  21884. * @param {Highcharts.TooltipFormatterContextObject} this
  21885. * Context to format
  21886. *
  21887. * @param {Highcharts.Tooltip} tooltip
  21888. * The tooltip instance
  21889. *
  21890. * @return {false|string|Array<(string|null|undefined)>|null|undefined}
  21891. * Formatted text or false
  21892. */
  21893. /**
  21894. * @interface Highcharts.TooltipFormatterContextObject
  21895. */ /**
  21896. * @name Highcharts.TooltipFormatterContextObject#color
  21897. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  21898. */ /**
  21899. * @name Highcharts.TooltipFormatterContextObject#colorIndex
  21900. * @type {number|undefined}
  21901. */ /**
  21902. * @name Highcharts.TooltipFormatterContextObject#key
  21903. * @type {number}
  21904. */ /**
  21905. * @name Highcharts.TooltipFormatterContextObject#percentage
  21906. * @type {number|undefined}
  21907. */ /**
  21908. * @name Highcharts.TooltipFormatterContextObject#point
  21909. * @type {Highcharts.Point}
  21910. */ /**
  21911. * @name Highcharts.TooltipFormatterContextObject#points
  21912. * @type {Array<Highcharts.TooltipFormatterContextObject>|undefined}
  21913. */ /**
  21914. * @name Highcharts.TooltipFormatterContextObject#series
  21915. * @type {Highcharts.Series}
  21916. */ /**
  21917. * @name Highcharts.TooltipFormatterContextObject#total
  21918. * @type {number|undefined}
  21919. */ /**
  21920. * @name Highcharts.TooltipFormatterContextObject#x
  21921. * @type {number}
  21922. */ /**
  21923. * @name Highcharts.TooltipFormatterContextObject#y
  21924. * @type {number}
  21925. */
  21926. /**
  21927. * A callback function to place the tooltip in a specific position.
  21928. *
  21929. * @callback Highcharts.TooltipPositionerCallbackFunction
  21930. *
  21931. * @param {Highcharts.Tooltip} this
  21932. * Tooltip context of the callback.
  21933. *
  21934. * @param {number} labelWidth
  21935. * Width of the tooltip.
  21936. *
  21937. * @param {number} labelHeight
  21938. * Height of the tooltip.
  21939. *
  21940. * @param {Highcharts.Point|Highcharts.TooltipPositionerPointObject} point
  21941. * Point information for positioning a tooltip.
  21942. *
  21943. * @return {Highcharts.PositionObject}
  21944. * New position for the tooltip.
  21945. */
  21946. /**
  21947. * Point information for positioning a tooltip.
  21948. *
  21949. * @interface Highcharts.TooltipPositionerPointObject
  21950. */ /**
  21951. * If `tooltip.split` option is enabled and positioner is called for each of the
  21952. * boxes separately, this property indicates the call on the xAxis header, which
  21953. * is not a point itself.
  21954. * @name Highcharts.TooltipPositionerPointObject#isHeader
  21955. * @type {boolean}
  21956. */ /**
  21957. * The reference point relative to the plot area. Add chart.plotLeft to get the
  21958. * full coordinates.
  21959. * @name Highcharts.TooltipPositionerPointObject#plotX
  21960. * @type {number}
  21961. */ /**
  21962. * The reference point relative to the plot area. Add chart.plotTop to get the
  21963. * full coordinates.
  21964. * @name Highcharts.TooltipPositionerPointObject#plotY
  21965. * @type {number}
  21966. */
  21967. /**
  21968. * @typedef {"callout"|"circle"|"square"} Highcharts.TooltipShapeValue
  21969. */
  21970. ''; // separates doclets above from variables below
  21971. /* eslint-disable no-invalid-this, valid-jsdoc */
  21972. /**
  21973. * Tooltip of a chart.
  21974. *
  21975. * @class
  21976. * @name Highcharts.Tooltip
  21977. *
  21978. * @param {Highcharts.Chart} chart
  21979. * The chart instance.
  21980. *
  21981. * @param {Highcharts.TooltipOptions} options
  21982. * Tooltip options.
  21983. */
  21984. var Tooltip = /** @class */ (function () {
  21985. /* *
  21986. *
  21987. * Constructors
  21988. *
  21989. * */
  21990. function Tooltip(chart, options) {
  21991. this.container = void 0;
  21992. this.crosshairs = [];
  21993. this.distance = 0;
  21994. this.isHidden = true;
  21995. this.isSticky = false;
  21996. this.now = {};
  21997. this.options = {};
  21998. this.outside = false;
  21999. this.chart = chart;
  22000. this.init(chart, options);
  22001. }
  22002. /* *
  22003. *
  22004. * Functions
  22005. *
  22006. * */
  22007. /**
  22008. * In styled mode, apply the default filter for the tooltip drop-shadow. It
  22009. * needs to have an id specific to the chart, otherwise there will be issues
  22010. * when one tooltip adopts the filter of a different chart, specifically one
  22011. * where the container is hidden.
  22012. *
  22013. * @private
  22014. * @function Highcharts.Tooltip#applyFilter
  22015. */
  22016. Tooltip.prototype.applyFilter = function () {
  22017. var chart = this.chart;
  22018. chart.renderer.definition({
  22019. tagName: 'filter',
  22020. id: 'drop-shadow-' + chart.index,
  22021. opacity: 0.5,
  22022. children: [{
  22023. tagName: 'feGaussianBlur',
  22024. 'in': 'SourceAlpha',
  22025. stdDeviation: 1
  22026. }, {
  22027. tagName: 'feOffset',
  22028. dx: 1,
  22029. dy: 1
  22030. }, {
  22031. tagName: 'feComponentTransfer',
  22032. children: [{
  22033. tagName: 'feFuncA',
  22034. type: 'linear',
  22035. slope: 0.3
  22036. }]
  22037. }, {
  22038. tagName: 'feMerge',
  22039. children: [{
  22040. tagName: 'feMergeNode'
  22041. }, {
  22042. tagName: 'feMergeNode',
  22043. 'in': 'SourceGraphic'
  22044. }]
  22045. }]
  22046. });
  22047. chart.renderer.definition({
  22048. tagName: 'style',
  22049. textContent: '.highcharts-tooltip-' + chart.index + '{' +
  22050. 'filter:url(#drop-shadow-' + chart.index + ')' +
  22051. '}'
  22052. });
  22053. };
  22054. /**
  22055. * Build the body (lines) of the tooltip by iterating over the items and
  22056. * returning one entry for each item, abstracting this functionality allows
  22057. * to easily overwrite and extend it.
  22058. *
  22059. * @private
  22060. * @function Highcharts.Tooltip#bodyFormatter
  22061. * @param {Array<(Highcharts.Point|Highcharts.Series)>} items
  22062. * @return {Array<string>}
  22063. */
  22064. Tooltip.prototype.bodyFormatter = function (items) {
  22065. return items.map(function (item) {
  22066. var tooltipOptions = item.series.tooltipOptions;
  22067. return (tooltipOptions[(item.point.formatPrefix || 'point') + 'Formatter'] ||
  22068. item.point.tooltipFormatter).call(item.point, tooltipOptions[(item.point.formatPrefix || 'point') + 'Format'] || '');
  22069. });
  22070. };
  22071. /**
  22072. * Destroy the single tooltips in a split tooltip.
  22073. * If the tooltip is active then it is not destroyed, unless forced to.
  22074. *
  22075. * @private
  22076. * @function Highcharts.Tooltip#cleanSplit
  22077. *
  22078. * @param {boolean} [force]
  22079. * Force destroy all tooltips.
  22080. */
  22081. Tooltip.prototype.cleanSplit = function (force) {
  22082. this.chart.series.forEach(function (series) {
  22083. var tt = series && series.tt;
  22084. if (tt) {
  22085. if (!tt.isActive || force) {
  22086. series.tt = tt.destroy();
  22087. }
  22088. else {
  22089. tt.isActive = false;
  22090. }
  22091. }
  22092. });
  22093. };
  22094. /**
  22095. * In case no user defined formatter is given, this will be used. Note that
  22096. * the context here is an object holding point, series, x, y etc.
  22097. *
  22098. * @function Highcharts.Tooltip#defaultFormatter
  22099. *
  22100. * @param {Highcharts.Tooltip} tooltip
  22101. *
  22102. * @return {Array<string>}
  22103. */
  22104. Tooltip.prototype.defaultFormatter = function (tooltip) {
  22105. var items = this.points || splat(this),
  22106. s;
  22107. // Build the header
  22108. s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
  22109. // build the values
  22110. s = s.concat(tooltip.bodyFormatter(items));
  22111. // footer
  22112. s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
  22113. return s;
  22114. };
  22115. /**
  22116. * Removes and destroys the tooltip and its elements.
  22117. *
  22118. * @function Highcharts.Tooltip#destroy
  22119. */
  22120. Tooltip.prototype.destroy = function () {
  22121. // Destroy and clear local variables
  22122. if (this.label) {
  22123. this.label = this.label.destroy();
  22124. }
  22125. if (this.split && this.tt) {
  22126. this.cleanSplit(this.chart, true);
  22127. this.tt = this.tt.destroy();
  22128. }
  22129. if (this.renderer) {
  22130. this.renderer = this.renderer.destroy();
  22131. discardElement(this.container);
  22132. }
  22133. U.clearTimeout(this.hideTimer);
  22134. U.clearTimeout(this.tooltipTimeout);
  22135. };
  22136. /**
  22137. * Extendable method to get the anchor position of the tooltip
  22138. * from a point or set of points
  22139. *
  22140. * @private
  22141. * @function Highcharts.Tooltip#getAnchor
  22142. *
  22143. * @param {Highcharts.Point|Array<Highcharts.Point>} points
  22144. *
  22145. * @param {Highcharts.PointerEventObject} [mouseEvent]
  22146. *
  22147. * @return {Array<number>}
  22148. */
  22149. Tooltip.prototype.getAnchor = function (points, mouseEvent) {
  22150. var ret,
  22151. chart = this.chart,
  22152. pointer = chart.pointer,
  22153. inverted = chart.inverted,
  22154. plotTop = chart.plotTop,
  22155. plotLeft = chart.plotLeft,
  22156. plotX = 0,
  22157. plotY = 0,
  22158. yAxis,
  22159. xAxis;
  22160. points = splat(points);
  22161. // When tooltip follows mouse, relate the position to the mouse
  22162. if (this.followPointer && mouseEvent) {
  22163. if (typeof mouseEvent.chartX === 'undefined') {
  22164. mouseEvent = pointer.normalize(mouseEvent);
  22165. }
  22166. ret = [
  22167. mouseEvent.chartX - plotLeft,
  22168. mouseEvent.chartY - plotTop
  22169. ];
  22170. // Some series types use a specificly calculated tooltip position for
  22171. // each point
  22172. }
  22173. else if (points[0].tooltipPos) {
  22174. ret = points[0].tooltipPos;
  22175. // When shared, use the average position
  22176. }
  22177. else {
  22178. points.forEach(function (point) {
  22179. yAxis = point.series.yAxis;
  22180. xAxis = point.series.xAxis;
  22181. plotX += point.plotX +
  22182. (!inverted && xAxis ? xAxis.left - plotLeft : 0);
  22183. plotY += (point.plotLow ?
  22184. (point.plotLow + point.plotHigh) / 2 :
  22185. point.plotY) + (!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
  22186. });
  22187. plotX /= points.length;
  22188. plotY /= points.length;
  22189. ret = [
  22190. inverted ? chart.plotWidth - plotY : plotX,
  22191. this.shared && !inverted && points.length > 1 && mouseEvent ?
  22192. // place shared tooltip next to the mouse (#424)
  22193. mouseEvent.chartY - plotTop :
  22194. inverted ? chart.plotHeight - plotX : plotY
  22195. ];
  22196. }
  22197. return ret.map(Math.round);
  22198. };
  22199. /**
  22200. * Get the optimal date format for a point, based on a range.
  22201. *
  22202. * @private
  22203. * @function Highcharts.Tooltip#getDateFormat
  22204. *
  22205. * @param {number} range
  22206. * The time range
  22207. *
  22208. * @param {number} date
  22209. * The date of the point in question
  22210. *
  22211. * @param {number} startOfWeek
  22212. * An integer representing the first day of the week, where 0 is
  22213. * Sunday.
  22214. *
  22215. * @param {Highcharts.Dictionary<string>} dateTimeLabelFormats
  22216. * A map of time units to formats.
  22217. *
  22218. * @return {string}
  22219. * The optimal date format for a point.
  22220. */
  22221. Tooltip.prototype.getDateFormat = function (range, date, startOfWeek, dateTimeLabelFormats) {
  22222. 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 = {
  22223. millisecond: 15,
  22224. second: 12,
  22225. minute: 9,
  22226. hour: 6,
  22227. day: 3
  22228. }, lastN = 'millisecond'; // for sub-millisecond data, #4223
  22229. for (n in timeUnits) { // eslint-disable-line guard-for-in
  22230. // If the range is exactly one week and we're looking at a
  22231. // Sunday/Monday, go for the week format
  22232. if (range === timeUnits.week &&
  22233. +time.dateFormat('%w', date) === startOfWeek &&
  22234. dateStr.substr(6) === blank.substr(6)) {
  22235. n = 'week';
  22236. break;
  22237. }
  22238. // The first format that is too great for the range
  22239. if (timeUnits[n] > range) {
  22240. n = lastN;
  22241. break;
  22242. }
  22243. // If the point is placed every day at 23:59, we need to show
  22244. // the minutes as well. #2637.
  22245. if (strpos[n] &&
  22246. dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
  22247. break;
  22248. }
  22249. // Weeks are outside the hierarchy, only apply them on
  22250. // Mondays/Sundays like in the first condition
  22251. if (n !== 'week') {
  22252. lastN = n;
  22253. }
  22254. }
  22255. if (n) {
  22256. format = time.resolveDTLFormat(dateTimeLabelFormats[n]).main;
  22257. }
  22258. return format;
  22259. };
  22260. /**
  22261. * Creates the Tooltip label element if it does not exist, then returns it.
  22262. *
  22263. * @function Highcharts.Tooltip#getLabel
  22264. * @return {Highcharts.SVGElement}
  22265. */
  22266. Tooltip.prototype.getLabel = function () {
  22267. var _a,
  22268. _b;
  22269. var tooltip = this,
  22270. renderer = this.chart.renderer,
  22271. styledMode = this.chart.styledMode,
  22272. options = this.options,
  22273. className = ('tooltip' + (defined(options.className) ?
  22274. ' ' + options.className :
  22275. '')),
  22276. pointerEvents = (((_a = options.style) === null || _a === void 0 ? void 0 : _a.pointerEvents) ||
  22277. (!this.followPointer && options.stickOnContact ? 'auto' : 'none')),
  22278. container,
  22279. set,
  22280. onMouseEnter = function () {
  22281. tooltip.inContact = true;
  22282. }, onMouseLeave = function () {
  22283. var series = tooltip.chart.hoverSeries;
  22284. tooltip.inContact = false;
  22285. if (series &&
  22286. series.onMouseOut) {
  22287. series.onMouseOut();
  22288. }
  22289. };
  22290. if (!this.label) {
  22291. if (this.outside) {
  22292. /**
  22293. * Reference to the tooltip's container, when
  22294. * [Highcharts.Tooltip#outside] is set to true, otherwise
  22295. * it's undefined.
  22296. *
  22297. * @name Highcharts.Tooltip#container
  22298. * @type {Highcharts.HTMLDOMElement|undefined}
  22299. */
  22300. this.container = container = H.doc.createElement('div');
  22301. container.className = 'highcharts-tooltip-container';
  22302. css(container, {
  22303. position: 'absolute',
  22304. top: '1px',
  22305. pointerEvents: pointerEvents,
  22306. zIndex: 3
  22307. });
  22308. H.doc.body.appendChild(container);
  22309. /**
  22310. * Reference to the tooltip's renderer, when
  22311. * [Highcharts.Tooltip#outside] is set to true, otherwise
  22312. * it's undefined.
  22313. *
  22314. * @name Highcharts.Tooltip#renderer
  22315. * @type {Highcharts.SVGRenderer|undefined}
  22316. */
  22317. this.renderer = renderer = new H.Renderer(container, 0, 0, (_b = this.chart.options.chart) === null || _b === void 0 ? void 0 : _b.style, void 0, void 0, renderer.styledMode);
  22318. }
  22319. // Create the label
  22320. if (this.split) {
  22321. this.label = renderer.g(className);
  22322. }
  22323. else {
  22324. this.label = renderer
  22325. .label('', 0, 0, options.shape || 'callout', null, null, options.useHTML, null, className)
  22326. .attr({
  22327. padding: options.padding,
  22328. r: options.borderRadius
  22329. });
  22330. if (!styledMode) {
  22331. this.label
  22332. .attr({
  22333. fill: options.backgroundColor,
  22334. 'stroke-width': options.borderWidth
  22335. })
  22336. // #2301, #2657
  22337. .css(options.style)
  22338. .css({ pointerEvents: pointerEvents })
  22339. .shadow(options.shadow);
  22340. }
  22341. }
  22342. if (styledMode) {
  22343. // Apply the drop-shadow filter
  22344. this.applyFilter();
  22345. this.label.addClass('highcharts-tooltip-' + this.chart.index);
  22346. }
  22347. // Split tooltip use updateTooltipContainer to position the tooltip
  22348. // container.
  22349. if (tooltip.outside && !tooltip.split) {
  22350. var label_1 = this.label;
  22351. var xSetter_1 = label_1.xSetter,
  22352. ySetter_1 = label_1.ySetter;
  22353. label_1.xSetter = function (value) {
  22354. xSetter_1.call(label_1, tooltip.distance);
  22355. container.style.left = value + 'px';
  22356. };
  22357. label_1.ySetter = function (value) {
  22358. ySetter_1.call(label_1, tooltip.distance);
  22359. container.style.top = value + 'px';
  22360. };
  22361. }
  22362. this.label
  22363. .on('mouseenter', onMouseEnter)
  22364. .on('mouseleave', onMouseLeave)
  22365. .attr({ zIndex: 8 })
  22366. .add();
  22367. }
  22368. return this.label;
  22369. };
  22370. /**
  22371. * Place the tooltip in a chart without spilling over
  22372. * and not covering the point it self.
  22373. *
  22374. * @private
  22375. * @function Highcharts.Tooltip#getPosition
  22376. *
  22377. * @param {number} boxWidth
  22378. *
  22379. * @param {number} boxHeight
  22380. *
  22381. * @param {Highcharts.Point} point
  22382. *
  22383. * @return {Highcharts.PositionObject}
  22384. */
  22385. Tooltip.prototype.getPosition = function (boxWidth, boxHeight, point) {
  22386. var chart = this.chart,
  22387. distance = this.distance,
  22388. ret = {},
  22389. // Don't use h if chart isn't inverted (#7242) ???
  22390. h = (chart.inverted && point.h) || 0, // #4117 ???
  22391. swapped,
  22392. outside = this.outside,
  22393. outerWidth = outside ?
  22394. // substract distance to prevent scrollbars
  22395. doc.documentElement.clientWidth - 2 * distance :
  22396. chart.chartWidth,
  22397. outerHeight = outside ?
  22398. Math.max(doc.body.scrollHeight,
  22399. doc.documentElement.scrollHeight,
  22400. doc.body.offsetHeight,
  22401. doc.documentElement.offsetHeight,
  22402. doc.documentElement.clientHeight) :
  22403. chart.chartHeight,
  22404. chartPosition = chart.pointer.getChartPosition(),
  22405. containerScaling = chart.containerScaling,
  22406. scaleX = function (val) { return ( // eslint-disable-line no-confusing-arrow
  22407. containerScaling ? val * containerScaling.scaleX : val); },
  22408. scaleY = function (val) { return ( // eslint-disable-line no-confusing-arrow
  22409. containerScaling ? val * containerScaling.scaleY : val); },
  22410. // Build parameter arrays for firstDimension()/secondDimension()
  22411. buildDimensionArray = function (dim) {
  22412. var isX = dim === 'x';
  22413. return [
  22414. dim,
  22415. isX ? outerWidth : outerHeight,
  22416. isX ? boxWidth : boxHeight
  22417. ].concat(outside ? [
  22418. // If we are using tooltip.outside, we need to scale the
  22419. // position to match scaling of the container in case there
  22420. // is a transform/zoom on the container. #11329
  22421. isX ? scaleX(boxWidth) : scaleY(boxHeight),
  22422. isX ? chartPosition.left - distance +
  22423. scaleX(point.plotX + chart.plotLeft) :
  22424. chartPosition.top - distance +
  22425. scaleY(point.plotY + chart.plotTop),
  22426. 0,
  22427. isX ? outerWidth : outerHeight
  22428. ] : [
  22429. // Not outside, no scaling is needed
  22430. isX ? boxWidth : boxHeight,
  22431. isX ? point.plotX + chart.plotLeft :
  22432. point.plotY + chart.plotTop,
  22433. isX ? chart.plotLeft : chart.plotTop,
  22434. isX ? chart.plotLeft + chart.plotWidth :
  22435. chart.plotTop + chart.plotHeight
  22436. ]);
  22437. }, first = buildDimensionArray('y'), second = buildDimensionArray('x'),
  22438. // The far side is right or bottom
  22439. preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
  22440. /*
  22441. * Handle the preferred dimension. When the preferred dimension is
  22442. * tooltip on top or bottom of the point, it will look for space
  22443. * there.
  22444. *
  22445. * @private
  22446. */
  22447. firstDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  22448. point, min, max) {
  22449. var scaledDist = dim === 'y' ?
  22450. scaleY(distance) : scaleX(distance),
  22451. scaleDiff = (innerSize - scaledInnerSize) / 2,
  22452. roomLeft = scaledInnerSize < point - distance,
  22453. roomRight = point + distance + scaledInnerSize < outerSize,
  22454. alignedLeft = point - scaledDist - innerSize + scaleDiff,
  22455. alignedRight = point + scaledDist - scaleDiff;
  22456. if (preferFarSide && roomRight) {
  22457. ret[dim] = alignedRight;
  22458. }
  22459. else if (!preferFarSide && roomLeft) {
  22460. ret[dim] = alignedLeft;
  22461. }
  22462. else if (roomLeft) {
  22463. ret[dim] = Math.min(max - scaledInnerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
  22464. }
  22465. else if (roomRight) {
  22466. ret[dim] = Math.max(min, alignedRight + h + innerSize > outerSize ?
  22467. alignedRight :
  22468. alignedRight + h);
  22469. }
  22470. else {
  22471. return false;
  22472. }
  22473. },
  22474. /*
  22475. * Handle the secondary dimension. If the preferred dimension is
  22476. * tooltip on top or bottom of the point, the second dimension is to
  22477. * align the tooltip above the point, trying to align center but
  22478. * allowing left or right align within the chart box.
  22479. *
  22480. * @private
  22481. */
  22482. secondDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  22483. point) {
  22484. var retVal;
  22485. // Too close to the edge, return false and swap dimensions
  22486. if (point < distance || point > outerSize - distance) {
  22487. retVal = false;
  22488. // Align left/top
  22489. }
  22490. else if (point < innerSize / 2) {
  22491. ret[dim] = 1;
  22492. // Align right/bottom
  22493. }
  22494. else if (point > outerSize - scaledInnerSize / 2) {
  22495. ret[dim] = outerSize - scaledInnerSize - 2;
  22496. // Align center
  22497. }
  22498. else {
  22499. ret[dim] = point - innerSize / 2;
  22500. }
  22501. return retVal;
  22502. },
  22503. /*
  22504. * Swap the dimensions
  22505. */
  22506. swap = function (count) {
  22507. var temp = first;
  22508. first = second;
  22509. second = temp;
  22510. swapped = count;
  22511. }, run = function () {
  22512. if (firstDimension.apply(0, first) !== false) {
  22513. if (secondDimension.apply(0, second) === false &&
  22514. !swapped) {
  22515. swap(true);
  22516. run();
  22517. }
  22518. }
  22519. else if (!swapped) {
  22520. swap(true);
  22521. run();
  22522. }
  22523. else {
  22524. ret.x = ret.y = 0;
  22525. }
  22526. };
  22527. // Under these conditions, prefer the tooltip on the side of the point
  22528. if (chart.inverted || this.len > 1) {
  22529. swap();
  22530. }
  22531. run();
  22532. return ret;
  22533. };
  22534. /**
  22535. * Get the best X date format based on the closest point range on the axis.
  22536. *
  22537. * @private
  22538. * @function Highcharts.Tooltip#getXDateFormat
  22539. *
  22540. * @param {Highcharts.Point} point
  22541. *
  22542. * @param {Highcharts.TooltipOptions} options
  22543. *
  22544. * @param {Highcharts.Axis} xAxis
  22545. *
  22546. * @return {string}
  22547. */
  22548. Tooltip.prototype.getXDateFormat = function (point, options, xAxis) {
  22549. var xDateFormat,
  22550. dateTimeLabelFormats = options.dateTimeLabelFormats,
  22551. closestPointRange = xAxis && xAxis.closestPointRange;
  22552. if (closestPointRange) {
  22553. xDateFormat = this.getDateFormat(closestPointRange, point.x, xAxis.options.startOfWeek, dateTimeLabelFormats);
  22554. }
  22555. else {
  22556. xDateFormat = dateTimeLabelFormats.day;
  22557. }
  22558. return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
  22559. };
  22560. /**
  22561. * Hides the tooltip with a fade out animation.
  22562. *
  22563. * @function Highcharts.Tooltip#hide
  22564. *
  22565. * @param {number} [delay]
  22566. * The fade out in milliseconds. If no value is provided the value
  22567. * of the tooltip.hideDelay option is used. A value of 0 disables
  22568. * the fade out animation.
  22569. */
  22570. Tooltip.prototype.hide = function (delay) {
  22571. var tooltip = this;
  22572. // disallow duplicate timers (#1728, #1766)
  22573. U.clearTimeout(this.hideTimer);
  22574. delay = pick(delay, this.options.hideDelay, 500);
  22575. if (!this.isHidden) {
  22576. this.hideTimer = syncTimeout(function () {
  22577. // If there is a delay, do fadeOut with the default duration. If
  22578. // the hideDelay is 0, we assume no animation is wanted, so we
  22579. // pass 0 duration. #12994.
  22580. tooltip.getLabel().fadeOut(delay ? void 0 : delay);
  22581. tooltip.isHidden = true;
  22582. }, delay);
  22583. }
  22584. };
  22585. /**
  22586. * @private
  22587. * @function Highcharts.Tooltip#init
  22588. *
  22589. * @param {Highcharts.Chart} chart
  22590. * The chart instance.
  22591. *
  22592. * @param {Highcharts.TooltipOptions} options
  22593. * Tooltip options.
  22594. */
  22595. Tooltip.prototype.init = function (chart, options) {
  22596. /**
  22597. * Chart of the tooltip.
  22598. *
  22599. * @readonly
  22600. * @name Highcharts.Tooltip#chart
  22601. * @type {Highcharts.Chart}
  22602. */
  22603. this.chart = chart;
  22604. /**
  22605. * Used tooltip options.
  22606. *
  22607. * @readonly
  22608. * @name Highcharts.Tooltip#options
  22609. * @type {Highcharts.TooltipOptions}
  22610. */
  22611. this.options = options;
  22612. /**
  22613. * List of crosshairs.
  22614. *
  22615. * @private
  22616. * @readonly
  22617. * @name Highcharts.Tooltip#crosshairs
  22618. * @type {Array<null>}
  22619. */
  22620. this.crosshairs = [];
  22621. /**
  22622. * Current values of x and y when animating.
  22623. *
  22624. * @private
  22625. * @readonly
  22626. * @name Highcharts.Tooltip#now
  22627. * @type {Highcharts.PositionObject}
  22628. */
  22629. this.now = { x: 0, y: 0 };
  22630. /**
  22631. * Tooltips are initially hidden.
  22632. *
  22633. * @private
  22634. * @readonly
  22635. * @name Highcharts.Tooltip#isHidden
  22636. * @type {boolean}
  22637. */
  22638. this.isHidden = true;
  22639. /**
  22640. * True, if the tooltip is split into one label per series, with the
  22641. * header close to the axis.
  22642. *
  22643. * @readonly
  22644. * @name Highcharts.Tooltip#split
  22645. * @type {boolean|undefined}
  22646. */
  22647. this.split = options.split && !chart.inverted && !chart.polar;
  22648. /**
  22649. * When the tooltip is shared, the entire plot area will capture mouse
  22650. * movement or touch events.
  22651. *
  22652. * @readonly
  22653. * @name Highcharts.Tooltip#shared
  22654. * @type {boolean|undefined}
  22655. */
  22656. this.shared = options.shared || this.split;
  22657. /**
  22658. * Whether to allow the tooltip to render outside the chart's SVG
  22659. * element box. By default (false), the tooltip is rendered within the
  22660. * chart's SVG element, which results in the tooltip being aligned
  22661. * inside the chart area.
  22662. *
  22663. * @readonly
  22664. * @name Highcharts.Tooltip#outside
  22665. * @type {boolean}
  22666. *
  22667. * @todo
  22668. * Split tooltip does not support outside in the first iteration. Should
  22669. * not be too complicated to implement.
  22670. */
  22671. this.outside = pick(options.outside, Boolean(chart.scrollablePixelsX || chart.scrollablePixelsY));
  22672. };
  22673. /**
  22674. * Returns true, if the pointer is in contact with the tooltip tracker.
  22675. */
  22676. Tooltip.prototype.isStickyOnContact = function () {
  22677. return !!(!this.followPointer &&
  22678. this.options.stickOnContact &&
  22679. this.inContact);
  22680. };
  22681. /**
  22682. * Moves the tooltip with a soft animation to a new position.
  22683. *
  22684. * @private
  22685. * @function Highcharts.Tooltip#move
  22686. *
  22687. * @param {number} x
  22688. *
  22689. * @param {number} y
  22690. *
  22691. * @param {number} anchorX
  22692. *
  22693. * @param {number} anchorY
  22694. */
  22695. Tooltip.prototype.move = function (x, y, anchorX, anchorY) {
  22696. var tooltip = this,
  22697. now = tooltip.now,
  22698. animate = tooltip.options.animation !== false &&
  22699. !tooltip.isHidden &&
  22700. // When we get close to the target position, abort animation and
  22701. // land on the right place (#3056)
  22702. (Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
  22703. skipAnchor = tooltip.followPointer || tooltip.len > 1;
  22704. // Get intermediate values for animation
  22705. extend(now, {
  22706. x: animate ? (2 * now.x + x) / 3 : x,
  22707. y: animate ? (now.y + y) / 2 : y,
  22708. anchorX: skipAnchor ?
  22709. void 0 :
  22710. animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
  22711. anchorY: skipAnchor ?
  22712. void 0 :
  22713. animate ? (now.anchorY + anchorY) / 2 : anchorY
  22714. });
  22715. // Move to the intermediate value
  22716. tooltip.getLabel().attr(now);
  22717. tooltip.drawTracker();
  22718. // Run on next tick of the mouse tracker
  22719. if (animate) {
  22720. // Never allow two timeouts
  22721. U.clearTimeout(this.tooltipTimeout);
  22722. // Set the fixed interval ticking for the smooth tooltip
  22723. this.tooltipTimeout = setTimeout(function () {
  22724. // The interval function may still be running during destroy,
  22725. // so check that the chart is really there before calling.
  22726. if (tooltip) {
  22727. tooltip.move(x, y, anchorX, anchorY);
  22728. }
  22729. }, 32);
  22730. }
  22731. };
  22732. /**
  22733. * Refresh the tooltip's text and position.
  22734. *
  22735. * @function Highcharts.Tooltip#refresh
  22736. *
  22737. * @param {Highcharts.Point|Array<Highcharts.Point>} pointOrPoints
  22738. * Either a point or an array of points.
  22739. *
  22740. * @param {Highcharts.PointerEventObject} [mouseEvent]
  22741. * Mouse event, that is responsible for the refresh and should be
  22742. * used for the tooltip update.
  22743. */
  22744. Tooltip.prototype.refresh = function (pointOrPoints, mouseEvent) {
  22745. var tooltip = this,
  22746. chart = this.chart,
  22747. options = tooltip.options,
  22748. x,
  22749. y,
  22750. point = pointOrPoints,
  22751. anchor,
  22752. textConfig = {},
  22753. text,
  22754. pointConfig = [],
  22755. formatter = options.formatter || tooltip.defaultFormatter,
  22756. shared = tooltip.shared,
  22757. currentSeries,
  22758. styledMode = chart.styledMode;
  22759. if (!options.enabled) {
  22760. return;
  22761. }
  22762. U.clearTimeout(this.hideTimer);
  22763. // get the reference point coordinates (pie charts use tooltipPos)
  22764. tooltip.followPointer = splat(point)[0].series.tooltipOptions
  22765. .followPointer;
  22766. anchor = tooltip.getAnchor(point, mouseEvent);
  22767. x = anchor[0];
  22768. y = anchor[1];
  22769. // shared tooltip, array is sent over
  22770. if (shared &&
  22771. !(point.series &&
  22772. point.series.noSharedTooltip)) {
  22773. chart.pointer.applyInactiveState(point);
  22774. // Now set hover state for the choosen ones:
  22775. point.forEach(function (item) {
  22776. item.setState('hover');
  22777. pointConfig.push(item.getLabelConfig());
  22778. });
  22779. textConfig = {
  22780. x: point[0].category,
  22781. y: point[0].y
  22782. };
  22783. textConfig.points = pointConfig;
  22784. point = point[0];
  22785. // single point tooltip
  22786. }
  22787. else {
  22788. textConfig = point.getLabelConfig();
  22789. }
  22790. this.len = pointConfig.length; // #6128
  22791. text = formatter.call(textConfig, tooltip);
  22792. // register the current series
  22793. currentSeries = point.series;
  22794. this.distance = pick(currentSeries.tooltipOptions.distance, 16);
  22795. // update the inner HTML
  22796. if (text === false) {
  22797. this.hide();
  22798. }
  22799. else {
  22800. // update text
  22801. if (tooltip.split) {
  22802. this.renderSplit(text, splat(pointOrPoints));
  22803. }
  22804. else {
  22805. var label = tooltip.getLabel();
  22806. // Prevent the tooltip from flowing over the chart box (#6659)
  22807. if (!options.style.width || styledMode) {
  22808. label.css({
  22809. width: this.chart.spacingBox.width + 'px'
  22810. });
  22811. }
  22812. label.attr({
  22813. text: text && text.join ?
  22814. text.join('') :
  22815. text
  22816. });
  22817. // Set the stroke color of the box to reflect the point
  22818. label.removeClass(/highcharts-color-[\d]+/g)
  22819. .addClass('highcharts-color-' +
  22820. pick(point.colorIndex, currentSeries.colorIndex));
  22821. if (!styledMode) {
  22822. label.attr({
  22823. stroke: (options.borderColor ||
  22824. point.color ||
  22825. currentSeries.color ||
  22826. '#666666')
  22827. });
  22828. }
  22829. tooltip.updatePosition({
  22830. plotX: x,
  22831. plotY: y,
  22832. negative: point.negative,
  22833. ttBelow: point.ttBelow,
  22834. h: anchor[2] || 0
  22835. });
  22836. }
  22837. // show it
  22838. if (tooltip.isHidden && tooltip.label) {
  22839. tooltip.label.attr({
  22840. opacity: 1
  22841. }).show();
  22842. }
  22843. tooltip.isHidden = false;
  22844. }
  22845. fireEvent(this, 'refresh');
  22846. };
  22847. /**
  22848. * Render the split tooltip. Loops over each point's text and adds
  22849. * a label next to the point, then uses the distribute function to
  22850. * find best non-overlapping positions.
  22851. *
  22852. * @private
  22853. * @function Highcharts.Tooltip#renderSplit
  22854. *
  22855. * @param {string|Array<(boolean|string)>} labels
  22856. *
  22857. * @param {Array<Highcharts.Point>} points
  22858. */
  22859. Tooltip.prototype.renderSplit = function (labels, points) {
  22860. var tooltip = this;
  22861. var chart = tooltip.chart,
  22862. _a = tooltip.chart,
  22863. chartWidth = _a.chartWidth,
  22864. chartHeight = _a.chartHeight,
  22865. plotHeight = _a.plotHeight,
  22866. plotLeft = _a.plotLeft,
  22867. plotTop = _a.plotTop,
  22868. pointer = _a.pointer,
  22869. ren = _a.renderer,
  22870. _b = _a.scrollablePixelsY,
  22871. scrollablePixelsY = _b === void 0 ? 0 : _b,
  22872. _c = _a.scrollingContainer,
  22873. _d = _c === void 0 ? { scrollLeft: 0,
  22874. scrollTop: 0 } : _c,
  22875. scrollLeft = _d.scrollLeft,
  22876. scrollTop = _d.scrollTop,
  22877. styledMode = _a.styledMode,
  22878. distance = tooltip.distance,
  22879. options = tooltip.options,
  22880. positioner = tooltip.options.positioner;
  22881. // The area which the tooltip should be limited to. Limit to scrollable
  22882. // plot area if enabled, otherwise limit to the chart container.
  22883. var bounds = {
  22884. left: scrollLeft,
  22885. right: scrollLeft + chartWidth,
  22886. top: scrollTop,
  22887. bottom: scrollTop + chartHeight
  22888. };
  22889. var tooltipLabel = tooltip.getLabel();
  22890. var headerTop = Boolean(chart.xAxis[0] && chart.xAxis[0].opposite);
  22891. var distributionBoxTop = plotTop + scrollTop;
  22892. var headerHeight = 0;
  22893. var adjustedPlotHeight = plotHeight - scrollablePixelsY;
  22894. /**
  22895. * Calculates the anchor position for the partial tooltip
  22896. *
  22897. * @private
  22898. * @param {Highcharts.Point} point The point related to the tooltip
  22899. * @return {object} Returns an object with anchorX and anchorY
  22900. */
  22901. function getAnchor(point) {
  22902. var isHeader = point.isHeader,
  22903. _a = point.plotX,
  22904. plotX = _a === void 0 ? 0 : _a,
  22905. _b = point.plotY,
  22906. plotY = _b === void 0 ? 0 : _b,
  22907. series = point.series;
  22908. var anchorX;
  22909. var anchorY;
  22910. if (isHeader) {
  22911. // Set anchorX to plotX
  22912. anchorX = plotLeft + plotX;
  22913. // Set anchorY to center of visible plot area.
  22914. anchorY = plotTop + plotHeight / 2;
  22915. }
  22916. else {
  22917. var xAxis = series.xAxis,
  22918. yAxis = series.yAxis;
  22919. // Set anchorX to plotX. Limit to within xAxis.
  22920. anchorX = xAxis.pos + clamp(plotX, -distance, xAxis.len + distance);
  22921. // Set anchorY, limit to the scrollable plot area
  22922. if (yAxis.pos + plotY >= scrollTop + plotTop &&
  22923. yAxis.pos + plotY <= scrollTop + plotTop + plotHeight - scrollablePixelsY) {
  22924. anchorY = yAxis.pos + plotY;
  22925. }
  22926. }
  22927. // Limit values to plot area
  22928. anchorX = clamp(anchorX, bounds.left - distance, bounds.right + distance);
  22929. return { anchorX: anchorX, anchorY: anchorY };
  22930. }
  22931. /**
  22932. * Calculates the position of the partial tooltip
  22933. *
  22934. * @private
  22935. * @param {number} anchorX The partial tooltip anchor x position
  22936. * @param {number} anchorY The partial tooltip anchor y position
  22937. * @param {boolean} isHeader Whether the partial tooltip is a header
  22938. * @param {number} boxWidth Width of the partial tooltip
  22939. * @return {Highcharts.PositionObject} Returns the partial tooltip x and
  22940. * y position
  22941. */
  22942. function defaultPositioner(anchorX, anchorY, isHeader, boxWidth, alignedLeft) {
  22943. if (alignedLeft === void 0) { alignedLeft = true; }
  22944. var y;
  22945. var x;
  22946. if (isHeader) {
  22947. y = headerTop ? 0 : adjustedPlotHeight;
  22948. x = clamp(anchorX - (boxWidth / 2), bounds.left, bounds.right - boxWidth);
  22949. }
  22950. else {
  22951. y = anchorY - distributionBoxTop;
  22952. x = alignedLeft ?
  22953. anchorX - boxWidth - distance :
  22954. anchorX + distance;
  22955. x = clamp(x, alignedLeft ? x : bounds.left, bounds.right);
  22956. }
  22957. // NOTE: y is relative to distributionBoxTop
  22958. return { x: x, y: y };
  22959. }
  22960. /**
  22961. * Updates the attributes and styling of the partial tooltip. Creates a
  22962. * new partial tooltip if it does not exists.
  22963. *
  22964. * @private
  22965. * @param {Highcharts.SVGElement|undefined} partialTooltip
  22966. * The partial tooltip to update
  22967. * @param {Highcharts.Point} point
  22968. * The point related to the partial tooltip
  22969. * @param {boolean|string} str The text for the partial tooltip
  22970. * @return {Highcharts.SVGElement} Returns the updated partial tooltip
  22971. */
  22972. function updatePartialTooltip(partialTooltip, point, str) {
  22973. var tt = partialTooltip;
  22974. var isHeader = point.isHeader,
  22975. series = point.series;
  22976. var colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none');
  22977. if (!tt) {
  22978. var attribs = {
  22979. padding: options.padding,
  22980. r: options.borderRadius
  22981. };
  22982. if (!styledMode) {
  22983. attribs.fill = options.backgroundColor;
  22984. attribs['stroke-width'] = options.borderWidth;
  22985. }
  22986. tt = ren
  22987. .label('', 0, 0, (options[isHeader ? 'headerShape' : 'shape']) ||
  22988. 'callout', void 0, void 0, options.useHTML)
  22989. .addClass((isHeader ? 'highcharts-tooltip-header ' : '') +
  22990. 'highcharts-tooltip-box ' +
  22991. colorClass)
  22992. .attr(attribs)
  22993. .add(tooltipLabel);
  22994. }
  22995. tt.isActive = true;
  22996. tt.attr({
  22997. text: str
  22998. });
  22999. if (!styledMode) {
  23000. tt.css(options.style)
  23001. .shadow(options.shadow)
  23002. .attr({
  23003. stroke: (options.borderColor ||
  23004. point.color ||
  23005. series.color ||
  23006. '#333333')
  23007. });
  23008. }
  23009. return tt;
  23010. }
  23011. // Graceful degradation for legacy formatters
  23012. if (isString(labels)) {
  23013. labels = [false, labels];
  23014. }
  23015. // Create the individual labels for header and points, ignore footer
  23016. var boxes = labels.slice(0,
  23017. points.length + 1).reduce(function (boxes,
  23018. str,
  23019. i) {
  23020. if (str !== false && str !== '') {
  23021. var point = (points[i - 1] ||
  23022. {
  23023. // Item 0 is the header. Instead of this, we could also
  23024. // use the crosshair label
  23025. isHeader: true,
  23026. plotX: points[0].plotX,
  23027. plotY: plotHeight,
  23028. series: {}
  23029. });
  23030. var isHeader = point.isHeader;
  23031. // Store the tooltip label referance on the series
  23032. var owner = isHeader ? tooltip : point.series;
  23033. var tt = owner.tt = updatePartialTooltip(owner.tt,
  23034. point,
  23035. str);
  23036. // Get X position now, so we can move all to the other side in
  23037. // case of overflow
  23038. var bBox = tt.getBBox();
  23039. var boxWidth = bBox.width + tt.strokeWidth();
  23040. if (isHeader) {
  23041. headerHeight = bBox.height;
  23042. adjustedPlotHeight += headerHeight;
  23043. if (headerTop) {
  23044. distributionBoxTop -= headerHeight;
  23045. }
  23046. }
  23047. var _a = getAnchor(point),
  23048. anchorX = _a.anchorX,
  23049. anchorY = _a.anchorY;
  23050. if (typeof anchorY === 'number') {
  23051. var size = bBox.height + 1;
  23052. var boxPosition = (positioner ?
  23053. positioner.call(tooltip,
  23054. boxWidth,
  23055. size,
  23056. point) :
  23057. defaultPositioner(anchorX,
  23058. anchorY,
  23059. isHeader,
  23060. boxWidth));
  23061. boxes.push({
  23062. // 0-align to the top, 1-align to the bottom
  23063. align: positioner ? 0 : void 0,
  23064. anchorX: anchorX,
  23065. anchorY: anchorY,
  23066. boxWidth: boxWidth,
  23067. point: point,
  23068. rank: pick(boxPosition.rank, isHeader ? 1 : 0),
  23069. size: size,
  23070. target: boxPosition.y,
  23071. tt: tt,
  23072. x: boxPosition.x
  23073. });
  23074. }
  23075. else {
  23076. // Hide tooltips which anchorY is outside the visible plot
  23077. // area
  23078. tt.isActive = false;
  23079. }
  23080. }
  23081. return boxes;
  23082. }, []);
  23083. // If overflow left then align all labels to the right
  23084. if (!positioner && boxes.some(function (box) { return box.x < bounds.left; })) {
  23085. boxes = boxes.map(function (box) {
  23086. var _a = defaultPositioner(box.anchorX,
  23087. box.anchorY,
  23088. box.point.isHeader,
  23089. box.boxWidth,
  23090. false),
  23091. x = _a.x,
  23092. y = _a.y;
  23093. return extend(box, {
  23094. target: y,
  23095. x: x
  23096. });
  23097. });
  23098. }
  23099. // Clean previous run (for missing points)
  23100. tooltip.cleanSplit();
  23101. // Distribute and put in place
  23102. H.distribute(boxes, adjustedPlotHeight);
  23103. boxes.forEach(function (box) {
  23104. var anchorX = box.anchorX,
  23105. anchorY = box.anchorY,
  23106. pos = box.pos,
  23107. x = box.x;
  23108. // Put the label in place
  23109. box.tt.attr({
  23110. visibility: typeof pos === 'undefined' ? 'hidden' : 'inherit',
  23111. x: x,
  23112. /* NOTE: y should equal pos to be consistent with !split
  23113. * tooltip, but is currently relative to plotTop. Is left as is
  23114. * to avoid breaking change. Remove distributionBoxTop to make
  23115. * it consistent.
  23116. */
  23117. y: pos + distributionBoxTop,
  23118. anchorX: anchorX,
  23119. anchorY: anchorY
  23120. });
  23121. });
  23122. /* If we have a seperate tooltip container, then update the necessary
  23123. * container properties.
  23124. * Test that tooltip has its own container and renderer before executing
  23125. * the operation.
  23126. */
  23127. var container = tooltip.container,
  23128. outside = tooltip.outside,
  23129. renderer = tooltip.renderer;
  23130. if (outside && container && renderer) {
  23131. // Set container size to fit the tooltip
  23132. var _e = tooltipLabel.getBBox(),
  23133. width = _e.width,
  23134. height = _e.height,
  23135. x = _e.x,
  23136. y = _e.y;
  23137. renderer.setSize(width + x, height + y, false);
  23138. // Position the tooltip container to the chart container
  23139. var chartPosition = pointer.getChartPosition();
  23140. container.style.left = chartPosition.left + 'px';
  23141. container.style.top = chartPosition.top + 'px';
  23142. }
  23143. };
  23144. /**
  23145. * If the `stickOnContact` option is active, this will add a tracker shape.
  23146. *
  23147. * @private
  23148. * @function Highcharts.Tooltip#drawTracker
  23149. */
  23150. Tooltip.prototype.drawTracker = function () {
  23151. var tooltip = this;
  23152. if (tooltip.followPointer ||
  23153. !tooltip.options.stickOnContact) {
  23154. if (tooltip.tracker) {
  23155. tooltip.tracker.destroy();
  23156. }
  23157. return;
  23158. }
  23159. var chart = tooltip.chart;
  23160. var label = tooltip.label;
  23161. var point = chart.hoverPoint;
  23162. if (!label || !point) {
  23163. return;
  23164. }
  23165. var box = {
  23166. x: 0,
  23167. y: 0,
  23168. width: 0,
  23169. height: 0
  23170. };
  23171. // Combine anchor and tooltip
  23172. var anchorPos = this.getAnchor(point);
  23173. var labelBBox = label.getBBox();
  23174. anchorPos[0] += chart.plotLeft - label.translateX;
  23175. anchorPos[1] += chart.plotTop - label.translateY;
  23176. // When the mouse pointer is between the anchor point and the label,
  23177. // the label should stick.
  23178. box.x = Math.min(0, anchorPos[0]);
  23179. box.y = Math.min(0, anchorPos[1]);
  23180. box.width = (anchorPos[0] < 0 ?
  23181. Math.max(Math.abs(anchorPos[0]), (labelBBox.width - anchorPos[0])) :
  23182. Math.max(Math.abs(anchorPos[0]), labelBBox.width));
  23183. box.height = (anchorPos[1] < 0 ?
  23184. Math.max(Math.abs(anchorPos[1]), (labelBBox.height - Math.abs(anchorPos[1]))) :
  23185. Math.max(Math.abs(anchorPos[1]), labelBBox.height));
  23186. if (tooltip.tracker) {
  23187. tooltip.tracker.attr(box);
  23188. }
  23189. else {
  23190. tooltip.tracker = label.renderer
  23191. .rect(box)
  23192. .addClass('highcharts-tracker')
  23193. .add(label);
  23194. if (!chart.styledMode) {
  23195. tooltip.tracker.attr({
  23196. fill: 'rgba(0,0,0,0)'
  23197. });
  23198. }
  23199. }
  23200. };
  23201. /**
  23202. * @private
  23203. */
  23204. Tooltip.prototype.styledModeFormat = function (formatString) {
  23205. return formatString
  23206. .replace('style="font-size: 10px"', 'class="highcharts-header"')
  23207. .replace(/style="color:{(point|series)\.color}"/g, 'class="highcharts-color-{$1.colorIndex}"');
  23208. };
  23209. /**
  23210. * Format the footer/header of the tooltip
  23211. * #3397: abstraction to enable formatting of footer and header
  23212. *
  23213. * @private
  23214. * @function Highcharts.Tooltip#tooltipFooterHeaderFormatter
  23215. * @param {Highcharts.PointLabelObject} labelConfig
  23216. * @param {boolean} [isFooter]
  23217. * @return {string}
  23218. */
  23219. Tooltip.prototype.tooltipFooterHeaderFormatter = function (labelConfig, isFooter) {
  23220. var footOrHead = isFooter ? 'footer' : 'header',
  23221. series = labelConfig.series,
  23222. tooltipOptions = series.tooltipOptions,
  23223. xDateFormat = tooltipOptions.xDateFormat,
  23224. xAxis = series.xAxis,
  23225. isDateTime = (xAxis &&
  23226. xAxis.options.type === 'datetime' &&
  23227. isNumber(labelConfig.key)),
  23228. formatString = tooltipOptions[footOrHead + 'Format'],
  23229. e = {
  23230. isFooter: isFooter,
  23231. labelConfig: labelConfig
  23232. };
  23233. fireEvent(this, 'headerFormatter', e, function (e) {
  23234. // Guess the best date format based on the closest point distance
  23235. // (#568, #3418)
  23236. if (isDateTime && !xDateFormat) {
  23237. xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
  23238. }
  23239. // Insert the footer date format if any
  23240. if (isDateTime && xDateFormat) {
  23241. ((labelConfig.point && labelConfig.point.tooltipDateKeys) ||
  23242. ['key']).forEach(function (key) {
  23243. formatString = formatString.replace('{point.' + key + '}', '{point.' + key + ':' + xDateFormat + '}');
  23244. });
  23245. }
  23246. // Replace default header style with class name
  23247. if (series.chart.styledMode) {
  23248. formatString = this.styledModeFormat(formatString);
  23249. }
  23250. e.text = format(formatString, {
  23251. point: labelConfig,
  23252. series: series
  23253. }, this.chart);
  23254. });
  23255. return e.text;
  23256. };
  23257. /**
  23258. * Updates the tooltip with the provided tooltip options.
  23259. *
  23260. * @function Highcharts.Tooltip#update
  23261. *
  23262. * @param {Highcharts.TooltipOptions} options
  23263. * The tooltip options to update.
  23264. */
  23265. Tooltip.prototype.update = function (options) {
  23266. this.destroy();
  23267. // Update user options (#6218)
  23268. merge(true, this.chart.options.tooltip.userOptions, options);
  23269. this.init(this.chart, merge(true, this.options, options));
  23270. };
  23271. /**
  23272. * Find the new position and perform the move
  23273. *
  23274. * @private
  23275. * @function Highcharts.Tooltip#updatePosition
  23276. *
  23277. * @param {Highcharts.Point} point
  23278. */
  23279. Tooltip.prototype.updatePosition = function (point) {
  23280. var chart = this.chart,
  23281. pointer = chart.pointer,
  23282. label = this.getLabel(),
  23283. pos,
  23284. anchorX = point.plotX + chart.plotLeft,
  23285. anchorY = point.plotY + chart.plotTop,
  23286. pad;
  23287. // Needed for outside: true (#11688)
  23288. var chartPosition = pointer.getChartPosition();
  23289. pos = (this.options.positioner || this.getPosition).call(this, label.width, label.height, point);
  23290. // Set the renderer size dynamically to prevent document size to change
  23291. if (this.outside) {
  23292. pad = (this.options.borderWidth || 0) + 2 * this.distance;
  23293. this.renderer.setSize(label.width + pad, label.height + pad, false);
  23294. // Anchor and tooltip container need scaling if chart container has
  23295. // scale transform/css zoom. #11329.
  23296. var containerScaling = chart.containerScaling;
  23297. if (containerScaling) {
  23298. css(this.container, {
  23299. transform: "scale(" + containerScaling.scaleX + ", " + containerScaling.scaleY + ")"
  23300. });
  23301. anchorX *= containerScaling.scaleX;
  23302. anchorY *= containerScaling.scaleY;
  23303. }
  23304. anchorX += chartPosition.left - pos.x;
  23305. anchorY += chartPosition.top - pos.y;
  23306. }
  23307. // do the move
  23308. this.move(Math.round(pos.x), Math.round(pos.y || 0), // can be undefined (#3977)
  23309. anchorX, anchorY);
  23310. };
  23311. return Tooltip;
  23312. }());
  23313. H.Tooltip = Tooltip;
  23314. return H.Tooltip;
  23315. });
  23316. _registerModule(_modules, 'Core/Pointer.js', [_modules['Core/Color.js'], _modules['Core/Globals.js'], _modules['Core/Tooltip.js'], _modules['Core/Utilities.js']], function (Color, H, Tooltip, U) {
  23317. /* *
  23318. *
  23319. * (c) 2010-2020 Torstein Honsi
  23320. *
  23321. * License: www.highcharts.com/license
  23322. *
  23323. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  23324. *
  23325. * */
  23326. var color = Color.parse;
  23327. var charts = H.charts,
  23328. noop = H.noop;
  23329. var addEvent = U.addEvent,
  23330. attr = U.attr,
  23331. css = U.css,
  23332. defined = U.defined,
  23333. extend = U.extend,
  23334. find = U.find,
  23335. fireEvent = U.fireEvent,
  23336. isNumber = U.isNumber,
  23337. isObject = U.isObject,
  23338. objectEach = U.objectEach,
  23339. offset = U.offset,
  23340. pick = U.pick,
  23341. splat = U.splat;
  23342. /**
  23343. * One position in relation to an axis.
  23344. *
  23345. * @interface Highcharts.PointerAxisCoordinateObject
  23346. */ /**
  23347. * Related axis.
  23348. *
  23349. * @name Highcharts.PointerAxisCoordinateObject#axis
  23350. * @type {Highcharts.Axis}
  23351. */ /**
  23352. * Axis value.
  23353. *
  23354. * @name Highcharts.PointerAxisCoordinateObject#value
  23355. * @type {number}
  23356. */
  23357. /**
  23358. * Positions in terms of axis values.
  23359. *
  23360. * @interface Highcharts.PointerAxisCoordinatesObject
  23361. */ /**
  23362. * Positions on the x-axis.
  23363. * @name Highcharts.PointerAxisCoordinatesObject#xAxis
  23364. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  23365. */ /**
  23366. * Positions on the y-axis.
  23367. * @name Highcharts.PointerAxisCoordinatesObject#yAxis
  23368. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  23369. */
  23370. /**
  23371. * Pointer coordinates.
  23372. *
  23373. * @interface Highcharts.PointerCoordinatesObject
  23374. */ /**
  23375. * @name Highcharts.PointerCoordinatesObject#chartX
  23376. * @type {number}
  23377. */ /**
  23378. * @name Highcharts.PointerCoordinatesObject#chartY
  23379. * @type {number}
  23380. */
  23381. /**
  23382. * A native browser mouse or touch event, extended with position information
  23383. * relative to the {@link Chart.container}.
  23384. *
  23385. * @interface Highcharts.PointerEventObject
  23386. * @extends global.PointerEvent
  23387. */ /**
  23388. * The X coordinate of the pointer interaction relative to the chart.
  23389. *
  23390. * @name Highcharts.PointerEventObject#chartX
  23391. * @type {number}
  23392. */ /**
  23393. * The Y coordinate of the pointer interaction relative to the chart.
  23394. *
  23395. * @name Highcharts.PointerEventObject#chartY
  23396. * @type {number}
  23397. */
  23398. /**
  23399. * Axis-specific data of a selection.
  23400. *
  23401. * @interface Highcharts.SelectDataObject
  23402. */ /**
  23403. * @name Highcharts.SelectDataObject#axis
  23404. * @type {Highcharts.Axis}
  23405. */ /**
  23406. * @name Highcharts.SelectDataObject#max
  23407. * @type {number}
  23408. */ /**
  23409. * @name Highcharts.SelectDataObject#min
  23410. * @type {number}
  23411. */
  23412. /**
  23413. * Object for select events.
  23414. *
  23415. * @interface Highcharts.SelectEventObject
  23416. */ /**
  23417. * @name Highcharts.SelectEventObject#originalEvent
  23418. * @type {global.Event}
  23419. */ /**
  23420. * @name Highcharts.SelectEventObject#xAxis
  23421. * @type {Array<Highcharts.SelectDataObject>}
  23422. */ /**
  23423. * @name Highcharts.SelectEventObject#yAxis
  23424. * @type {Array<Highcharts.SelectDataObject>}
  23425. */
  23426. ''; // detach doclets above
  23427. /* eslint-disable no-invalid-this, valid-jsdoc */
  23428. /**
  23429. * The mouse and touch tracker object. Each {@link Chart} item has one
  23430. * assosiated Pointer item that can be accessed from the {@link Chart.pointer}
  23431. * property.
  23432. *
  23433. * @class
  23434. * @name Highcharts.Pointer
  23435. *
  23436. * @param {Highcharts.Chart} chart
  23437. * The chart instance.
  23438. *
  23439. * @param {Highcharts.Options} options
  23440. * The root options object. The pointer uses options from the chart and
  23441. * tooltip structures.
  23442. */
  23443. var Pointer = /** @class */ (function () {
  23444. /* *
  23445. *
  23446. * Constructors
  23447. *
  23448. * */
  23449. function Pointer(chart, options) {
  23450. this.lastValidTouch = {};
  23451. this.pinchDown = [];
  23452. this.runChartClick = false;
  23453. this.chart = chart;
  23454. this.hasDragged = false;
  23455. this.options = options;
  23456. this.unbindContainerMouseLeave = function () { };
  23457. this.unbindContainerMouseEnter = function () { };
  23458. this.init(chart, options);
  23459. }
  23460. /* *
  23461. *
  23462. * Functions
  23463. *
  23464. * */
  23465. /**
  23466. * Set inactive state to all series that are not currently hovered,
  23467. * or, if `inactiveOtherPoints` is set to true, set inactive state to
  23468. * all points within that series.
  23469. *
  23470. * @private
  23471. * @function Highcharts.Pointer#applyInactiveState
  23472. * @param {Array<Highcharts.Point>} points
  23473. * Currently hovered points
  23474. */
  23475. Pointer.prototype.applyInactiveState = function (points) {
  23476. var activeSeries = [],
  23477. series;
  23478. // Get all active series from the hovered points
  23479. (points || []).forEach(function (item) {
  23480. series = item.series;
  23481. // Include itself
  23482. activeSeries.push(series);
  23483. // Include parent series
  23484. if (series.linkedParent) {
  23485. activeSeries.push(series.linkedParent);
  23486. }
  23487. // Include all child series
  23488. if (series.linkedSeries) {
  23489. activeSeries = activeSeries.concat(series.linkedSeries);
  23490. }
  23491. // Include navigator series
  23492. if (series.navigatorSeries) {
  23493. activeSeries.push(series.navigatorSeries);
  23494. }
  23495. });
  23496. // Now loop over all series, filtering out active series
  23497. this.chart.series.forEach(function (inactiveSeries) {
  23498. if (activeSeries.indexOf(inactiveSeries) === -1) {
  23499. // Inactive series
  23500. inactiveSeries.setState('inactive', true);
  23501. }
  23502. else if (inactiveSeries.options.inactiveOtherPoints) {
  23503. // Active series, but other points should be inactivated
  23504. inactiveSeries.setAllPointsToState('inactive');
  23505. }
  23506. });
  23507. };
  23508. /**
  23509. * Destroys the Pointer object and disconnects DOM events.
  23510. *
  23511. * @function Highcharts.Pointer#destroy
  23512. */
  23513. Pointer.prototype.destroy = function () {
  23514. var pointer = this;
  23515. if (typeof pointer.unDocMouseMove !== 'undefined') {
  23516. pointer.unDocMouseMove();
  23517. }
  23518. this.unbindContainerMouseLeave();
  23519. if (!H.chartCount) {
  23520. if (H.unbindDocumentMouseUp) {
  23521. H.unbindDocumentMouseUp = H.unbindDocumentMouseUp();
  23522. }
  23523. if (H.unbindDocumentTouchEnd) {
  23524. H.unbindDocumentTouchEnd = H.unbindDocumentTouchEnd();
  23525. }
  23526. }
  23527. // memory and CPU leak
  23528. clearInterval(pointer.tooltipTimeout);
  23529. objectEach(pointer, function (_val, prop) {
  23530. pointer[prop] = void 0;
  23531. });
  23532. };
  23533. /**
  23534. * Perform a drag operation in response to a mousemove event while the mouse
  23535. * is down.
  23536. *
  23537. * @private
  23538. * @function Highcharts.Pointer#drag
  23539. *
  23540. * @param {Highcharts.PointerEventObject} e
  23541. *
  23542. * @return {void}
  23543. */
  23544. Pointer.prototype.drag = function (e) {
  23545. var chart = this.chart,
  23546. chartOptions = chart.options.chart,
  23547. chartX = e.chartX,
  23548. chartY = e.chartY,
  23549. zoomHor = this.zoomHor,
  23550. zoomVert = this.zoomVert,
  23551. plotLeft = chart.plotLeft,
  23552. plotTop = chart.plotTop,
  23553. plotWidth = chart.plotWidth,
  23554. plotHeight = chart.plotHeight,
  23555. clickedInside,
  23556. size,
  23557. selectionMarker = this.selectionMarker,
  23558. mouseDownX = (this.mouseDownX || 0),
  23559. mouseDownY = (this.mouseDownY || 0),
  23560. panningEnabled = isObject(chartOptions.panning) ?
  23561. chartOptions.panning && chartOptions.panning.enabled :
  23562. chartOptions.panning,
  23563. panKey = (chartOptions.panKey && e[chartOptions.panKey + 'Key']);
  23564. // If the device supports both touch and mouse (like IE11), and we are
  23565. // touch-dragging inside the plot area, don't handle the mouse event.
  23566. // #4339.
  23567. if (selectionMarker && selectionMarker.touch) {
  23568. return;
  23569. }
  23570. // If the mouse is outside the plot area, adjust to cooordinates
  23571. // inside to prevent the selection marker from going outside
  23572. if (chartX < plotLeft) {
  23573. chartX = plotLeft;
  23574. }
  23575. else if (chartX > plotLeft + plotWidth) {
  23576. chartX = plotLeft + plotWidth;
  23577. }
  23578. if (chartY < plotTop) {
  23579. chartY = plotTop;
  23580. }
  23581. else if (chartY > plotTop + plotHeight) {
  23582. chartY = plotTop + plotHeight;
  23583. }
  23584. // determine if the mouse has moved more than 10px
  23585. this.hasDragged = Math.sqrt(Math.pow(mouseDownX - chartX, 2) +
  23586. Math.pow(mouseDownY - chartY, 2));
  23587. if (this.hasDragged > 10) {
  23588. clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop);
  23589. // make a selection
  23590. if (chart.hasCartesianSeries &&
  23591. (this.zoomX || this.zoomY) &&
  23592. clickedInside &&
  23593. !panKey) {
  23594. if (!selectionMarker) {
  23595. this.selectionMarker = selectionMarker =
  23596. chart.renderer.rect(plotLeft, plotTop, zoomHor ? 1 : plotWidth, zoomVert ? 1 : plotHeight, 0)
  23597. .attr({
  23598. 'class': 'highcharts-selection-marker',
  23599. zIndex: 7
  23600. })
  23601. .add();
  23602. if (!chart.styledMode) {
  23603. selectionMarker.attr({
  23604. fill: (chartOptions.selectionMarkerFill ||
  23605. color('#335cad')
  23606. .setOpacity(0.25).get())
  23607. });
  23608. }
  23609. }
  23610. }
  23611. // adjust the width of the selection marker
  23612. if (selectionMarker && zoomHor) {
  23613. size = chartX - mouseDownX;
  23614. selectionMarker.attr({
  23615. width: Math.abs(size),
  23616. x: (size > 0 ? 0 : size) + mouseDownX
  23617. });
  23618. }
  23619. // adjust the height of the selection marker
  23620. if (selectionMarker && zoomVert) {
  23621. size = chartY - mouseDownY;
  23622. selectionMarker.attr({
  23623. height: Math.abs(size),
  23624. y: (size > 0 ? 0 : size) + mouseDownY
  23625. });
  23626. }
  23627. // panning
  23628. if (clickedInside &&
  23629. !selectionMarker &&
  23630. panningEnabled) {
  23631. chart.pan(e, chartOptions.panning);
  23632. }
  23633. }
  23634. };
  23635. /**
  23636. * Start a drag operation.
  23637. *
  23638. * @private
  23639. * @function Highcharts.Pointer#dragStart
  23640. *
  23641. * @param {Highcharts.PointerEventObject} e
  23642. *
  23643. * @return {void}
  23644. */
  23645. Pointer.prototype.dragStart = function (e) {
  23646. var chart = this.chart;
  23647. // Record the start position
  23648. chart.mouseIsDown = e.type;
  23649. chart.cancelClick = false;
  23650. chart.mouseDownX = this.mouseDownX = e.chartX;
  23651. chart.mouseDownY = this.mouseDownY = e.chartY;
  23652. };
  23653. /**
  23654. * On mouse up or touch end across the entire document, drop the selection.
  23655. *
  23656. * @private
  23657. * @function Highcharts.Pointer#drop
  23658. *
  23659. * @param {global.Event} e
  23660. */
  23661. Pointer.prototype.drop = function (e) {
  23662. var pointer = this,
  23663. chart = this.chart,
  23664. hasPinched = this.hasPinched;
  23665. if (this.selectionMarker) {
  23666. var selectionData = {
  23667. originalEvent: e,
  23668. xAxis: [],
  23669. yAxis: []
  23670. },
  23671. selectionBox = this.selectionMarker,
  23672. selectionLeft = selectionBox.attr ?
  23673. selectionBox.attr('x') :
  23674. selectionBox.x,
  23675. selectionTop = selectionBox.attr ?
  23676. selectionBox.attr('y') :
  23677. selectionBox.y,
  23678. selectionWidth = selectionBox.attr ?
  23679. selectionBox.attr('width') :
  23680. selectionBox.width,
  23681. selectionHeight = selectionBox.attr ?
  23682. selectionBox.attr('height') :
  23683. selectionBox.height,
  23684. runZoom;
  23685. // a selection has been made
  23686. if (this.hasDragged || hasPinched) {
  23687. // record each axis' min and max
  23688. chart.axes.forEach(function (axis) {
  23689. if (axis.zoomEnabled &&
  23690. defined(axis.min) &&
  23691. (hasPinched ||
  23692. pointer[{
  23693. xAxis: 'zoomX',
  23694. yAxis: 'zoomY'
  23695. }[axis.coll]]) &&
  23696. isNumber(selectionLeft) &&
  23697. isNumber(selectionTop)) { // #859, #3569
  23698. var horiz = axis.horiz,
  23699. minPixelPadding = e.type === 'touchend' ?
  23700. axis.minPixelPadding :
  23701. 0, // #1207, #3075
  23702. selectionMin = axis.toValue((horiz ? selectionLeft : selectionTop) +
  23703. minPixelPadding),
  23704. selectionMax = axis.toValue((horiz ?
  23705. selectionLeft + selectionWidth :
  23706. selectionTop + selectionHeight) - minPixelPadding);
  23707. selectionData[axis.coll].push({
  23708. axis: axis,
  23709. // Min/max for reversed axes
  23710. min: Math.min(selectionMin, selectionMax),
  23711. max: Math.max(selectionMin, selectionMax)
  23712. });
  23713. runZoom = true;
  23714. }
  23715. });
  23716. if (runZoom) {
  23717. fireEvent(chart, 'selection', selectionData, function (args) {
  23718. chart.zoom(extend(args, hasPinched ?
  23719. { animation: false } :
  23720. null));
  23721. });
  23722. }
  23723. }
  23724. if (isNumber(chart.index)) {
  23725. this.selectionMarker = this.selectionMarker.destroy();
  23726. }
  23727. // Reset scaling preview
  23728. if (hasPinched) {
  23729. this.scaleGroups();
  23730. }
  23731. }
  23732. // Reset all. Check isNumber because it may be destroyed on mouse up
  23733. // (#877)
  23734. if (chart && isNumber(chart.index)) {
  23735. css(chart.container, { cursor: chart._cursor });
  23736. chart.cancelClick = this.hasDragged > 10; // #370
  23737. chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
  23738. this.pinchDown = [];
  23739. }
  23740. };
  23741. /**
  23742. * Finds the closest point to a set of coordinates, using the k-d-tree
  23743. * algorithm.
  23744. *
  23745. * @function Highcharts.Pointer#findNearestKDPoint
  23746. *
  23747. * @param {Array<Highcharts.Series>} series
  23748. * All the series to search in.
  23749. *
  23750. * @param {boolean|undefined} shared
  23751. * Whether it is a shared tooltip or not.
  23752. *
  23753. * @param {Highcharts.PointerEventObject} e
  23754. * The pointer event object, containing chart coordinates of the
  23755. * pointer.
  23756. *
  23757. * @return {Highcharts.Point|undefined}
  23758. * The point closest to given coordinates.
  23759. */
  23760. Pointer.prototype.findNearestKDPoint = function (series, shared, e) {
  23761. var chart = this.chart;
  23762. var hoverPoint = chart.hoverPoint;
  23763. var tooltip = chart.tooltip;
  23764. if (hoverPoint &&
  23765. tooltip &&
  23766. tooltip.isStickyOnContact()) {
  23767. return hoverPoint;
  23768. }
  23769. var closest;
  23770. /** @private */
  23771. function sort(p1, p2) {
  23772. var isCloserX = p1.distX - p2.distX,
  23773. isCloser = p1.dist - p2.dist,
  23774. isAbove = (p2.series.group && p2.series.group.zIndex) -
  23775. (p1.series.group && p1.series.group.zIndex),
  23776. result;
  23777. // We have two points which are not in the same place on xAxis
  23778. // and shared tooltip:
  23779. if (isCloserX !== 0 && shared) { // #5721
  23780. result = isCloserX;
  23781. // Points are not exactly in the same place on x/yAxis:
  23782. }
  23783. else if (isCloser !== 0) {
  23784. result = isCloser;
  23785. // The same xAxis and yAxis position, sort by z-index:
  23786. }
  23787. else if (isAbove !== 0) {
  23788. result = isAbove;
  23789. // The same zIndex, sort by array index:
  23790. }
  23791. else {
  23792. result =
  23793. p1.series.index > p2.series.index ?
  23794. -1 :
  23795. 1;
  23796. }
  23797. return result;
  23798. }
  23799. series.forEach(function (s) {
  23800. var noSharedTooltip = s.noSharedTooltip && shared,
  23801. compareX = (!noSharedTooltip &&
  23802. s.options.findNearestPointBy.indexOf('y') < 0),
  23803. point = s.searchPoint(e,
  23804. compareX);
  23805. if ( // Check that we actually found a point on the series.
  23806. isObject(point, true) &&
  23807. // Use the new point if it is closer.
  23808. (!isObject(closest, true) ||
  23809. (sort(closest, point) > 0))) {
  23810. closest = point;
  23811. }
  23812. });
  23813. return closest;
  23814. };
  23815. /**
  23816. * @private
  23817. * @function Highcharts.Pointer#getChartCoordinatesFromPoint
  23818. * @param {Highcharts.Point} point
  23819. * @param {boolean} [inverted]
  23820. * @return {Highcharts.PointerCoordinatesObject|undefined}
  23821. */
  23822. Pointer.prototype.getChartCoordinatesFromPoint = function (point, inverted) {
  23823. var series = point.series,
  23824. xAxis = series.xAxis,
  23825. yAxis = series.yAxis,
  23826. plotX = pick(point.clientX,
  23827. point.plotX),
  23828. shapeArgs = point.shapeArgs;
  23829. if (xAxis && yAxis) {
  23830. return inverted ? {
  23831. chartX: xAxis.len + xAxis.pos - plotX,
  23832. chartY: yAxis.len + yAxis.pos - point.plotY
  23833. } : {
  23834. chartX: plotX + xAxis.pos,
  23835. chartY: point.plotY + yAxis.pos
  23836. };
  23837. }
  23838. if (shapeArgs && shapeArgs.x && shapeArgs.y) {
  23839. // E.g. pies do not have axes
  23840. return {
  23841. chartX: shapeArgs.x,
  23842. chartY: shapeArgs.y
  23843. };
  23844. }
  23845. };
  23846. /**
  23847. * Return the cached chartPosition if it is available on the Pointer,
  23848. * otherwise find it. Running offset is quite expensive, so it should be
  23849. * avoided when we know the chart hasn't moved.
  23850. *
  23851. * @function Highcharts.Pointer#getChartPosition
  23852. *
  23853. * @return {Highcharts.OffsetObject}
  23854. * The offset of the chart container within the page
  23855. */
  23856. Pointer.prototype.getChartPosition = function () {
  23857. return (this.chartPosition ||
  23858. (this.chartPosition = offset(this.chart.container)));
  23859. };
  23860. /**
  23861. * Get the click position in terms of axis values.
  23862. *
  23863. * @function Highcharts.Pointer#getCoordinates
  23864. *
  23865. * @param {Highcharts.PointerEventObject} e
  23866. * Pointer event, extended with `chartX` and `chartY` properties.
  23867. *
  23868. * @return {Highcharts.PointerAxisCoordinatesObject}
  23869. */
  23870. Pointer.prototype.getCoordinates = function (e) {
  23871. var coordinates = {
  23872. xAxis: [],
  23873. yAxis: []
  23874. };
  23875. this.chart.axes.forEach(function (axis) {
  23876. coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
  23877. axis: axis,
  23878. value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
  23879. });
  23880. });
  23881. return coordinates;
  23882. };
  23883. /**
  23884. * Calculates what is the current hovered point/points and series.
  23885. *
  23886. * @private
  23887. * @function Highcharts.Pointer#getHoverData
  23888. *
  23889. * @param {Highcharts.Point|undefined} existingHoverPoint
  23890. * The point currrently beeing hovered.
  23891. *
  23892. * @param {Highcharts.Series|undefined} existingHoverSeries
  23893. * The series currently beeing hovered.
  23894. *
  23895. * @param {Array<Highcharts.Series>} series
  23896. * All the series in the chart.
  23897. *
  23898. * @param {boolean} isDirectTouch
  23899. * Is the pointer directly hovering the point.
  23900. *
  23901. * @param {boolean|undefined} shared
  23902. * Whether it is a shared tooltip or not.
  23903. *
  23904. * @param {Highcharts.PointerEventObject} [e]
  23905. * The triggering event, containing chart coordinates of the pointer.
  23906. *
  23907. * @return {object}
  23908. * Object containing resulting hover data: hoverPoint, hoverSeries,
  23909. * and hoverPoints.
  23910. */
  23911. Pointer.prototype.getHoverData = function (existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
  23912. var hoverPoint,
  23913. hoverPoints = [],
  23914. hoverSeries = existingHoverSeries,
  23915. useExisting = !!(isDirectTouch && existingHoverPoint),
  23916. notSticky = hoverSeries && !hoverSeries.stickyTracking,
  23917. // Which series to look in for the hover point
  23918. searchSeries,
  23919. // Parameters needed for beforeGetHoverData event.
  23920. eventArgs = {
  23921. chartX: e ? e.chartX : void 0,
  23922. chartY: e ? e.chartY : void 0,
  23923. shared: shared
  23924. },
  23925. filter = function (s) {
  23926. return (s.visible &&
  23927. !(!shared && s.directTouch) && // #3821
  23928. pick(s.options.enableMouseTracking,
  23929. true));
  23930. };
  23931. // Find chart.hoverPane and update filter method in polar.
  23932. fireEvent(this, 'beforeGetHoverData', eventArgs);
  23933. searchSeries = notSticky ?
  23934. // Only search on hovered series if it has stickyTracking false
  23935. [hoverSeries] :
  23936. // Filter what series to look in.
  23937. series.filter(function (s) {
  23938. return eventArgs.filter ? eventArgs.filter(s) : filter(s) &&
  23939. s.stickyTracking;
  23940. });
  23941. // Use existing hovered point or find the one closest to coordinates.
  23942. hoverPoint = useExisting || !e ?
  23943. existingHoverPoint :
  23944. this.findNearestKDPoint(searchSeries, shared, e);
  23945. // Assign hover series
  23946. hoverSeries = hoverPoint && hoverPoint.series;
  23947. // If we have a hoverPoint, assign hoverPoints.
  23948. if (hoverPoint) {
  23949. // When tooltip is shared, it displays more than one point
  23950. if (shared && !hoverSeries.noSharedTooltip) {
  23951. searchSeries = series.filter(function (s) {
  23952. return eventArgs.filter ?
  23953. eventArgs.filter(s) : filter(s) && !s.noSharedTooltip;
  23954. });
  23955. // Get all points with the same x value as the hoverPoint
  23956. searchSeries.forEach(function (s) {
  23957. var point = find(s.points,
  23958. function (p) {
  23959. return p.x === hoverPoint.x && !p.isNull;
  23960. });
  23961. if (isObject(point)) {
  23962. /*
  23963. * Boost returns a minimal point. Convert it to a usable
  23964. * point for tooltip and states.
  23965. */
  23966. if (s.chart.isBoosting) {
  23967. point = s.getPoint(point);
  23968. }
  23969. hoverPoints.push(point);
  23970. }
  23971. });
  23972. }
  23973. else {
  23974. hoverPoints.push(hoverPoint);
  23975. }
  23976. }
  23977. // Check whether the hoverPoint is inside pane we are hovering over.
  23978. eventArgs = { hoverPoint: hoverPoint };
  23979. fireEvent(this, 'afterGetHoverData', eventArgs);
  23980. return {
  23981. hoverPoint: eventArgs.hoverPoint,
  23982. hoverSeries: hoverSeries,
  23983. hoverPoints: hoverPoints
  23984. };
  23985. };
  23986. /**
  23987. * @private
  23988. * @function Highcharts.Pointer#getPointFromEvent
  23989. *
  23990. * @param {global.Event} e
  23991. *
  23992. * @return {Highcharts.Point|undefined}
  23993. */
  23994. Pointer.prototype.getPointFromEvent = function (e) {
  23995. var target = e.target,
  23996. point;
  23997. while (target && !point) {
  23998. point = target.point;
  23999. target = target.parentNode;
  24000. }
  24001. return point;
  24002. };
  24003. /**
  24004. * @private
  24005. * @function Highcharts.Pointer#onTrackerMouseOut
  24006. *
  24007. * @param {Highcharts.PointerEventObject} e
  24008. *
  24009. * @return {void}
  24010. */
  24011. Pointer.prototype.onTrackerMouseOut = function (e) {
  24012. var chart = this.chart;
  24013. var relatedTarget = e.relatedTarget || e.toElement;
  24014. var series = chart.hoverSeries;
  24015. this.isDirectTouch = false;
  24016. if (series &&
  24017. relatedTarget &&
  24018. !series.stickyTracking &&
  24019. !this.inClass(relatedTarget, 'highcharts-tooltip') &&
  24020. (!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465, #5553
  24021. !this.inClass(relatedTarget, 'highcharts-tracker'))) {
  24022. series.onMouseOut();
  24023. }
  24024. };
  24025. /**
  24026. * Utility to detect whether an element has, or has a parent with, a
  24027. * specificclass name. Used on detection of tracker objects and on deciding
  24028. * whether hovering the tooltip should cause the active series to mouse out.
  24029. *
  24030. * @function Highcharts.Pointer#inClass
  24031. *
  24032. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  24033. * The element to investigate.
  24034. *
  24035. * @param {string} className
  24036. * The class name to look for.
  24037. *
  24038. * @return {boolean|undefined}
  24039. * True if either the element or one of its parents has the given
  24040. * class name.
  24041. */
  24042. Pointer.prototype.inClass = function (element, className) {
  24043. var elemClassName;
  24044. while (element) {
  24045. elemClassName = attr(element, 'class');
  24046. if (elemClassName) {
  24047. if (elemClassName.indexOf(className) !== -1) {
  24048. return true;
  24049. }
  24050. if (elemClassName.indexOf('highcharts-container') !== -1) {
  24051. return false;
  24052. }
  24053. }
  24054. element = element.parentNode;
  24055. }
  24056. };
  24057. /**
  24058. * Initialize the Pointer.
  24059. *
  24060. * @private
  24061. * @function Highcharts.Pointer#init
  24062. *
  24063. * @param {Highcharts.Chart} chart
  24064. * The Chart instance.
  24065. *
  24066. * @param {Highcharts.Options} options
  24067. * The root options object. The pointer uses options from the chart
  24068. * and tooltip structures.
  24069. *
  24070. * @return {void}
  24071. */
  24072. Pointer.prototype.init = function (chart, options) {
  24073. // Store references
  24074. this.options = options;
  24075. this.chart = chart;
  24076. // Do we need to handle click on a touch device?
  24077. this.runChartClick =
  24078. options.chart.events &&
  24079. !!options.chart.events.click;
  24080. this.pinchDown = [];
  24081. this.lastValidTouch = {};
  24082. if (Tooltip) {
  24083. /**
  24084. * Tooltip object for points of series.
  24085. *
  24086. * @name Highcharts.Chart#tooltip
  24087. * @type {Highcharts.Tooltip}
  24088. */
  24089. chart.tooltip = new Tooltip(chart, options.tooltip);
  24090. this.followTouchMove = pick(options.tooltip.followTouchMove, true);
  24091. }
  24092. this.setDOMEvents();
  24093. };
  24094. /**
  24095. * Takes a browser event object and extends it with custom Highcharts
  24096. * properties `chartX` and `chartY` in order to work on the internal
  24097. * coordinate system.
  24098. *
  24099. * @function Highcharts.Pointer#normalize
  24100. *
  24101. * @param {global.MouseEvent|global.PointerEvent|global.TouchEvent} e
  24102. * Event object in standard browsers.
  24103. *
  24104. * @param {Highcharts.OffsetObject} [chartPosition]
  24105. * Additional chart offset.
  24106. *
  24107. * @return {Highcharts.PointerEventObject}
  24108. * A browser event with extended properties `chartX` and `chartY`.
  24109. */
  24110. Pointer.prototype.normalize = function (e, chartPosition) {
  24111. var touches = e.touches;
  24112. // iOS (#2757)
  24113. var ePos = (touches ?
  24114. touches.length ?
  24115. touches.item(0) :
  24116. (pick(// #13534
  24117. touches.changedTouches,
  24118. e.changedTouches))[0] :
  24119. e);
  24120. // Get mouse position
  24121. if (!chartPosition) {
  24122. chartPosition = this.getChartPosition();
  24123. }
  24124. var chartX = ePos.pageX - chartPosition.left,
  24125. chartY = ePos.pageY - chartPosition.top;
  24126. // #11329 - when there is scaling on a parent element, we need to take
  24127. // this into account
  24128. var containerScaling = this.chart.containerScaling;
  24129. if (containerScaling) {
  24130. chartX /= containerScaling.scaleX;
  24131. chartY /= containerScaling.scaleY;
  24132. }
  24133. return extend(e, {
  24134. chartX: Math.round(chartX),
  24135. chartY: Math.round(chartY)
  24136. });
  24137. };
  24138. /**
  24139. * @private
  24140. * @function Highcharts.Pointer#onContainerClick
  24141. */
  24142. Pointer.prototype.onContainerClick = function (e) {
  24143. var chart = this.chart;
  24144. var hoverPoint = chart.hoverPoint;
  24145. var pEvt = this.normalize(e);
  24146. var plotLeft = chart.plotLeft;
  24147. var plotTop = chart.plotTop;
  24148. if (!chart.cancelClick) {
  24149. // On tracker click, fire the series and point events. #783, #1583
  24150. if (hoverPoint &&
  24151. this.inClass(pEvt.target, 'highcharts-tracker')) {
  24152. // the series click event
  24153. fireEvent(hoverPoint.series, 'click', extend(pEvt, {
  24154. point: hoverPoint
  24155. }));
  24156. // the point click event
  24157. if (chart.hoverPoint) { // it may be destroyed (#1844)
  24158. hoverPoint.firePointEvent('click', pEvt);
  24159. }
  24160. // When clicking outside a tracker, fire a chart event
  24161. }
  24162. else {
  24163. extend(pEvt, this.getCoordinates(pEvt));
  24164. // fire a click event in the chart
  24165. if (chart.isInsidePlot((pEvt.chartX - plotLeft), (pEvt.chartY - plotTop))) {
  24166. fireEvent(chart, 'click', pEvt);
  24167. }
  24168. }
  24169. }
  24170. };
  24171. /**
  24172. * @private
  24173. * @function Highcharts.Pointer#onContainerMouseDown
  24174. *
  24175. * @param {global.MouseEvent} e
  24176. */
  24177. Pointer.prototype.onContainerMouseDown = function (e) {
  24178. var isPrimaryButton = ((e.buttons || e.button) & 1) === 1;
  24179. // Normalize before the 'if' for the legacy IE (#7850)
  24180. e = this.normalize(e);
  24181. // #11635, Firefox does not reliable fire move event after click scroll
  24182. if (H.isFirefox &&
  24183. e.button !== 0) {
  24184. this.onContainerMouseMove(e);
  24185. }
  24186. // #11635, limiting to primary button (incl. IE 8 support)
  24187. if (typeof e.button === 'undefined' ||
  24188. isPrimaryButton) {
  24189. this.zoomOption(e);
  24190. // #295, #13737 solve conflict between container drag and chart zoom
  24191. if (isPrimaryButton &&
  24192. e.preventDefault) {
  24193. e.preventDefault();
  24194. }
  24195. this.dragStart(e);
  24196. }
  24197. };
  24198. /**
  24199. * When mouse leaves the container, hide the tooltip.
  24200. *
  24201. * @private
  24202. * @function Highcharts.Pointer#onContainerMouseLeave
  24203. *
  24204. * @param {global.MouseEvent} e
  24205. *
  24206. * @return {void}
  24207. */
  24208. Pointer.prototype.onContainerMouseLeave = function (e) {
  24209. var chart = charts[pick(H.hoverChartIndex, -1)];
  24210. var tooltip = this.chart.tooltip;
  24211. e = this.normalize(e);
  24212. // #4886, MS Touch end fires mouseleave but with no related target
  24213. if (chart &&
  24214. (e.relatedTarget || e.toElement)) {
  24215. chart.pointer.reset();
  24216. // Also reset the chart position, used in #149 fix
  24217. chart.pointer.chartPosition = void 0;
  24218. }
  24219. if ( // #11635, Firefox wheel scroll does not fire out events consistently
  24220. tooltip &&
  24221. !tooltip.isHidden) {
  24222. this.reset();
  24223. }
  24224. };
  24225. /**
  24226. * When mouse enters the container, delete pointer's chartPosition.
  24227. *
  24228. * @private
  24229. * @function Highcharts.Pointer#onContainerMouseEnter
  24230. *
  24231. * @param {global.MouseEvent} e
  24232. *
  24233. * @return {void}
  24234. */
  24235. Pointer.prototype.onContainerMouseEnter = function (e) {
  24236. delete this.chartPosition;
  24237. };
  24238. /**
  24239. * The mousemove, touchmove and touchstart event handler
  24240. *
  24241. * @private
  24242. * @function Highcharts.Pointer#onContainerMouseMove
  24243. *
  24244. * @param {global.MouseEvent} e
  24245. *
  24246. * @return {void}
  24247. */
  24248. Pointer.prototype.onContainerMouseMove = function (e) {
  24249. var chart = this.chart;
  24250. var pEvt = this.normalize(e);
  24251. this.setHoverChartIndex();
  24252. // In IE8 we apparently need this returnValue set to false in order to
  24253. // avoid text being selected. But in Chrome, e.returnValue is prevented,
  24254. // plus we don't need to run e.preventDefault to prevent selected text
  24255. // in modern browsers. So we set it conditionally. Remove it when IE8 is
  24256. // no longer needed. #2251, #3224.
  24257. if (!pEvt.preventDefault) {
  24258. pEvt.returnValue = false;
  24259. }
  24260. if (chart.mouseIsDown === 'mousedown') {
  24261. this.drag(pEvt);
  24262. }
  24263. // Show the tooltip and run mouse over events (#977)
  24264. if (!chart.openMenu &&
  24265. (this.inClass(pEvt.target, 'highcharts-tracker') ||
  24266. chart.isInsidePlot((pEvt.chartX - chart.plotLeft), (pEvt.chartY - chart.plotTop)))) {
  24267. this.runPointActions(pEvt);
  24268. }
  24269. };
  24270. /**
  24271. * @private
  24272. * @function Highcharts.Pointer#onDocumentTouchEnd
  24273. *
  24274. * @param {Highcharts.PointerEventObject} e
  24275. *
  24276. * @return {void}
  24277. */
  24278. Pointer.prototype.onDocumentTouchEnd = function (e) {
  24279. if (charts[H.hoverChartIndex]) {
  24280. charts[H.hoverChartIndex].pointer.drop(e);
  24281. }
  24282. };
  24283. /**
  24284. * @private
  24285. * @function Highcharts.Pointer#onContainerTouchMove
  24286. *
  24287. * @param {Highcharts.PointerEventObject} e
  24288. *
  24289. * @return {void}
  24290. */
  24291. Pointer.prototype.onContainerTouchMove = function (e) {
  24292. this.touch(e);
  24293. };
  24294. /**
  24295. * @private
  24296. * @function Highcharts.Pointer#onContainerTouchStart
  24297. *
  24298. * @param {Highcharts.PointerEventObject} e
  24299. *
  24300. * @return {void}
  24301. */
  24302. Pointer.prototype.onContainerTouchStart = function (e) {
  24303. this.zoomOption(e);
  24304. this.touch(e, true);
  24305. };
  24306. /**
  24307. * Special handler for mouse move that will hide the tooltip when the mouse
  24308. * leaves the plotarea. Issue #149 workaround. The mouseleave event does not
  24309. * always fire.
  24310. *
  24311. * @private
  24312. * @function Highcharts.Pointer#onDocumentMouseMove
  24313. *
  24314. * @param {global.MouseEvent} e
  24315. *
  24316. * @return {void}
  24317. */
  24318. Pointer.prototype.onDocumentMouseMove = function (e) {
  24319. var chart = this.chart;
  24320. var chartPosition = this.chartPosition;
  24321. var pEvt = this.normalize(e,
  24322. chartPosition);
  24323. var tooltip = chart.tooltip;
  24324. // If we're outside, hide the tooltip
  24325. if (chartPosition &&
  24326. (!tooltip ||
  24327. !tooltip.isStickyOnContact()) &&
  24328. !chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop) &&
  24329. !this.inClass(pEvt.target, 'highcharts-tracker')) {
  24330. this.reset();
  24331. }
  24332. };
  24333. /**
  24334. * @private
  24335. * @function Highcharts.Pointer#onDocumentMouseUp
  24336. *
  24337. * @param {global.MouseEvent} e
  24338. *
  24339. * @return {void}
  24340. */
  24341. Pointer.prototype.onDocumentMouseUp = function (e) {
  24342. var chart = charts[pick(H.hoverChartIndex, -1)];
  24343. if (chart) {
  24344. chart.pointer.drop(e);
  24345. }
  24346. };
  24347. /**
  24348. * Handle touch events with two touches
  24349. *
  24350. * @private
  24351. * @function Highcharts.Pointer#pinch
  24352. *
  24353. * @param {Highcharts.PointerEventObject} e
  24354. *
  24355. * @return {void}
  24356. */
  24357. Pointer.prototype.pinch = function (e) {
  24358. var self = this,
  24359. chart = self.chart,
  24360. pinchDown = self.pinchDown,
  24361. touches = (e.touches || []),
  24362. touchesLength = touches.length,
  24363. lastValidTouch = self.lastValidTouch,
  24364. hasZoom = self.hasZoom,
  24365. selectionMarker = self.selectionMarker,
  24366. transform = {},
  24367. fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
  24368. chart.runTrackerClick) ||
  24369. self.runChartClick),
  24370. clip = {};
  24371. // Don't initiate panning until the user has pinched. This prevents us
  24372. // from blocking page scrolling as users scroll down a long page
  24373. // (#4210).
  24374. if (touchesLength > 1) {
  24375. self.initiated = true;
  24376. }
  24377. // On touch devices, only proceed to trigger click if a handler is
  24378. // defined
  24379. if (hasZoom && self.initiated && !fireClickEvent) {
  24380. e.preventDefault();
  24381. }
  24382. // Normalize each touch
  24383. [].map.call(touches, function (e) {
  24384. return self.normalize(e);
  24385. });
  24386. // Register the touch start position
  24387. if (e.type === 'touchstart') {
  24388. [].forEach.call(touches, function (e, i) {
  24389. pinchDown[i] = { chartX: e.chartX, chartY: e.chartY };
  24390. });
  24391. lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] &&
  24392. pinchDown[1].chartX];
  24393. lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] &&
  24394. pinchDown[1].chartY];
  24395. // Identify the data bounds in pixels
  24396. chart.axes.forEach(function (axis) {
  24397. if (axis.zoomEnabled) {
  24398. var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
  24399. minPixelPadding = axis.minPixelPadding,
  24400. min = axis.toPixels(Math.min(pick(axis.options.min,
  24401. axis.dataMin),
  24402. axis.dataMin)),
  24403. max = axis.toPixels(Math.max(pick(axis.options.max,
  24404. axis.dataMax),
  24405. axis.dataMax)),
  24406. absMin = Math.min(min,
  24407. max),
  24408. absMax = Math.max(min,
  24409. max);
  24410. // Store the bounds for use in the touchmove handler
  24411. bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
  24412. bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
  24413. }
  24414. });
  24415. self.res = true; // reset on next move
  24416. // Optionally move the tooltip on touchmove
  24417. }
  24418. else if (self.followTouchMove && touchesLength === 1) {
  24419. this.runPointActions(self.normalize(e));
  24420. // Event type is touchmove, handle panning and pinching
  24421. }
  24422. else if (pinchDown.length) { // can be 0 when releasing, if touchend
  24423. // fires first
  24424. // Set the marker
  24425. if (!selectionMarker) {
  24426. self.selectionMarker = selectionMarker = extend({
  24427. destroy: noop,
  24428. touch: true
  24429. }, chart.plotBox);
  24430. }
  24431. self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  24432. self.hasPinched = hasZoom;
  24433. // Scale and translate the groups to provide visual feedback during
  24434. // pinching
  24435. self.scaleGroups(transform, clip);
  24436. if (self.res) {
  24437. self.res = false;
  24438. this.reset(false, 0);
  24439. }
  24440. }
  24441. };
  24442. /**
  24443. * Run translation operations
  24444. *
  24445. * @private
  24446. * @function Highcharts.Pointer#pinchTranslate
  24447. *
  24448. * @param {Array<*>} pinchDown
  24449. *
  24450. * @param {Array<Highcharts.PointerEventObject>} touches
  24451. *
  24452. * @param {*} transform
  24453. *
  24454. * @param {*} selectionMarker
  24455. *
  24456. * @param {*} clip
  24457. *
  24458. * @param {*} lastValidTouch
  24459. *
  24460. * @return {void}
  24461. */
  24462. Pointer.prototype.pinchTranslate = function (pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  24463. if (this.zoomHor) {
  24464. this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  24465. }
  24466. if (this.zoomVert) {
  24467. this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  24468. }
  24469. };
  24470. /**
  24471. * Run translation operations for each direction (horizontal and vertical)
  24472. * independently.
  24473. *
  24474. * @private
  24475. * @function Highcharts.Pointer#pinchTranslateDirection
  24476. *
  24477. * @param {boolean} horiz
  24478. *
  24479. * @param {Array<*>} pinchDown
  24480. *
  24481. * @param {Array<Highcharts.PointerEventObject>} touches
  24482. *
  24483. * @param {*} transform
  24484. *
  24485. * @param {*} selectionMarker
  24486. *
  24487. * @param {*} clip
  24488. *
  24489. * @param {*} lastValidTouch
  24490. *
  24491. * @param {number|undefined} [forcedScale=1]
  24492. *
  24493. * @return {void}
  24494. */
  24495. Pointer.prototype.pinchTranslateDirection = function (horiz, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, forcedScale) {
  24496. 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 () {
  24497. // Don't zoom if fingers are too close on this axis
  24498. if (typeof touch1Now === 'number' &&
  24499. Math.abs(touch0Start - touch1Start) > 20) {
  24500. scale = forcedScale ||
  24501. Math.abs(touch0Now - touch1Now) /
  24502. Math.abs(touch0Start - touch1Start);
  24503. }
  24504. clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
  24505. selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
  24506. };
  24507. // Set the scale, first pass
  24508. setScale();
  24509. // The clip position (x or y) is altered if out of bounds, the selection
  24510. // position is not
  24511. selectionXY = clipXY;
  24512. // Out of bounds
  24513. if (selectionXY < bounds.min) {
  24514. selectionXY = bounds.min;
  24515. outOfBounds = true;
  24516. }
  24517. else if (selectionXY + selectionWH > bounds.max) {
  24518. selectionXY = bounds.max - selectionWH;
  24519. outOfBounds = true;
  24520. }
  24521. // Is the chart dragged off its bounds, determined by dataMin and
  24522. // dataMax?
  24523. if (outOfBounds) {
  24524. // Modify the touchNow position in order to create an elastic drag
  24525. // movement. This indicates to the user that the chart is responsive
  24526. // but can't be dragged further.
  24527. touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
  24528. if (typeof touch1Now === 'number') {
  24529. touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
  24530. }
  24531. // Set the scale, second pass to adapt to the modified touchNow
  24532. // positions
  24533. setScale();
  24534. }
  24535. else {
  24536. lastValidTouch[xy] = [touch0Now, touch1Now];
  24537. }
  24538. // Set geometry for clipping, selection and transformation
  24539. if (!inverted) {
  24540. clip[xy] = clipXY - plotLeftTop;
  24541. clip[wh] = selectionWH;
  24542. }
  24543. scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
  24544. transformScale = inverted ? 1 / scale : scale;
  24545. selectionMarker[wh] = selectionWH;
  24546. selectionMarker[xy] = selectionXY;
  24547. transform[scaleKey] = scale;
  24548. transform['translate' + XY] = (transformScale * plotLeftTop) +
  24549. (touch0Now - (transformScale * touch0Start));
  24550. };
  24551. /**
  24552. * Reset the tracking by hiding the tooltip, the hover series state and the
  24553. * hover point
  24554. *
  24555. * @function Highcharts.Pointer#reset
  24556. *
  24557. * @param {boolean} [allowMove]
  24558. * Instead of destroying the tooltip altogether, allow moving it if
  24559. * possible.
  24560. *
  24561. * @param {number} [delay]
  24562. *
  24563. * @return {void}
  24564. */
  24565. Pointer.prototype.reset = function (allowMove, delay) {
  24566. var pointer = this,
  24567. chart = pointer.chart,
  24568. hoverSeries = chart.hoverSeries,
  24569. hoverPoint = chart.hoverPoint,
  24570. hoverPoints = chart.hoverPoints,
  24571. tooltip = chart.tooltip,
  24572. tooltipPoints = tooltip && tooltip.shared ?
  24573. hoverPoints :
  24574. hoverPoint;
  24575. // Check if the points have moved outside the plot area (#1003, #4736,
  24576. // #5101)
  24577. if (allowMove && tooltipPoints) {
  24578. splat(tooltipPoints).forEach(function (point) {
  24579. if (point.series.isCartesian &&
  24580. typeof point.plotX === 'undefined') {
  24581. allowMove = false;
  24582. }
  24583. });
  24584. }
  24585. // Just move the tooltip, #349
  24586. if (allowMove) {
  24587. if (tooltip && tooltipPoints && splat(tooltipPoints).length) {
  24588. tooltip.refresh(tooltipPoints);
  24589. if (tooltip.shared && hoverPoints) { // #8284
  24590. hoverPoints.forEach(function (point) {
  24591. point.setState(point.state, true);
  24592. if (point.series.isCartesian) {
  24593. if (point.series.xAxis.crosshair) {
  24594. point.series.xAxis
  24595. .drawCrosshair(null, point);
  24596. }
  24597. if (point.series.yAxis.crosshair) {
  24598. point.series.yAxis
  24599. .drawCrosshair(null, point);
  24600. }
  24601. }
  24602. });
  24603. }
  24604. else if (hoverPoint) { // #2500
  24605. hoverPoint.setState(hoverPoint.state, true);
  24606. chart.axes.forEach(function (axis) {
  24607. if (axis.crosshair &&
  24608. hoverPoint.series[axis.coll] === axis) {
  24609. axis.drawCrosshair(null, hoverPoint);
  24610. }
  24611. });
  24612. }
  24613. }
  24614. // Full reset
  24615. }
  24616. else {
  24617. if (hoverPoint) {
  24618. hoverPoint.onMouseOut();
  24619. }
  24620. if (hoverPoints) {
  24621. hoverPoints.forEach(function (point) {
  24622. point.setState();
  24623. });
  24624. }
  24625. if (hoverSeries) {
  24626. hoverSeries.onMouseOut();
  24627. }
  24628. if (tooltip) {
  24629. tooltip.hide(delay);
  24630. }
  24631. if (pointer.unDocMouseMove) {
  24632. pointer.unDocMouseMove = pointer.unDocMouseMove();
  24633. }
  24634. // Remove crosshairs
  24635. chart.axes.forEach(function (axis) {
  24636. axis.hideCrosshair();
  24637. });
  24638. pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
  24639. }
  24640. };
  24641. /**
  24642. * With line type charts with a single tracker, get the point closest to the
  24643. * mouse. Run Point.onMouseOver and display tooltip for the point or points.
  24644. *
  24645. * @private
  24646. * @function Highcharts.Pointer#runPointActions
  24647. *
  24648. * @param {global.Event} e
  24649. *
  24650. * @param {Highcharts.PointerEventObject} [p]
  24651. *
  24652. * @return {void}
  24653. *
  24654. * @fires Highcharts.Point#event:mouseOut
  24655. * @fires Highcharts.Point#event:mouseOver
  24656. */
  24657. Pointer.prototype.runPointActions = function (e, p) {
  24658. var pointer = this,
  24659. chart = pointer.chart,
  24660. series = chart.series,
  24661. tooltip = (chart.tooltip && chart.tooltip.options.enabled ?
  24662. chart.tooltip :
  24663. void 0),
  24664. shared = (tooltip ?
  24665. tooltip.shared :
  24666. false),
  24667. hoverPoint = p || chart.hoverPoint,
  24668. hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
  24669. // onMouseOver or already hovering a series with directTouch
  24670. isDirectTouch = (!e || e.type !== 'touchmove') && (!!p || ((hoverSeries && hoverSeries.directTouch) &&
  24671. pointer.isDirectTouch)),
  24672. hoverData = this.getHoverData(hoverPoint,
  24673. hoverSeries,
  24674. series,
  24675. isDirectTouch,
  24676. shared,
  24677. e),
  24678. useSharedTooltip,
  24679. followPointer,
  24680. anchor,
  24681. points;
  24682. // Update variables from hoverData.
  24683. hoverPoint = hoverData.hoverPoint;
  24684. points = hoverData.hoverPoints;
  24685. hoverSeries = hoverData.hoverSeries;
  24686. followPointer = hoverSeries && hoverSeries.tooltipOptions.followPointer;
  24687. useSharedTooltip = (shared &&
  24688. hoverSeries &&
  24689. !hoverSeries.noSharedTooltip);
  24690. // Refresh tooltip for kdpoint if new hover point or tooltip was hidden
  24691. // #3926, #4200
  24692. if (hoverPoint &&
  24693. // !(hoverSeries && hoverSeries.directTouch) &&
  24694. (hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))) {
  24695. (chart.hoverPoints || []).forEach(function (p) {
  24696. if (points.indexOf(p) === -1) {
  24697. p.setState();
  24698. }
  24699. });
  24700. // Set normal state to previous series
  24701. if (chart.hoverSeries !== hoverSeries) {
  24702. hoverSeries.onMouseOver();
  24703. }
  24704. pointer.applyInactiveState(points);
  24705. // Do mouseover on all points (#3919, #3985, #4410, #5622)
  24706. (points || []).forEach(function (p) {
  24707. p.setState('hover');
  24708. });
  24709. // If tracking is on series in stead of on each point,
  24710. // fire mouseOver on hover point. // #4448
  24711. if (chart.hoverPoint) {
  24712. chart.hoverPoint.firePointEvent('mouseOut');
  24713. }
  24714. // Hover point may have been destroyed in the event handlers (#7127)
  24715. if (!hoverPoint.series) {
  24716. return;
  24717. }
  24718. /**
  24719. * Contains all hovered points.
  24720. *
  24721. * @name Highcharts.Chart#hoverPoints
  24722. * @type {Array<Highcharts.Point>|null}
  24723. */
  24724. chart.hoverPoints = points;
  24725. /**
  24726. * Contains the original hovered point.
  24727. *
  24728. * @name Highcharts.Chart#hoverPoint
  24729. * @type {Highcharts.Point|null}
  24730. */
  24731. chart.hoverPoint = hoverPoint;
  24732. /**
  24733. * Hover state should not be lost when axis is updated (#12569)
  24734. * Axis.update runs pointer.reset which uses chart.hoverPoint.state
  24735. * to apply state which does not exist in hoverPoint yet.
  24736. * The mouseOver event should be triggered when hoverPoint
  24737. * is correct.
  24738. */
  24739. hoverPoint.firePointEvent('mouseOver');
  24740. // Draw tooltip if necessary
  24741. if (tooltip) {
  24742. tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
  24743. }
  24744. // Update positions (regardless of kdpoint or hoverPoint)
  24745. }
  24746. else if (followPointer && tooltip && !tooltip.isHidden) {
  24747. anchor = tooltip.getAnchor([{}], e);
  24748. tooltip.updatePosition({ plotX: anchor[0], plotY: anchor[1] });
  24749. }
  24750. // Start the event listener to pick up the tooltip and crosshairs
  24751. if (!pointer.unDocMouseMove) {
  24752. pointer.unDocMouseMove = addEvent(chart.container.ownerDocument, 'mousemove', function (e) {
  24753. var chart = charts[H.hoverChartIndex];
  24754. if (chart) {
  24755. chart.pointer.onDocumentMouseMove(e);
  24756. }
  24757. });
  24758. }
  24759. // Issues related to crosshair #4927, #5269 #5066, #5658
  24760. chart.axes.forEach(function drawAxisCrosshair(axis) {
  24761. var snap = pick((axis.crosshair || {}).snap,
  24762. true);
  24763. var point;
  24764. if (snap) {
  24765. point = chart.hoverPoint; // #13002
  24766. if (!point || point.series[axis.coll] !== axis) {
  24767. point = find(points, function (p) {
  24768. return p.series[axis.coll] === axis;
  24769. });
  24770. }
  24771. }
  24772. // Axis has snapping crosshairs, and one of the hover points belongs
  24773. // to axis. Always call drawCrosshair when it is not snap.
  24774. if (point || !snap) {
  24775. axis.drawCrosshair(e, point);
  24776. // Axis has snapping crosshairs, but no hover point belongs to axis
  24777. }
  24778. else {
  24779. axis.hideCrosshair();
  24780. }
  24781. });
  24782. };
  24783. /**
  24784. * Scale series groups to a certain scale and translation.
  24785. *
  24786. * @private
  24787. * @function Highcharts.Pointer#scaleGroups
  24788. *
  24789. * @param {Highcharts.SeriesPlotBoxObject} [attribs]
  24790. *
  24791. * @param {boolean} [clip]
  24792. *
  24793. * @return {void}
  24794. */
  24795. Pointer.prototype.scaleGroups = function (attribs, clip) {
  24796. var chart = this.chart,
  24797. seriesAttribs;
  24798. // Scale each series
  24799. chart.series.forEach(function (series) {
  24800. seriesAttribs = attribs || series.getPlotBox(); // #1701
  24801. if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
  24802. series.group.attr(seriesAttribs);
  24803. if (series.markerGroup) {
  24804. series.markerGroup.attr(seriesAttribs);
  24805. series.markerGroup.clip(clip ? chart.clipRect : null);
  24806. }
  24807. if (series.dataLabelsGroup) {
  24808. series.dataLabelsGroup.attr(seriesAttribs);
  24809. }
  24810. }
  24811. });
  24812. // Clip
  24813. chart.clipRect.attr(clip || chart.clipBox);
  24814. };
  24815. /**
  24816. * Set the JS DOM events on the container and document. This method should
  24817. * contain a one-to-one assignment between methods and their handlers. Any
  24818. * advanced logic should be moved to the handler reflecting the event's
  24819. * name.
  24820. *
  24821. * @private
  24822. * @function Highcharts.Pointer#setDOMEvents
  24823. *
  24824. * @return {void}
  24825. */
  24826. Pointer.prototype.setDOMEvents = function () {
  24827. var container = this.chart.container,
  24828. ownerDoc = container.ownerDocument;
  24829. container.onmousedown = this.onContainerMouseDown.bind(this);
  24830. container.onmousemove = this.onContainerMouseMove.bind(this);
  24831. container.onclick = this.onContainerClick.bind(this);
  24832. this.unbindContainerMouseEnter = addEvent(container, 'mouseenter', this.onContainerMouseEnter.bind(this));
  24833. this.unbindContainerMouseLeave = addEvent(container, 'mouseleave', this.onContainerMouseLeave.bind(this));
  24834. if (!H.unbindDocumentMouseUp) {
  24835. H.unbindDocumentMouseUp = addEvent(ownerDoc, 'mouseup', this.onDocumentMouseUp.bind(this));
  24836. }
  24837. if (H.hasTouch) {
  24838. addEvent(container, 'touchstart', this.onContainerTouchStart.bind(this));
  24839. addEvent(container, 'touchmove', this.onContainerTouchMove.bind(this));
  24840. if (!H.unbindDocumentTouchEnd) {
  24841. H.unbindDocumentTouchEnd = addEvent(ownerDoc, 'touchend', this.onDocumentTouchEnd.bind(this));
  24842. }
  24843. }
  24844. };
  24845. /**
  24846. * Sets the index of the hovered chart and leaves the previous hovered
  24847. * chart, to reset states like tooltip.
  24848. *
  24849. * @private
  24850. * @function Highcharts.Pointer#setHoverChartIndex
  24851. */
  24852. Pointer.prototype.setHoverChartIndex = function () {
  24853. var chart = this.chart;
  24854. var hoverChart = H.charts[pick(H.hoverChartIndex, -1)];
  24855. if (hoverChart &&
  24856. hoverChart !== chart) {
  24857. hoverChart.pointer.onContainerMouseLeave({ relatedTarget: true });
  24858. }
  24859. if (!hoverChart ||
  24860. !hoverChart.mouseIsDown) {
  24861. H.hoverChartIndex = chart.index;
  24862. }
  24863. };
  24864. /**
  24865. * General touch handler shared by touchstart and touchmove.
  24866. *
  24867. * @private
  24868. * @function Highcharts.Pointer#touch
  24869. *
  24870. * @param {Highcharts.PointerEventObject} e
  24871. *
  24872. * @param {boolean} [start]
  24873. *
  24874. * @return {void}
  24875. */
  24876. Pointer.prototype.touch = function (e, start) {
  24877. var chart = this.chart,
  24878. hasMoved,
  24879. pinchDown,
  24880. isInside;
  24881. this.setHoverChartIndex();
  24882. if (e.touches.length === 1) {
  24883. e = this.normalize(e);
  24884. isInside = chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop);
  24885. if (isInside && !chart.openMenu) {
  24886. // Run mouse events and display tooltip etc
  24887. if (start) {
  24888. this.runPointActions(e);
  24889. }
  24890. // Android fires touchmove events after the touchstart even if
  24891. // the finger hasn't moved, or moved only a pixel or two. In iOS
  24892. // however, the touchmove doesn't fire unless the finger moves
  24893. // more than ~4px. So we emulate this behaviour in Android by
  24894. // checking how much it moved, and cancelling on small
  24895. // distances. #3450.
  24896. if (e.type === 'touchmove') {
  24897. pinchDown = this.pinchDown;
  24898. hasMoved = pinchDown[0] ? Math.sqrt(// #5266
  24899. Math.pow(pinchDown[0].chartX - e.chartX, 2) +
  24900. Math.pow(pinchDown[0].chartY - e.chartY, 2)) >= 4 : false;
  24901. }
  24902. if (pick(hasMoved, true)) {
  24903. this.pinch(e);
  24904. }
  24905. }
  24906. else if (start) {
  24907. // Hide the tooltip on touching outside the plot area (#1203)
  24908. this.reset();
  24909. }
  24910. }
  24911. else if (e.touches.length === 2) {
  24912. this.pinch(e);
  24913. }
  24914. };
  24915. /**
  24916. * Resolve the zoomType option, this is reset on all touch start and mouse
  24917. * down events.
  24918. *
  24919. * @private
  24920. * @function Highcharts.Pointer#zoomOption
  24921. *
  24922. * @param {global.Event} e
  24923. * Event object.
  24924. *
  24925. * @param {void}
  24926. */
  24927. Pointer.prototype.zoomOption = function (e) {
  24928. var chart = this.chart,
  24929. options = chart.options.chart,
  24930. zoomType = options.zoomType || '',
  24931. inverted = chart.inverted,
  24932. zoomX,
  24933. zoomY;
  24934. // Look for the pinchType option
  24935. if (/touch/.test(e.type)) {
  24936. zoomType = pick(options.pinchType, zoomType);
  24937. }
  24938. this.zoomX = zoomX = /x/.test(zoomType);
  24939. this.zoomY = zoomY = /y/.test(zoomType);
  24940. this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
  24941. this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
  24942. this.hasZoom = zoomX || zoomY;
  24943. };
  24944. return Pointer;
  24945. }());
  24946. H.Pointer = Pointer;
  24947. return Pointer;
  24948. });
  24949. _registerModule(_modules, 'Core/MSPointer.js', [_modules['Core/Globals.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (H, Pointer, U) {
  24950. /* *
  24951. *
  24952. * (c) 2010-2020 Torstein Honsi
  24953. *
  24954. * License: www.highcharts.com/license
  24955. *
  24956. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  24957. *
  24958. * */
  24959. var __extends = (this && this.__extends) || (function () {
  24960. var extendStatics = function (d,
  24961. b) {
  24962. extendStatics = Object.setPrototypeOf ||
  24963. ({ __proto__: [] } instanceof Array && function (d,
  24964. b) { d.__proto__ = b; }) ||
  24965. function (d,
  24966. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  24967. return extendStatics(d, b);
  24968. };
  24969. return function (d, b) {
  24970. extendStatics(d, b);
  24971. function __() { this.constructor = d; }
  24972. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24973. };
  24974. })();
  24975. var charts = H.charts,
  24976. doc = H.doc,
  24977. noop = H.noop,
  24978. win = H.win;
  24979. var addEvent = U.addEvent,
  24980. css = U.css,
  24981. objectEach = U.objectEach,
  24982. removeEvent = U.removeEvent;
  24983. /* globals MSPointerEvent, PointerEvent */
  24984. // The touches object keeps track of the points being touched at all times
  24985. var touches = {};
  24986. var hasPointerEvent = !!win.PointerEvent;
  24987. /* eslint-disable valid-jsdoc */
  24988. /** @private */
  24989. function getWebkitTouches() {
  24990. var fake = [];
  24991. fake.item = function (i) {
  24992. return this[i];
  24993. };
  24994. objectEach(touches, function (touch) {
  24995. fake.push({
  24996. pageX: touch.pageX,
  24997. pageY: touch.pageY,
  24998. target: touch.target
  24999. });
  25000. });
  25001. return fake;
  25002. }
  25003. /** @private */
  25004. function translateMSPointer(e, method, wktype, func) {
  25005. var p;
  25006. if ((e.pointerType === 'touch' ||
  25007. e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
  25008. func(e);
  25009. p = charts[H.hoverChartIndex].pointer;
  25010. p[method]({
  25011. type: wktype,
  25012. target: e.currentTarget,
  25013. preventDefault: noop,
  25014. touches: getWebkitTouches()
  25015. });
  25016. }
  25017. }
  25018. /** @private */
  25019. var MSPointer = /** @class */ (function (_super) {
  25020. __extends(MSPointer, _super);
  25021. function MSPointer() {
  25022. return _super !== null && _super.apply(this, arguments) || this;
  25023. }
  25024. /* *
  25025. *
  25026. * Functions
  25027. *
  25028. * */
  25029. /**
  25030. * Add or remove the MS Pointer specific events
  25031. *
  25032. * @private
  25033. * @function Highcharts.Pointer#batchMSEvents
  25034. *
  25035. * @param {Function} fn
  25036. *
  25037. * @return {void}
  25038. */
  25039. MSPointer.prototype.batchMSEvents = function (fn) {
  25040. fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
  25041. fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
  25042. fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
  25043. };
  25044. // Destroy MS events also
  25045. MSPointer.prototype.destroy = function () {
  25046. this.batchMSEvents(removeEvent);
  25047. _super.prototype.destroy.call(this);
  25048. };
  25049. // Disable default IE actions for pinch and such on chart element
  25050. MSPointer.prototype.init = function (chart, options) {
  25051. _super.prototype.init.call(this, chart, options);
  25052. if (this.hasZoom) { // #4014
  25053. css(chart.container, {
  25054. '-ms-touch-action': 'none',
  25055. 'touch-action': 'none'
  25056. });
  25057. }
  25058. };
  25059. /**
  25060. * @private
  25061. * @function Highcharts.Pointer#onContainerPointerDown
  25062. *
  25063. * @param {Highcharts.PointerEventObject} e
  25064. *
  25065. * @return {void}
  25066. */
  25067. MSPointer.prototype.onContainerPointerDown = function (e) {
  25068. translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function (e) {
  25069. touches[e.pointerId] = {
  25070. pageX: e.pageX,
  25071. pageY: e.pageY,
  25072. target: e.currentTarget
  25073. };
  25074. });
  25075. };
  25076. /**
  25077. * @private
  25078. * @function Highcharts.Pointer#onContainerPointerMove
  25079. *
  25080. * @param {Highcharts.PointerEventObject} e
  25081. *
  25082. * @return {void}
  25083. */
  25084. MSPointer.prototype.onContainerPointerMove = function (e) {
  25085. translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function (e) {
  25086. touches[e.pointerId] = ({ pageX: e.pageX, pageY: e.pageY });
  25087. if (!touches[e.pointerId].target) {
  25088. touches[e.pointerId].target = e.currentTarget;
  25089. }
  25090. });
  25091. };
  25092. /**
  25093. * @private
  25094. * @function Highcharts.Pointer#onDocumentPointerUp
  25095. *
  25096. * @param {Highcharts.PointerEventObject} e
  25097. *
  25098. * @return {void}
  25099. */
  25100. MSPointer.prototype.onDocumentPointerUp = function (e) {
  25101. translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function (e) {
  25102. delete touches[e.pointerId];
  25103. });
  25104. };
  25105. // Add IE specific touch events to chart
  25106. MSPointer.prototype.setDOMEvents = function () {
  25107. _super.prototype.setDOMEvents.call(this);
  25108. if (this.hasZoom || this.followTouchMove) {
  25109. this.batchMSEvents(addEvent);
  25110. }
  25111. };
  25112. return MSPointer;
  25113. }(Pointer));
  25114. return MSPointer;
  25115. });
  25116. _registerModule(_modules, 'Core/Legend.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  25117. /* *
  25118. *
  25119. * (c) 2010-2020 Torstein Honsi
  25120. *
  25121. * License: www.highcharts.com/license
  25122. *
  25123. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  25124. *
  25125. * */
  25126. /**
  25127. * Gets fired when the legend item belonging to a point is clicked. The default
  25128. * action is to toggle the visibility of the point. This can be prevented by
  25129. * returning `false` or calling `event.preventDefault()`.
  25130. *
  25131. * @callback Highcharts.PointLegendItemClickCallbackFunction
  25132. *
  25133. * @param {Highcharts.Point} this
  25134. * The point on which the event occured.
  25135. *
  25136. * @param {Highcharts.PointLegendItemClickEventObject} event
  25137. * The event that occured.
  25138. */
  25139. /**
  25140. * Information about the legend click event.
  25141. *
  25142. * @interface Highcharts.PointLegendItemClickEventObject
  25143. */ /**
  25144. * Related browser event.
  25145. * @name Highcharts.PointLegendItemClickEventObject#browserEvent
  25146. * @type {Highcharts.PointerEvent}
  25147. */ /**
  25148. * Prevent the default action of toggle the visibility of the point.
  25149. * @name Highcharts.PointLegendItemClickEventObject#preventDefault
  25150. * @type {Function}
  25151. */ /**
  25152. * Related point.
  25153. * @name Highcharts.PointLegendItemClickEventObject#target
  25154. * @type {Highcharts.Point}
  25155. */ /**
  25156. * Event type.
  25157. * @name Highcharts.PointLegendItemClickEventObject#type
  25158. * @type {"legendItemClick"}
  25159. */
  25160. /**
  25161. * Gets fired when the legend item belonging to a series is clicked. The default
  25162. * action is to toggle the visibility of the series. This can be prevented by
  25163. * returning `false` or calling `event.preventDefault()`.
  25164. *
  25165. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  25166. *
  25167. * @param {Highcharts.Series} this
  25168. * The series where the event occured.
  25169. *
  25170. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  25171. * The event that occured.
  25172. */
  25173. /**
  25174. * Information about the legend click event.
  25175. *
  25176. * @interface Highcharts.SeriesLegendItemClickEventObject
  25177. */ /**
  25178. * Related browser event.
  25179. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  25180. * @type {Highcharts.PointerEvent}
  25181. */ /**
  25182. * Prevent the default action of toggle the visibility of the series.
  25183. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  25184. * @type {Function}
  25185. */ /**
  25186. * Related series.
  25187. * @name Highcharts.SeriesLegendItemClickEventObject#target
  25188. * @type {Highcharts.Series}
  25189. */ /**
  25190. * Event type.
  25191. * @name Highcharts.SeriesLegendItemClickEventObject#type
  25192. * @type {"legendItemClick"}
  25193. */
  25194. var addEvent = U.addEvent,
  25195. animObject = U.animObject,
  25196. css = U.css,
  25197. defined = U.defined,
  25198. discardElement = U.discardElement,
  25199. find = U.find,
  25200. fireEvent = U.fireEvent,
  25201. format = U.format,
  25202. isNumber = U.isNumber,
  25203. merge = U.merge,
  25204. pick = U.pick,
  25205. relativeLength = U.relativeLength,
  25206. setAnimation = U.setAnimation,
  25207. stableSort = U.stableSort,
  25208. syncTimeout = U.syncTimeout,
  25209. wrap = U.wrap;
  25210. var isFirefox = H.isFirefox,
  25211. marginNames = H.marginNames,
  25212. win = H.win;
  25213. /* eslint-disable no-invalid-this, valid-jsdoc */
  25214. /**
  25215. * The overview of the chart's series. The legend object is instanciated
  25216. * internally in the chart constructor, and is available from the `chart.legend`
  25217. * property. Each chart has only one legend.
  25218. *
  25219. * @class
  25220. * @name Highcharts.Legend
  25221. *
  25222. * @param {Highcharts.Chart} chart
  25223. * The chart instance.
  25224. *
  25225. * @param {Highcharts.LegendOptions} options
  25226. * Legend options.
  25227. */
  25228. var Legend = /** @class */ (function () {
  25229. /* *
  25230. *
  25231. * Constructors
  25232. *
  25233. * */
  25234. function Legend(chart, options) {
  25235. /* *
  25236. *
  25237. * Properties
  25238. *
  25239. * */
  25240. this.allItems = [];
  25241. this.box = void 0;
  25242. this.contentGroup = void 0;
  25243. this.display = false;
  25244. this.group = void 0;
  25245. this.initialItemY = 0;
  25246. this.itemHeight = 0;
  25247. this.itemMarginBottom = 0;
  25248. this.itemMarginTop = 0;
  25249. this.itemX = 0;
  25250. this.itemY = 0;
  25251. this.lastItemY = 0;
  25252. this.lastLineHeight = 0;
  25253. this.legendHeight = 0;
  25254. this.legendWidth = 0;
  25255. this.maxItemWidth = 0;
  25256. this.maxLegendWidth = 0;
  25257. this.offsetWidth = 0;
  25258. this.options = {};
  25259. this.padding = 0;
  25260. this.pages = [];
  25261. this.proximate = false;
  25262. this.scrollGroup = void 0;
  25263. this.symbolHeight = 0;
  25264. this.symbolWidth = 0;
  25265. this.titleHeight = 0;
  25266. this.totalItemWidth = 0;
  25267. this.widthOption = 0;
  25268. this.chart = chart;
  25269. this.init(chart, options);
  25270. }
  25271. /* *
  25272. *
  25273. * Functions
  25274. *
  25275. * */
  25276. /**
  25277. * Initialize the legend.
  25278. *
  25279. * @private
  25280. * @function Highcharts.Legend#init
  25281. *
  25282. * @param {Highcharts.Chart} chart
  25283. * The chart instance.
  25284. *
  25285. * @param {Highcharts.LegendOptions} options
  25286. * Legend options.
  25287. */
  25288. Legend.prototype.init = function (chart, options) {
  25289. /**
  25290. * Chart of this legend.
  25291. *
  25292. * @readonly
  25293. * @name Highcharts.Legend#chart
  25294. * @type {Highcharts.Chart}
  25295. */
  25296. this.chart = chart;
  25297. this.setOptions(options);
  25298. if (options.enabled) {
  25299. // Render it
  25300. this.render();
  25301. // move checkboxes
  25302. addEvent(this.chart, 'endResize', function () {
  25303. this.legend.positionCheckboxes();
  25304. });
  25305. if (this.proximate) {
  25306. this.unchartrender = addEvent(this.chart, 'render', function () {
  25307. this.legend.proximatePositions();
  25308. this.legend.positionItems();
  25309. });
  25310. }
  25311. else if (this.unchartrender) {
  25312. this.unchartrender();
  25313. }
  25314. }
  25315. };
  25316. /**
  25317. * @private
  25318. * @function Highcharts.Legend#setOptions
  25319. * @param {Highcharts.LegendOptions} options
  25320. */
  25321. Legend.prototype.setOptions = function (options) {
  25322. var padding = pick(options.padding, 8);
  25323. /**
  25324. * Legend options.
  25325. *
  25326. * @readonly
  25327. * @name Highcharts.Legend#options
  25328. * @type {Highcharts.LegendOptions}
  25329. */
  25330. this.options = options;
  25331. if (!this.chart.styledMode) {
  25332. this.itemStyle = options.itemStyle;
  25333. this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
  25334. }
  25335. this.itemMarginTop = options.itemMarginTop || 0;
  25336. this.itemMarginBottom = options.itemMarginBottom || 0;
  25337. this.padding = padding;
  25338. this.initialItemY = padding - 5; // 5 is pixels above the text
  25339. this.symbolWidth = pick(options.symbolWidth, 16);
  25340. this.pages = [];
  25341. this.proximate = options.layout === 'proximate' && !this.chart.inverted;
  25342. this.baseline = void 0; // #12705: baseline has to be reset on every update
  25343. };
  25344. /**
  25345. * Update the legend with new options. Equivalent to running `chart.update`
  25346. * with a legend configuration option.
  25347. *
  25348. * @sample highcharts/legend/legend-update/
  25349. * Legend update
  25350. *
  25351. * @function Highcharts.Legend#update
  25352. *
  25353. * @param {Highcharts.LegendOptions} options
  25354. * Legend options.
  25355. *
  25356. * @param {boolean} [redraw=true]
  25357. * Whether to redraw the chart after the axis is altered. If doing more
  25358. * operations on the chart, it is a good idea to set redraw to false and
  25359. * call {@link Chart#redraw} after. Whether to redraw the chart.
  25360. *
  25361. * @fires Highcharts.Legends#event:afterUpdate
  25362. */
  25363. Legend.prototype.update = function (options, redraw) {
  25364. var chart = this.chart;
  25365. this.setOptions(merge(true, this.options, options));
  25366. this.destroy();
  25367. chart.isDirtyLegend = chart.isDirtyBox = true;
  25368. if (pick(redraw, true)) {
  25369. chart.redraw();
  25370. }
  25371. fireEvent(this, 'afterUpdate');
  25372. };
  25373. /**
  25374. * Set the colors for the legend item.
  25375. *
  25376. * @private
  25377. * @function Highcharts.Legend#colorizeItem
  25378. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25379. * A Series or Point instance
  25380. * @param {boolean} [visible=false]
  25381. * Dimmed or colored
  25382. *
  25383. * @todo
  25384. * Make events official: Fires the event `afterColorizeItem`.
  25385. */
  25386. Legend.prototype.colorizeItem = function (item, visible) {
  25387. item.legendGroup[visible ? 'removeClass' : 'addClass']('highcharts-legend-item-hidden');
  25388. if (!this.chart.styledMode) {
  25389. var legend = this,
  25390. options = legend.options,
  25391. legendItem = item.legendItem,
  25392. legendLine = item.legendLine,
  25393. legendSymbol = item.legendSymbol,
  25394. hiddenColor = legend.itemHiddenStyle.color,
  25395. textColor = visible ?
  25396. options.itemStyle.color :
  25397. hiddenColor,
  25398. symbolColor = visible ?
  25399. (item.color || hiddenColor) :
  25400. hiddenColor,
  25401. markerOptions = item.options && item.options.marker,
  25402. symbolAttr = { fill: symbolColor };
  25403. if (legendItem) {
  25404. legendItem.css({
  25405. fill: textColor,
  25406. color: textColor // #1553, oldIE
  25407. });
  25408. }
  25409. if (legendLine) {
  25410. legendLine.attr({ stroke: symbolColor });
  25411. }
  25412. if (legendSymbol) {
  25413. // Apply marker options
  25414. if (markerOptions && legendSymbol.isMarker) { // #585
  25415. symbolAttr = item.pointAttribs();
  25416. if (!visible) {
  25417. // #6769
  25418. symbolAttr.stroke = symbolAttr.fill = hiddenColor;
  25419. }
  25420. }
  25421. legendSymbol.attr(symbolAttr);
  25422. }
  25423. }
  25424. fireEvent(this, 'afterColorizeItem', { item: item, visible: visible });
  25425. };
  25426. /**
  25427. * @private
  25428. * @function Highcharts.Legend#positionItems
  25429. */
  25430. Legend.prototype.positionItems = function () {
  25431. // Now that the legend width and height are established, put the items
  25432. // in the final position
  25433. this.allItems.forEach(this.positionItem, this);
  25434. if (!this.chart.isResizing) {
  25435. this.positionCheckboxes();
  25436. }
  25437. };
  25438. /**
  25439. * Position the legend item.
  25440. *
  25441. * @private
  25442. * @function Highcharts.Legend#positionItem
  25443. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25444. * The item to position
  25445. */
  25446. Legend.prototype.positionItem = function (item) {
  25447. var _this = this;
  25448. var legend = this,
  25449. options = legend.options,
  25450. symbolPadding = options.symbolPadding,
  25451. ltr = !options.rtl,
  25452. legendItemPos = item._legendItemPos,
  25453. itemX = legendItemPos[0],
  25454. itemY = legendItemPos[1],
  25455. checkbox = item.checkbox,
  25456. legendGroup = item.legendGroup;
  25457. if (legendGroup && legendGroup.element) {
  25458. var attribs = {
  25459. translateX: ltr ?
  25460. itemX :
  25461. legend.legendWidth - itemX - 2 * symbolPadding - 4,
  25462. translateY: itemY
  25463. };
  25464. var complete = function () {
  25465. fireEvent(_this, 'afterPositionItem', { item: item });
  25466. };
  25467. if (defined(legendGroup.translateY)) {
  25468. legendGroup.animate(attribs, void 0, complete);
  25469. }
  25470. else {
  25471. legendGroup.attr(attribs);
  25472. complete();
  25473. }
  25474. }
  25475. if (checkbox) {
  25476. checkbox.x = itemX;
  25477. checkbox.y = itemY;
  25478. }
  25479. };
  25480. /**
  25481. * Destroy a single legend item, used internally on removing series items.
  25482. *
  25483. * @private
  25484. * @function Highcharts.Legend#destroyItem
  25485. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25486. * The item to remove
  25487. */
  25488. Legend.prototype.destroyItem = function (item) {
  25489. var checkbox = item.checkbox;
  25490. // destroy SVG elements
  25491. ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(function (key) {
  25492. if (item[key]) {
  25493. item[key] = item[key].destroy();
  25494. }
  25495. });
  25496. if (checkbox) {
  25497. discardElement(item.checkbox);
  25498. }
  25499. };
  25500. /**
  25501. * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
  25502. * must be called after destruction.
  25503. *
  25504. * @private
  25505. * @function Highcharts.Legend#destroy
  25506. */
  25507. Legend.prototype.destroy = function () {
  25508. /**
  25509. * @private
  25510. * @param {string} key
  25511. * @return {void}
  25512. */
  25513. function destroyItems(key) {
  25514. if (this[key]) {
  25515. this[key] = this[key].destroy();
  25516. }
  25517. }
  25518. // Destroy items
  25519. this.getAllItems().forEach(function (item) {
  25520. ['legendItem', 'legendGroup'].forEach(destroyItems, item);
  25521. });
  25522. // Destroy legend elements
  25523. [
  25524. 'clipRect',
  25525. 'up',
  25526. 'down',
  25527. 'pager',
  25528. 'nav',
  25529. 'box',
  25530. 'title',
  25531. 'group'
  25532. ].forEach(destroyItems, this);
  25533. this.display = null; // Reset in .render on update.
  25534. };
  25535. /**
  25536. * Position the checkboxes after the width is determined.
  25537. *
  25538. * @private
  25539. * @function Highcharts.Legend#positionCheckboxes
  25540. */
  25541. Legend.prototype.positionCheckboxes = function () {
  25542. var alignAttr = this.group && this.group.alignAttr,
  25543. translateY,
  25544. clipHeight = this.clipHeight || this.legendHeight,
  25545. titleHeight = this.titleHeight;
  25546. if (alignAttr) {
  25547. translateY = alignAttr.translateY;
  25548. this.allItems.forEach(function (item) {
  25549. var checkbox = item.checkbox,
  25550. top;
  25551. if (checkbox) {
  25552. top = translateY + titleHeight + checkbox.y +
  25553. (this.scrollOffset || 0) + 3;
  25554. css(checkbox, {
  25555. left: (alignAttr.translateX + item.checkboxOffset +
  25556. checkbox.x - 20) + 'px',
  25557. top: top + 'px',
  25558. display: this.proximate || (top > translateY - 6 &&
  25559. top < translateY + clipHeight - 6) ?
  25560. '' :
  25561. 'none'
  25562. });
  25563. }
  25564. }, this);
  25565. }
  25566. };
  25567. /**
  25568. * Render the legend title on top of the legend.
  25569. *
  25570. * @private
  25571. * @function Highcharts.Legend#renderTitle
  25572. */
  25573. Legend.prototype.renderTitle = function () {
  25574. var options = this.options,
  25575. padding = this.padding,
  25576. titleOptions = options.title,
  25577. titleHeight = 0,
  25578. bBox;
  25579. if (titleOptions.text) {
  25580. if (!this.title) {
  25581. /**
  25582. * SVG element of the legend title.
  25583. *
  25584. * @readonly
  25585. * @name Highcharts.Legend#title
  25586. * @type {Highcharts.SVGElement}
  25587. */
  25588. this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, options.useHTML, null, 'legend-title')
  25589. .attr({ zIndex: 1 });
  25590. if (!this.chart.styledMode) {
  25591. this.title.css(titleOptions.style);
  25592. }
  25593. this.title.add(this.group);
  25594. }
  25595. // Set the max title width (#7253)
  25596. if (!titleOptions.width) {
  25597. this.title.css({
  25598. width: this.maxLegendWidth + 'px'
  25599. });
  25600. }
  25601. bBox = this.title.getBBox();
  25602. titleHeight = bBox.height;
  25603. this.offsetWidth = bBox.width; // #1717
  25604. this.contentGroup.attr({ translateY: titleHeight });
  25605. }
  25606. this.titleHeight = titleHeight;
  25607. };
  25608. /**
  25609. * Set the legend item text.
  25610. *
  25611. * @function Highcharts.Legend#setText
  25612. * @param {Highcharts.Point|Highcharts.Series} item
  25613. * The item for which to update the text in the legend.
  25614. */
  25615. Legend.prototype.setText = function (item) {
  25616. var options = this.options;
  25617. item.legendItem.attr({
  25618. text: options.labelFormat ?
  25619. format(options.labelFormat, item, this.chart) :
  25620. options.labelFormatter.call(item)
  25621. });
  25622. };
  25623. /**
  25624. * Render a single specific legend item. Called internally from the `render`
  25625. * function.
  25626. *
  25627. * @private
  25628. * @function Highcharts.Legend#renderItem
  25629. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25630. * The item to render.
  25631. */
  25632. Legend.prototype.renderItem = function (item) {
  25633. var legend = this,
  25634. chart = legend.chart,
  25635. renderer = chart.renderer,
  25636. options = legend.options,
  25637. horizontal = options.layout === 'horizontal',
  25638. symbolWidth = legend.symbolWidth,
  25639. symbolPadding = options.symbolPadding,
  25640. itemStyle = legend.itemStyle,
  25641. itemHiddenStyle = legend.itemHiddenStyle,
  25642. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  25643. ltr = !options.rtl,
  25644. bBox,
  25645. li = item.legendItem,
  25646. isSeries = !item.series,
  25647. series = !isSeries && item.series.drawLegendSymbol ?
  25648. item.series :
  25649. item,
  25650. seriesOptions = series.options,
  25651. showCheckbox = legend.createCheckboxForItem &&
  25652. seriesOptions &&
  25653. seriesOptions.showCheckbox,
  25654. // full width minus text width
  25655. itemExtraWidth = symbolWidth + symbolPadding +
  25656. itemDistance + (showCheckbox ? 20 : 0),
  25657. useHTML = options.useHTML,
  25658. itemClassName = item.options.className;
  25659. if (!li) { // generate it once, later move it
  25660. // Generate the group box, a group to hold the symbol and text. Text
  25661. // is to be appended in Legend class.
  25662. item.legendGroup = renderer
  25663. .g('legend-item')
  25664. .addClass('highcharts-' + series.type + '-series ' +
  25665. 'highcharts-color-' + item.colorIndex +
  25666. (itemClassName ? ' ' + itemClassName : '') +
  25667. (isSeries ?
  25668. ' highcharts-series-' + item.index :
  25669. ''))
  25670. .attr({ zIndex: 1 })
  25671. .add(legend.scrollGroup);
  25672. // Generate the list item text and add it to the group
  25673. item.legendItem = li = renderer.text('', ltr ?
  25674. symbolWidth + symbolPadding :
  25675. -symbolPadding, legend.baseline || 0, useHTML);
  25676. if (!chart.styledMode) {
  25677. // merge to prevent modifying original (#1021)
  25678. li.css(merge(item.visible ?
  25679. itemStyle :
  25680. itemHiddenStyle));
  25681. }
  25682. li
  25683. .attr({
  25684. align: ltr ? 'left' : 'right',
  25685. zIndex: 2
  25686. })
  25687. .add(item.legendGroup);
  25688. // Get the baseline for the first item - the font size is equal for
  25689. // all
  25690. if (!legend.baseline) {
  25691. legend.fontMetrics = renderer.fontMetrics(chart.styledMode ? 12 : itemStyle.fontSize, li);
  25692. legend.baseline =
  25693. legend.fontMetrics.f + 3 + legend.itemMarginTop;
  25694. li.attr('y', legend.baseline);
  25695. }
  25696. // Draw the legend symbol inside the group box
  25697. legend.symbolHeight =
  25698. options.symbolHeight || legend.fontMetrics.f;
  25699. series.drawLegendSymbol(legend, item);
  25700. if (legend.setItemEvents) {
  25701. legend.setItemEvents(item, li, useHTML);
  25702. }
  25703. }
  25704. // Add the HTML checkbox on top
  25705. if (showCheckbox && !item.checkbox && legend.createCheckboxForItem) {
  25706. legend.createCheckboxForItem(item);
  25707. }
  25708. // Colorize the items
  25709. legend.colorizeItem(item, item.visible);
  25710. // Take care of max width and text overflow (#6659)
  25711. if (chart.styledMode || !itemStyle.width) {
  25712. li.css({
  25713. width: ((options.itemWidth ||
  25714. legend.widthOption ||
  25715. chart.spacingBox.width) - itemExtraWidth) + 'px'
  25716. });
  25717. }
  25718. // Always update the text
  25719. legend.setText(item);
  25720. // calculate the positions for the next line
  25721. bBox = li.getBBox();
  25722. item.itemWidth = item.checkboxOffset =
  25723. options.itemWidth ||
  25724. item.legendItemWidth ||
  25725. bBox.width + itemExtraWidth;
  25726. legend.maxItemWidth = Math.max(legend.maxItemWidth, item.itemWidth);
  25727. legend.totalItemWidth += item.itemWidth;
  25728. legend.itemHeight = item.itemHeight = Math.round(item.legendItemHeight || bBox.height || legend.symbolHeight);
  25729. };
  25730. /**
  25731. * Get the position of the item in the layout. We now know the
  25732. * maxItemWidth from the previous loop.
  25733. *
  25734. * @private
  25735. * @function Highcharts.Legend#layoutItem
  25736. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25737. */
  25738. Legend.prototype.layoutItem = function (item) {
  25739. var options = this.options,
  25740. padding = this.padding,
  25741. horizontal = options.layout === 'horizontal',
  25742. itemHeight = item.itemHeight,
  25743. itemMarginBottom = this.itemMarginBottom,
  25744. itemMarginTop = this.itemMarginTop,
  25745. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  25746. maxLegendWidth = this.maxLegendWidth,
  25747. itemWidth = (options.alignColumns &&
  25748. this.totalItemWidth > maxLegendWidth) ?
  25749. this.maxItemWidth :
  25750. item.itemWidth;
  25751. // If the item exceeds the width, start a new line
  25752. if (horizontal &&
  25753. this.itemX - padding + itemWidth > maxLegendWidth) {
  25754. this.itemX = padding;
  25755. if (this.lastLineHeight) { // Not for the first line (#10167)
  25756. this.itemY += (itemMarginTop +
  25757. this.lastLineHeight +
  25758. itemMarginBottom);
  25759. }
  25760. this.lastLineHeight = 0; // reset for next line (#915, #3976)
  25761. }
  25762. // Set the edge positions
  25763. this.lastItemY = itemMarginTop + this.itemY + itemMarginBottom;
  25764. this.lastLineHeight = Math.max(// #915
  25765. itemHeight, this.lastLineHeight);
  25766. // cache the position of the newly generated or reordered items
  25767. item._legendItemPos = [this.itemX, this.itemY];
  25768. // advance
  25769. if (horizontal) {
  25770. this.itemX += itemWidth;
  25771. }
  25772. else {
  25773. this.itemY +=
  25774. itemMarginTop + itemHeight + itemMarginBottom;
  25775. this.lastLineHeight = itemHeight;
  25776. }
  25777. // the width of the widest item
  25778. this.offsetWidth = this.widthOption || Math.max((horizontal ? this.itemX - padding - (item.checkbox ?
  25779. // decrease by itemDistance only when no checkbox #4853
  25780. 0 :
  25781. itemDistance) : itemWidth) + padding, this.offsetWidth);
  25782. };
  25783. /**
  25784. * Get all items, which is one item per series for most series and one
  25785. * item per point for pie series and its derivatives. Fires the event
  25786. * `afterGetAllItems`.
  25787. *
  25788. * @private
  25789. * @function Highcharts.Legend#getAllItems
  25790. * @return {Array<(Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series)>}
  25791. * The current items in the legend.
  25792. * @fires Highcharts.Legend#event:afterGetAllItems
  25793. */
  25794. Legend.prototype.getAllItems = function () {
  25795. var allItems = [];
  25796. this.chart.series.forEach(function (series) {
  25797. var seriesOptions = series && series.options;
  25798. // Handle showInLegend. If the series is linked to another series,
  25799. // defaults to false.
  25800. if (series && pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? void 0 : false, true)) {
  25801. // Use points or series for the legend item depending on
  25802. // legendType
  25803. allItems = allItems.concat(series.legendItems ||
  25804. (seriesOptions.legendType === 'point' ?
  25805. series.data :
  25806. series));
  25807. }
  25808. });
  25809. fireEvent(this, 'afterGetAllItems', { allItems: allItems });
  25810. return allItems;
  25811. };
  25812. /**
  25813. * Get a short, three letter string reflecting the alignment and layout.
  25814. *
  25815. * @private
  25816. * @function Highcharts.Legend#getAlignment
  25817. * @return {string}
  25818. * The alignment, empty string if floating
  25819. */
  25820. Legend.prototype.getAlignment = function () {
  25821. var options = this.options;
  25822. // Use the first letter of each alignment option in order to detect
  25823. // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
  25824. if (this.proximate) {
  25825. return options.align.charAt(0) + 'tv';
  25826. }
  25827. return options.floating ? '' : (options.align.charAt(0) +
  25828. options.verticalAlign.charAt(0) +
  25829. options.layout.charAt(0));
  25830. };
  25831. /**
  25832. * Adjust the chart margins by reserving space for the legend on only one
  25833. * side of the chart. If the position is set to a corner, top or bottom is
  25834. * reserved for horizontal legends and left or right for vertical ones.
  25835. *
  25836. * @private
  25837. * @function Highcharts.Legend#adjustMargins
  25838. * @param {Array<number>} margin
  25839. * @param {Array<number>} spacing
  25840. */
  25841. Legend.prototype.adjustMargins = function (margin, spacing) {
  25842. var chart = this.chart,
  25843. options = this.options,
  25844. alignment = this.getAlignment();
  25845. if (alignment) {
  25846. ([
  25847. /(lth|ct|rth)/,
  25848. /(rtv|rm|rbv)/,
  25849. /(rbh|cb|lbh)/,
  25850. /(lbv|lm|ltv)/
  25851. ]).forEach(function (alignments, side) {
  25852. if (alignments.test(alignment) && !defined(margin[side])) {
  25853. // Now we have detected on which side of the chart we should
  25854. // reserve space for the legend
  25855. chart[marginNames[side]] = Math.max(chart[marginNames[side]], (chart.legend[(side + 1) % 2 ? 'legendHeight' : 'legendWidth'] +
  25856. [1, -1, -1, 1][side] * options[(side % 2) ? 'x' : 'y'] +
  25857. pick(options.margin, 12) +
  25858. spacing[side] +
  25859. (chart.titleOffset[side] || 0)));
  25860. }
  25861. });
  25862. }
  25863. };
  25864. /**
  25865. * @private
  25866. * @function Highcharts.Legend#proximatePositions
  25867. */
  25868. Legend.prototype.proximatePositions = function () {
  25869. var chart = this.chart,
  25870. boxes = [],
  25871. alignLeft = this.options.align === 'left';
  25872. this.allItems.forEach(function (item) {
  25873. var lastPoint,
  25874. height,
  25875. useFirstPoint = alignLeft,
  25876. target,
  25877. top;
  25878. if (item.yAxis) {
  25879. if (item.xAxis.options.reversed) {
  25880. useFirstPoint = !useFirstPoint;
  25881. }
  25882. if (item.points) {
  25883. lastPoint = find(useFirstPoint ?
  25884. item.points :
  25885. item.points.slice(0).reverse(), function (item) {
  25886. return isNumber(item.plotY);
  25887. });
  25888. }
  25889. height = this.itemMarginTop +
  25890. item.legendItem.getBBox().height +
  25891. this.itemMarginBottom;
  25892. top = item.yAxis.top - chart.plotTop;
  25893. if (item.visible) {
  25894. target = lastPoint ?
  25895. lastPoint.plotY :
  25896. item.yAxis.height;
  25897. target += top - 0.3 * height;
  25898. }
  25899. else {
  25900. target = top + item.yAxis.height;
  25901. }
  25902. boxes.push({
  25903. target: target,
  25904. size: height,
  25905. item: item
  25906. });
  25907. }
  25908. }, this);
  25909. H.distribute(boxes, chart.plotHeight);
  25910. boxes.forEach(function (box) {
  25911. box.item._legendItemPos[1] =
  25912. chart.plotTop - chart.spacing[0] + box.pos;
  25913. });
  25914. };
  25915. /**
  25916. * Render the legend. This method can be called both before and after
  25917. * `chart.render`. If called after, it will only rearrange items instead
  25918. * of creating new ones. Called internally on initial render and after
  25919. * redraws.
  25920. *
  25921. * @private
  25922. * @function Highcharts.Legend#render
  25923. */
  25924. Legend.prototype.render = function () {
  25925. var legend = this,
  25926. chart = legend.chart,
  25927. renderer = chart.renderer,
  25928. legendGroup = legend.group,
  25929. allItems,
  25930. display,
  25931. legendWidth,
  25932. legendHeight,
  25933. box = legend.box,
  25934. options = legend.options,
  25935. padding = legend.padding,
  25936. allowedWidth;
  25937. legend.itemX = padding;
  25938. legend.itemY = legend.initialItemY;
  25939. legend.offsetWidth = 0;
  25940. legend.lastItemY = 0;
  25941. legend.widthOption = relativeLength(options.width, chart.spacingBox.width - padding);
  25942. // Compute how wide the legend is allowed to be
  25943. allowedWidth =
  25944. chart.spacingBox.width - 2 * padding - options.x;
  25945. if (['rm', 'lm'].indexOf(legend.getAlignment().substring(0, 2)) > -1) {
  25946. allowedWidth /= 2;
  25947. }
  25948. legend.maxLegendWidth = legend.widthOption || allowedWidth;
  25949. if (!legendGroup) {
  25950. /**
  25951. * SVG group of the legend.
  25952. *
  25953. * @readonly
  25954. * @name Highcharts.Legend#group
  25955. * @type {Highcharts.SVGElement}
  25956. */
  25957. legend.group = legendGroup = renderer.g('legend')
  25958. .attr({ zIndex: 7 })
  25959. .add();
  25960. legend.contentGroup = renderer.g()
  25961. .attr({ zIndex: 1 }) // above background
  25962. .add(legendGroup);
  25963. legend.scrollGroup = renderer.g()
  25964. .add(legend.contentGroup);
  25965. }
  25966. legend.renderTitle();
  25967. // add each series or point
  25968. allItems = legend.getAllItems();
  25969. // sort by legendIndex
  25970. stableSort(allItems, function (a, b) {
  25971. return ((a.options && a.options.legendIndex) || 0) -
  25972. ((b.options && b.options.legendIndex) || 0);
  25973. });
  25974. // reversed legend
  25975. if (options.reversed) {
  25976. allItems.reverse();
  25977. }
  25978. /**
  25979. * All items for the legend, which is an array of series for most series
  25980. * and an array of points for pie series and its derivatives.
  25981. *
  25982. * @readonly
  25983. * @name Highcharts.Legend#allItems
  25984. * @type {Array<(Highcharts.Point|Highcharts.Series)>}
  25985. */
  25986. legend.allItems = allItems;
  25987. legend.display = display = !!allItems.length;
  25988. // Render the items. First we run a loop to set the text and properties
  25989. // and read all the bounding boxes. The next loop computes the item
  25990. // positions based on the bounding boxes.
  25991. legend.lastLineHeight = 0;
  25992. legend.maxItemWidth = 0;
  25993. legend.totalItemWidth = 0;
  25994. legend.itemHeight = 0;
  25995. allItems.forEach(legend.renderItem, legend);
  25996. allItems.forEach(legend.layoutItem, legend);
  25997. // Get the box
  25998. legendWidth = (legend.widthOption || legend.offsetWidth) + padding;
  25999. legendHeight = legend.lastItemY + legend.lastLineHeight +
  26000. legend.titleHeight;
  26001. legendHeight = legend.handleOverflow(legendHeight);
  26002. legendHeight += padding;
  26003. // Draw the border and/or background
  26004. if (!box) {
  26005. /**
  26006. * SVG element of the legend box.
  26007. *
  26008. * @readonly
  26009. * @name Highcharts.Legend#box
  26010. * @type {Highcharts.SVGElement}
  26011. */
  26012. legend.box = box = renderer.rect()
  26013. .addClass('highcharts-legend-box')
  26014. .attr({
  26015. r: options.borderRadius
  26016. })
  26017. .add(legendGroup);
  26018. box.isNew = true;
  26019. }
  26020. // Presentational
  26021. if (!chart.styledMode) {
  26022. box
  26023. .attr({
  26024. stroke: options.borderColor,
  26025. 'stroke-width': options.borderWidth || 0,
  26026. fill: options.backgroundColor || 'none'
  26027. })
  26028. .shadow(options.shadow);
  26029. }
  26030. if (legendWidth > 0 && legendHeight > 0) {
  26031. box[box.isNew ? 'attr' : 'animate'](box.crisp.call({}, {
  26032. x: 0,
  26033. y: 0,
  26034. width: legendWidth,
  26035. height: legendHeight
  26036. }, box.strokeWidth()));
  26037. box.isNew = false;
  26038. }
  26039. // hide the border if no items
  26040. box[display ? 'show' : 'hide']();
  26041. // Open for responsiveness
  26042. if (chart.styledMode && legendGroup.getStyle('display') === 'none') {
  26043. legendWidth = legendHeight = 0;
  26044. }
  26045. legend.legendWidth = legendWidth;
  26046. legend.legendHeight = legendHeight;
  26047. if (display) {
  26048. legend.align();
  26049. }
  26050. if (!this.proximate) {
  26051. this.positionItems();
  26052. }
  26053. fireEvent(this, 'afterRender');
  26054. };
  26055. /**
  26056. * Align the legend to chart's box.
  26057. *
  26058. * @private
  26059. * @function Highcharts.align
  26060. * @param {Highcharts.BBoxObject} alignTo
  26061. * @return {void}
  26062. */
  26063. Legend.prototype.align = function (alignTo) {
  26064. if (alignTo === void 0) { alignTo = this.chart.spacingBox; }
  26065. var chart = this.chart,
  26066. options = this.options;
  26067. // If aligning to the top and the layout is horizontal, adjust for
  26068. // the title (#7428)
  26069. var y = alignTo.y;
  26070. if (/(lth|ct|rth)/.test(this.getAlignment()) &&
  26071. chart.titleOffset[0] > 0) {
  26072. y += chart.titleOffset[0];
  26073. }
  26074. else if (/(lbh|cb|rbh)/.test(this.getAlignment()) &&
  26075. chart.titleOffset[2] > 0) {
  26076. y -= chart.titleOffset[2];
  26077. }
  26078. if (y !== alignTo.y) {
  26079. alignTo = merge(alignTo, { y: y });
  26080. }
  26081. this.group.align(merge(options, {
  26082. width: this.legendWidth,
  26083. height: this.legendHeight,
  26084. verticalAlign: this.proximate ? 'top' : options.verticalAlign
  26085. }), true, alignTo);
  26086. };
  26087. /**
  26088. * Set up the overflow handling by adding navigation with up and down arrows
  26089. * below the legend.
  26090. *
  26091. * @private
  26092. * @function Highcharts.Legend#handleOverflow
  26093. * @param {number} legendHeight
  26094. * @return {number}
  26095. */
  26096. Legend.prototype.handleOverflow = function (legendHeight) {
  26097. var legend = this,
  26098. chart = this.chart,
  26099. renderer = chart.renderer,
  26100. options = this.options,
  26101. optionsY = options.y,
  26102. alignTop = options.verticalAlign === 'top',
  26103. padding = this.padding,
  26104. spaceHeight = (chart.spacingBox.height +
  26105. (alignTop ? -optionsY : optionsY) - padding),
  26106. maxHeight = options.maxHeight,
  26107. clipHeight,
  26108. clipRect = this.clipRect,
  26109. navOptions = options.navigation,
  26110. animation = pick(navOptions.animation,
  26111. true),
  26112. arrowSize = navOptions.arrowSize || 12,
  26113. nav = this.nav,
  26114. pages = this.pages,
  26115. lastY,
  26116. allItems = this.allItems,
  26117. clipToHeight = function (height) {
  26118. if (typeof height === 'number') {
  26119. clipRect.attr({
  26120. height: height
  26121. });
  26122. }
  26123. else if (clipRect) { // Reset (#5912)
  26124. legend.clipRect = clipRect.destroy();
  26125. legend.contentGroup.clip();
  26126. }
  26127. // useHTML
  26128. if (legend.contentGroup.div) {
  26129. legend.contentGroup.div.style.clip = height ?
  26130. 'rect(' + padding + 'px,9999px,' +
  26131. (padding + height) + 'px,0)' :
  26132. 'auto';
  26133. }
  26134. }, addTracker = function (key) {
  26135. legend[key] = renderer
  26136. .circle(0, 0, arrowSize * 1.3)
  26137. .translate(arrowSize / 2, arrowSize / 2)
  26138. .add(nav);
  26139. if (!chart.styledMode) {
  26140. legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
  26141. }
  26142. return legend[key];
  26143. };
  26144. // Adjust the height
  26145. if (options.layout === 'horizontal' &&
  26146. options.verticalAlign !== 'middle' &&
  26147. !options.floating) {
  26148. spaceHeight /= 2;
  26149. }
  26150. if (maxHeight) {
  26151. spaceHeight = Math.min(spaceHeight, maxHeight);
  26152. }
  26153. // Reset the legend height and adjust the clipping rectangle
  26154. pages.length = 0;
  26155. if (legendHeight > spaceHeight &&
  26156. navOptions.enabled !== false) {
  26157. this.clipHeight = clipHeight =
  26158. Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
  26159. this.currentPage = pick(this.currentPage, 1);
  26160. this.fullHeight = legendHeight;
  26161. // Fill pages with Y positions so that the top of each a legend item
  26162. // defines the scroll top for each page (#2098)
  26163. allItems.forEach(function (item, i) {
  26164. var y = item._legendItemPos[1],
  26165. h = Math.round(item.legendItem.getBBox().height),
  26166. len = pages.length;
  26167. if (!len || (y - pages[len - 1] > clipHeight &&
  26168. (lastY || y) !== pages[len - 1])) {
  26169. pages.push(lastY || y);
  26170. len++;
  26171. }
  26172. // Keep track of which page each item is on
  26173. item.pageIx = len - 1;
  26174. if (lastY) {
  26175. allItems[i - 1].pageIx = len - 1;
  26176. }
  26177. if (i === allItems.length - 1 &&
  26178. y + h - pages[len - 1] > clipHeight &&
  26179. y !== lastY // #2617
  26180. ) {
  26181. pages.push(y);
  26182. item.pageIx = len;
  26183. }
  26184. if (y !== lastY) {
  26185. lastY = y;
  26186. }
  26187. });
  26188. // Only apply clipping if needed. Clipping causes blurred legend in
  26189. // PDF export (#1787)
  26190. if (!clipRect) {
  26191. clipRect = legend.clipRect =
  26192. renderer.clipRect(0, padding, 9999, 0);
  26193. legend.contentGroup.clip(clipRect);
  26194. }
  26195. clipToHeight(clipHeight);
  26196. // Add navigation elements
  26197. if (!nav) {
  26198. this.nav = nav = renderer.g()
  26199. .attr({ zIndex: 1 })
  26200. .add(this.group);
  26201. this.up = renderer
  26202. .symbol('triangle', 0, 0, arrowSize, arrowSize)
  26203. .add(nav);
  26204. addTracker('upTracker')
  26205. .on('click', function () {
  26206. legend.scroll(-1, animation);
  26207. });
  26208. this.pager = renderer.text('', 15, 10)
  26209. .addClass('highcharts-legend-navigation');
  26210. if (!chart.styledMode) {
  26211. this.pager.css(navOptions.style);
  26212. }
  26213. this.pager.add(nav);
  26214. this.down = renderer
  26215. .symbol('triangle-down', 0, 0, arrowSize, arrowSize)
  26216. .add(nav);
  26217. addTracker('downTracker')
  26218. .on('click', function () {
  26219. legend.scroll(1, animation);
  26220. });
  26221. }
  26222. // Set initial position
  26223. legend.scroll(0);
  26224. legendHeight = spaceHeight;
  26225. // Reset
  26226. }
  26227. else if (nav) {
  26228. clipToHeight();
  26229. this.nav = nav.destroy(); // #6322
  26230. this.scrollGroup.attr({
  26231. translateY: 1
  26232. });
  26233. this.clipHeight = 0; // #1379
  26234. }
  26235. return legendHeight;
  26236. };
  26237. /**
  26238. * Scroll the legend by a number of pages.
  26239. *
  26240. * @private
  26241. * @function Highcharts.Legend#scroll
  26242. *
  26243. * @param {number} scrollBy
  26244. * The number of pages to scroll.
  26245. *
  26246. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  26247. * Whether and how to apply animation.
  26248. *
  26249. * @return {void}
  26250. */
  26251. Legend.prototype.scroll = function (scrollBy, animation) {
  26252. var _this = this;
  26253. var chart = this.chart,
  26254. pages = this.pages,
  26255. pageCount = pages.length,
  26256. currentPage = this.currentPage + scrollBy,
  26257. clipHeight = this.clipHeight,
  26258. navOptions = this.options.navigation,
  26259. pager = this.pager,
  26260. padding = this.padding;
  26261. // When resizing while looking at the last page
  26262. if (currentPage > pageCount) {
  26263. currentPage = pageCount;
  26264. }
  26265. if (currentPage > 0) {
  26266. if (typeof animation !== 'undefined') {
  26267. setAnimation(animation, chart);
  26268. }
  26269. this.nav.attr({
  26270. translateX: padding,
  26271. translateY: clipHeight + this.padding + 7 + this.titleHeight,
  26272. visibility: 'visible'
  26273. });
  26274. [this.up, this.upTracker].forEach(function (elem) {
  26275. elem.attr({
  26276. 'class': currentPage === 1 ?
  26277. 'highcharts-legend-nav-inactive' :
  26278. 'highcharts-legend-nav-active'
  26279. });
  26280. });
  26281. pager.attr({
  26282. text: currentPage + '/' + pageCount
  26283. });
  26284. [this.down, this.downTracker].forEach(function (elem) {
  26285. elem.attr({
  26286. // adjust to text width
  26287. x: 18 + this.pager.getBBox().width,
  26288. 'class': currentPage === pageCount ?
  26289. 'highcharts-legend-nav-inactive' :
  26290. 'highcharts-legend-nav-active'
  26291. });
  26292. }, this);
  26293. if (!chart.styledMode) {
  26294. this.up
  26295. .attr({
  26296. fill: currentPage === 1 ?
  26297. navOptions.inactiveColor :
  26298. navOptions.activeColor
  26299. });
  26300. this.upTracker
  26301. .css({
  26302. cursor: currentPage === 1 ? 'default' : 'pointer'
  26303. });
  26304. this.down
  26305. .attr({
  26306. fill: currentPage === pageCount ?
  26307. navOptions.inactiveColor :
  26308. navOptions.activeColor
  26309. });
  26310. this.downTracker
  26311. .css({
  26312. cursor: currentPage === pageCount ?
  26313. 'default' :
  26314. 'pointer'
  26315. });
  26316. }
  26317. this.scrollOffset = -pages[currentPage - 1] + this.initialItemY;
  26318. this.scrollGroup.animate({
  26319. translateY: this.scrollOffset
  26320. });
  26321. this.currentPage = currentPage;
  26322. this.positionCheckboxes();
  26323. // Fire event after scroll animation is complete
  26324. var animOptions = animObject(pick(animation,
  26325. chart.renderer.globalAnimation,
  26326. true));
  26327. syncTimeout(function () {
  26328. fireEvent(_this, 'afterScroll', { currentPage: currentPage });
  26329. }, animOptions.duration);
  26330. }
  26331. };
  26332. return Legend;
  26333. }());
  26334. // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
  26335. // and for #2580, a similar drawing flaw in Firefox 26.
  26336. // Explore if there's a general cause for this. The problem may be related
  26337. // to nested group elements, as the legend item texts are within 4 group
  26338. // elements.
  26339. if (/Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
  26340. isFirefox) {
  26341. wrap(Legend.prototype, 'positionItem', function (proceed, item) {
  26342. var legend = this,
  26343. // If chart destroyed in sync, this is undefined (#2030)
  26344. runPositionItem = function () {
  26345. if (item._legendItemPos) {
  26346. proceed.call(legend,
  26347. item);
  26348. }
  26349. };
  26350. // Do it now, for export and to get checkbox placement
  26351. runPositionItem();
  26352. // Do it after to work around the core issue
  26353. if (!legend.bubbleLegend) {
  26354. setTimeout(runPositionItem);
  26355. }
  26356. });
  26357. }
  26358. H.Legend = Legend;
  26359. return H.Legend;
  26360. });
  26361. _registerModule(_modules, 'Core/Chart/Chart.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/MSPointer.js'], _modules['Core/Options.js'], _modules['Core/Pointer.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (Axis, H, Legend, MSPointer, O, Pointer, Time, U) {
  26362. /* *
  26363. *
  26364. * (c) 2010-2020 Torstein Honsi
  26365. *
  26366. * License: www.highcharts.com/license
  26367. *
  26368. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26369. *
  26370. * */
  26371. var charts = H.charts,
  26372. doc = H.doc,
  26373. seriesTypes = H.seriesTypes,
  26374. win = H.win;
  26375. var defaultOptions = O.defaultOptions;
  26376. var addEvent = U.addEvent,
  26377. animate = U.animate,
  26378. animObject = U.animObject,
  26379. attr = U.attr,
  26380. createElement = U.createElement,
  26381. css = U.css,
  26382. defined = U.defined,
  26383. discardElement = U.discardElement,
  26384. erase = U.erase,
  26385. error = U.error,
  26386. extend = U.extend,
  26387. find = U.find,
  26388. fireEvent = U.fireEvent,
  26389. getStyle = U.getStyle,
  26390. isArray = U.isArray,
  26391. isFunction = U.isFunction,
  26392. isNumber = U.isNumber,
  26393. isObject = U.isObject,
  26394. isString = U.isString,
  26395. merge = U.merge,
  26396. numberFormat = U.numberFormat,
  26397. objectEach = U.objectEach,
  26398. pick = U.pick,
  26399. pInt = U.pInt,
  26400. relativeLength = U.relativeLength,
  26401. removeEvent = U.removeEvent,
  26402. setAnimation = U.setAnimation,
  26403. splat = U.splat,
  26404. syncTimeout = U.syncTimeout,
  26405. uniqueKey = U.uniqueKey;
  26406. /**
  26407. * Callback for chart constructors.
  26408. *
  26409. * @callback Highcharts.ChartCallbackFunction
  26410. *
  26411. * @param {Highcharts.Chart} chart
  26412. * Created chart.
  26413. */
  26414. /**
  26415. * Format a number and return a string based on input settings.
  26416. *
  26417. * @callback Highcharts.NumberFormatterCallbackFunction
  26418. *
  26419. * @param {number} number
  26420. * The input number to format.
  26421. *
  26422. * @param {number} decimals
  26423. * The amount of decimals. A value of -1 preserves the amount in the
  26424. * input number.
  26425. *
  26426. * @param {string} [decimalPoint]
  26427. * The decimal point, defaults to the one given in the lang options, or
  26428. * a dot.
  26429. *
  26430. * @param {string} [thousandsSep]
  26431. * The thousands separator, defaults to the one given in the lang
  26432. * options, or a space character.
  26433. *
  26434. * @return {string} The formatted number.
  26435. */
  26436. /**
  26437. * The chart title. The title has an `update` method that allows modifying the
  26438. * options directly or indirectly via `chart.update`.
  26439. *
  26440. * @interface Highcharts.TitleObject
  26441. * @extends Highcharts.SVGElement
  26442. */ /**
  26443. * Modify options for the title.
  26444. *
  26445. * @function Highcharts.TitleObject#update
  26446. *
  26447. * @param {Highcharts.TitleOptions} titleOptions
  26448. * Options to modify.
  26449. *
  26450. * @param {boolean} [redraw=true]
  26451. * Whether to redraw the chart after the title is altered. If doing more
  26452. * operations on the chart, it is a good idea to set redraw to false and
  26453. * call {@link Chart#redraw} after.
  26454. */
  26455. /**
  26456. * The chart subtitle. The subtitle has an `update` method that
  26457. * allows modifying the options directly or indirectly via
  26458. * `chart.update`.
  26459. *
  26460. * @interface Highcharts.SubtitleObject
  26461. * @extends Highcharts.SVGElement
  26462. */ /**
  26463. * Modify options for the subtitle.
  26464. *
  26465. * @function Highcharts.SubtitleObject#update
  26466. *
  26467. * @param {Highcharts.SubtitleOptions} subtitleOptions
  26468. * Options to modify.
  26469. *
  26470. * @param {boolean} [redraw=true]
  26471. * Whether to redraw the chart after the subtitle is altered. If doing
  26472. * more operations on the chart, it is a good idea to set redraw to false
  26473. * and call {@link Chart#redraw} after.
  26474. */
  26475. /**
  26476. * The chart caption. The caption has an `update` method that
  26477. * allows modifying the options directly or indirectly via
  26478. * `chart.update`.
  26479. *
  26480. * @interface Highcharts.CaptionObject
  26481. * @extends Highcharts.SVGElement
  26482. */ /**
  26483. * Modify options for the caption.
  26484. *
  26485. * @function Highcharts.CaptionObject#update
  26486. *
  26487. * @param {Highcharts.CaptionOptions} captionOptions
  26488. * Options to modify.
  26489. *
  26490. * @param {boolean} [redraw=true]
  26491. * Whether to redraw the chart after the caption is altered. If doing
  26492. * more operations on the chart, it is a good idea to set redraw to false
  26493. * and call {@link Chart#redraw} after.
  26494. */
  26495. var marginNames = H.marginNames;
  26496. /* eslint-disable no-invalid-this, valid-jsdoc */
  26497. /**
  26498. * The Chart class. The recommended constructor is {@link Highcharts#chart}.
  26499. *
  26500. * @example
  26501. * var chart = Highcharts.chart('container', {
  26502. * title: {
  26503. * text: 'My chart'
  26504. * },
  26505. * series: [{
  26506. * data: [1, 3, 2, 4]
  26507. * }]
  26508. * })
  26509. *
  26510. * @class
  26511. * @name Highcharts.Chart
  26512. *
  26513. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  26514. * The DOM element to render to, or its id.
  26515. *
  26516. * @param {Highcharts.Options} options
  26517. * The chart options structure.
  26518. *
  26519. * @param {Highcharts.ChartCallbackFunction} [callback]
  26520. * Function to run when the chart has loaded and and all external images
  26521. * are loaded. Defining a
  26522. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  26523. * handler is equivalent.
  26524. */
  26525. var Chart = /** @class */ (function () {
  26526. function Chart(a, b, c) {
  26527. this.axes = void 0;
  26528. this.axisOffset = void 0;
  26529. this.bounds = void 0;
  26530. this.chartHeight = void 0;
  26531. this.chartWidth = void 0;
  26532. this.clipBox = void 0;
  26533. this.colorCounter = void 0;
  26534. this.container = void 0;
  26535. this.index = void 0;
  26536. this.isResizing = void 0;
  26537. this.labelCollectors = void 0;
  26538. this.legend = void 0;
  26539. this.margin = void 0;
  26540. this.numberFormatter = void 0;
  26541. this.options = void 0;
  26542. this.plotBox = void 0;
  26543. this.plotHeight = void 0;
  26544. this.plotLeft = void 0;
  26545. this.plotTop = void 0;
  26546. this.plotWidth = void 0;
  26547. this.pointCount = void 0;
  26548. this.pointer = void 0;
  26549. this.renderer = void 0;
  26550. this.renderTo = void 0;
  26551. this.series = void 0;
  26552. this.spacing = void 0;
  26553. this.spacingBox = void 0;
  26554. this.symbolCounter = void 0;
  26555. this.time = void 0;
  26556. this.titleOffset = void 0;
  26557. this.userOptions = void 0;
  26558. this.xAxis = void 0;
  26559. this.yAxis = void 0;
  26560. this.getArgs(a, b, c);
  26561. }
  26562. /* *
  26563. *
  26564. * Functions
  26565. *
  26566. * */
  26567. /**
  26568. * Handle the arguments passed to the constructor.
  26569. *
  26570. * @private
  26571. * @function Highcharts.Chart#getArgs
  26572. *
  26573. * @param {...Array<*>} arguments
  26574. * All arguments for the constructor.
  26575. *
  26576. * @fires Highcharts.Chart#event:init
  26577. * @fires Highcharts.Chart#event:afterInit
  26578. */
  26579. Chart.prototype.getArgs = function (a, b, c) {
  26580. // Remove the optional first argument, renderTo, and
  26581. // set it on this.
  26582. if (isString(a) || a.nodeName) {
  26583. this.renderTo = a;
  26584. this.init(b, c);
  26585. }
  26586. else {
  26587. this.init(a, b);
  26588. }
  26589. };
  26590. /**
  26591. * Overridable function that initializes the chart. The constructor's
  26592. * arguments are passed on directly.
  26593. *
  26594. * @function Highcharts.Chart#init
  26595. *
  26596. * @param {Highcharts.Options} userOptions
  26597. * Custom options.
  26598. *
  26599. * @param {Function} [callback]
  26600. * Function to run when the chart has loaded and and all external
  26601. * images are loaded.
  26602. *
  26603. * @return {void}
  26604. *
  26605. * @fires Highcharts.Chart#event:init
  26606. * @fires Highcharts.Chart#event:afterInit
  26607. */
  26608. Chart.prototype.init = function (userOptions, callback) {
  26609. // Handle regular options
  26610. var options,
  26611. // skip merging data points to increase performance
  26612. seriesOptions = userOptions.series,
  26613. userPlotOptions = userOptions.plotOptions || {};
  26614. // Fire the event with a default function
  26615. fireEvent(this, 'init', { args: arguments }, function () {
  26616. userOptions.series = null;
  26617. options = merge(defaultOptions, userOptions); // do the merge
  26618. var optionsChart = options.chart || {};
  26619. // Override (by copy of user options) or clear tooltip options
  26620. // in chart.options.plotOptions (#6218)
  26621. objectEach(options.plotOptions, function (typeOptions, type) {
  26622. if (isObject(typeOptions)) { // #8766
  26623. typeOptions.tooltip = (userPlotOptions[type] && // override by copy:
  26624. merge(userPlotOptions[type].tooltip)) || void 0; // or clear
  26625. }
  26626. });
  26627. // User options have higher priority than default options
  26628. // (#6218). In case of exporting: path is changed
  26629. options.tooltip.userOptions = (userOptions.chart &&
  26630. userOptions.chart.forExport &&
  26631. userOptions.tooltip.userOptions) || userOptions.tooltip;
  26632. // set back the series data
  26633. options.series = userOptions.series = seriesOptions;
  26634. /**
  26635. * The original options given to the constructor or a chart factory
  26636. * like {@link Highcharts.chart} and {@link Highcharts.stockChart}.
  26637. *
  26638. * @name Highcharts.Chart#userOptions
  26639. * @type {Highcharts.Options}
  26640. */
  26641. this.userOptions = userOptions;
  26642. var chartEvents = optionsChart.events;
  26643. this.margin = [];
  26644. this.spacing = [];
  26645. // Pixel data bounds for touch zoom
  26646. this.bounds = { h: {}, v: {} };
  26647. // An array of functions that returns labels that should be
  26648. // considered for anti-collision
  26649. this.labelCollectors = [];
  26650. this.callback = callback;
  26651. this.isResizing = 0;
  26652. /**
  26653. * The options structure for the chart after merging
  26654. * {@link #defaultOptions} and {@link #userOptions}. It contains
  26655. * members for the sub elements like series, legend, tooltip etc.
  26656. *
  26657. * @name Highcharts.Chart#options
  26658. * @type {Highcharts.Options}
  26659. */
  26660. this.options = options;
  26661. /**
  26662. * All the axes in the chart.
  26663. *
  26664. * @see Highcharts.Chart.xAxis
  26665. * @see Highcharts.Chart.yAxis
  26666. *
  26667. * @name Highcharts.Chart#axes
  26668. * @type {Array<Highcharts.Axis>}
  26669. */
  26670. this.axes = [];
  26671. /**
  26672. * All the current series in the chart.
  26673. *
  26674. * @name Highcharts.Chart#series
  26675. * @type {Array<Highcharts.Series>}
  26676. */
  26677. this.series = [];
  26678. /**
  26679. * The `Time` object associated with the chart. Since v6.0.5,
  26680. * time settings can be applied individually for each chart. If
  26681. * no individual settings apply, the `Time` object is shared by
  26682. * all instances.
  26683. *
  26684. * @name Highcharts.Chart#time
  26685. * @type {Highcharts.Time}
  26686. */
  26687. this.time =
  26688. userOptions.time && Object.keys(userOptions.time).length ?
  26689. new Time(userOptions.time) :
  26690. H.time;
  26691. /**
  26692. * Callback function to override the default function that formats
  26693. * all the numbers in the chart. Returns a string with the formatted
  26694. * number.
  26695. *
  26696. * @name Highcharts.Chart#numberFormatter
  26697. * @type {Highcharts.NumberFormatterCallbackFunction}
  26698. */
  26699. this.numberFormatter = optionsChart.numberFormatter || numberFormat;
  26700. /**
  26701. * Whether the chart is in styled mode, meaning all presentatinoal
  26702. * attributes are avoided.
  26703. *
  26704. * @name Highcharts.Chart#styledMode
  26705. * @type {boolean}
  26706. */
  26707. this.styledMode = optionsChart.styledMode;
  26708. this.hasCartesianSeries = optionsChart.showAxes;
  26709. var chart = this;
  26710. /**
  26711. * Index position of the chart in the {@link Highcharts#charts}
  26712. * property.
  26713. *
  26714. * @name Highcharts.Chart#index
  26715. * @type {number}
  26716. * @readonly
  26717. */
  26718. chart.index = charts.length; // Add the chart to the global lookup
  26719. charts.push(chart);
  26720. H.chartCount++;
  26721. // Chart event handlers
  26722. if (chartEvents) {
  26723. objectEach(chartEvents, function (event, eventType) {
  26724. if (isFunction(event)) {
  26725. addEvent(chart, eventType, event);
  26726. }
  26727. });
  26728. }
  26729. /**
  26730. * A collection of the X axes in the chart.
  26731. *
  26732. * @name Highcharts.Chart#xAxis
  26733. * @type {Array<Highcharts.Axis>}
  26734. */
  26735. chart.xAxis = [];
  26736. /**
  26737. * A collection of the Y axes in the chart.
  26738. *
  26739. * @name Highcharts.Chart#yAxis
  26740. * @type {Array<Highcharts.Axis>}
  26741. *
  26742. * @todo
  26743. * Make events official: Fire the event `afterInit`.
  26744. */
  26745. chart.yAxis = [];
  26746. chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
  26747. // Fire after init but before first render, before axes and series
  26748. // have been initialized.
  26749. fireEvent(chart, 'afterInit');
  26750. chart.firstRender();
  26751. });
  26752. };
  26753. /**
  26754. * Internal function to unitialize an individual series.
  26755. *
  26756. * @private
  26757. * @function Highcharts.Chart#initSeries
  26758. */
  26759. Chart.prototype.initSeries = function (options) {
  26760. var chart = this,
  26761. optionsChart = chart.options.chart,
  26762. type = (options.type ||
  26763. optionsChart.type ||
  26764. optionsChart.defaultSeriesType),
  26765. series,
  26766. Constr = seriesTypes[type];
  26767. // No such series type
  26768. if (!Constr) {
  26769. error(17, true, chart, { missingModuleFor: type });
  26770. }
  26771. series = new Constr();
  26772. series.init(this, options);
  26773. return series;
  26774. };
  26775. /**
  26776. * Internal function to set data for all series with enabled sorting.
  26777. *
  26778. * @private
  26779. * @function Highcharts.Chart#setSeriesData
  26780. */
  26781. Chart.prototype.setSeriesData = function () {
  26782. this.getSeriesOrderByLinks().forEach(function (series) {
  26783. // We need to set data for series with sorting after series init
  26784. if (!series.points && !series.data && series.enabledDataSorting) {
  26785. series.setData(series.options.data, false);
  26786. }
  26787. });
  26788. };
  26789. /**
  26790. * Sort and return chart series in order depending on the number of linked
  26791. * series.
  26792. *
  26793. * @private
  26794. * @function Highcharts.Series#getSeriesOrderByLinks
  26795. * @return {Array<Highcharts.Series>}
  26796. */
  26797. Chart.prototype.getSeriesOrderByLinks = function () {
  26798. return this.series.concat().sort(function (a, b) {
  26799. if (a.linkedSeries.length || b.linkedSeries.length) {
  26800. return b.linkedSeries.length - a.linkedSeries.length;
  26801. }
  26802. return 0;
  26803. });
  26804. };
  26805. /**
  26806. * Order all series above a given index. When series are added and ordered
  26807. * by configuration, only the last series is handled (#248, #1123, #2456,
  26808. * #6112). This function is called on series initialization and destroy.
  26809. *
  26810. * @private
  26811. * @function Highcharts.Series#orderSeries
  26812. * @param {number} [fromIndex]
  26813. * If this is given, only the series above this index are handled.
  26814. */
  26815. Chart.prototype.orderSeries = function (fromIndex) {
  26816. var series = this.series,
  26817. i = fromIndex || 0;
  26818. for (; i < series.length; i++) {
  26819. if (series[i]) {
  26820. /**
  26821. * Contains the series' index in the `Chart.series` array.
  26822. *
  26823. * @name Highcharts.Series#index
  26824. * @type {number}
  26825. * @readonly
  26826. */
  26827. series[i].index = i;
  26828. series[i].name = series[i].getName();
  26829. }
  26830. }
  26831. };
  26832. /**
  26833. * Check whether a given point is within the plot area.
  26834. *
  26835. * @function Highcharts.Chart#isInsidePlot
  26836. *
  26837. * @param {number} plotX
  26838. * Pixel x relative to the plot area.
  26839. *
  26840. * @param {number} plotY
  26841. * Pixel y relative to the plot area.
  26842. *
  26843. * @param {boolean} [inverted]
  26844. * Whether the chart is inverted.
  26845. *
  26846. * @return {boolean}
  26847. * Returns true if the given point is inside the plot area.
  26848. */
  26849. Chart.prototype.isInsidePlot = function (plotX, plotY, inverted) {
  26850. var x = inverted ? plotY : plotX,
  26851. y = inverted ? plotX : plotY,
  26852. e = {
  26853. x: x,
  26854. y: y,
  26855. isInsidePlot: x >= 0 &&
  26856. x <= this.plotWidth &&
  26857. y >= 0 &&
  26858. y <= this.plotHeight
  26859. };
  26860. fireEvent(this, 'afterIsInsidePlot', e);
  26861. return e.isInsidePlot;
  26862. };
  26863. /**
  26864. * Redraw the chart after changes have been done to the data, axis extremes
  26865. * chart size or chart elements. All methods for updating axes, series or
  26866. * points have a parameter for redrawing the chart. This is `true` by
  26867. * default. But in many cases you want to do more than one operation on the
  26868. * chart before redrawing, for example add a number of points. In those
  26869. * cases it is a waste of resources to redraw the chart for each new point
  26870. * added. So you add the points and call `chart.redraw()` after.
  26871. *
  26872. * @function Highcharts.Chart#redraw
  26873. *
  26874. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  26875. * If or how to apply animation to the redraw.
  26876. *
  26877. * @fires Highcharts.Chart#event:afterSetExtremes
  26878. * @fires Highcharts.Chart#event:beforeRedraw
  26879. * @fires Highcharts.Chart#event:predraw
  26880. * @fires Highcharts.Chart#event:redraw
  26881. * @fires Highcharts.Chart#event:render
  26882. * @fires Highcharts.Chart#event:updatedData
  26883. */
  26884. Chart.prototype.redraw = function (animation) {
  26885. fireEvent(this, 'beforeRedraw');
  26886. var chart = this,
  26887. axes = chart.axes,
  26888. series = chart.series,
  26889. pointer = chart.pointer,
  26890. legend = chart.legend,
  26891. legendUserOptions = chart.userOptions.legend,
  26892. redrawLegend = chart.isDirtyLegend,
  26893. hasStackedSeries,
  26894. hasDirtyStacks,
  26895. hasCartesianSeries = chart.hasCartesianSeries,
  26896. isDirtyBox = chart.isDirtyBox,
  26897. i,
  26898. serie,
  26899. renderer = chart.renderer,
  26900. isHiddenChart = renderer.isHidden(),
  26901. afterRedraw = [];
  26902. // Handle responsive rules, not only on resize (#6130)
  26903. if (chart.setResponsive) {
  26904. chart.setResponsive(false);
  26905. }
  26906. // Set the global animation. When chart.hasRendered is not true, the
  26907. // redraw call comes from a responsive rule and animation should not
  26908. // occur.
  26909. setAnimation(chart.hasRendered ? animation : false, chart);
  26910. if (isHiddenChart) {
  26911. chart.temporaryDisplay();
  26912. }
  26913. // Adjust title layout (reflow multiline text)
  26914. chart.layOutTitles();
  26915. // link stacked series
  26916. i = series.length;
  26917. while (i--) {
  26918. serie = series[i];
  26919. if (serie.options.stacking) {
  26920. hasStackedSeries = true;
  26921. if (serie.isDirty) {
  26922. hasDirtyStacks = true;
  26923. break;
  26924. }
  26925. }
  26926. }
  26927. if (hasDirtyStacks) { // mark others as dirty
  26928. i = series.length;
  26929. while (i--) {
  26930. serie = series[i];
  26931. if (serie.options.stacking) {
  26932. serie.isDirty = true;
  26933. }
  26934. }
  26935. }
  26936. // Handle updated data in the series
  26937. series.forEach(function (serie) {
  26938. if (serie.isDirty) {
  26939. if (serie.options.legendType === 'point') {
  26940. if (serie.updateTotals) {
  26941. serie.updateTotals();
  26942. }
  26943. redrawLegend = true;
  26944. }
  26945. else if (legendUserOptions &&
  26946. (legendUserOptions.labelFormatter ||
  26947. legendUserOptions.labelFormat)) {
  26948. redrawLegend = true; // #2165
  26949. }
  26950. }
  26951. if (serie.isDirtyData) {
  26952. fireEvent(serie, 'updatedData');
  26953. }
  26954. });
  26955. // handle added or removed series
  26956. if (redrawLegend && legend && legend.options.enabled) {
  26957. // draw legend graphics
  26958. legend.render();
  26959. chart.isDirtyLegend = false;
  26960. }
  26961. // reset stacks
  26962. if (hasStackedSeries) {
  26963. chart.getStacks();
  26964. }
  26965. if (hasCartesianSeries) {
  26966. // set axes scales
  26967. axes.forEach(function (axis) {
  26968. // Don't do setScale again if we're only resizing. Regression
  26969. // #13507. But we need it after chart.update (responsive), as
  26970. // axis is initialized again (#12137).
  26971. if (!chart.isResizing || !isNumber(axis.min)) {
  26972. axis.updateNames();
  26973. axis.setScale();
  26974. }
  26975. });
  26976. }
  26977. chart.getMargins(); // #3098
  26978. if (hasCartesianSeries) {
  26979. // If one axis is dirty, all axes must be redrawn (#792, #2169)
  26980. axes.forEach(function (axis) {
  26981. if (axis.isDirty) {
  26982. isDirtyBox = true;
  26983. }
  26984. });
  26985. // redraw axes
  26986. axes.forEach(function (axis) {
  26987. // Fire 'afterSetExtremes' only if extremes are set
  26988. var key = axis.min + ',' + axis.max;
  26989. if (axis.extKey !== key) { // #821, #4452
  26990. axis.extKey = key;
  26991. // prevent a recursive call to chart.redraw() (#1119)
  26992. afterRedraw.push(function () {
  26993. fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
  26994. delete axis.eventArgs;
  26995. });
  26996. }
  26997. if (isDirtyBox || hasStackedSeries) {
  26998. axis.redraw();
  26999. }
  27000. });
  27001. }
  27002. // the plot areas size has changed
  27003. if (isDirtyBox) {
  27004. chart.drawChartBox();
  27005. }
  27006. // Fire an event before redrawing series, used by the boost module to
  27007. // clear previous series renderings.
  27008. fireEvent(chart, 'predraw');
  27009. // redraw affected series
  27010. series.forEach(function (serie) {
  27011. if ((isDirtyBox || serie.isDirty) && serie.visible) {
  27012. serie.redraw();
  27013. }
  27014. // Set it here, otherwise we will have unlimited 'updatedData' calls
  27015. // for a hidden series after setData(). Fixes #6012
  27016. serie.isDirtyData = false;
  27017. });
  27018. // move tooltip or reset
  27019. if (pointer) {
  27020. pointer.reset(true);
  27021. }
  27022. // redraw if canvas
  27023. renderer.draw();
  27024. // Fire the events
  27025. fireEvent(chart, 'redraw');
  27026. fireEvent(chart, 'render');
  27027. if (isHiddenChart) {
  27028. chart.temporaryDisplay(true);
  27029. }
  27030. // Fire callbacks that are put on hold until after the redraw
  27031. afterRedraw.forEach(function (callback) {
  27032. callback.call();
  27033. });
  27034. };
  27035. /**
  27036. * Get an axis, series or point object by `id` as given in the configuration
  27037. * options. Returns `undefined` if no item is found.
  27038. *
  27039. * @sample highcharts/plotoptions/series-id/
  27040. * Get series by id
  27041. *
  27042. * @function Highcharts.Chart#get
  27043. *
  27044. * @param {string} id
  27045. * The id as given in the configuration options.
  27046. *
  27047. * @return {Highcharts.Axis|Highcharts.Series|Highcharts.Point|undefined}
  27048. * The retrieved item.
  27049. */
  27050. Chart.prototype.get = function (id) {
  27051. var ret,
  27052. series = this.series,
  27053. i;
  27054. /**
  27055. * @private
  27056. * @param {Highcharts.Axis|Highcharts.Series} item
  27057. * @return {boolean}
  27058. */
  27059. function itemById(item) {
  27060. return (item.id === id ||
  27061. (item.options && item.options.id === id));
  27062. }
  27063. ret =
  27064. // Search axes
  27065. find(this.axes, itemById) ||
  27066. // Search series
  27067. find(this.series, itemById);
  27068. // Search points
  27069. for (i = 0; !ret && i < series.length; i++) {
  27070. ret = find(series[i].points || [], itemById);
  27071. }
  27072. return ret;
  27073. };
  27074. /**
  27075. * Create the Axis instances based on the config options.
  27076. *
  27077. * @private
  27078. * @function Highcharts.Chart#getAxes
  27079. * @fires Highcharts.Chart#event:afterGetAxes
  27080. * @fires Highcharts.Chart#event:getAxes
  27081. */
  27082. Chart.prototype.getAxes = function () {
  27083. var chart = this,
  27084. options = this.options,
  27085. xAxisOptions = options.xAxis = splat(options.xAxis || {}),
  27086. yAxisOptions = options.yAxis = splat(options.yAxis || {}),
  27087. optionsArray;
  27088. fireEvent(this, 'getAxes');
  27089. // make sure the options are arrays and add some members
  27090. xAxisOptions.forEach(function (axis, i) {
  27091. axis.index = i;
  27092. axis.isX = true;
  27093. });
  27094. yAxisOptions.forEach(function (axis, i) {
  27095. axis.index = i;
  27096. });
  27097. // concatenate all axis options into one array
  27098. optionsArray = xAxisOptions.concat(yAxisOptions);
  27099. optionsArray.forEach(function (axisOptions) {
  27100. new Axis(chart, axisOptions); // eslint-disable-line no-new
  27101. });
  27102. fireEvent(this, 'afterGetAxes');
  27103. };
  27104. /**
  27105. * Returns an array of all currently selected points in the chart. Points
  27106. * can be selected by clicking or programmatically by the
  27107. * {@link Highcharts.Point#select}
  27108. * function.
  27109. *
  27110. * @sample highcharts/plotoptions/series-allowpointselect-line/
  27111. * Get selected points
  27112. *
  27113. * @function Highcharts.Chart#getSelectedPoints
  27114. *
  27115. * @return {Array<Highcharts.Point>}
  27116. * The currently selected points.
  27117. */
  27118. Chart.prototype.getSelectedPoints = function () {
  27119. var points = [];
  27120. this.series.forEach(function (serie) {
  27121. // For one-to-one points inspect series.data in order to retrieve
  27122. // points outside the visible range (#6445). For grouped data,
  27123. // inspect the generated series.points.
  27124. points = points.concat(serie.getPointsCollection().filter(function (point) {
  27125. return pick(point.selectedStaging, point.selected);
  27126. }));
  27127. });
  27128. return points;
  27129. };
  27130. /**
  27131. * Returns an array of all currently selected series in the chart. Series
  27132. * can be selected either programmatically by the
  27133. * {@link Highcharts.Series#select}
  27134. * function or by checking the checkbox next to the legend item if
  27135. * [series.showCheckBox](https://api.highcharts.com/highcharts/plotOptions.series.showCheckbox)
  27136. * is true.
  27137. *
  27138. * @sample highcharts/members/chart-getselectedseries/
  27139. * Get selected series
  27140. *
  27141. * @function Highcharts.Chart#getSelectedSeries
  27142. *
  27143. * @return {Array<Highcharts.Series>}
  27144. * The currently selected series.
  27145. */
  27146. Chart.prototype.getSelectedSeries = function () {
  27147. return this.series.filter(function (serie) {
  27148. return serie.selected;
  27149. });
  27150. };
  27151. /**
  27152. * Set a new title or subtitle for the chart.
  27153. *
  27154. * @sample highcharts/members/chart-settitle/
  27155. * Set title text and styles
  27156. *
  27157. * @function Highcharts.Chart#setTitle
  27158. *
  27159. * @param {Highcharts.TitleOptions} [titleOptions]
  27160. * New title options. The title text itself is set by the
  27161. * `titleOptions.text` property.
  27162. *
  27163. * @param {Highcharts.SubtitleOptions} [subtitleOptions]
  27164. * New subtitle options. The subtitle text itself is set by the
  27165. * `subtitleOptions.text` property.
  27166. *
  27167. * @param {boolean} [redraw]
  27168. * Whether to redraw the chart or wait for a later call to
  27169. * `chart.redraw()`.
  27170. */
  27171. Chart.prototype.setTitle = function (titleOptions, subtitleOptions, redraw) {
  27172. this.applyDescription('title', titleOptions);
  27173. this.applyDescription('subtitle', subtitleOptions);
  27174. // The initial call also adds the caption. On update, chart.update will
  27175. // relay to Chart.setCaption.
  27176. this.applyDescription('caption', void 0);
  27177. this.layOutTitles(redraw);
  27178. };
  27179. /**
  27180. * Apply a title, subtitle or caption for the chart
  27181. *
  27182. * @private
  27183. * @function Highcharts.Chart#applyDescription
  27184. * @param name {string}
  27185. * Either title, subtitle or caption
  27186. * @param {Highcharts.TitleOptions|Highcharts.SubtitleOptions|Highcharts.CaptionOptions|undefined} explicitOptions
  27187. * The options to set, will be merged with default options.
  27188. */
  27189. Chart.prototype.applyDescription = function (name, explicitOptions) {
  27190. var chart = this;
  27191. // Default style
  27192. var style = name === 'title' ? {
  27193. color: '#333333',
  27194. fontSize: this.options.isStock ? '16px' : '18px' // #2944
  27195. } : {
  27196. color: '#666666'
  27197. };
  27198. // Merge default options with explicit options
  27199. var options = this.options[name] = merge(
  27200. // Default styles
  27201. (!this.styledMode && { style: style }),
  27202. this.options[name],
  27203. explicitOptions);
  27204. var elem = this[name];
  27205. if (elem && explicitOptions) {
  27206. this[name] = elem = elem.destroy(); // remove old
  27207. }
  27208. if (options && !elem) {
  27209. elem = this.renderer.text(options.text, 0, 0, options.useHTML)
  27210. .attr({
  27211. align: options.align,
  27212. 'class': 'highcharts-' + name,
  27213. zIndex: options.zIndex || 4
  27214. })
  27215. .add();
  27216. // Update methods, shortcut to Chart.setTitle, Chart.setSubtitle and
  27217. // Chart.setCaption
  27218. elem.update = function (updateOptions) {
  27219. var fn = {
  27220. title: 'setTitle',
  27221. subtitle: 'setSubtitle',
  27222. caption: 'setCaption'
  27223. }[name];
  27224. chart[fn](updateOptions);
  27225. };
  27226. // Presentational
  27227. if (!this.styledMode) {
  27228. elem.css(options.style);
  27229. }
  27230. /**
  27231. * The chart title. The title has an `update` method that allows
  27232. * modifying the options directly or indirectly via
  27233. * `chart.update`.
  27234. *
  27235. * @sample highcharts/members/title-update/
  27236. * Updating titles
  27237. *
  27238. * @name Highcharts.Chart#title
  27239. * @type {Highcharts.TitleObject}
  27240. */
  27241. /**
  27242. * The chart subtitle. The subtitle has an `update` method that
  27243. * allows modifying the options directly or indirectly via
  27244. * `chart.update`.
  27245. *
  27246. * @name Highcharts.Chart#subtitle
  27247. * @type {Highcharts.SubtitleObject}
  27248. */
  27249. this[name] = elem;
  27250. }
  27251. };
  27252. /**
  27253. * Internal function to lay out the chart title, subtitle and caption, and
  27254. * cache the full offset height for use in `getMargins`. The result is
  27255. * stored in `this.titleOffset`.
  27256. *
  27257. * @private
  27258. * @function Highcharts.Chart#layOutTitles
  27259. *
  27260. * @param {boolean} [redraw=true]
  27261. * @fires Highcharts.Chart#event:afterLayOutTitles
  27262. */
  27263. Chart.prototype.layOutTitles = function (redraw) {
  27264. var titleOffset = [0, 0, 0],
  27265. requiresDirtyBox,
  27266. renderer = this.renderer,
  27267. spacingBox = this.spacingBox;
  27268. // Lay out the title and the subtitle respectively
  27269. ['title', 'subtitle', 'caption'].forEach(function (key) {
  27270. var title = this[key], titleOptions = this.options[key], verticalAlign = titleOptions.verticalAlign || 'top', offset = key === 'title' ? -3 :
  27271. // Floating subtitle (#6574)
  27272. verticalAlign === 'top' ? titleOffset[0] + 2 : 0, titleSize, height;
  27273. if (title) {
  27274. if (!this.styledMode) {
  27275. titleSize = titleOptions.style.fontSize;
  27276. }
  27277. titleSize = renderer.fontMetrics(titleSize, title).b;
  27278. title
  27279. .css({
  27280. width: (titleOptions.width ||
  27281. spacingBox.width + (titleOptions.widthAdjust || 0)) + 'px'
  27282. });
  27283. // Skip the cache for HTML (#3481, #11666)
  27284. height = Math.round(title.getBBox(titleOptions.useHTML).height);
  27285. title.align(extend({
  27286. y: verticalAlign === 'bottom' ?
  27287. titleSize :
  27288. offset + titleSize,
  27289. height: height
  27290. }, titleOptions), false, 'spacingBox');
  27291. if (!titleOptions.floating) {
  27292. if (verticalAlign === 'top') {
  27293. titleOffset[0] = Math.ceil(titleOffset[0] +
  27294. height);
  27295. }
  27296. else if (verticalAlign === 'bottom') {
  27297. titleOffset[2] = Math.ceil(titleOffset[2] +
  27298. height);
  27299. }
  27300. }
  27301. }
  27302. }, this);
  27303. // Handle title.margin and caption.margin
  27304. if (titleOffset[0] &&
  27305. (this.options.title.verticalAlign || 'top') === 'top') {
  27306. titleOffset[0] += this.options.title.margin;
  27307. }
  27308. if (titleOffset[2] &&
  27309. this.options.caption.verticalAlign === 'bottom') {
  27310. titleOffset[2] += this.options.caption.margin;
  27311. }
  27312. requiresDirtyBox = (!this.titleOffset ||
  27313. this.titleOffset.join(',') !== titleOffset.join(','));
  27314. // Used in getMargins
  27315. this.titleOffset = titleOffset;
  27316. fireEvent(this, 'afterLayOutTitles');
  27317. if (!this.isDirtyBox && requiresDirtyBox) {
  27318. this.isDirtyBox = this.isDirtyLegend = requiresDirtyBox;
  27319. // Redraw if necessary (#2719, #2744)
  27320. if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
  27321. this.redraw();
  27322. }
  27323. }
  27324. };
  27325. /**
  27326. * Internal function to get the chart width and height according to options
  27327. * and container size. Sets {@link Chart.chartWidth} and
  27328. * {@link Chart.chartHeight}.
  27329. *
  27330. * @private
  27331. * @function Highcharts.Chart#getChartSize
  27332. */
  27333. Chart.prototype.getChartSize = function () {
  27334. var chart = this,
  27335. optionsChart = chart.options.chart,
  27336. widthOption = optionsChart.width,
  27337. heightOption = optionsChart.height,
  27338. renderTo = chart.renderTo;
  27339. // Get inner width and height
  27340. if (!defined(widthOption)) {
  27341. chart.containerWidth = getStyle(renderTo, 'width');
  27342. }
  27343. if (!defined(heightOption)) {
  27344. chart.containerHeight = getStyle(renderTo, 'height');
  27345. }
  27346. /**
  27347. * The current pixel width of the chart.
  27348. *
  27349. * @name Highcharts.Chart#chartWidth
  27350. * @type {number}
  27351. */
  27352. chart.chartWidth = Math.max(// #1393
  27353. 0, widthOption || chart.containerWidth || 600 // #1460
  27354. );
  27355. /**
  27356. * The current pixel height of the chart.
  27357. *
  27358. * @name Highcharts.Chart#chartHeight
  27359. * @type {number}
  27360. */
  27361. chart.chartHeight = Math.max(0, relativeLength(heightOption, chart.chartWidth) ||
  27362. (chart.containerHeight > 1 ?
  27363. chart.containerHeight :
  27364. 400));
  27365. };
  27366. /**
  27367. * If the renderTo element has no offsetWidth, most likely one or more of
  27368. * its parents are hidden. Loop up the DOM tree to temporarily display the
  27369. * parents, then save the original display properties, and when the true
  27370. * size is retrieved, reset them. Used on first render and on redraws.
  27371. *
  27372. * @private
  27373. * @function Highcharts.Chart#temporaryDisplay
  27374. *
  27375. * @param {boolean} [revert]
  27376. * Revert to the saved original styles.
  27377. */
  27378. Chart.prototype.temporaryDisplay = function (revert) {
  27379. var node = this.renderTo,
  27380. tempStyle;
  27381. if (!revert) {
  27382. while (node && node.style) {
  27383. // When rendering to a detached node, it needs to be temporarily
  27384. // attached in order to read styling and bounding boxes (#5783,
  27385. // #7024).
  27386. if (!doc.body.contains(node) && !node.parentNode) {
  27387. node.hcOrigDetached = true;
  27388. doc.body.appendChild(node);
  27389. }
  27390. if (getStyle(node, 'display', false) === 'none' ||
  27391. node.hcOricDetached) {
  27392. node.hcOrigStyle = {
  27393. display: node.style.display,
  27394. height: node.style.height,
  27395. overflow: node.style.overflow
  27396. };
  27397. tempStyle = {
  27398. display: 'block',
  27399. overflow: 'hidden'
  27400. };
  27401. if (node !== this.renderTo) {
  27402. tempStyle.height = 0;
  27403. }
  27404. css(node, tempStyle);
  27405. // If it still doesn't have an offset width after setting
  27406. // display to block, it probably has an !important priority
  27407. // #2631, 6803
  27408. if (!node.offsetWidth) {
  27409. node.style.setProperty('display', 'block', 'important');
  27410. }
  27411. }
  27412. node = node.parentNode;
  27413. if (node === doc.body) {
  27414. break;
  27415. }
  27416. }
  27417. }
  27418. else {
  27419. while (node && node.style) {
  27420. if (node.hcOrigStyle) {
  27421. css(node, node.hcOrigStyle);
  27422. delete node.hcOrigStyle;
  27423. }
  27424. if (node.hcOrigDetached) {
  27425. doc.body.removeChild(node);
  27426. node.hcOrigDetached = false;
  27427. }
  27428. node = node.parentNode;
  27429. }
  27430. }
  27431. };
  27432. /**
  27433. * Set the {@link Chart.container|chart container's} class name, in
  27434. * addition to `highcharts-container`.
  27435. *
  27436. * @function Highcharts.Chart#setClassName
  27437. *
  27438. * @param {string} [className]
  27439. * The additional class name.
  27440. */
  27441. Chart.prototype.setClassName = function (className) {
  27442. this.container.className = 'highcharts-container ' + (className || '');
  27443. };
  27444. /**
  27445. * Get the containing element, determine the size and create the inner
  27446. * container div to hold the chart.
  27447. *
  27448. * @private
  27449. * @function Highcharts.Chart#afterGetContainer
  27450. * @fires Highcharts.Chart#event:afterGetContainer
  27451. */
  27452. Chart.prototype.getContainer = function () {
  27453. var chart = this,
  27454. container,
  27455. options = chart.options,
  27456. optionsChart = options.chart,
  27457. chartWidth,
  27458. chartHeight,
  27459. renderTo = chart.renderTo,
  27460. indexAttrName = 'data-highcharts-chart',
  27461. oldChartIndex,
  27462. Ren,
  27463. containerId = uniqueKey(),
  27464. containerStyle,
  27465. key;
  27466. if (!renderTo) {
  27467. chart.renderTo = renderTo =
  27468. optionsChart.renderTo;
  27469. }
  27470. if (isString(renderTo)) {
  27471. chart.renderTo = renderTo =
  27472. doc.getElementById(renderTo);
  27473. }
  27474. // Display an error if the renderTo is wrong
  27475. if (!renderTo) {
  27476. error(13, true, chart);
  27477. }
  27478. // If the container already holds a chart, destroy it. The check for
  27479. // hasRendered is there because web pages that are saved to disk from
  27480. // the browser, will preserve the data-highcharts-chart attribute and
  27481. // the SVG contents, but not an interactive chart. So in this case,
  27482. // charts[oldChartIndex] will point to the wrong chart if any (#2609).
  27483. oldChartIndex = pInt(attr(renderTo, indexAttrName));
  27484. if (isNumber(oldChartIndex) &&
  27485. charts[oldChartIndex] &&
  27486. charts[oldChartIndex].hasRendered) {
  27487. charts[oldChartIndex].destroy();
  27488. }
  27489. // Make a reference to the chart from the div
  27490. attr(renderTo, indexAttrName, chart.index);
  27491. // remove previous chart
  27492. renderTo.innerHTML = '';
  27493. // If the container doesn't have an offsetWidth, it has or is a child of
  27494. // a node that has display:none. We need to temporarily move it out to a
  27495. // visible state to determine the size, else the legend and tooltips
  27496. // won't render properly. The skipClone option is used in sparklines as
  27497. // a micro optimization, saving about 1-2 ms each chart.
  27498. if (!optionsChart.skipClone && !renderTo.offsetWidth) {
  27499. chart.temporaryDisplay();
  27500. }
  27501. // get the width and height
  27502. chart.getChartSize();
  27503. chartWidth = chart.chartWidth;
  27504. chartHeight = chart.chartHeight;
  27505. // Allow table cells and flex-boxes to shrink without the chart blocking
  27506. // them out (#6427)
  27507. css(renderTo, { overflow: 'hidden' });
  27508. // Create the inner container
  27509. if (!chart.styledMode) {
  27510. containerStyle = extend({
  27511. position: 'relative',
  27512. // needed for context menu (avoidscrollbars) and content
  27513. // overflow in IE
  27514. overflow: 'hidden',
  27515. width: chartWidth + 'px',
  27516. height: chartHeight + 'px',
  27517. textAlign: 'left',
  27518. lineHeight: 'normal',
  27519. zIndex: 0,
  27520. '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
  27521. userSelect: 'none' // #13503
  27522. }, optionsChart.style);
  27523. }
  27524. /**
  27525. * The containing HTML element of the chart. The container is
  27526. * dynamically inserted into the element given as the `renderTo`
  27527. * parameter in the {@link Highcharts#chart} constructor.
  27528. *
  27529. * @name Highcharts.Chart#container
  27530. * @type {Highcharts.HTMLDOMElement}
  27531. */
  27532. container = createElement('div', {
  27533. id: containerId
  27534. }, containerStyle, renderTo);
  27535. chart.container = container;
  27536. // cache the cursor (#1650)
  27537. chart._cursor = container.style.cursor;
  27538. // Initialize the renderer
  27539. Ren = H[optionsChart.renderer] || H.Renderer;
  27540. /**
  27541. * The renderer instance of the chart. Each chart instance has only one
  27542. * associated renderer.
  27543. *
  27544. * @name Highcharts.Chart#renderer
  27545. * @type {Highcharts.SVGRenderer}
  27546. */
  27547. chart.renderer = new Ren(container, chartWidth, chartHeight, null, optionsChart.forExport, options.exporting && options.exporting.allowHTML, chart.styledMode);
  27548. // Set the initial animation from the options
  27549. setAnimation(void 0, chart);
  27550. chart.setClassName(optionsChart.className);
  27551. if (!chart.styledMode) {
  27552. chart.renderer.setStyle(optionsChart.style);
  27553. }
  27554. else {
  27555. // Initialize definitions
  27556. for (key in options.defs) { // eslint-disable-line guard-for-in
  27557. this.renderer.definition(options.defs[key]);
  27558. }
  27559. }
  27560. // Add a reference to the charts index
  27561. chart.renderer.chartIndex = chart.index;
  27562. fireEvent(this, 'afterGetContainer');
  27563. };
  27564. /**
  27565. * Calculate margins by rendering axis labels in a preliminary position.
  27566. * Title, subtitle and legend have already been rendered at this stage, but
  27567. * will be moved into their final positions.
  27568. *
  27569. * @private
  27570. * @function Highcharts.Chart#getMargins
  27571. * @fires Highcharts.Chart#event:getMargins
  27572. */
  27573. Chart.prototype.getMargins = function (skipAxes) {
  27574. var _a = this,
  27575. spacing = _a.spacing,
  27576. margin = _a.margin,
  27577. titleOffset = _a.titleOffset;
  27578. this.resetMargins();
  27579. // Adjust for title and subtitle
  27580. if (titleOffset[0] && !defined(margin[0])) {
  27581. this.plotTop = Math.max(this.plotTop, titleOffset[0] + spacing[0]);
  27582. }
  27583. if (titleOffset[2] && !defined(margin[2])) {
  27584. this.marginBottom = Math.max(this.marginBottom, titleOffset[2] + spacing[2]);
  27585. }
  27586. // Adjust for legend
  27587. if (this.legend && this.legend.display) {
  27588. this.legend.adjustMargins(margin, spacing);
  27589. }
  27590. fireEvent(this, 'getMargins');
  27591. if (!skipAxes) {
  27592. this.getAxisMargins();
  27593. }
  27594. };
  27595. /**
  27596. * @private
  27597. * @function Highcharts.Chart#getAxisMargins
  27598. */
  27599. Chart.prototype.getAxisMargins = function () {
  27600. var chart = this,
  27601. // [top, right, bottom, left]
  27602. axisOffset = chart.axisOffset = [0, 0, 0, 0],
  27603. colorAxis = chart.colorAxis,
  27604. margin = chart.margin,
  27605. getOffset = function (axes) {
  27606. axes.forEach(function (axis) {
  27607. if (axis.visible) {
  27608. axis.getOffset();
  27609. }
  27610. });
  27611. };
  27612. // pre-render axes to get labels offset width
  27613. if (chart.hasCartesianSeries) {
  27614. getOffset(chart.axes);
  27615. }
  27616. else if (colorAxis && colorAxis.length) {
  27617. getOffset(colorAxis);
  27618. }
  27619. // Add the axis offsets
  27620. marginNames.forEach(function (m, side) {
  27621. if (!defined(margin[side])) {
  27622. chart[m] += axisOffset[side];
  27623. }
  27624. });
  27625. chart.setChartSize();
  27626. };
  27627. /**
  27628. * Reflows the chart to its container. By default, the chart reflows
  27629. * automatically to its container following a `window.resize` event, as per
  27630. * the [chart.reflow](https://api.highcharts.com/highcharts/chart.reflow)
  27631. * option. However, there are no reliable events for div resize, so if the
  27632. * container is resized without a window resize event, this must be called
  27633. * explicitly.
  27634. *
  27635. * @sample highcharts/members/chart-reflow/
  27636. * Resize div and reflow
  27637. * @sample highcharts/chart/events-container/
  27638. * Pop up and reflow
  27639. *
  27640. * @function Highcharts.Chart#reflow
  27641. *
  27642. * @param {global.Event} [e]
  27643. * Event arguments. Used primarily when the function is called
  27644. * internally as a response to window resize.
  27645. */
  27646. Chart.prototype.reflow = function (e) {
  27647. var chart = this, optionsChart = chart.options.chart, renderTo = chart.renderTo, hasUserSize = (defined(optionsChart.width) &&
  27648. defined(optionsChart.height)), width = optionsChart.width || getStyle(renderTo, 'width'), height = optionsChart.height || getStyle(renderTo, 'height'), target = e ? e.target : win;
  27649. // Width and height checks for display:none. Target is doc in IE8 and
  27650. // Opera, win in Firefox, Chrome and IE9.
  27651. if (!hasUserSize &&
  27652. !chart.isPrinting &&
  27653. width &&
  27654. height &&
  27655. (target === win || target === doc)) {
  27656. if (width !== chart.containerWidth ||
  27657. height !== chart.containerHeight) {
  27658. U.clearTimeout(chart.reflowTimeout);
  27659. // When called from window.resize, e is set, else it's called
  27660. // directly (#2224)
  27661. chart.reflowTimeout = syncTimeout(function () {
  27662. // Set size, it may have been destroyed in the meantime
  27663. // (#1257)
  27664. if (chart.container) {
  27665. chart.setSize(void 0, void 0, false);
  27666. }
  27667. }, e ? 100 : 0);
  27668. }
  27669. chart.containerWidth = width;
  27670. chart.containerHeight = height;
  27671. }
  27672. };
  27673. /**
  27674. * Toggle the event handlers necessary for auto resizing, depending on the
  27675. * `chart.reflow` option.
  27676. *
  27677. * @private
  27678. * @function Highcharts.Chart#setReflow
  27679. */
  27680. Chart.prototype.setReflow = function (reflow) {
  27681. var chart = this;
  27682. if (reflow !== false && !this.unbindReflow) {
  27683. this.unbindReflow = addEvent(win, 'resize', function (e) {
  27684. // a removed event listener still runs in Edge and IE if the
  27685. // listener was removed while the event runs, so check if the
  27686. // chart is not destroyed (#11609)
  27687. if (chart.options) {
  27688. chart.reflow(e);
  27689. }
  27690. });
  27691. addEvent(this, 'destroy', this.unbindReflow);
  27692. }
  27693. else if (reflow === false && this.unbindReflow) {
  27694. // Unbind and unset
  27695. this.unbindReflow = this.unbindReflow();
  27696. }
  27697. // The following will add listeners to re-fit the chart before and after
  27698. // printing (#2284). However it only works in WebKit. Should have worked
  27699. // in Firefox, but not supported in IE.
  27700. /*
  27701. if (win.matchMedia) {
  27702. win.matchMedia('print').addListener(function reflow() {
  27703. chart.reflow();
  27704. });
  27705. }
  27706. //*/
  27707. };
  27708. /**
  27709. * Resize the chart to a given width and height. In order to set the width
  27710. * only, the height argument may be skipped. To set the height only, pass
  27711. * `undefined` for the width.
  27712. *
  27713. * @sample highcharts/members/chart-setsize-button/
  27714. * Test resizing from buttons
  27715. * @sample highcharts/members/chart-setsize-jquery-resizable/
  27716. * Add a jQuery UI resizable
  27717. * @sample stock/members/chart-setsize/
  27718. * Highstock with UI resizable
  27719. *
  27720. * @function Highcharts.Chart#setSize
  27721. *
  27722. * @param {number|null} [width]
  27723. * The new pixel width of the chart. Since v4.2.6, the argument can
  27724. * be `undefined` in order to preserve the current value (when
  27725. * setting height only), or `null` to adapt to the width of the
  27726. * containing element.
  27727. *
  27728. * @param {number|null} [height]
  27729. * The new pixel height of the chart. Since v4.2.6, the argument can
  27730. * be `undefined` in order to preserve the current value, or `null`
  27731. * in order to adapt to the height of the containing element.
  27732. *
  27733. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  27734. * Whether and how to apply animation.
  27735. *
  27736. * @return {void}
  27737. *
  27738. * @fires Highcharts.Chart#event:endResize
  27739. * @fires Highcharts.Chart#event:resize
  27740. */
  27741. Chart.prototype.setSize = function (width, height, animation) {
  27742. var chart = this,
  27743. renderer = chart.renderer,
  27744. globalAnimation;
  27745. // Handle the isResizing counter
  27746. chart.isResizing += 1;
  27747. // set the animation for the current process
  27748. setAnimation(animation, chart);
  27749. globalAnimation = renderer.globalAnimation;
  27750. chart.oldChartHeight = chart.chartHeight;
  27751. chart.oldChartWidth = chart.chartWidth;
  27752. if (typeof width !== 'undefined') {
  27753. chart.options.chart.width = width;
  27754. }
  27755. if (typeof height !== 'undefined') {
  27756. chart.options.chart.height = height;
  27757. }
  27758. chart.getChartSize();
  27759. // Resize the container with the global animation applied if enabled
  27760. // (#2503)
  27761. if (!chart.styledMode) {
  27762. (globalAnimation ? animate : css)(chart.container, {
  27763. width: chart.chartWidth + 'px',
  27764. height: chart.chartHeight + 'px'
  27765. }, globalAnimation);
  27766. }
  27767. chart.setChartSize(true);
  27768. renderer.setSize(chart.chartWidth, chart.chartHeight, globalAnimation);
  27769. // handle axes
  27770. chart.axes.forEach(function (axis) {
  27771. axis.isDirty = true;
  27772. axis.setScale();
  27773. });
  27774. chart.isDirtyLegend = true; // force legend redraw
  27775. chart.isDirtyBox = true; // force redraw of plot and chart border
  27776. chart.layOutTitles(); // #2857
  27777. chart.getMargins();
  27778. chart.redraw(globalAnimation);
  27779. chart.oldChartHeight = null;
  27780. fireEvent(chart, 'resize');
  27781. // Fire endResize and set isResizing back. If animation is disabled,
  27782. // fire without delay
  27783. syncTimeout(function () {
  27784. if (chart) {
  27785. fireEvent(chart, 'endResize', null, function () {
  27786. chart.isResizing -= 1;
  27787. });
  27788. }
  27789. }, animObject(globalAnimation).duration);
  27790. };
  27791. /**
  27792. * Set the public chart properties. This is done before and after the
  27793. * pre-render to determine margin sizes.
  27794. *
  27795. * @private
  27796. * @function Highcharts.Chart#setChartSize
  27797. * @fires Highcharts.Chart#event:afterSetChartSize
  27798. */
  27799. Chart.prototype.setChartSize = function (skipAxes) {
  27800. var chart = this,
  27801. inverted = chart.inverted,
  27802. renderer = chart.renderer,
  27803. chartWidth = chart.chartWidth,
  27804. chartHeight = chart.chartHeight,
  27805. optionsChart = chart.options.chart,
  27806. spacing = chart.spacing,
  27807. clipOffset = chart.clipOffset,
  27808. clipX,
  27809. clipY,
  27810. plotLeft,
  27811. plotTop,
  27812. plotWidth,
  27813. plotHeight,
  27814. plotBorderWidth;
  27815. /**
  27816. * The current left position of the plot area in pixels.
  27817. *
  27818. * @name Highcharts.Chart#plotLeft
  27819. * @type {number}
  27820. */
  27821. chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
  27822. /**
  27823. * The current top position of the plot area in pixels.
  27824. *
  27825. * @name Highcharts.Chart#plotTop
  27826. * @type {number}
  27827. */
  27828. chart.plotTop = plotTop = Math.round(chart.plotTop);
  27829. /**
  27830. * The current width of the plot area in pixels.
  27831. *
  27832. * @name Highcharts.Chart#plotWidth
  27833. * @type {number}
  27834. */
  27835. chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
  27836. /**
  27837. * The current height of the plot area in pixels.
  27838. *
  27839. * @name Highcharts.Chart#plotHeight
  27840. * @type {number}
  27841. */
  27842. chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
  27843. chart.plotSizeX = inverted ? plotHeight : plotWidth;
  27844. chart.plotSizeY = inverted ? plotWidth : plotHeight;
  27845. chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
  27846. // Set boxes used for alignment
  27847. chart.spacingBox = renderer.spacingBox = {
  27848. x: spacing[3],
  27849. y: spacing[0],
  27850. width: chartWidth - spacing[3] - spacing[1],
  27851. height: chartHeight - spacing[0] - spacing[2]
  27852. };
  27853. chart.plotBox = renderer.plotBox = {
  27854. x: plotLeft,
  27855. y: plotTop,
  27856. width: plotWidth,
  27857. height: plotHeight
  27858. };
  27859. plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
  27860. clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
  27861. clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
  27862. chart.clipBox = {
  27863. x: clipX,
  27864. y: clipY,
  27865. width: Math.floor(chart.plotSizeX -
  27866. Math.max(plotBorderWidth, clipOffset[1]) / 2 -
  27867. clipX),
  27868. height: Math.max(0, Math.floor(chart.plotSizeY -
  27869. Math.max(plotBorderWidth, clipOffset[2]) / 2 -
  27870. clipY))
  27871. };
  27872. if (!skipAxes) {
  27873. chart.axes.forEach(function (axis) {
  27874. axis.setAxisSize();
  27875. axis.setAxisTranslation();
  27876. });
  27877. }
  27878. fireEvent(chart, 'afterSetChartSize', { skipAxes: skipAxes });
  27879. };
  27880. /**
  27881. * Initial margins before auto size margins are applied.
  27882. *
  27883. * @private
  27884. * @function Highcharts.Chart#resetMargins
  27885. */
  27886. Chart.prototype.resetMargins = function () {
  27887. fireEvent(this, 'resetMargins');
  27888. var chart = this,
  27889. chartOptions = chart.options.chart;
  27890. // Create margin and spacing array
  27891. ['margin', 'spacing'].forEach(function splashArrays(target) {
  27892. var value = chartOptions[target],
  27893. values = isObject(value) ? value : [value,
  27894. value,
  27895. value,
  27896. value];
  27897. [
  27898. 'Top',
  27899. 'Right',
  27900. 'Bottom',
  27901. 'Left'
  27902. ].forEach(function (sideName, side) {
  27903. chart[target][side] = pick(chartOptions[target + sideName], values[side]);
  27904. });
  27905. });
  27906. // Set margin names like chart.plotTop, chart.plotLeft,
  27907. // chart.marginRight, chart.marginBottom.
  27908. marginNames.forEach(function (m, side) {
  27909. chart[m] = pick(chart.margin[side], chart.spacing[side]);
  27910. });
  27911. chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
  27912. chart.clipOffset = [0, 0, 0, 0];
  27913. };
  27914. /**
  27915. * Internal function to draw or redraw the borders and backgrounds for chart
  27916. * and plot area.
  27917. *
  27918. * @private
  27919. * @function Highcharts.Chart#drawChartBox
  27920. * @fires Highcharts.Chart#event:afterDrawChartBox
  27921. */
  27922. Chart.prototype.drawChartBox = function () {
  27923. var chart = this,
  27924. optionsChart = chart.options.chart,
  27925. renderer = chart.renderer,
  27926. chartWidth = chart.chartWidth,
  27927. chartHeight = chart.chartHeight,
  27928. chartBackground = chart.chartBackground,
  27929. plotBackground = chart.plotBackground,
  27930. plotBorder = chart.plotBorder,
  27931. chartBorderWidth,
  27932. styledMode = chart.styledMode,
  27933. plotBGImage = chart.plotBGImage,
  27934. chartBackgroundColor = optionsChart.backgroundColor,
  27935. plotBackgroundColor = optionsChart.plotBackgroundColor,
  27936. plotBackgroundImage = optionsChart.plotBackgroundImage,
  27937. mgn,
  27938. bgAttr,
  27939. plotLeft = chart.plotLeft,
  27940. plotTop = chart.plotTop,
  27941. plotWidth = chart.plotWidth,
  27942. plotHeight = chart.plotHeight,
  27943. plotBox = chart.plotBox,
  27944. clipRect = chart.clipRect,
  27945. clipBox = chart.clipBox,
  27946. verb = 'animate';
  27947. // Chart area
  27948. if (!chartBackground) {
  27949. chart.chartBackground = chartBackground = renderer.rect()
  27950. .addClass('highcharts-background')
  27951. .add();
  27952. verb = 'attr';
  27953. }
  27954. if (!styledMode) {
  27955. // Presentational
  27956. chartBorderWidth = optionsChart.borderWidth || 0;
  27957. mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
  27958. bgAttr = {
  27959. fill: chartBackgroundColor || 'none'
  27960. };
  27961. if (chartBorderWidth || chartBackground['stroke-width']) { // #980
  27962. bgAttr.stroke = optionsChart.borderColor;
  27963. bgAttr['stroke-width'] = chartBorderWidth;
  27964. }
  27965. chartBackground
  27966. .attr(bgAttr)
  27967. .shadow(optionsChart.shadow);
  27968. }
  27969. else {
  27970. chartBorderWidth = mgn = chartBackground.strokeWidth();
  27971. }
  27972. chartBackground[verb]({
  27973. x: mgn / 2,
  27974. y: mgn / 2,
  27975. width: chartWidth - mgn - chartBorderWidth % 2,
  27976. height: chartHeight - mgn - chartBorderWidth % 2,
  27977. r: optionsChart.borderRadius
  27978. });
  27979. // Plot background
  27980. verb = 'animate';
  27981. if (!plotBackground) {
  27982. verb = 'attr';
  27983. chart.plotBackground = plotBackground = renderer.rect()
  27984. .addClass('highcharts-plot-background')
  27985. .add();
  27986. }
  27987. plotBackground[verb](plotBox);
  27988. if (!styledMode) {
  27989. // Presentational attributes for the background
  27990. plotBackground
  27991. .attr({
  27992. fill: plotBackgroundColor || 'none'
  27993. })
  27994. .shadow(optionsChart.plotShadow);
  27995. // Create the background image
  27996. if (plotBackgroundImage) {
  27997. if (!plotBGImage) {
  27998. chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight).add();
  27999. }
  28000. else {
  28001. if (plotBackgroundImage !== plotBGImage.attr('href')) {
  28002. plotBGImage.attr('href', plotBackgroundImage);
  28003. }
  28004. plotBGImage.animate(plotBox);
  28005. }
  28006. }
  28007. }
  28008. // Plot clip
  28009. if (!clipRect) {
  28010. chart.clipRect = renderer.clipRect(clipBox);
  28011. }
  28012. else {
  28013. clipRect.animate({
  28014. width: clipBox.width,
  28015. height: clipBox.height
  28016. });
  28017. }
  28018. // Plot area border
  28019. verb = 'animate';
  28020. if (!plotBorder) {
  28021. verb = 'attr';
  28022. chart.plotBorder = plotBorder = renderer.rect()
  28023. .addClass('highcharts-plot-border')
  28024. .attr({
  28025. zIndex: 1 // Above the grid
  28026. })
  28027. .add();
  28028. }
  28029. if (!styledMode) {
  28030. // Presentational
  28031. plotBorder.attr({
  28032. stroke: optionsChart.plotBorderColor,
  28033. 'stroke-width': optionsChart.plotBorderWidth || 0,
  28034. fill: 'none'
  28035. });
  28036. }
  28037. plotBorder[verb](plotBorder.crisp({
  28038. x: plotLeft,
  28039. y: plotTop,
  28040. width: plotWidth,
  28041. height: plotHeight
  28042. }, -plotBorder.strokeWidth())); // #3282 plotBorder should be negative;
  28043. // reset
  28044. chart.isDirtyBox = false;
  28045. fireEvent(this, 'afterDrawChartBox');
  28046. };
  28047. /**
  28048. * Detect whether a certain chart property is needed based on inspecting its
  28049. * options and series. This mainly applies to the chart.inverted property,
  28050. * and in extensions to the chart.angular and chart.polar properties.
  28051. *
  28052. * @private
  28053. * @function Highcharts.Chart#propFromSeries
  28054. * @return {void}
  28055. */
  28056. Chart.prototype.propFromSeries = function () {
  28057. var chart = this,
  28058. optionsChart = chart.options.chart,
  28059. klass,
  28060. seriesOptions = chart.options.series,
  28061. i,
  28062. value;
  28063. /**
  28064. * The flag is set to `true` if a series of the chart is inverted.
  28065. *
  28066. * @name Highcharts.Chart#inverted
  28067. * @type {boolean|undefined}
  28068. */
  28069. ['inverted', 'angular', 'polar'].forEach(function (key) {
  28070. // The default series type's class
  28071. klass = seriesTypes[(optionsChart.type ||
  28072. optionsChart.defaultSeriesType)];
  28073. // Get the value from available chart-wide properties
  28074. value =
  28075. // It is set in the options:
  28076. optionsChart[key] ||
  28077. // The default series class:
  28078. (klass && klass.prototype[key]);
  28079. // requires it
  28080. // 4. Check if any the chart's series require it
  28081. i = seriesOptions && seriesOptions.length;
  28082. while (!value && i--) {
  28083. klass = seriesTypes[seriesOptions[i].type];
  28084. if (klass && klass.prototype[key]) {
  28085. value = true;
  28086. }
  28087. }
  28088. // Set the chart property
  28089. chart[key] = value;
  28090. });
  28091. };
  28092. /**
  28093. * Internal function to link two or more series together, based on the
  28094. * `linkedTo` option. This is done from `Chart.render`, and after
  28095. * `Chart.addSeries` and `Series.remove`.
  28096. *
  28097. * @private
  28098. * @function Highcharts.Chart#linkSeries
  28099. * @fires Highcharts.Chart#event:afterLinkSeries
  28100. */
  28101. Chart.prototype.linkSeries = function () {
  28102. var chart = this,
  28103. chartSeries = chart.series;
  28104. // Reset links
  28105. chartSeries.forEach(function (series) {
  28106. series.linkedSeries.length = 0;
  28107. });
  28108. // Apply new links
  28109. chartSeries.forEach(function (series) {
  28110. var linkedTo = series.options.linkedTo;
  28111. if (isString(linkedTo)) {
  28112. if (linkedTo === ':previous') {
  28113. linkedTo = chart.series[series.index - 1];
  28114. }
  28115. else {
  28116. linkedTo = chart.get(linkedTo);
  28117. }
  28118. // #3341 avoid mutual linking
  28119. if (linkedTo && linkedTo.linkedParent !== series) {
  28120. linkedTo.linkedSeries.push(series);
  28121. series.linkedParent = linkedTo;
  28122. if (linkedTo.enabledDataSorting) {
  28123. series.setDataSortingOptions();
  28124. }
  28125. series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
  28126. }
  28127. }
  28128. });
  28129. fireEvent(this, 'afterLinkSeries');
  28130. };
  28131. /**
  28132. * Render series for the chart.
  28133. *
  28134. * @private
  28135. * @function Highcharts.Chart#renderSeries
  28136. */
  28137. Chart.prototype.renderSeries = function () {
  28138. this.series.forEach(function (serie) {
  28139. serie.translate();
  28140. serie.render();
  28141. });
  28142. };
  28143. /**
  28144. * Render labels for the chart.
  28145. *
  28146. * @private
  28147. * @function Highcharts.Chart#renderLabels
  28148. */
  28149. Chart.prototype.renderLabels = function () {
  28150. var chart = this,
  28151. labels = chart.options.labels;
  28152. if (labels.items) {
  28153. labels.items.forEach(function (label) {
  28154. var style = extend(labels.style,
  28155. label.style),
  28156. x = pInt(style.left) + chart.plotLeft,
  28157. y = pInt(style.top) + chart.plotTop + 12;
  28158. // delete to prevent rewriting in IE
  28159. delete style.left;
  28160. delete style.top;
  28161. chart.renderer.text(label.html, x, y)
  28162. .attr({ zIndex: 2 })
  28163. .css(style)
  28164. .add();
  28165. });
  28166. }
  28167. };
  28168. /**
  28169. * Render all graphics for the chart. Runs internally on initialization.
  28170. *
  28171. * @private
  28172. * @function Highcharts.Chart#render
  28173. */
  28174. Chart.prototype.render = function () {
  28175. var chart = this,
  28176. axes = chart.axes,
  28177. colorAxis = chart.colorAxis,
  28178. renderer = chart.renderer,
  28179. options = chart.options,
  28180. correction = 0, // correction for X axis labels
  28181. tempWidth,
  28182. tempHeight,
  28183. redoHorizontal,
  28184. redoVertical,
  28185. renderAxes = function (axes) {
  28186. axes.forEach(function (axis) {
  28187. if (axis.visible) {
  28188. axis.render();
  28189. }
  28190. });
  28191. };
  28192. // Title
  28193. chart.setTitle();
  28194. /**
  28195. * The overview of the chart's series.
  28196. *
  28197. * @name Highcharts.Chart#legend
  28198. * @type {Highcharts.Legend}
  28199. */
  28200. chart.legend = new Legend(chart, options.legend);
  28201. // Get stacks
  28202. if (chart.getStacks) {
  28203. chart.getStacks();
  28204. }
  28205. // Get chart margins
  28206. chart.getMargins(true);
  28207. chart.setChartSize();
  28208. // Record preliminary dimensions for later comparison
  28209. tempWidth = chart.plotWidth;
  28210. axes.some(function (axis) {
  28211. if (axis.horiz &&
  28212. axis.visible &&
  28213. axis.options.labels.enabled &&
  28214. axis.series.length) {
  28215. // 21 is the most common correction for X axis labels
  28216. correction = 21;
  28217. return true;
  28218. }
  28219. });
  28220. // use Math.max to prevent negative plotHeight
  28221. chart.plotHeight = Math.max(chart.plotHeight - correction, 0);
  28222. tempHeight = chart.plotHeight;
  28223. // Get margins by pre-rendering axes
  28224. axes.forEach(function (axis) {
  28225. axis.setScale();
  28226. });
  28227. chart.getAxisMargins();
  28228. // If the plot area size has changed significantly, calculate tick
  28229. // positions again
  28230. redoHorizontal = tempWidth / chart.plotWidth > 1.1;
  28231. // Height is more sensitive, use lower threshold
  28232. redoVertical = tempHeight / chart.plotHeight > 1.05;
  28233. if (redoHorizontal || redoVertical) {
  28234. axes.forEach(function (axis) {
  28235. if ((axis.horiz && redoHorizontal) ||
  28236. (!axis.horiz && redoVertical)) {
  28237. // update to reflect the new margins
  28238. axis.setTickInterval(true);
  28239. }
  28240. });
  28241. chart.getMargins(); // second pass to check for new labels
  28242. }
  28243. // Draw the borders and backgrounds
  28244. chart.drawChartBox();
  28245. // Axes
  28246. if (chart.hasCartesianSeries) {
  28247. renderAxes(axes);
  28248. }
  28249. else if (colorAxis && colorAxis.length) {
  28250. renderAxes(colorAxis);
  28251. }
  28252. // The series
  28253. if (!chart.seriesGroup) {
  28254. chart.seriesGroup = renderer.g('series-group')
  28255. .attr({ zIndex: 3 })
  28256. .add();
  28257. }
  28258. chart.renderSeries();
  28259. // Labels
  28260. chart.renderLabels();
  28261. // Credits
  28262. chart.addCredits();
  28263. // Handle responsiveness
  28264. if (chart.setResponsive) {
  28265. chart.setResponsive();
  28266. }
  28267. // Handle scaling
  28268. chart.updateContainerScaling();
  28269. // Set flag
  28270. chart.hasRendered = true;
  28271. };
  28272. /**
  28273. * Set a new credits label for the chart.
  28274. *
  28275. * @sample highcharts/credits/credits-update/
  28276. * Add and update credits
  28277. *
  28278. * @function Highcharts.Chart#addCredits
  28279. *
  28280. * @param {Highcharts.CreditsOptions} [credits]
  28281. * A configuration object for the new credits.
  28282. */
  28283. Chart.prototype.addCredits = function (credits) {
  28284. var chart = this,
  28285. creds = merge(true,
  28286. this.options.credits,
  28287. credits);
  28288. if (creds.enabled && !this.credits) {
  28289. /**
  28290. * The chart's credits label. The label has an `update` method that
  28291. * allows setting new options as per the
  28292. * [credits options set](https://api.highcharts.com/highcharts/credits).
  28293. *
  28294. * @name Highcharts.Chart#credits
  28295. * @type {Highcharts.SVGElement}
  28296. */
  28297. this.credits = this.renderer.text(creds.text + (this.mapCredits || ''), 0, 0)
  28298. .addClass('highcharts-credits')
  28299. .on('click', function () {
  28300. if (creds.href) {
  28301. win.location.href = creds.href;
  28302. }
  28303. })
  28304. .attr({
  28305. align: creds.position.align,
  28306. zIndex: 8
  28307. });
  28308. if (!chart.styledMode) {
  28309. this.credits.css(creds.style);
  28310. }
  28311. this.credits
  28312. .add()
  28313. .align(creds.position);
  28314. // Dynamically update
  28315. this.credits.update = function (options) {
  28316. chart.credits = chart.credits.destroy();
  28317. chart.addCredits(options);
  28318. };
  28319. }
  28320. };
  28321. /**
  28322. * Handle scaling, #11329 - when there is scaling/transform on the container
  28323. * or on a parent element, we need to take this into account. We calculate
  28324. * the scaling once here and it is picked up where we need to use it
  28325. * (Pointer, Tooltip).
  28326. *
  28327. * @private
  28328. * @function Highcharts.Chart#updateContainerScaling
  28329. */
  28330. Chart.prototype.updateContainerScaling = function () {
  28331. var container = this.container;
  28332. // #13342 - tooltip was not visible in Chrome, when chart
  28333. // updates height.
  28334. if (container.offsetWidth > 2 && // #13342
  28335. container.offsetHeight > 2 && // #13342
  28336. container.getBoundingClientRect) {
  28337. var bb = container.getBoundingClientRect(),
  28338. scaleX = bb.width / container.offsetWidth,
  28339. scaleY = bb.height / container.offsetHeight;
  28340. if (scaleX !== 1 || scaleY !== 1) {
  28341. this.containerScaling = { scaleX: scaleX, scaleY: scaleY };
  28342. }
  28343. else {
  28344. delete this.containerScaling;
  28345. }
  28346. }
  28347. };
  28348. /**
  28349. * Remove the chart and purge memory. This method is called internally
  28350. * before adding a second chart into the same container, as well as on
  28351. * window unload to prevent leaks.
  28352. *
  28353. * @sample highcharts/members/chart-destroy/
  28354. * Destroy the chart from a button
  28355. * @sample stock/members/chart-destroy/
  28356. * Destroy with Highstock
  28357. *
  28358. * @function Highcharts.Chart#destroy
  28359. *
  28360. * @fires Highcharts.Chart#event:destroy
  28361. */
  28362. Chart.prototype.destroy = function () {
  28363. var chart = this,
  28364. axes = chart.axes,
  28365. series = chart.series,
  28366. container = chart.container,
  28367. i,
  28368. parentNode = container && container.parentNode;
  28369. // fire the chart.destoy event
  28370. fireEvent(chart, 'destroy');
  28371. // Delete the chart from charts lookup array
  28372. if (chart.renderer.forExport) {
  28373. erase(charts, chart); // #6569
  28374. }
  28375. else {
  28376. charts[chart.index] = void 0;
  28377. }
  28378. H.chartCount--;
  28379. chart.renderTo.removeAttribute('data-highcharts-chart');
  28380. // remove events
  28381. removeEvent(chart);
  28382. // ==== Destroy collections:
  28383. // Destroy axes
  28384. i = axes.length;
  28385. while (i--) {
  28386. axes[i] = axes[i].destroy();
  28387. }
  28388. // Destroy scroller & scroller series before destroying base series
  28389. if (this.scroller && this.scroller.destroy) {
  28390. this.scroller.destroy();
  28391. }
  28392. // Destroy each series
  28393. i = series.length;
  28394. while (i--) {
  28395. series[i] = series[i].destroy();
  28396. }
  28397. // ==== Destroy chart properties:
  28398. [
  28399. 'title', 'subtitle', 'chartBackground', 'plotBackground',
  28400. 'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
  28401. 'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
  28402. 'renderer'
  28403. ].forEach(function (name) {
  28404. var prop = chart[name];
  28405. if (prop && prop.destroy) {
  28406. chart[name] = prop.destroy();
  28407. }
  28408. });
  28409. // Remove container and all SVG, check container as it can break in IE
  28410. // when destroyed before finished loading
  28411. if (container) {
  28412. container.innerHTML = '';
  28413. removeEvent(container);
  28414. if (parentNode) {
  28415. discardElement(container);
  28416. }
  28417. }
  28418. // clean it all up
  28419. objectEach(chart, function (val, key) {
  28420. delete chart[key];
  28421. });
  28422. };
  28423. /**
  28424. * Prepare for first rendering after all data are loaded.
  28425. *
  28426. * @private
  28427. * @function Highcharts.Chart#firstRender
  28428. * @fires Highcharts.Chart#event:beforeRender
  28429. */
  28430. Chart.prototype.firstRender = function () {
  28431. var chart = this,
  28432. options = chart.options;
  28433. // Hook for oldIE to check whether the chart is ready to render
  28434. if (chart.isReadyToRender && !chart.isReadyToRender()) {
  28435. return;
  28436. }
  28437. // Create the container
  28438. chart.getContainer();
  28439. chart.resetMargins();
  28440. chart.setChartSize();
  28441. // Set the common chart properties (mainly invert) from the given series
  28442. chart.propFromSeries();
  28443. // get axes
  28444. chart.getAxes();
  28445. // Initialize the series
  28446. (isArray(options.series) ? options.series : []).forEach(
  28447. // #9680
  28448. function (serieOptions) {
  28449. chart.initSeries(serieOptions);
  28450. });
  28451. chart.linkSeries();
  28452. chart.setSeriesData();
  28453. // Run an event after axes and series are initialized, but before
  28454. // render. At this stage, the series data is indexed and cached in the
  28455. // xData and yData arrays, so we can access those before rendering. Used
  28456. // in Highstock.
  28457. fireEvent(chart, 'beforeRender');
  28458. // depends on inverted and on margins being set
  28459. if (Pointer) {
  28460. if (!H.hasTouch && (win.PointerEvent || win.MSPointerEvent)) {
  28461. chart.pointer = new MSPointer(chart, options);
  28462. }
  28463. else {
  28464. /**
  28465. * The Pointer that keeps track of mouse and touch interaction.
  28466. *
  28467. * @memberof Highcharts.Chart
  28468. * @name pointer
  28469. * @type {Highcharts.Pointer}
  28470. * @instance
  28471. */
  28472. chart.pointer = new Pointer(chart, options);
  28473. }
  28474. }
  28475. chart.render();
  28476. // Fire the load event if there are no external images
  28477. if (!chart.renderer.imgCount && !chart.hasLoaded) {
  28478. chart.onload();
  28479. }
  28480. // If the chart was rendered outside the top container, put it back in
  28481. // (#3679)
  28482. chart.temporaryDisplay(true);
  28483. };
  28484. /**
  28485. * Internal function that runs on chart load, async if any images are loaded
  28486. * in the chart. Runs the callbacks and triggers the `load` and `render`
  28487. * events.
  28488. *
  28489. * @private
  28490. * @function Highcharts.Chart#onload
  28491. * @fires Highcharts.Chart#event:load
  28492. * @fires Highcharts.Chart#event:render
  28493. */
  28494. Chart.prototype.onload = function () {
  28495. // Run callbacks, first the ones registered by modules, then user's one
  28496. this.callbacks.concat([this.callback]).forEach(function (fn) {
  28497. // Chart destroyed in its own callback (#3600)
  28498. if (fn && typeof this.index !== 'undefined') {
  28499. fn.apply(this, [this]);
  28500. }
  28501. }, this);
  28502. fireEvent(this, 'load');
  28503. fireEvent(this, 'render');
  28504. // Set up auto resize, check for not destroyed (#6068)
  28505. if (defined(this.index)) {
  28506. this.setReflow(this.options.chart.reflow);
  28507. }
  28508. // Don't run again
  28509. this.hasLoaded = true;
  28510. };
  28511. return Chart;
  28512. }());
  28513. // Hook for adding callbacks in modules
  28514. Chart.prototype.callbacks = [];
  28515. /**
  28516. * Factory function for basic charts.
  28517. *
  28518. * @example
  28519. * // Render a chart in to div#container
  28520. * var chart = Highcharts.chart('container', {
  28521. * title: {
  28522. * text: 'My chart'
  28523. * },
  28524. * series: [{
  28525. * data: [1, 3, 2, 4]
  28526. * }]
  28527. * });
  28528. *
  28529. * @function Highcharts.chart
  28530. *
  28531. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  28532. * The DOM element to render to, or its id.
  28533. *
  28534. * @param {Highcharts.Options} options
  28535. * The chart options structure.
  28536. *
  28537. * @param {Highcharts.ChartCallbackFunction} [callback]
  28538. * Function to run when the chart has loaded and and all external images
  28539. * are loaded. Defining a
  28540. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  28541. * handler is equivalent.
  28542. *
  28543. * @return {Highcharts.Chart}
  28544. * Returns the Chart object.
  28545. */
  28546. function chart(a, b, c) {
  28547. return new Chart(a, b, c);
  28548. }
  28549. H.chart = chart;
  28550. H.Chart = Chart;
  28551. return Chart;
  28552. });
  28553. _registerModule(_modules, 'Extensions/ScrollablePlotArea.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Chart, H, U) {
  28554. /* *
  28555. *
  28556. * (c) 2010-2020 Torstein Honsi
  28557. *
  28558. * License: www.highcharts.com/license
  28559. *
  28560. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  28561. *
  28562. * Highcharts feature to make the Y axis stay fixed when scrolling the chart
  28563. * horizontally on mobile devices. Supports left and right side axes.
  28564. */
  28565. /*
  28566. WIP on vertical scrollable plot area (#9378). To do:
  28567. - Bottom axis positioning
  28568. - Test with Gantt
  28569. - Look for size optimizing the code
  28570. - API and demos
  28571. */
  28572. var addEvent = U.addEvent,
  28573. createElement = U.createElement,
  28574. pick = U.pick,
  28575. stop = U.stop;
  28576. /**
  28577. * Options for a scrollable plot area. This feature provides a minimum size for
  28578. * the plot area of the chart. If the size gets smaller than this, typically
  28579. * on mobile devices, a native browser scrollbar is presented. This scrollbar
  28580. * provides smooth scrolling for the contents of the plot area, whereas the
  28581. * title, legend and unaffected axes are fixed.
  28582. *
  28583. * Since v7.1.2, a scrollable plot area can be defined for either horizontal or
  28584. * vertical scrolling, depending on whether the `minWidth` or `minHeight`
  28585. * option is set.
  28586. *
  28587. * @sample highcharts/chart/scrollable-plotarea
  28588. * Scrollable plot area
  28589. * @sample highcharts/chart/scrollable-plotarea-vertical
  28590. * Vertically scrollable plot area
  28591. * @sample {gantt} highcharts/chart/scrollable-plotarea-vertical
  28592. * Gantt chart with vertically scrollable plot area
  28593. *
  28594. * @since 6.1.0
  28595. * @product highcharts gantt
  28596. * @apioption chart.scrollablePlotArea
  28597. */
  28598. /**
  28599. * The minimum height for the plot area. If it gets smaller than this, the plot
  28600. * area will become scrollable.
  28601. *
  28602. * @type {number}
  28603. * @apioption chart.scrollablePlotArea.minHeight
  28604. */
  28605. /**
  28606. * The minimum width for the plot area. If it gets smaller than this, the plot
  28607. * area will become scrollable.
  28608. *
  28609. * @type {number}
  28610. * @apioption chart.scrollablePlotArea.minWidth
  28611. */
  28612. /**
  28613. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  28614. * 1, where 0 aligns the plot area to the left and 1 aligns it to the right.
  28615. * Typically we would use 1 if the chart has right aligned Y axes.
  28616. *
  28617. * @type {number}
  28618. * @apioption chart.scrollablePlotArea.scrollPositionX
  28619. */
  28620. /**
  28621. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  28622. * 1, where 0 aligns the plot area to the top and 1 aligns it to the bottom.
  28623. *
  28624. * @type {number}
  28625. * @apioption chart.scrollablePlotArea.scrollPositionY
  28626. */
  28627. /**
  28628. * The opacity of mask applied on one of the sides of the plot
  28629. * area.
  28630. *
  28631. * @sample {highcharts} highcharts/chart/scrollable-plotarea-opacity
  28632. * Disabled opacity for the mask
  28633. *
  28634. * @type {number}
  28635. * @default 0.85
  28636. * @since 7.1.1
  28637. * @apioption chart.scrollablePlotArea.opacity
  28638. */
  28639. ''; // detach API doclets
  28640. /* eslint-disable no-invalid-this, valid-jsdoc */
  28641. addEvent(Chart, 'afterSetChartSize', function (e) {
  28642. var scrollablePlotArea = this.options.chart.scrollablePlotArea,
  28643. scrollableMinWidth = scrollablePlotArea && scrollablePlotArea.minWidth,
  28644. scrollableMinHeight = scrollablePlotArea && scrollablePlotArea.minHeight,
  28645. scrollablePixelsX,
  28646. scrollablePixelsY,
  28647. corrections;
  28648. if (!this.renderer.forExport) {
  28649. // The amount of pixels to scroll, the difference between chart
  28650. // width and scrollable width
  28651. if (scrollableMinWidth) {
  28652. this.scrollablePixelsX = scrollablePixelsX = Math.max(0, scrollableMinWidth - this.chartWidth);
  28653. if (scrollablePixelsX) {
  28654. this.plotWidth += scrollablePixelsX;
  28655. if (this.inverted) {
  28656. this.clipBox.height += scrollablePixelsX;
  28657. this.plotBox.height += scrollablePixelsX;
  28658. }
  28659. else {
  28660. this.clipBox.width += scrollablePixelsX;
  28661. this.plotBox.width += scrollablePixelsX;
  28662. }
  28663. corrections = {
  28664. // Corrections for right side
  28665. 1: { name: 'right', value: scrollablePixelsX }
  28666. };
  28667. }
  28668. // Currently we can only do either X or Y
  28669. }
  28670. else if (scrollableMinHeight) {
  28671. this.scrollablePixelsY = scrollablePixelsY = Math.max(0, scrollableMinHeight - this.chartHeight);
  28672. if (scrollablePixelsY) {
  28673. this.plotHeight += scrollablePixelsY;
  28674. if (this.inverted) {
  28675. this.clipBox.width += scrollablePixelsY;
  28676. this.plotBox.width += scrollablePixelsY;
  28677. }
  28678. else {
  28679. this.clipBox.height += scrollablePixelsY;
  28680. this.plotBox.height += scrollablePixelsY;
  28681. }
  28682. corrections = {
  28683. 2: { name: 'bottom', value: scrollablePixelsY }
  28684. };
  28685. }
  28686. }
  28687. if (corrections && !e.skipAxes) {
  28688. this.axes.forEach(function (axis) {
  28689. // For right and bottom axes, only fix the plot line length
  28690. if (corrections[axis.side]) {
  28691. // Get the plot lines right in getPlotLinePath,
  28692. // temporarily set it to the adjusted plot width.
  28693. axis.getPlotLinePath = function () {
  28694. var marginName = corrections[axis.side].name,
  28695. correctionValue = corrections[axis.side].value,
  28696. // axis.right or axis.bottom
  28697. margin = this[marginName],
  28698. path;
  28699. // Temporarily adjust
  28700. this[marginName] = margin - correctionValue;
  28701. path = H.Axis.prototype.getPlotLinePath.apply(this, arguments);
  28702. // Reset
  28703. this[marginName] = margin;
  28704. return path;
  28705. };
  28706. }
  28707. else {
  28708. // Apply the corrected plotWidth
  28709. axis.setAxisSize();
  28710. axis.setAxisTranslation();
  28711. }
  28712. });
  28713. }
  28714. }
  28715. });
  28716. addEvent(Chart, 'render', function () {
  28717. if (this.scrollablePixelsX || this.scrollablePixelsY) {
  28718. if (this.setUpScrolling) {
  28719. this.setUpScrolling();
  28720. }
  28721. this.applyFixed();
  28722. }
  28723. else if (this.fixedDiv) { // Has been in scrollable mode
  28724. this.applyFixed();
  28725. }
  28726. });
  28727. /**
  28728. * @private
  28729. * @function Highcharts.Chart#setUpScrolling
  28730. * @return {void}
  28731. */
  28732. Chart.prototype.setUpScrolling = function () {
  28733. var _this = this;
  28734. var attribs = {
  28735. WebkitOverflowScrolling: 'touch',
  28736. overflowX: 'hidden',
  28737. overflowY: 'hidden'
  28738. };
  28739. if (this.scrollablePixelsX) {
  28740. attribs.overflowX = 'auto';
  28741. }
  28742. if (this.scrollablePixelsY) {
  28743. attribs.overflowY = 'auto';
  28744. }
  28745. // Insert a container with position relative
  28746. // that scrolling and fixed container renders to (#10555)
  28747. this.scrollingParent = createElement('div', {
  28748. className: 'highcharts-scrolling-parent'
  28749. }, {
  28750. position: 'relative'
  28751. }, this.renderTo);
  28752. // Add the necessary divs to provide scrolling
  28753. this.scrollingContainer = createElement('div', {
  28754. 'className': 'highcharts-scrolling'
  28755. }, attribs, this.scrollingParent);
  28756. // On scroll, reset the chart position because it applies to the scrolled
  28757. // container
  28758. addEvent(this.scrollingContainer, 'scroll', function () {
  28759. if (_this.pointer) {
  28760. delete _this.pointer.chartPosition;
  28761. }
  28762. });
  28763. this.innerContainer = createElement('div', {
  28764. 'className': 'highcharts-inner-container'
  28765. }, null, this.scrollingContainer);
  28766. // Now move the container inside
  28767. this.innerContainer.appendChild(this.container);
  28768. // Don't run again
  28769. this.setUpScrolling = null;
  28770. };
  28771. /**
  28772. * These elements are moved over to the fixed renderer and stay fixed when the
  28773. * user scrolls the chart
  28774. * @private
  28775. */
  28776. Chart.prototype.moveFixedElements = function () {
  28777. var container = this.container,
  28778. fixedRenderer = this.fixedRenderer,
  28779. fixedSelectors = [
  28780. '.highcharts-contextbutton',
  28781. '.highcharts-credits',
  28782. '.highcharts-legend',
  28783. '.highcharts-legend-checkbox',
  28784. '.highcharts-navigator-series',
  28785. '.highcharts-navigator-xaxis',
  28786. '.highcharts-navigator-yaxis',
  28787. '.highcharts-navigator',
  28788. '.highcharts-reset-zoom',
  28789. '.highcharts-scrollbar',
  28790. '.highcharts-subtitle',
  28791. '.highcharts-title'
  28792. ],
  28793. axisClass;
  28794. if (this.scrollablePixelsX && !this.inverted) {
  28795. axisClass = '.highcharts-yaxis';
  28796. }
  28797. else if (this.scrollablePixelsX && this.inverted) {
  28798. axisClass = '.highcharts-xaxis';
  28799. }
  28800. else if (this.scrollablePixelsY && !this.inverted) {
  28801. axisClass = '.highcharts-xaxis';
  28802. }
  28803. else if (this.scrollablePixelsY && this.inverted) {
  28804. axisClass = '.highcharts-yaxis';
  28805. }
  28806. fixedSelectors.push(axisClass, axisClass + '-labels');
  28807. fixedSelectors.forEach(function (className) {
  28808. [].forEach.call(container.querySelectorAll(className), function (elem) {
  28809. (elem.namespaceURI === fixedRenderer.SVG_NS ?
  28810. fixedRenderer.box :
  28811. fixedRenderer.box.parentNode).appendChild(elem);
  28812. elem.style.pointerEvents = 'auto';
  28813. });
  28814. });
  28815. };
  28816. /**
  28817. * @private
  28818. * @function Highcharts.Chart#applyFixed
  28819. * @return {void}
  28820. */
  28821. Chart.prototype.applyFixed = function () {
  28822. var _a,
  28823. _b;
  28824. var fixedRenderer,
  28825. scrollableWidth,
  28826. scrollableHeight,
  28827. firstTime = !this.fixedDiv,
  28828. scrollableOptions = this.options.chart.scrollablePlotArea;
  28829. // First render
  28830. if (firstTime) {
  28831. this.fixedDiv = createElement('div', {
  28832. className: 'highcharts-fixed'
  28833. }, {
  28834. position: 'absolute',
  28835. overflow: 'hidden',
  28836. pointerEvents: 'none',
  28837. zIndex: 2,
  28838. top: 0
  28839. }, null, true);
  28840. (_a = this.scrollingContainer) === null || _a === void 0 ? void 0 : _a.parentNode.insertBefore(this.fixedDiv, this.scrollingContainer);
  28841. this.renderTo.style.overflow = 'visible';
  28842. this.fixedRenderer = fixedRenderer = new H.Renderer(this.fixedDiv, this.chartWidth, this.chartHeight, (_b = this.options.chart) === null || _b === void 0 ? void 0 : _b.style);
  28843. // Mask
  28844. this.scrollableMask = fixedRenderer
  28845. .path()
  28846. .attr({
  28847. fill: this.options.chart.backgroundColor || '#fff',
  28848. 'fill-opacity': pick(scrollableOptions.opacity, 0.85),
  28849. zIndex: -1
  28850. })
  28851. .addClass('highcharts-scrollable-mask')
  28852. .add();
  28853. this.moveFixedElements();
  28854. addEvent(this, 'afterShowResetZoom', this.moveFixedElements);
  28855. addEvent(this, 'afterLayOutTitles', this.moveFixedElements);
  28856. }
  28857. else {
  28858. // Set the size of the fixed renderer to the visible width
  28859. this.fixedRenderer.setSize(this.chartWidth, this.chartHeight);
  28860. }
  28861. // Increase the size of the scrollable renderer and background
  28862. scrollableWidth = this.chartWidth + (this.scrollablePixelsX || 0);
  28863. scrollableHeight = this.chartHeight + (this.scrollablePixelsY || 0);
  28864. stop(this.container);
  28865. this.container.style.width = scrollableWidth + 'px';
  28866. this.container.style.height = scrollableHeight + 'px';
  28867. this.renderer.boxWrapper.attr({
  28868. width: scrollableWidth,
  28869. height: scrollableHeight,
  28870. viewBox: [0, 0, scrollableWidth, scrollableHeight].join(' ')
  28871. });
  28872. this.chartBackground.attr({
  28873. width: scrollableWidth,
  28874. height: scrollableHeight
  28875. });
  28876. this.scrollingContainer.style.height = this.chartHeight + 'px';
  28877. // Set scroll position
  28878. if (firstTime) {
  28879. if (scrollableOptions.scrollPositionX) {
  28880. this.scrollingContainer.scrollLeft =
  28881. this.scrollablePixelsX *
  28882. scrollableOptions.scrollPositionX;
  28883. }
  28884. if (scrollableOptions.scrollPositionY) {
  28885. this.scrollingContainer.scrollTop =
  28886. this.scrollablePixelsY *
  28887. scrollableOptions.scrollPositionY;
  28888. }
  28889. }
  28890. // Mask behind the left and right side
  28891. var axisOffset = this.axisOffset,
  28892. maskTop = this.plotTop - axisOffset[0] - 1,
  28893. maskLeft = this.plotLeft - axisOffset[3] - 1,
  28894. maskBottom = this.plotTop + this.plotHeight + axisOffset[2] + 1,
  28895. maskRight = this.plotLeft + this.plotWidth + axisOffset[1] + 1,
  28896. maskPlotRight = this.plotLeft + this.plotWidth -
  28897. (this.scrollablePixelsX || 0),
  28898. maskPlotBottom = this.plotTop + this.plotHeight -
  28899. (this.scrollablePixelsY || 0),
  28900. d;
  28901. if (this.scrollablePixelsX) {
  28902. d = [
  28903. // Left side
  28904. ['M', 0, maskTop],
  28905. ['L', this.plotLeft - 1, maskTop],
  28906. ['L', this.plotLeft - 1, maskBottom],
  28907. ['L', 0, maskBottom],
  28908. ['Z'],
  28909. // Right side
  28910. ['M', maskPlotRight, maskTop],
  28911. ['L', this.chartWidth, maskTop],
  28912. ['L', this.chartWidth, maskBottom],
  28913. ['L', maskPlotRight, maskBottom],
  28914. ['Z']
  28915. ];
  28916. }
  28917. else if (this.scrollablePixelsY) {
  28918. d = [
  28919. // Top side
  28920. ['M', maskLeft, 0],
  28921. ['L', maskLeft, this.plotTop - 1],
  28922. ['L', maskRight, this.plotTop - 1],
  28923. ['L', maskRight, 0],
  28924. ['Z'],
  28925. // Bottom side
  28926. ['M', maskLeft, maskPlotBottom],
  28927. ['L', maskLeft, this.chartHeight],
  28928. ['L', maskRight, this.chartHeight],
  28929. ['L', maskRight, maskPlotBottom],
  28930. ['Z']
  28931. ];
  28932. }
  28933. else {
  28934. d = [['M', 0, 0]];
  28935. }
  28936. if (this.redrawTrigger !== 'adjustHeight') {
  28937. this.scrollableMask.attr({ d: d });
  28938. }
  28939. };
  28940. });
  28941. _registerModule(_modules, 'Core/Axis/StackingAxis.js', [_modules['Core/Utilities.js']], function (U) {
  28942. /* *
  28943. *
  28944. * (c) 2010-2020 Torstein Honsi
  28945. *
  28946. * License: www.highcharts.com/license
  28947. *
  28948. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  28949. *
  28950. * */
  28951. var addEvent = U.addEvent,
  28952. destroyObjectProperties = U.destroyObjectProperties,
  28953. fireEvent = U.fireEvent,
  28954. getDeferredAnimation = U.getDeferredAnimation,
  28955. objectEach = U.objectEach,
  28956. pick = U.pick;
  28957. /* eslint-disable valid-jsdoc */
  28958. /**
  28959. * Adds stacking support to axes.
  28960. * @private
  28961. * @class
  28962. */
  28963. var StackingAxisAdditions = /** @class */ (function () {
  28964. /* *
  28965. *
  28966. * Constructors
  28967. *
  28968. * */
  28969. function StackingAxisAdditions(axis) {
  28970. this.oldStacks = {};
  28971. this.stacks = {};
  28972. this.stacksTouched = 0;
  28973. this.axis = axis;
  28974. }
  28975. /* *
  28976. *
  28977. * Functions
  28978. *
  28979. * */
  28980. /**
  28981. * Build the stacks from top down
  28982. * @private
  28983. */
  28984. StackingAxisAdditions.prototype.buildStacks = function () {
  28985. var stacking = this;
  28986. var axis = stacking.axis;
  28987. var axisSeries = axis.series;
  28988. var reversedStacks = pick(axis.options.reversedStacks,
  28989. true);
  28990. var len = axisSeries.length;
  28991. var actualSeries,
  28992. i;
  28993. if (!axis.isXAxis) {
  28994. stacking.usePercentage = false;
  28995. i = len;
  28996. while (i--) {
  28997. actualSeries = axisSeries[reversedStacks ? i : len - i - 1];
  28998. actualSeries.setStackedPoints();
  28999. actualSeries.setGroupedPoints();
  29000. }
  29001. // Loop up again to compute percent and stream stack
  29002. for (i = 0; i < len; i++) {
  29003. axisSeries[i].modifyStacks();
  29004. }
  29005. fireEvent(axis, 'afterBuildStacks');
  29006. }
  29007. };
  29008. /**
  29009. * @private
  29010. */
  29011. StackingAxisAdditions.prototype.cleanStacks = function () {
  29012. var stacking = this;
  29013. var axis = stacking.axis;
  29014. var stacks;
  29015. if (!axis.isXAxis) {
  29016. if (stacking.oldStacks) {
  29017. stacks = stacking.stacks = stacking.oldStacks;
  29018. }
  29019. // reset stacks
  29020. objectEach(stacks, function (type) {
  29021. objectEach(type, function (stack) {
  29022. stack.cumulative = stack.total;
  29023. });
  29024. });
  29025. }
  29026. };
  29027. /**
  29028. * Set all the stacks to initial states and destroy unused ones.
  29029. * @private
  29030. */
  29031. StackingAxisAdditions.prototype.resetStacks = function () {
  29032. var stacking = this;
  29033. var axis = stacking.axis;
  29034. var stacks = stacking.stacks;
  29035. if (!axis.isXAxis) {
  29036. objectEach(stacks, function (type) {
  29037. objectEach(type, function (stack, key) {
  29038. // Clean up memory after point deletion (#1044, #4320)
  29039. if (stack.touched < stacking.stacksTouched) {
  29040. stack.destroy();
  29041. delete type[key];
  29042. // Reset stacks
  29043. }
  29044. else {
  29045. stack.total = null;
  29046. stack.cumulative = null;
  29047. }
  29048. });
  29049. });
  29050. }
  29051. };
  29052. /**
  29053. * @private
  29054. */
  29055. StackingAxisAdditions.prototype.renderStackTotals = function () {
  29056. var stacking = this;
  29057. var axis = stacking.axis;
  29058. var chart = axis.chart;
  29059. var renderer = chart.renderer;
  29060. var stacks = stacking.stacks;
  29061. var stackLabelsAnim = axis.options.stackLabels.animation;
  29062. var animationConfig = getDeferredAnimation(chart,
  29063. stackLabelsAnim);
  29064. var stackTotalGroup = stacking.stackTotalGroup = (stacking.stackTotalGroup ||
  29065. renderer
  29066. .g('stack-labels')
  29067. .attr({
  29068. visibility: 'visible',
  29069. zIndex: 6,
  29070. opacity: 0
  29071. })
  29072. .add());
  29073. // plotLeft/Top will change when y axis gets wider so we need to
  29074. // translate the stackTotalGroup at every render call. See bug #506
  29075. // and #516
  29076. stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
  29077. // Render each stack total
  29078. objectEach(stacks, function (type) {
  29079. objectEach(type, function (stack) {
  29080. stack.render(stackTotalGroup);
  29081. });
  29082. });
  29083. stackTotalGroup.animate({
  29084. opacity: 1
  29085. }, animationConfig);
  29086. };
  29087. return StackingAxisAdditions;
  29088. }());
  29089. /**
  29090. * Axis with stacking support.
  29091. * @private
  29092. * @class
  29093. */
  29094. var StackingAxis = /** @class */ (function () {
  29095. function StackingAxis() {
  29096. }
  29097. /* *
  29098. *
  29099. * Static Functions
  29100. *
  29101. * */
  29102. /**
  29103. * Extends axis with stacking support.
  29104. * @private
  29105. */
  29106. StackingAxis.compose = function (AxisClass) {
  29107. var axisProto = AxisClass.prototype;
  29108. addEvent(AxisClass, 'init', StackingAxis.onInit);
  29109. addEvent(AxisClass, 'destroy', StackingAxis.onDestroy);
  29110. };
  29111. /**
  29112. * @private
  29113. */
  29114. StackingAxis.onDestroy = function () {
  29115. var stacking = this.stacking;
  29116. if (!stacking) {
  29117. return;
  29118. }
  29119. var stacks = stacking.stacks;
  29120. // Destroy each stack total
  29121. objectEach(stacks, function (stack, stackKey) {
  29122. destroyObjectProperties(stack);
  29123. stacks[stackKey] = null;
  29124. });
  29125. if (stacking &&
  29126. stacking.stackTotalGroup) {
  29127. stacking.stackTotalGroup.destroy();
  29128. }
  29129. };
  29130. /**
  29131. * @private
  29132. */
  29133. StackingAxis.onInit = function () {
  29134. var axis = this;
  29135. if (!axis.stacking) {
  29136. axis.stacking = new StackingAxisAdditions(axis);
  29137. }
  29138. };
  29139. return StackingAxis;
  29140. }());
  29141. return StackingAxis;
  29142. });
  29143. _registerModule(_modules, 'Mixins/LegendSymbol.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  29144. /* *
  29145. *
  29146. * (c) 2010-2020 Torstein Honsi
  29147. *
  29148. * License: www.highcharts.com/license
  29149. *
  29150. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29151. *
  29152. * */
  29153. var merge = U.merge,
  29154. pick = U.pick;
  29155. /* eslint-disable valid-jsdoc */
  29156. /**
  29157. * Legend symbol mixin.
  29158. *
  29159. * @private
  29160. * @mixin Highcharts.LegendSymbolMixin
  29161. */
  29162. var LegendSymbolMixin = H.LegendSymbolMixin = {
  29163. /**
  29164. * Get the series' symbol in the legend
  29165. *
  29166. * @private
  29167. * @function Highcharts.LegendSymbolMixin.drawRectangle
  29168. *
  29169. * @param {Highcharts.Legend} legend
  29170. * The legend object
  29171. *
  29172. * @param {Highcharts.Point|Highcharts.Series} item
  29173. * The series (this) or point
  29174. */
  29175. drawRectangle: function (legend,
  29176. item) {
  29177. var options = legend.options,
  29178. symbolHeight = legend.symbolHeight,
  29179. square = options.squareSymbol,
  29180. symbolWidth = square ? symbolHeight : legend.symbolWidth;
  29181. item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, // #3988
  29182. symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2))
  29183. .addClass('highcharts-point')
  29184. .attr({
  29185. zIndex: 3
  29186. }).add(item.legendGroup);
  29187. },
  29188. /**
  29189. * Get the series' symbol in the legend. This method should be overridable
  29190. * to create custom symbols through
  29191. * Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
  29192. *
  29193. * @private
  29194. * @function Highcharts.LegendSymbolMixin.drawLineMarker
  29195. *
  29196. * @param {Highcharts.Legend} legend
  29197. * The legend object.
  29198. */
  29199. drawLineMarker: function (legend) {
  29200. var options = this.options,
  29201. markerOptions = options.marker,
  29202. radius,
  29203. legendSymbol,
  29204. symbolWidth = legend.symbolWidth,
  29205. symbolHeight = legend.symbolHeight,
  29206. generalRadius = symbolHeight / 2,
  29207. renderer = this.chart.renderer,
  29208. legendItemGroup = this.legendGroup,
  29209. verticalCenter = legend.baseline -
  29210. Math.round(legend.fontMetrics.b * 0.3),
  29211. attr = {};
  29212. // Draw the line
  29213. if (!this.chart.styledMode) {
  29214. attr = {
  29215. 'stroke-width': options.lineWidth || 0
  29216. };
  29217. if (options.dashStyle) {
  29218. attr.dashstyle = options.dashStyle;
  29219. }
  29220. }
  29221. this.legendLine = renderer
  29222. .path([
  29223. ['M', 0, verticalCenter],
  29224. ['L', symbolWidth, verticalCenter]
  29225. ])
  29226. .addClass('highcharts-graph')
  29227. .attr(attr)
  29228. .add(legendItemGroup);
  29229. // Draw the marker
  29230. if (markerOptions && markerOptions.enabled !== false && symbolWidth) {
  29231. // Do not allow the marker to be larger than the symbolHeight
  29232. radius = Math.min(pick(markerOptions.radius, generalRadius), generalRadius);
  29233. // Restrict symbol markers size
  29234. if (this.symbol.indexOf('url') === 0) {
  29235. markerOptions = merge(markerOptions, {
  29236. width: symbolHeight,
  29237. height: symbolHeight
  29238. });
  29239. radius = 0;
  29240. }
  29241. this.legendSymbol = legendSymbol = renderer.symbol(this.symbol, (symbolWidth / 2) - radius, verticalCenter - radius, 2 * radius, 2 * radius, markerOptions)
  29242. .addClass('highcharts-point')
  29243. .add(legendItemGroup);
  29244. legendSymbol.isMarker = true;
  29245. }
  29246. }
  29247. };
  29248. return LegendSymbolMixin;
  29249. });
  29250. _registerModule(_modules, 'Core/Series/Point.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  29251. /* *
  29252. *
  29253. * (c) 2010-2020 Torstein Honsi
  29254. *
  29255. * License: www.highcharts.com/license
  29256. *
  29257. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29258. *
  29259. * */
  29260. var animObject = U.animObject,
  29261. defined = U.defined,
  29262. erase = U.erase,
  29263. extend = U.extend,
  29264. fireEvent = U.fireEvent,
  29265. format = U.format,
  29266. getNestedProperty = U.getNestedProperty,
  29267. isArray = U.isArray,
  29268. isNumber = U.isNumber,
  29269. isObject = U.isObject,
  29270. syncTimeout = U.syncTimeout,
  29271. pick = U.pick,
  29272. removeEvent = U.removeEvent,
  29273. uniqueKey = U.uniqueKey;
  29274. /**
  29275. * Function callback when a series point is clicked. Return false to cancel the
  29276. * action.
  29277. *
  29278. * @callback Highcharts.PointClickCallbackFunction
  29279. *
  29280. * @param {Highcharts.Point} this
  29281. * The point where the event occured.
  29282. *
  29283. * @param {Highcharts.PointClickEventObject} event
  29284. * Event arguments.
  29285. */
  29286. /**
  29287. * Common information for a click event on a series point.
  29288. *
  29289. * @interface Highcharts.PointClickEventObject
  29290. * @extends Highcharts.PointerEventObject
  29291. */ /**
  29292. * Clicked point.
  29293. * @name Highcharts.PointClickEventObject#point
  29294. * @type {Highcharts.Point}
  29295. */
  29296. /**
  29297. * Configuration hash for the data label and tooltip formatters.
  29298. *
  29299. * @interface Highcharts.PointLabelObject
  29300. */ /**
  29301. * The point's current color.
  29302. * @name Highcharts.PointLabelObject#color
  29303. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  29304. */ /**
  29305. * The point's current color index, used in styled mode instead of `color`. The
  29306. * color index is inserted in class names used for styling.
  29307. * @name Highcharts.PointLabelObject#colorIndex
  29308. * @type {number}
  29309. */ /**
  29310. * The name of the related point.
  29311. * @name Highcharts.PointLabelObject#key
  29312. * @type {string|undefined}
  29313. */ /**
  29314. * The percentage for related points in a stacked series or pies.
  29315. * @name Highcharts.PointLabelObject#percentage
  29316. * @type {number}
  29317. */ /**
  29318. * The related point. The point name, if defined, is available through
  29319. * `this.point.name`.
  29320. * @name Highcharts.PointLabelObject#point
  29321. * @type {Highcharts.Point}
  29322. */ /**
  29323. * The related series. The series name is available through `this.series.name`.
  29324. * @name Highcharts.PointLabelObject#series
  29325. * @type {Highcharts.Series}
  29326. */ /**
  29327. * The total of values in either a stack for stacked series, or a pie in a pie
  29328. * series.
  29329. * @name Highcharts.PointLabelObject#total
  29330. * @type {number|undefined}
  29331. */ /**
  29332. * For categorized axes this property holds the category name for the point. For
  29333. * other axes it holds the X value.
  29334. * @name Highcharts.PointLabelObject#x
  29335. * @type {number|string|undefined}
  29336. */ /**
  29337. * The y value of the point.
  29338. * @name Highcharts.PointLabelObject#y
  29339. * @type {number|undefined}
  29340. */
  29341. /**
  29342. * Gets fired when the mouse leaves the area close to the point.
  29343. *
  29344. * @callback Highcharts.PointMouseOutCallbackFunction
  29345. *
  29346. * @param {Highcharts.Point} this
  29347. * Point where the event occured.
  29348. *
  29349. * @param {global.PointerEvent} event
  29350. * Event that occured.
  29351. */
  29352. /**
  29353. * Gets fired when the mouse enters the area close to the point.
  29354. *
  29355. * @callback Highcharts.PointMouseOverCallbackFunction
  29356. *
  29357. * @param {Highcharts.Point} this
  29358. * Point where the event occured.
  29359. *
  29360. * @param {global.Event} event
  29361. * Event that occured.
  29362. */
  29363. /**
  29364. * The generic point options for all series.
  29365. *
  29366. * In TypeScript you have to extend `PointOptionsObject` with an additional
  29367. * declaration to allow custom data options:
  29368. *
  29369. * ```
  29370. * declare interface PointOptionsObject {
  29371. * customProperty: string;
  29372. * }
  29373. * ```
  29374. *
  29375. * @interface Highcharts.PointOptionsObject
  29376. */
  29377. /**
  29378. * Possible option types for a data point.
  29379. *
  29380. * @typedef {number|string|Array<(number|string)>|Highcharts.PointOptionsObject|null} Highcharts.PointOptionsType
  29381. */
  29382. /**
  29383. * Gets fired when the point is removed using the `.remove()` method.
  29384. *
  29385. * @callback Highcharts.PointRemoveCallbackFunction
  29386. *
  29387. * @param {Highcharts.Point} this
  29388. * Point where the event occured.
  29389. *
  29390. * @param {global.Event} event
  29391. * Event that occured.
  29392. */
  29393. /**
  29394. * Possible key values for the point state options.
  29395. *
  29396. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.PointStateValue
  29397. */
  29398. /**
  29399. * Gets fired when the point is updated programmatically through the `.update()`
  29400. * method.
  29401. *
  29402. * @callback Highcharts.PointUpdateCallbackFunction
  29403. *
  29404. * @param {Highcharts.Point} this
  29405. * Point where the event occured.
  29406. *
  29407. * @param {Highcharts.PointUpdateEventObject} event
  29408. * Event that occured.
  29409. */
  29410. /**
  29411. * Information about the update event.
  29412. *
  29413. * @interface Highcharts.PointUpdateEventObject
  29414. * @extends global.Event
  29415. */ /**
  29416. * Options data of the update event.
  29417. * @name Highcharts.PointUpdateEventObject#options
  29418. * @type {Highcharts.PointOptionsType}
  29419. */
  29420. ''; // detach doclet above
  29421. /* eslint-disable no-invalid-this, valid-jsdoc */
  29422. /**
  29423. * The Point object. The point objects are generated from the `series.data`
  29424. * configuration objects or raw numbers. They can be accessed from the
  29425. * `Series.points` array. Other ways to instantiate points are through {@link
  29426. * Highcharts.Series#addPoint} or {@link Highcharts.Series#setData}.
  29427. *
  29428. * @class
  29429. * @name Highcharts.Point
  29430. */
  29431. var Point = /** @class */ (function () {
  29432. function Point() {
  29433. /* *
  29434. *
  29435. * Properties
  29436. *
  29437. * */
  29438. /**
  29439. * For categorized axes this property holds the category name for the
  29440. * point. For other axes it holds the X value.
  29441. *
  29442. * @name Highcharts.Point#category
  29443. * @type {string}
  29444. */
  29445. this.category = void 0;
  29446. /**
  29447. * The point's current color index, used in styled mode instead of
  29448. * `color`. The color index is inserted in class names used for styling.
  29449. *
  29450. * @name Highcharts.Point#colorIndex
  29451. * @type {number}
  29452. */
  29453. this.colorIndex = void 0;
  29454. this.formatPrefix = 'point';
  29455. this.id = void 0;
  29456. this.isNull = false;
  29457. /**
  29458. * The name of the point. The name can be given as the first position of the
  29459. * point configuration array, or as a `name` property in the configuration:
  29460. *
  29461. * @example
  29462. * // Array config
  29463. * data: [
  29464. * ['John', 1],
  29465. * ['Jane', 2]
  29466. * ]
  29467. *
  29468. * // Object config
  29469. * data: [{
  29470. * name: 'John',
  29471. * y: 1
  29472. * }, {
  29473. * name: 'Jane',
  29474. * y: 2
  29475. * }]
  29476. *
  29477. * @name Highcharts.Point#name
  29478. * @type {string}
  29479. */
  29480. this.name = void 0;
  29481. /**
  29482. * The point's options as applied in the initial configuration, or
  29483. * extended through `Point.update`.
  29484. *
  29485. * In TypeScript you have to extend `PointOptionsObject` via an
  29486. * additional interface to allow custom data options:
  29487. *
  29488. * ```
  29489. * declare interface PointOptionsObject {
  29490. * customProperty: string;
  29491. * }
  29492. * ```
  29493. *
  29494. * @name Highcharts.Point#options
  29495. * @type {Highcharts.PointOptionsObject}
  29496. */
  29497. this.options = void 0;
  29498. /**
  29499. * The percentage for points in a stacked series or pies.
  29500. *
  29501. * @name Highcharts.Point#percentage
  29502. * @type {number|undefined}
  29503. */
  29504. this.percentage = void 0;
  29505. this.selected = false;
  29506. /**
  29507. * The series object associated with the point.
  29508. *
  29509. * @name Highcharts.Point#series
  29510. * @type {Highcharts.Series}
  29511. */
  29512. this.series = void 0;
  29513. /**
  29514. * The total of values in either a stack for stacked series, or a pie in a
  29515. * pie series.
  29516. *
  29517. * @name Highcharts.Point#total
  29518. * @type {number|undefined}
  29519. */
  29520. this.total = void 0;
  29521. /**
  29522. * For certain series types, like pie charts, where individual points can
  29523. * be shown or hidden.
  29524. *
  29525. * @name Highcharts.Point#visible
  29526. * @type {boolean}
  29527. * @default true
  29528. */
  29529. this.visible = true;
  29530. this.x = void 0;
  29531. }
  29532. /* *
  29533. *
  29534. * Functions
  29535. *
  29536. * */
  29537. /**
  29538. * Animate SVG elements associated with the point.
  29539. *
  29540. * @private
  29541. * @function Highcharts.Point#animateBeforeDestroy
  29542. */
  29543. Point.prototype.animateBeforeDestroy = function () {
  29544. var point = this,
  29545. animateParams = { x: point.startXPos,
  29546. opacity: 0 },
  29547. isDataLabel,
  29548. graphicalProps = point.getGraphicalProps();
  29549. graphicalProps.singular.forEach(function (prop) {
  29550. isDataLabel = prop === 'dataLabel';
  29551. point[prop] = point[prop].animate(isDataLabel ? {
  29552. x: point[prop].startXPos,
  29553. y: point[prop].startYPos,
  29554. opacity: 0
  29555. } : animateParams);
  29556. });
  29557. graphicalProps.plural.forEach(function (plural) {
  29558. point[plural].forEach(function (item) {
  29559. if (item.element) {
  29560. item.animate(extend({ x: point.startXPos }, (item.startYPos ? {
  29561. x: item.startXPos,
  29562. y: item.startYPos
  29563. } : {})));
  29564. }
  29565. });
  29566. });
  29567. };
  29568. /**
  29569. * Apply the options containing the x and y data and possible some extra
  29570. * properties. Called on point init or from point.update.
  29571. *
  29572. * @private
  29573. * @function Highcharts.Point#applyOptions
  29574. *
  29575. * @param {Highcharts.PointOptionsType} options
  29576. * The point options as defined in series.data.
  29577. *
  29578. * @param {number} [x]
  29579. * Optionally, the x value.
  29580. *
  29581. * @return {Highcharts.Point}
  29582. * The Point instance.
  29583. */
  29584. Point.prototype.applyOptions = function (options, x) {
  29585. var point = this,
  29586. series = point.series,
  29587. pointValKey = series.options.pointValKey || series.pointValKey;
  29588. options = Point.prototype.optionsToObject.call(this, options);
  29589. // copy options directly to point
  29590. extend(point, options);
  29591. point.options = point.options ? extend(point.options, options) : options;
  29592. // Since options are copied into the Point instance, some accidental
  29593. // options must be shielded (#5681)
  29594. if (options.group) {
  29595. delete point.group;
  29596. }
  29597. if (options.dataLabels) {
  29598. delete point.dataLabels;
  29599. }
  29600. /**
  29601. * The y value of the point.
  29602. * @name Highcharts.Point#y
  29603. * @type {number|undefined}
  29604. */
  29605. // For higher dimension series types. For instance, for ranges, point.y
  29606. // is mapped to point.low.
  29607. if (pointValKey) {
  29608. point.y = Point.prototype.getNestedProperty.call(point, pointValKey);
  29609. }
  29610. point.isNull = pick(point.isValid && !point.isValid(), point.x === null || !isNumber(point.y)); // #3571, check for NaN
  29611. point.formatPrefix = point.isNull ? 'null' : 'point'; // #9233, #10874
  29612. // The point is initially selected by options (#5777)
  29613. if (point.selected) {
  29614. point.state = 'select';
  29615. }
  29616. /**
  29617. * The x value of the point.
  29618. * @name Highcharts.Point#x
  29619. * @type {number}
  29620. */
  29621. // If no x is set by now, get auto incremented value. All points must
  29622. // have an x value, however the y value can be null to create a gap in
  29623. // the series
  29624. if ('name' in point &&
  29625. typeof x === 'undefined' &&
  29626. series.xAxis &&
  29627. series.xAxis.hasNames) {
  29628. point.x = series.xAxis.nameToX(point);
  29629. }
  29630. if (typeof point.x === 'undefined' && series) {
  29631. if (typeof x === 'undefined') {
  29632. point.x = series.autoIncrement(point);
  29633. }
  29634. else {
  29635. point.x = x;
  29636. }
  29637. }
  29638. return point;
  29639. };
  29640. /**
  29641. * Destroy a point to clear memory. Its reference still stays in
  29642. * `series.data`.
  29643. *
  29644. * @private
  29645. * @function Highcharts.Point#destroy
  29646. */
  29647. Point.prototype.destroy = function () {
  29648. var point = this,
  29649. series = point.series,
  29650. chart = series.chart,
  29651. dataSorting = series.options.dataSorting,
  29652. hoverPoints = chart.hoverPoints,
  29653. globalAnimation = point.series.chart.renderer.globalAnimation,
  29654. animation = animObject(globalAnimation),
  29655. prop;
  29656. /**
  29657. * Allow to call after animation.
  29658. * @private
  29659. */
  29660. function destroyPoint() {
  29661. // Remove all events and elements
  29662. if (point.graphic || point.dataLabel || point.dataLabels) {
  29663. removeEvent(point);
  29664. point.destroyElements();
  29665. }
  29666. for (prop in point) { // eslint-disable-line guard-for-in
  29667. point[prop] = null;
  29668. }
  29669. }
  29670. if (point.legendItem) { // pies have legend items
  29671. chart.legend.destroyItem(point);
  29672. }
  29673. if (hoverPoints) {
  29674. point.setState();
  29675. erase(hoverPoints, point);
  29676. if (!hoverPoints.length) {
  29677. chart.hoverPoints = null;
  29678. }
  29679. }
  29680. if (point === chart.hoverPoint) {
  29681. point.onMouseOut();
  29682. }
  29683. // Remove properties after animation
  29684. if (!dataSorting || !dataSorting.enabled) {
  29685. destroyPoint();
  29686. }
  29687. else {
  29688. this.animateBeforeDestroy();
  29689. syncTimeout(destroyPoint, animation.duration);
  29690. }
  29691. chart.pointCount--;
  29692. };
  29693. /**
  29694. * Destroy SVG elements associated with the point.
  29695. *
  29696. * @private
  29697. * @function Highcharts.Point#destroyElements
  29698. * @param {Highcharts.Dictionary<number>} [kinds]
  29699. */
  29700. Point.prototype.destroyElements = function (kinds) {
  29701. var point = this,
  29702. props = point.getGraphicalProps(kinds);
  29703. props.singular.forEach(function (prop) {
  29704. point[prop] = point[prop].destroy();
  29705. });
  29706. props.plural.forEach(function (plural) {
  29707. point[plural].forEach(function (item) {
  29708. if (item.element) {
  29709. item.destroy();
  29710. }
  29711. });
  29712. delete point[plural];
  29713. });
  29714. };
  29715. /**
  29716. * Fire an event on the Point object.
  29717. *
  29718. * @private
  29719. * @function Highcharts.Point#firePointEvent
  29720. *
  29721. * @param {string} eventType
  29722. * Type of the event.
  29723. *
  29724. * @param {Highcharts.Dictionary<any>|Event} [eventArgs]
  29725. * Additional event arguments.
  29726. *
  29727. * @param {Highcharts.EventCallbackFunction<Highcharts.Point>|Function} [defaultFunction]
  29728. * Default event handler.
  29729. *
  29730. * @fires Highcharts.Point#event:*
  29731. */
  29732. Point.prototype.firePointEvent = function (eventType, eventArgs, defaultFunction) {
  29733. var point = this,
  29734. series = this.series,
  29735. seriesOptions = series.options;
  29736. // load event handlers on demand to save time on mouseover/out
  29737. if (seriesOptions.point.events[eventType] ||
  29738. (point.options &&
  29739. point.options.events &&
  29740. point.options.events[eventType])) {
  29741. point.importEvents();
  29742. }
  29743. // add default handler if in selection mode
  29744. if (eventType === 'click' && seriesOptions.allowPointSelect) {
  29745. defaultFunction = function (event) {
  29746. // Control key is for Windows, meta (= Cmd key) for Mac, Shift
  29747. // for Opera.
  29748. if (point.select) { // #2911
  29749. point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
  29750. }
  29751. };
  29752. }
  29753. fireEvent(point, eventType, eventArgs, defaultFunction);
  29754. };
  29755. /**
  29756. * Get the CSS class names for individual points. Used internally where the
  29757. * returned value is set on every point.
  29758. *
  29759. * @function Highcharts.Point#getClassName
  29760. *
  29761. * @return {string}
  29762. * The class names.
  29763. */
  29764. Point.prototype.getClassName = function () {
  29765. var point = this;
  29766. return 'highcharts-point' +
  29767. (point.selected ? ' highcharts-point-select' : '') +
  29768. (point.negative ? ' highcharts-negative' : '') +
  29769. (point.isNull ? ' highcharts-null-point' : '') +
  29770. (typeof point.colorIndex !== 'undefined' ?
  29771. ' highcharts-color-' + point.colorIndex : '') +
  29772. (point.options.className ? ' ' + point.options.className : '') +
  29773. (point.zone && point.zone.className ? ' ' +
  29774. point.zone.className.replace('highcharts-negative', '') : '');
  29775. };
  29776. /**
  29777. * Get props of all existing graphical point elements.
  29778. *
  29779. * @private
  29780. * @function Highcharts.Point#getGraphicalProps
  29781. * @param {Highcharts.Dictionary<number>} [kinds]
  29782. * @return {Highcharts.PointGraphicalProps}
  29783. */
  29784. Point.prototype.getGraphicalProps = function (kinds) {
  29785. var point = this,
  29786. props = [],
  29787. prop,
  29788. i,
  29789. graphicalProps = { singular: [],
  29790. plural: [] };
  29791. kinds = kinds || { graphic: 1, dataLabel: 1 };
  29792. if (kinds.graphic) {
  29793. props.push('graphic', 'shadowGroup');
  29794. }
  29795. if (kinds.dataLabel) {
  29796. props.push('dataLabel', 'dataLabelUpper', 'connector');
  29797. }
  29798. i = props.length;
  29799. while (i--) {
  29800. prop = props[i];
  29801. if (point[prop]) {
  29802. graphicalProps.singular.push(prop);
  29803. }
  29804. }
  29805. ['dataLabel', 'connector'].forEach(function (prop) {
  29806. var plural = prop + 's';
  29807. if (kinds[prop] && point[plural]) {
  29808. graphicalProps.plural.push(plural);
  29809. }
  29810. });
  29811. return graphicalProps;
  29812. };
  29813. /**
  29814. * Return the configuration hash needed for the data label and tooltip
  29815. * formatters.
  29816. *
  29817. * @function Highcharts.Point#getLabelConfig
  29818. *
  29819. * @return {Highcharts.PointLabelObject}
  29820. * Abstract object used in formatters and formats.
  29821. */
  29822. Point.prototype.getLabelConfig = function () {
  29823. return {
  29824. x: this.category,
  29825. y: this.y,
  29826. color: this.color,
  29827. colorIndex: this.colorIndex,
  29828. key: this.name || this.category,
  29829. series: this.series,
  29830. point: this,
  29831. percentage: this.percentage,
  29832. total: this.total || this.stackTotal
  29833. };
  29834. };
  29835. /**
  29836. * Returns the value of the point property for a given value.
  29837. * @private
  29838. */
  29839. Point.prototype.getNestedProperty = function (key) {
  29840. if (!key) {
  29841. return;
  29842. }
  29843. if (key.indexOf('custom.') === 0) {
  29844. return getNestedProperty(key, this.options);
  29845. }
  29846. return this[key];
  29847. };
  29848. /**
  29849. * In a series with `zones`, return the zone that the point belongs to.
  29850. *
  29851. * @function Highcharts.Point#getZone
  29852. *
  29853. * @return {Highcharts.SeriesZonesOptionsObject}
  29854. * The zone item.
  29855. */
  29856. Point.prototype.getZone = function () {
  29857. var series = this.series,
  29858. zones = series.zones,
  29859. zoneAxis = series.zoneAxis || 'y',
  29860. i = 0,
  29861. zone;
  29862. zone = zones[i];
  29863. while (this[zoneAxis] >= zone.value) {
  29864. zone = zones[++i];
  29865. }
  29866. // For resetting or reusing the point (#8100)
  29867. if (!this.nonZonedColor) {
  29868. this.nonZonedColor = this.color;
  29869. }
  29870. if (zone && zone.color && !this.options.color) {
  29871. this.color = zone.color;
  29872. }
  29873. else {
  29874. this.color = this.nonZonedColor;
  29875. }
  29876. return zone;
  29877. };
  29878. /**
  29879. * Utility to check if point has new shape type. Used in column series and
  29880. * all others that are based on column series.
  29881. *
  29882. * @return boolean|undefined
  29883. */
  29884. Point.prototype.hasNewShapeType = function () {
  29885. var point = this;
  29886. var oldShapeType = point.graphic &&
  29887. (point.graphic.symbolName || point.graphic.element.nodeName);
  29888. return oldShapeType !== this.shapeType;
  29889. };
  29890. /**
  29891. * Initialize the point. Called internally based on the `series.data`
  29892. * option.
  29893. *
  29894. * @function Highcharts.Point#init
  29895. *
  29896. * @param {Highcharts.Series} series
  29897. * The series object containing this point.
  29898. *
  29899. * @param {Highcharts.PointOptionsType} options
  29900. * The data in either number, array or object format.
  29901. *
  29902. * @param {number} [x]
  29903. * Optionally, the X value of the point.
  29904. *
  29905. * @return {Highcharts.Point}
  29906. * The Point instance.
  29907. *
  29908. * @fires Highcharts.Point#event:afterInit
  29909. */
  29910. Point.prototype.init = function (series, options, x) {
  29911. this.series = series;
  29912. this.applyOptions(options, x);
  29913. // Add a unique ID to the point if none is assigned
  29914. this.id = defined(this.id) ? this.id : uniqueKey();
  29915. this.resolveColor();
  29916. series.chart.pointCount++;
  29917. fireEvent(this, 'afterInit');
  29918. return this;
  29919. };
  29920. /**
  29921. * Transform number or array configs into objects. Also called for object
  29922. * configs. Used internally to unify the different configuration formats for
  29923. * points. For example, a simple number `10` in a line series will be
  29924. * transformed to `{ y: 10 }`, and an array config like `[1, 10]` in a
  29925. * scatter series will be transformed to `{ x: 1, y: 10 }`.
  29926. *
  29927. * @function Highcharts.Point#optionsToObject
  29928. *
  29929. * @param {Highcharts.PointOptionsType} options
  29930. * The input option.
  29931. *
  29932. * @return {Highcharts.Dictionary<*>}
  29933. * Transformed options.
  29934. */
  29935. Point.prototype.optionsToObject = function (options) {
  29936. var ret = {},
  29937. series = this.series,
  29938. keys = series.options.keys,
  29939. pointArrayMap = keys || series.pointArrayMap || ['y'],
  29940. valueCount = pointArrayMap.length,
  29941. firstItemType,
  29942. i = 0,
  29943. j = 0;
  29944. if (isNumber(options) || options === null) {
  29945. ret[pointArrayMap[0]] = options;
  29946. }
  29947. else if (isArray(options)) {
  29948. // with leading x value
  29949. if (!keys && options.length > valueCount) {
  29950. firstItemType = typeof options[0];
  29951. if (firstItemType === 'string') {
  29952. ret.name = options[0];
  29953. }
  29954. else if (firstItemType === 'number') {
  29955. ret.x = options[0];
  29956. }
  29957. i++;
  29958. }
  29959. while (j < valueCount) {
  29960. // Skip undefined positions for keys
  29961. if (!keys || typeof options[i] !== 'undefined') {
  29962. if (pointArrayMap[j].indexOf('.') > 0) {
  29963. // Handle nested keys, e.g. ['color.pattern.image']
  29964. // Avoid function call unless necessary.
  29965. Point.prototype.setNestedProperty(ret, options[i], pointArrayMap[j]);
  29966. }
  29967. else {
  29968. ret[pointArrayMap[j]] = options[i];
  29969. }
  29970. }
  29971. i++;
  29972. j++;
  29973. }
  29974. }
  29975. else if (typeof options === 'object') {
  29976. ret = options;
  29977. // This is the fastest way to detect if there are individual point
  29978. // dataLabels that need to be considered in drawDataLabels. These
  29979. // can only occur in object configs.
  29980. if (options.dataLabels) {
  29981. series._hasPointLabels = true;
  29982. }
  29983. // Same approach as above for markers
  29984. if (options.marker) {
  29985. series._hasPointMarkers = true;
  29986. }
  29987. }
  29988. return ret;
  29989. };
  29990. /**
  29991. * @private
  29992. * @function Highcharts.Point#resolveColor
  29993. * @return {void}
  29994. */
  29995. Point.prototype.resolveColor = function () {
  29996. var series = this.series,
  29997. colors,
  29998. optionsChart = series.chart.options.chart,
  29999. colorCount = optionsChart.colorCount,
  30000. styledMode = series.chart.styledMode,
  30001. colorIndex;
  30002. // remove points nonZonedColor for later recalculation
  30003. delete this.nonZonedColor;
  30004. /**
  30005. * The point's current color.
  30006. *
  30007. * @name Highcharts.Point#color
  30008. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  30009. */
  30010. if (!styledMode && !this.options.color) {
  30011. this.color = series.color; // #3445
  30012. }
  30013. if (series.options.colorByPoint) {
  30014. if (!styledMode) {
  30015. colors = series.options.colors || series.chart.options.colors;
  30016. this.color = this.color || colors[series.colorCounter];
  30017. colorCount = colors.length;
  30018. }
  30019. colorIndex = series.colorCounter;
  30020. series.colorCounter++;
  30021. // loop back to zero
  30022. if (series.colorCounter === colorCount) {
  30023. series.colorCounter = 0;
  30024. }
  30025. }
  30026. else {
  30027. colorIndex = series.colorIndex;
  30028. }
  30029. this.colorIndex = pick(this.colorIndex, colorIndex);
  30030. };
  30031. /**
  30032. * Set a value in an object, on the property defined by key. The key
  30033. * supports nested properties using dot notation. The function modifies the
  30034. * input object and does not make a copy.
  30035. *
  30036. * @function Highcharts.Point#setNestedProperty<T>
  30037. *
  30038. * @param {T} object
  30039. * The object to set the value on.
  30040. *
  30041. * @param {*} value
  30042. * The value to set.
  30043. *
  30044. * @param {string} key
  30045. * Key to the property to set.
  30046. *
  30047. * @return {T}
  30048. * The modified object.
  30049. */
  30050. Point.prototype.setNestedProperty = function (object, value, key) {
  30051. var nestedKeys = key.split('.');
  30052. nestedKeys.reduce(function (result, key, i, arr) {
  30053. var isLastKey = arr.length - 1 === i;
  30054. result[key] = (isLastKey ?
  30055. value :
  30056. isObject(result[key], true) ?
  30057. result[key] :
  30058. {});
  30059. return result[key];
  30060. }, object);
  30061. return object;
  30062. };
  30063. /**
  30064. * Extendable method for formatting each point's tooltip line.
  30065. *
  30066. * @function Highcharts.Point#tooltipFormatter
  30067. *
  30068. * @param {string} pointFormat
  30069. * The point format.
  30070. *
  30071. * @return {string}
  30072. * A string to be concatenated in to the common tooltip text.
  30073. */
  30074. Point.prototype.tooltipFormatter = function (pointFormat) {
  30075. // Insert options for valueDecimals, valuePrefix, and valueSuffix
  30076. var series = this.series, seriesTooltipOptions = series.tooltipOptions, valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''), valuePrefix = seriesTooltipOptions.valuePrefix || '', valueSuffix = seriesTooltipOptions.valueSuffix || '';
  30077. // Replace default point style with class name
  30078. if (series.chart.styledMode) {
  30079. pointFormat =
  30080. series.chart.tooltip.styledModeFormat(pointFormat);
  30081. }
  30082. // Loop over the point array map and replace unformatted values with
  30083. // sprintf formatting markup
  30084. (series.pointArrayMap || ['y']).forEach(function (key) {
  30085. key = '{point.' + key; // without the closing bracket
  30086. if (valuePrefix || valueSuffix) {
  30087. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), valuePrefix + key + '}' + valueSuffix);
  30088. }
  30089. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), key + ':,.' + valueDecimals + 'f}');
  30090. });
  30091. return format(pointFormat, {
  30092. point: this,
  30093. series: this.series
  30094. }, series.chart);
  30095. };
  30096. return Point;
  30097. }());
  30098. H.Point = Point;
  30099. return Point;
  30100. });
  30101. _registerModule(_modules, 'Core/Series/Series.js', [_modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (H, LegendSymbolMixin, O, Point, SVGElement, U) {
  30102. /* *
  30103. *
  30104. * (c) 2010-2020 Torstein Honsi
  30105. *
  30106. * License: www.highcharts.com/license
  30107. *
  30108. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  30109. *
  30110. * */
  30111. var defaultOptions = O.defaultOptions;
  30112. var addEvent = U.addEvent,
  30113. animObject = U.animObject,
  30114. arrayMax = U.arrayMax,
  30115. arrayMin = U.arrayMin,
  30116. clamp = U.clamp,
  30117. correctFloat = U.correctFloat,
  30118. defined = U.defined,
  30119. erase = U.erase,
  30120. error = U.error,
  30121. extend = U.extend,
  30122. find = U.find,
  30123. fireEvent = U.fireEvent,
  30124. getNestedProperty = U.getNestedProperty,
  30125. isArray = U.isArray,
  30126. isFunction = U.isFunction,
  30127. isNumber = U.isNumber,
  30128. isString = U.isString,
  30129. merge = U.merge,
  30130. objectEach = U.objectEach,
  30131. pick = U.pick,
  30132. removeEvent = U.removeEvent,
  30133. seriesType = U.seriesType,
  30134. splat = U.splat,
  30135. syncTimeout = U.syncTimeout;
  30136. /**
  30137. * This is a placeholder type of the possible series options for
  30138. * [Highcharts](../highcharts/series), [Highstock](../highstock/series),
  30139. * [Highmaps](../highmaps/series), and [Gantt](../gantt/series).
  30140. *
  30141. * In TypeScript is this dynamically generated to reference all possible types
  30142. * of series options.
  30143. *
  30144. * @ignore-declaration
  30145. * @typedef {Highcharts.SeriesOptions|Highcharts.Dictionary<*>} Highcharts.SeriesOptionsType
  30146. */
  30147. /**
  30148. * Options for `dataSorting`.
  30149. *
  30150. * @interface Highcharts.DataSortingOptionsObject
  30151. * @since 8.0.0
  30152. */ /**
  30153. * Enable or disable data sorting for the series.
  30154. * @name Highcharts.DataSortingOptionsObject#enabled
  30155. * @type {boolean|undefined}
  30156. */ /**
  30157. * Whether to allow matching points by name in an update.
  30158. * @name Highcharts.DataSortingOptionsObject#matchByName
  30159. * @type {boolean|undefined}
  30160. */ /**
  30161. * Determines what data value should be used to sort by.
  30162. * @name Highcharts.DataSortingOptionsObject#sortKey
  30163. * @type {string|undefined}
  30164. */
  30165. /**
  30166. * Function callback when a series has been animated.
  30167. *
  30168. * @callback Highcharts.SeriesAfterAnimateCallbackFunction
  30169. *
  30170. * @param {Highcharts.Series} this
  30171. * The series where the event occured.
  30172. *
  30173. * @param {Highcharts.SeriesAfterAnimateEventObject} event
  30174. * Event arguments.
  30175. */
  30176. /**
  30177. * Event information regarding completed animation of a series.
  30178. *
  30179. * @interface Highcharts.SeriesAfterAnimateEventObject
  30180. */ /**
  30181. * Animated series.
  30182. * @name Highcharts.SeriesAfterAnimateEventObject#target
  30183. * @type {Highcharts.Series}
  30184. */ /**
  30185. * Event type.
  30186. * @name Highcharts.SeriesAfterAnimateEventObject#type
  30187. * @type {"afterAnimate"}
  30188. */
  30189. /**
  30190. * Function callback when the checkbox next to the series' name in the legend is
  30191. * clicked.
  30192. *
  30193. * @callback Highcharts.SeriesCheckboxClickCallbackFunction
  30194. *
  30195. * @param {Highcharts.Series} this
  30196. * The series where the event occured.
  30197. *
  30198. * @param {Highcharts.SeriesCheckboxClickEventObject} event
  30199. * Event arguments.
  30200. */
  30201. /**
  30202. * Event information regarding check of a series box.
  30203. *
  30204. * @interface Highcharts.SeriesCheckboxClickEventObject
  30205. */ /**
  30206. * Whether the box has been checked.
  30207. * @name Highcharts.SeriesCheckboxClickEventObject#checked
  30208. * @type {boolean}
  30209. */ /**
  30210. * Related series.
  30211. * @name Highcharts.SeriesCheckboxClickEventObject#item
  30212. * @type {Highcharts.Series}
  30213. */ /**
  30214. * Related series.
  30215. * @name Highcharts.SeriesCheckboxClickEventObject#target
  30216. * @type {Highcharts.Series}
  30217. */ /**
  30218. * Event type.
  30219. * @name Highcharts.SeriesCheckboxClickEventObject#type
  30220. * @type {"checkboxClick"}
  30221. */
  30222. /**
  30223. * Function callback when a series is clicked. Return false to cancel toogle
  30224. * actions.
  30225. *
  30226. * @callback Highcharts.SeriesClickCallbackFunction
  30227. *
  30228. * @param {Highcharts.Series} this
  30229. * The series where the event occured.
  30230. *
  30231. * @param {Highcharts.SeriesClickEventObject} event
  30232. * Event arguments.
  30233. */
  30234. /**
  30235. * Common information for a click event on a series.
  30236. *
  30237. * @interface Highcharts.SeriesClickEventObject
  30238. * @extends global.Event
  30239. */ /**
  30240. * Nearest point on the graph.
  30241. * @name Highcharts.SeriesClickEventObject#point
  30242. * @type {Highcharts.Point}
  30243. */
  30244. /**
  30245. * Gets fired when the series is hidden after chart generation time, either by
  30246. * clicking the legend item or by calling `.hide()`.
  30247. *
  30248. * @callback Highcharts.SeriesHideCallbackFunction
  30249. *
  30250. * @param {Highcharts.Series} this
  30251. * The series where the event occured.
  30252. *
  30253. * @param {global.Event} event
  30254. * The event that occured.
  30255. */
  30256. /**
  30257. * The SVG value used for the `stroke-linecap` and `stroke-linejoin` of a line
  30258. * graph.
  30259. *
  30260. * @typedef {"butt"|"round"|"square"|string} Highcharts.SeriesLinecapValue
  30261. */
  30262. /**
  30263. * Gets fired when the legend item belonging to the series is clicked. The
  30264. * default action is to toggle the visibility of the series. This can be
  30265. * prevented by returning `false` or calling `event.preventDefault()`.
  30266. *
  30267. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  30268. *
  30269. * @param {Highcharts.Series} this
  30270. * The series where the event occured.
  30271. *
  30272. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  30273. * The event that occured.
  30274. */
  30275. /**
  30276. * Information about the event.
  30277. *
  30278. * @interface Highcharts.SeriesLegendItemClickEventObject
  30279. */ /**
  30280. * Related browser event.
  30281. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  30282. * @type {global.PointerEvent}
  30283. */ /**
  30284. * Prevent the default action of toggle the visibility of the series.
  30285. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  30286. * @type {Function}
  30287. */ /**
  30288. * Related series.
  30289. * @name Highcharts.SeriesCheckboxClickEventObject#target
  30290. * @type {Highcharts.Series}
  30291. */ /**
  30292. * Event type.
  30293. * @name Highcharts.SeriesCheckboxClickEventObject#type
  30294. * @type {"checkboxClick"}
  30295. */
  30296. /**
  30297. * Gets fired when the mouse leaves the graph.
  30298. *
  30299. * @callback Highcharts.SeriesMouseOutCallbackFunction
  30300. *
  30301. * @param {Highcharts.Series} this
  30302. * Series where the event occured.
  30303. *
  30304. * @param {global.PointerEvent} event
  30305. * Event that occured.
  30306. */
  30307. /**
  30308. * Gets fired when the mouse enters the graph.
  30309. *
  30310. * @callback Highcharts.SeriesMouseOverCallbackFunction
  30311. *
  30312. * @param {Highcharts.Series} this
  30313. * Series where the event occured.
  30314. *
  30315. * @param {global.PointerEvent} event
  30316. * Event that occured.
  30317. */
  30318. /**
  30319. * Translation and scale for the plot area of a series.
  30320. *
  30321. * @interface Highcharts.SeriesPlotBoxObject
  30322. */ /**
  30323. * @name Highcharts.SeriesPlotBoxObject#scaleX
  30324. * @type {number}
  30325. */ /**
  30326. * @name Highcharts.SeriesPlotBoxObject#scaleY
  30327. * @type {number}
  30328. */ /**
  30329. * @name Highcharts.SeriesPlotBoxObject#translateX
  30330. * @type {number}
  30331. */ /**
  30332. * @name Highcharts.SeriesPlotBoxObject#translateY
  30333. * @type {number}
  30334. */
  30335. /**
  30336. * Gets fired when the series is shown after chart generation time, either by
  30337. * clicking the legend item or by calling `.show()`.
  30338. *
  30339. * @callback Highcharts.SeriesShowCallbackFunction
  30340. *
  30341. * @param {Highcharts.Series} this
  30342. * Series where the event occured.
  30343. *
  30344. * @param {global.Event} event
  30345. * Event that occured.
  30346. */
  30347. /**
  30348. * Possible key values for the series state options.
  30349. *
  30350. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.SeriesStateValue
  30351. */
  30352. ''; // detach doclets above
  30353. var seriesTypes = H.seriesTypes,
  30354. win = H.win;
  30355. /**
  30356. * This is the base series prototype that all other series types inherit from.
  30357. * A new series is initialized either through the
  30358. * [series](https://api.highcharts.com/highcharts/series)
  30359. * option structure, or after the chart is initialized, through
  30360. * {@link Highcharts.Chart#addSeries}.
  30361. *
  30362. * The object can be accessed in a number of ways. All series and point event
  30363. * handlers give a reference to the `series` object. The chart object has a
  30364. * {@link Highcharts.Chart#series|series} property that is a collection of all
  30365. * the chart's series. The point objects and axis objects also have the same
  30366. * reference.
  30367. *
  30368. * Another way to reference the series programmatically is by `id`. Add an id
  30369. * in the series configuration options, and get the series object by
  30370. * {@link Highcharts.Chart#get}.
  30371. *
  30372. * Configuration options for the series are given in three levels. Options for
  30373. * all series in a chart are given in the
  30374. * [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
  30375. * object. Then options for all series of a specific type
  30376. * are given in the plotOptions of that type, for example `plotOptions.line`.
  30377. * Next, options for one single series are given in the series array, or as
  30378. * arguments to `chart.addSeries`.
  30379. *
  30380. * The data in the series is stored in various arrays.
  30381. *
  30382. * - First, `series.options.data` contains all the original config options for
  30383. * each point whether added by options or methods like `series.addPoint`.
  30384. *
  30385. * - Next, `series.data` contains those values converted to points, but in case
  30386. * the series data length exceeds the `cropThreshold`, or if the data is
  30387. * grouped, `series.data` doesn't contain all the points. It only contains the
  30388. * points that have been created on demand.
  30389. *
  30390. * - Then there's `series.points` that contains all currently visible point
  30391. * objects. In case of cropping, the cropped-away points are not part of this
  30392. * array. The `series.points` array starts at `series.cropStart` compared to
  30393. * `series.data` and `series.options.data`. If however the series data is
  30394. * grouped, these can't be correlated one to one.
  30395. *
  30396. * - `series.xData` and `series.processedXData` contain clean x values,
  30397. * equivalent to `series.data` and `series.points`.
  30398. *
  30399. * - `series.yData` and `series.processedYData` contain clean y values,
  30400. * equivalent to `series.data` and `series.points`.
  30401. *
  30402. * @class
  30403. * @name Highcharts.Series
  30404. *
  30405. * @param {Highcharts.Chart} chart
  30406. * The chart instance.
  30407. *
  30408. * @param {Highcharts.SeriesOptionsType|object} options
  30409. * The series options.
  30410. */ /**
  30411. * The line series is the base type and is therefor the series base prototype.
  30412. *
  30413. * @private
  30414. * @class
  30415. * @name Highcharts.seriesTypes.line
  30416. *
  30417. * @augments Highcharts.Series
  30418. */
  30419. H.Series = seriesType('line',
  30420. /**
  30421. * Series options for specific data and the data itself. In TypeScript you
  30422. * have to cast the series options to specific series types, to get all
  30423. * possible options for a series.
  30424. *
  30425. * @example
  30426. * // TypeScript example
  30427. * Highcharts.chart('container', {
  30428. * series: [{
  30429. * color: '#06C',
  30430. * data: [[0, 1], [2, 3]]
  30431. * } as Highcharts.SeriesLineOptions ]
  30432. * });
  30433. *
  30434. * @type {Array<*>}
  30435. * @apioption series
  30436. */
  30437. /**
  30438. * An id for the series. This can be used after render time to get a pointer
  30439. * to the series object through `chart.get()`.
  30440. *
  30441. * @sample {highcharts} highcharts/plotoptions/series-id/
  30442. * Get series by id
  30443. *
  30444. * @type {string}
  30445. * @since 1.2.0
  30446. * @apioption series.id
  30447. */
  30448. /**
  30449. * The index of the series in the chart, affecting the internal index in the
  30450. * `chart.series` array, the visible Z index as well as the order in the
  30451. * legend.
  30452. *
  30453. * @type {number}
  30454. * @since 2.3.0
  30455. * @apioption series.index
  30456. */
  30457. /**
  30458. * The sequential index of the series in the legend.
  30459. *
  30460. * @see [legend.reversed](#legend.reversed),
  30461. * [yAxis.reversedStacks](#yAxis.reversedStacks)
  30462. *
  30463. * @sample {highcharts|highstock} highcharts/series/legendindex/
  30464. * Legend in opposite order
  30465. *
  30466. * @type {number}
  30467. * @apioption series.legendIndex
  30468. */
  30469. /**
  30470. * The name of the series as shown in the legend, tooltip etc.
  30471. *
  30472. * @sample {highcharts} highcharts/series/name/
  30473. * Series name
  30474. * @sample {highmaps} maps/demo/category-map/
  30475. * Series name
  30476. *
  30477. * @type {string}
  30478. * @apioption series.name
  30479. */
  30480. /**
  30481. * This option allows grouping series in a stacked chart. The stack option
  30482. * can be a string or anything else, as long as the grouped series' stack
  30483. * options match each other after conversion into a string.
  30484. *
  30485. * @sample {highcharts} highcharts/series/stack/
  30486. * Stacked and grouped columns
  30487. *
  30488. * @type {number|string}
  30489. * @since 2.1
  30490. * @product highcharts highstock
  30491. * @apioption series.stack
  30492. */
  30493. /**
  30494. * The type of series, for example `line` or `column`. By default, the
  30495. * series type is inherited from [chart.type](#chart.type), so unless the
  30496. * chart is a combination of series types, there is no need to set it on the
  30497. * series level.
  30498. *
  30499. * @sample {highcharts} highcharts/series/type/
  30500. * Line and column in the same chart
  30501. * @sample highcharts/series/type-dynamic/
  30502. * Dynamic types with button selector
  30503. * @sample {highmaps} maps/demo/mapline-mappoint/
  30504. * Multiple types in the same map
  30505. *
  30506. * @type {string}
  30507. * @apioption series.type
  30508. */
  30509. /**
  30510. * When using dual or multiple x axes, this number defines which xAxis the
  30511. * particular series is connected to. It refers to either the
  30512. * {@link #xAxis.id|axis id}
  30513. * or the index of the axis in the xAxis array, with 0 being the first.
  30514. *
  30515. * @type {number|string}
  30516. * @default 0
  30517. * @product highcharts highstock
  30518. * @apioption series.xAxis
  30519. */
  30520. /**
  30521. * When using dual or multiple y axes, this number defines which yAxis the
  30522. * particular series is connected to. It refers to either the
  30523. * {@link #yAxis.id|axis id}
  30524. * or the index of the axis in the yAxis array, with 0 being the first.
  30525. *
  30526. * @sample {highcharts} highcharts/series/yaxis/
  30527. * Apply the column series to the secondary Y axis
  30528. *
  30529. * @type {number|string}
  30530. * @default 0
  30531. * @product highcharts highstock
  30532. * @apioption series.yAxis
  30533. */
  30534. /**
  30535. * Define the visual z index of the series.
  30536. *
  30537. * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
  30538. * With no z index, the series defined last are on top
  30539. * @sample {highcharts} highcharts/plotoptions/series-zindex/
  30540. * With a z index, the series with the highest z index is on top
  30541. * @sample {highstock} highcharts/plotoptions/series-zindex-default/
  30542. * With no z index, the series defined last are on top
  30543. * @sample {highstock} highcharts/plotoptions/series-zindex/
  30544. * With a z index, the series with the highest z index is on top
  30545. *
  30546. * @type {number}
  30547. * @product highcharts highstock
  30548. * @apioption series.zIndex
  30549. */
  30550. null,
  30551. /**
  30552. * General options for all series types.
  30553. *
  30554. * @optionparent plotOptions.series
  30555. */
  30556. {
  30557. /**
  30558. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  30559. * of a line graph. Round means that lines are rounded in the ends and
  30560. * bends.
  30561. *
  30562. * @type {Highcharts.SeriesLinecapValue}
  30563. * @default round
  30564. * @since 3.0.7
  30565. * @apioption plotOptions.line.linecap
  30566. */
  30567. /**
  30568. * Pixel width of the graph line.
  30569. *
  30570. * @see In styled mode, the line stroke-width can be set with the
  30571. * `.highcharts-graph` class name.
  30572. *
  30573. * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
  30574. * On all series
  30575. * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
  30576. * On one single series
  30577. *
  30578. * @product highcharts highstock
  30579. *
  30580. * @private
  30581. */
  30582. lineWidth: 2,
  30583. /**
  30584. * For some series, there is a limit that shuts down initial animation
  30585. * by default when the total number of points in the chart is too high.
  30586. * For example, for a column chart and its derivatives, animation does
  30587. * not run if there is more than 250 points totally. To disable this
  30588. * cap, set `animationLimit` to `Infinity`.
  30589. *
  30590. * @type {number}
  30591. * @apioption plotOptions.series.animationLimit
  30592. */
  30593. /**
  30594. * Allow this series' points to be selected by clicking on the graphic
  30595. * (columns, point markers, pie slices, map areas etc).
  30596. *
  30597. * The selected points can be handled by point select and unselect
  30598. * events, or collectively by the [getSelectedPoints
  30599. * ](/class-reference/Highcharts.Chart#getSelectedPoints) function.
  30600. *
  30601. * And alternative way of selecting points is through dragging.
  30602. *
  30603. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
  30604. * Line
  30605. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-column/
  30606. * Column
  30607. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
  30608. * Pie
  30609. * @sample {highcharts} highcharts/chart/events-selection-points/
  30610. * Select a range of points through a drag selection
  30611. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  30612. * Map area
  30613. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  30614. * Map bubble
  30615. *
  30616. * @since 1.2.0
  30617. *
  30618. * @private
  30619. */
  30620. allowPointSelect: false,
  30621. /**
  30622. * When true, each point or column edge is rounded to its nearest pixel
  30623. * in order to render sharp on screen. In some cases, when there are a
  30624. * lot of densely packed columns, this leads to visible difference
  30625. * in column widths or distance between columns. In these cases,
  30626. * setting `crisp` to `false` may look better, even though each column
  30627. * is rendered blurry.
  30628. *
  30629. * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
  30630. * Crisp is false
  30631. *
  30632. * @since 5.0.10
  30633. * @product highcharts highstock gantt
  30634. *
  30635. * @private
  30636. */
  30637. crisp: true,
  30638. /**
  30639. * If true, a checkbox is displayed next to the legend item to allow
  30640. * selecting the series. The state of the checkbox is determined by
  30641. * the `selected` option.
  30642. *
  30643. * @productdesc {highmaps}
  30644. * Note that if a `colorAxis` is defined, the color axis is represented
  30645. * in the legend, not the series.
  30646. *
  30647. * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
  30648. * Show select box
  30649. *
  30650. * @since 1.2.0
  30651. *
  30652. * @private
  30653. */
  30654. showCheckbox: false,
  30655. /**
  30656. * Enable or disable the initial animation when a series is displayed.
  30657. * The animation can also be set as a configuration object. Please
  30658. * note that this option only applies to the initial animation of the
  30659. * series itself. For other animations, see [chart.animation](
  30660. * #chart.animation) and the animation parameter under the API methods.
  30661. * The following properties are supported:
  30662. *
  30663. * - `defer`: The animation delay time in milliseconds.
  30664. *
  30665. * - `duration`: The duration of the animation in milliseconds.
  30666. *
  30667. * - `easing`: Can be a string reference to an easing function set on
  30668. * the `Math` object or a function. See the _Custom easing function_
  30669. * demo below.
  30670. *
  30671. * Due to poor performance, animation is disabled in old IE browsers
  30672. * for several chart types.
  30673. *
  30674. * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
  30675. * Animation disabled
  30676. * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
  30677. * Slower animation
  30678. * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
  30679. * Custom easing function
  30680. * @sample {highstock} stock/plotoptions/animation-slower/
  30681. * Slower animation
  30682. * @sample {highstock} stock/plotoptions/animation-easing/
  30683. * Custom easing function
  30684. * @sample {highmaps} maps/plotoptions/series-animation-true/
  30685. * Animation enabled on map series
  30686. * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
  30687. * Disabled on mapbubble series
  30688. *
  30689. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  30690. * @default {highcharts} true
  30691. * @default {highstock} true
  30692. * @default {highmaps} false
  30693. *
  30694. * @private
  30695. */
  30696. animation: {
  30697. /** @internal */
  30698. duration: 1000
  30699. },
  30700. /**
  30701. * @default 0
  30702. * @type {number}
  30703. * @since 8.2.0
  30704. * @apioption plotOptions.series.animation.defer
  30705. */
  30706. /**
  30707. * An additional class name to apply to the series' graphical elements.
  30708. * This option does not replace default class names of the graphical
  30709. * element.
  30710. *
  30711. * @type {string}
  30712. * @since 5.0.0
  30713. * @apioption plotOptions.series.className
  30714. */
  30715. /**
  30716. * Disable this option to allow series rendering in the whole plotting
  30717. * area.
  30718. *
  30719. * **Note:** Clipping should be always enabled when
  30720. * [chart.zoomType](#chart.zoomType) is set
  30721. *
  30722. * @sample {highcharts} highcharts/plotoptions/series-clip/
  30723. * Disabled clipping
  30724. *
  30725. * @default true
  30726. * @type {boolean}
  30727. * @since 3.0.0
  30728. * @apioption plotOptions.series.clip
  30729. */
  30730. /**
  30731. * The main color of the series. In line type series it applies to the
  30732. * line and the point markers unless otherwise specified. In bar type
  30733. * series it applies to the bars unless a color is specified per point.
  30734. * The default value is pulled from the `options.colors` array.
  30735. *
  30736. * In styled mode, the color can be defined by the
  30737. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  30738. * color can be set with the `.highcharts-series`,
  30739. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  30740. * `.highcharts-series-{n}` class, or individual classes given by the
  30741. * `className` option.
  30742. *
  30743. * @productdesc {highmaps}
  30744. * In maps, the series color is rarely used, as most choropleth maps use
  30745. * the color to denote the value of each point. The series color can
  30746. * however be used in a map with multiple series holding categorized
  30747. * data.
  30748. *
  30749. * @sample {highcharts} highcharts/plotoptions/series-color-general/
  30750. * General plot option
  30751. * @sample {highcharts} highcharts/plotoptions/series-color-specific/
  30752. * One specific series
  30753. * @sample {highcharts} highcharts/plotoptions/series-color-area/
  30754. * Area color
  30755. * @sample {highcharts} highcharts/series/infographic/
  30756. * Pattern fill
  30757. * @sample {highmaps} maps/demo/category-map/
  30758. * Category map by multiple series
  30759. *
  30760. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  30761. * @apioption plotOptions.series.color
  30762. */
  30763. /**
  30764. * Styled mode only. A specific color index to use for the series, so
  30765. * its graphic representations are given the class name
  30766. * `highcharts-color-{n}`.
  30767. *
  30768. * @type {number}
  30769. * @since 5.0.0
  30770. * @apioption plotOptions.series.colorIndex
  30771. */
  30772. /**
  30773. * Whether to connect a graph line across null points, or render a gap
  30774. * between the two points on either side of the null.
  30775. *
  30776. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
  30777. * False by default
  30778. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
  30779. * True
  30780. *
  30781. * @type {boolean}
  30782. * @default false
  30783. * @product highcharts highstock
  30784. * @apioption plotOptions.series.connectNulls
  30785. */
  30786. /**
  30787. * You can set the cursor to "pointer" if you have click events attached
  30788. * to the series, to signal to the user that the points and lines can
  30789. * be clicked.
  30790. *
  30791. * In styled mode, the series cursor can be set with the same classes
  30792. * as listed under [series.color](#plotOptions.series.color).
  30793. *
  30794. * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
  30795. * On line graph
  30796. * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
  30797. * On columns
  30798. * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
  30799. * On scatter markers
  30800. * @sample {highstock} stock/plotoptions/cursor/
  30801. * Pointer on a line graph
  30802. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  30803. * Map area
  30804. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  30805. * Map bubble
  30806. *
  30807. * @type {string|Highcharts.CursorValue}
  30808. * @apioption plotOptions.series.cursor
  30809. */
  30810. /**
  30811. * A reserved subspace to store options and values for customized
  30812. * functionality. Here you can add additional data for your own event
  30813. * callbacks and formatter callbacks.
  30814. *
  30815. * @sample {highcharts} highcharts/point/custom/
  30816. * Point and series with custom data
  30817. *
  30818. * @type {Highcharts.Dictionary<*>}
  30819. * @apioption plotOptions.series.custom
  30820. */
  30821. /**
  30822. * Name of the dash style to use for the graph, or for some series types
  30823. * the outline of each shape.
  30824. *
  30825. * In styled mode, the
  30826. * [stroke dash-array](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-dashstyle/)
  30827. * can be set with the same classes as listed under
  30828. * [series.color](#plotOptions.series.color).
  30829. *
  30830. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  30831. * Possible values demonstrated
  30832. * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
  30833. * Chart suitable for printing in black and white
  30834. * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
  30835. * Possible values demonstrated
  30836. * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
  30837. * Possible values demonstrated
  30838. * @sample {highmaps} maps/plotoptions/series-dashstyle/
  30839. * Dotted borders on a map
  30840. *
  30841. * @type {Highcharts.DashStyleValue}
  30842. * @default Solid
  30843. * @since 2.1
  30844. * @apioption plotOptions.series.dashStyle
  30845. */
  30846. /**
  30847. * A description of the series to add to the screen reader information
  30848. * about the series.
  30849. *
  30850. * @type {string}
  30851. * @since 5.0.0
  30852. * @requires modules/accessibility
  30853. * @apioption plotOptions.series.description
  30854. */
  30855. /**
  30856. * Options for the series data sorting.
  30857. *
  30858. * @type {Highcharts.DataSortingOptionsObject}
  30859. * @since 8.0.0
  30860. * @product highcharts highstock
  30861. * @apioption plotOptions.series.dataSorting
  30862. */
  30863. /**
  30864. * Enable or disable data sorting for the series. Use [xAxis.reversed](
  30865. * #xAxis.reversed) to change the sorting order.
  30866. *
  30867. * @sample {highcharts} highcharts/datasorting/animation/
  30868. * Data sorting in scatter-3d
  30869. * @sample {highcharts} highcharts/datasorting/labels-animation/
  30870. * Axis labels animation
  30871. * @sample {highcharts} highcharts/datasorting/dependent-sorting/
  30872. * Dependent series sorting
  30873. * @sample {highcharts} highcharts/datasorting/independent-sorting/
  30874. * Independent series sorting
  30875. *
  30876. * @type {boolean}
  30877. * @since 8.0.0
  30878. * @apioption plotOptions.series.dataSorting.enabled
  30879. */
  30880. /**
  30881. * Whether to allow matching points by name in an update. If this option
  30882. * is disabled, points will be matched by order.
  30883. *
  30884. * @sample {highcharts} highcharts/datasorting/match-by-name/
  30885. * Enabled match by name
  30886. *
  30887. * @type {boolean}
  30888. * @since 8.0.0
  30889. * @apioption plotOptions.series.dataSorting.matchByName
  30890. */
  30891. /**
  30892. * Determines what data value should be used to sort by.
  30893. *
  30894. * @sample {highcharts} highcharts/datasorting/sort-key/
  30895. * Sort key as `z` value
  30896. *
  30897. * @type {string}
  30898. * @since 8.0.0
  30899. * @default y
  30900. * @apioption plotOptions.series.dataSorting.sortKey
  30901. */
  30902. /**
  30903. * Enable or disable the mouse tracking for a specific series. This
  30904. * includes point tooltips and click events on graphs and points. For
  30905. * large datasets it improves performance.
  30906. *
  30907. * @sample {highcharts} highcharts/plotoptions/series-enablemousetracking-false/
  30908. * No mouse tracking
  30909. * @sample {highmaps} maps/plotoptions/series-enablemousetracking-false/
  30910. * No mouse tracking
  30911. *
  30912. * @type {boolean}
  30913. * @default true
  30914. * @apioption plotOptions.series.enableMouseTracking
  30915. */
  30916. /**
  30917. * Whether to use the Y extremes of the total chart width or only the
  30918. * zoomed area when zooming in on parts of the X axis. By default, the
  30919. * Y axis adjusts to the min and max of the visible data. Cartesian
  30920. * series only.
  30921. *
  30922. * @type {boolean}
  30923. * @default false
  30924. * @since 4.1.6
  30925. * @product highcharts highstock gantt
  30926. * @apioption plotOptions.series.getExtremesFromAll
  30927. */
  30928. /**
  30929. * An array specifying which option maps to which key in the data point
  30930. * array. This makes it convenient to work with unstructured data arrays
  30931. * from different sources.
  30932. *
  30933. * @see [series.data](#series.line.data)
  30934. *
  30935. * @sample {highcharts|highstock} highcharts/series/data-keys/
  30936. * An extended data array with keys
  30937. * @sample {highcharts|highstock} highcharts/series/data-nested-keys/
  30938. * Nested keys used to access object properties
  30939. *
  30940. * @type {Array<string>}
  30941. * @since 4.1.6
  30942. * @apioption plotOptions.series.keys
  30943. */
  30944. /**
  30945. * The line cap used for line ends and line joins on the graph.
  30946. *
  30947. * @type {Highcharts.SeriesLinecapValue}
  30948. * @default round
  30949. * @product highcharts highstock
  30950. * @apioption plotOptions.series.linecap
  30951. */
  30952. /**
  30953. * The [id](#series.id) of another series to link to. Additionally,
  30954. * the value can be ":previous" to link to the previous series. When
  30955. * two series are linked, only the first one appears in the legend.
  30956. * Toggling the visibility of this also toggles the linked series.
  30957. *
  30958. * If master series uses data sorting and linked series does not have
  30959. * its own sorting definition, the linked series will be sorted in the
  30960. * same order as the master one.
  30961. *
  30962. * @sample {highcharts|highstock} highcharts/demo/arearange-line/
  30963. * Linked series
  30964. *
  30965. * @type {string}
  30966. * @since 3.0
  30967. * @product highcharts highstock gantt
  30968. * @apioption plotOptions.series.linkedTo
  30969. */
  30970. /**
  30971. * Options for the corresponding navigator series if `showInNavigator`
  30972. * is `true` for this series. Available options are the same as any
  30973. * series, documented at [plotOptions](#plotOptions.series) and
  30974. * [series](#series).
  30975. *
  30976. * These options are merged with options in [navigator.series](
  30977. * #navigator.series), and will take precedence if the same option is
  30978. * defined both places.
  30979. *
  30980. * @see [navigator.series](#navigator.series)
  30981. *
  30982. * @type {Highcharts.PlotSeriesOptions}
  30983. * @since 5.0.0
  30984. * @product highstock
  30985. * @apioption plotOptions.series.navigatorOptions
  30986. */
  30987. /**
  30988. * The color for the parts of the graph or points that are below the
  30989. * [threshold](#plotOptions.series.threshold). Note that `zones` takes
  30990. * precedence over the negative color. Using `negativeColor` is
  30991. * equivalent to applying a zone with value of 0.
  30992. *
  30993. * @see In styled mode, a negative color is applied by setting this option
  30994. * to `true` combined with the `.highcharts-negative` class name.
  30995. *
  30996. * @sample {highcharts} highcharts/plotoptions/series-negative-color/
  30997. * Spline, area and column
  30998. * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
  30999. * Arearange
  31000. * @sample {highcharts} highcharts/css/series-negative-color/
  31001. * Styled mode
  31002. * @sample {highstock} highcharts/plotoptions/series-negative-color/
  31003. * Spline, area and column
  31004. * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
  31005. * Arearange
  31006. * @sample {highmaps} highcharts/plotoptions/series-negative-color/
  31007. * Spline, area and column
  31008. * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
  31009. * Arearange
  31010. *
  31011. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31012. * @since 3.0
  31013. * @apioption plotOptions.series.negativeColor
  31014. */
  31015. /**
  31016. * Same as
  31017. * [accessibility.pointDescriptionFormatter](#accessibility.pointDescriptionFormatter),
  31018. * but for an individual series. Overrides the chart wide configuration.
  31019. *
  31020. * @type {Function}
  31021. * @since 5.0.12
  31022. * @apioption plotOptions.series.pointDescriptionFormatter
  31023. */
  31024. /**
  31025. * If no x values are given for the points in a series, `pointInterval`
  31026. * defines the interval of the x values. For example, if a series
  31027. * contains one value every decade starting from year 0, set
  31028. * `pointInterval` to `10`. In true `datetime` axes, the `pointInterval`
  31029. * is set in milliseconds.
  31030. *
  31031. * It can be also be combined with `pointIntervalUnit` to draw irregular
  31032. * time intervals.
  31033. *
  31034. * Please note that this options applies to the _series data_, not the
  31035. * interval of the axis ticks, which is independent.
  31036. *
  31037. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  31038. * Datetime X axis
  31039. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  31040. * Using pointStart and pointInterval
  31041. *
  31042. * @type {number}
  31043. * @default 1
  31044. * @product highcharts highstock gantt
  31045. * @apioption plotOptions.series.pointInterval
  31046. */
  31047. /**
  31048. * On datetime series, this allows for setting the
  31049. * [pointInterval](#plotOptions.series.pointInterval) to irregular time
  31050. * units, `day`, `month` and `year`. A day is usually the same as 24
  31051. * hours, but `pointIntervalUnit` also takes the DST crossover into
  31052. * consideration when dealing with local time. Combine this option with
  31053. * `pointInterval` to draw weeks, quarters, 6 months, 10 years etc.
  31054. *
  31055. * Please note that this options applies to the _series data_, not the
  31056. * interval of the axis ticks, which is independent.
  31057. *
  31058. * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
  31059. * One point a month
  31060. * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
  31061. * One point a month
  31062. *
  31063. * @type {string}
  31064. * @since 4.1.0
  31065. * @product highcharts highstock gantt
  31066. * @validvalue ["day", "month", "year"]
  31067. * @apioption plotOptions.series.pointIntervalUnit
  31068. */
  31069. /**
  31070. * Possible values: `"on"`, `"between"`, `number`.
  31071. *
  31072. * In a column chart, when pointPlacement is `"on"`, the point will not
  31073. * create any padding of the X axis. In a polar column chart this means
  31074. * that the first column points directly north. If the pointPlacement is
  31075. * `"between"`, the columns will be laid out between ticks. This is
  31076. * useful for example for visualising an amount between two points in
  31077. * time or in a certain sector of a polar chart.
  31078. *
  31079. * Since Highcharts 3.0.2, the point placement can also be numeric,
  31080. * where 0 is on the axis value, -0.5 is between this value and the
  31081. * previous, and 0.5 is between this value and the next. Unlike the
  31082. * textual options, numeric point placement options won't affect axis
  31083. * padding.
  31084. *
  31085. * Note that pointPlacement needs a [pointRange](
  31086. * #plotOptions.series.pointRange) to work. For column series this is
  31087. * computed, but for line-type series it needs to be set.
  31088. *
  31089. * For the `xrange` series type and gantt charts, if the Y axis is a
  31090. * category axis, the `pointPlacement` applies to the Y axis rather than
  31091. * the (typically datetime) X axis.
  31092. *
  31093. * Defaults to `undefined` in cartesian charts, `"between"` in polar
  31094. * charts.
  31095. *
  31096. * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
  31097. *
  31098. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-between/
  31099. * Between in a column chart
  31100. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-numeric/
  31101. * Numeric placement for custom layout
  31102. * @sample {highcharts|highstock} maps/plotoptions/heatmap-pointplacement/
  31103. * Placement in heatmap
  31104. *
  31105. * @type {string|number}
  31106. * @since 2.3.0
  31107. * @product highcharts highstock gantt
  31108. * @apioption plotOptions.series.pointPlacement
  31109. */
  31110. /**
  31111. * If no x values are given for the points in a series, pointStart
  31112. * defines on what value to start. For example, if a series contains one
  31113. * yearly value starting from 1945, set pointStart to 1945.
  31114. *
  31115. * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
  31116. * Linear
  31117. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  31118. * Datetime
  31119. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  31120. * Using pointStart and pointInterval
  31121. *
  31122. * @type {number}
  31123. * @default 0
  31124. * @product highcharts highstock gantt
  31125. * @apioption plotOptions.series.pointStart
  31126. */
  31127. /**
  31128. * Whether to select the series initially. If `showCheckbox` is true,
  31129. * the checkbox next to the series name in the legend will be checked
  31130. * for a selected series.
  31131. *
  31132. * @sample {highcharts} highcharts/plotoptions/series-selected/
  31133. * One out of two series selected
  31134. *
  31135. * @type {boolean}
  31136. * @default false
  31137. * @since 1.2.0
  31138. * @apioption plotOptions.series.selected
  31139. */
  31140. /**
  31141. * Whether to apply a drop shadow to the graph line. Since 2.3 the
  31142. * shadow can be an object configuration containing `color`, `offsetX`,
  31143. * `offsetY`, `opacity` and `width`.
  31144. *
  31145. * @sample {highcharts} highcharts/plotoptions/series-shadow/
  31146. * Shadow enabled
  31147. *
  31148. * @type {boolean|Highcharts.ShadowOptionsObject}
  31149. * @default false
  31150. * @apioption plotOptions.series.shadow
  31151. */
  31152. /**
  31153. * Whether to display this particular series or series type in the
  31154. * legend. Standalone series are shown in legend by default, and linked
  31155. * series are not. Since v7.2.0 it is possible to show series that use
  31156. * colorAxis by setting this option to `true`.
  31157. *
  31158. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  31159. * One series in the legend, one hidden
  31160. *
  31161. * @type {boolean}
  31162. * @apioption plotOptions.series.showInLegend
  31163. */
  31164. /**
  31165. * Whether or not to show the series in the navigator. Takes precedence
  31166. * over [navigator.baseSeries](#navigator.baseSeries) if defined.
  31167. *
  31168. * @type {boolean}
  31169. * @since 5.0.0
  31170. * @product highstock
  31171. * @apioption plotOptions.series.showInNavigator
  31172. */
  31173. /**
  31174. * If set to `true`, the accessibility module will skip past the points
  31175. * in this series for keyboard navigation.
  31176. *
  31177. * @type {boolean}
  31178. * @since 5.0.12
  31179. * @apioption plotOptions.series.skipKeyboardNavigation
  31180. */
  31181. /**
  31182. * Whether to stack the values of each series on top of each other.
  31183. * Possible values are `undefined` to disable, `"normal"` to stack by
  31184. * value or `"percent"`.
  31185. *
  31186. * When stacking is enabled, data must be sorted
  31187. * in ascending X order.
  31188. *
  31189. * Some stacking options are related to specific series types. In the
  31190. * streamgraph series type, the stacking option is set to `"stream"`.
  31191. * The second one is `"overlap"`, which only applies to waterfall
  31192. * series.
  31193. *
  31194. * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
  31195. *
  31196. * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
  31197. * Line
  31198. * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
  31199. * Column
  31200. * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
  31201. * Bar
  31202. * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
  31203. * Area
  31204. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
  31205. * Line
  31206. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-column/
  31207. * Column
  31208. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
  31209. * Bar
  31210. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
  31211. * Area
  31212. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-normal-stacking
  31213. * Waterfall with normal stacking
  31214. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-overlap-stacking
  31215. * Waterfall with overlap stacking
  31216. * @sample {highstock} stock/plotoptions/stacking/
  31217. * Area
  31218. *
  31219. * @type {string}
  31220. * @product highcharts highstock
  31221. * @validvalue ["normal", "overlap", "percent", "stream"]
  31222. * @apioption plotOptions.series.stacking
  31223. */
  31224. /**
  31225. * Whether to apply steps to the line. Possible values are `left`,
  31226. * `center` and `right`.
  31227. *
  31228. * @sample {highcharts} highcharts/plotoptions/line-step/
  31229. * Different step line options
  31230. * @sample {highcharts} highcharts/plotoptions/area-step/
  31231. * Stepped, stacked area
  31232. * @sample {highstock} stock/plotoptions/line-step/
  31233. * Step line
  31234. *
  31235. * @type {string}
  31236. * @since 1.2.5
  31237. * @product highcharts highstock
  31238. * @validvalue ["left", "center", "right"]
  31239. * @apioption plotOptions.series.step
  31240. */
  31241. /**
  31242. * The threshold, also called zero level or base level. For line type
  31243. * series this is only used in conjunction with
  31244. * [negativeColor](#plotOptions.series.negativeColor).
  31245. *
  31246. * @see [softThreshold](#plotOptions.series.softThreshold).
  31247. *
  31248. * @type {number}
  31249. * @default 0
  31250. * @since 3.0
  31251. * @product highcharts highstock
  31252. * @apioption plotOptions.series.threshold
  31253. */
  31254. /**
  31255. * Set the initial visibility of the series.
  31256. *
  31257. * @sample {highcharts} highcharts/plotoptions/series-visible/
  31258. * Two series, one hidden and one visible
  31259. * @sample {highstock} stock/plotoptions/series-visibility/
  31260. * Hidden series
  31261. *
  31262. * @type {boolean}
  31263. * @default true
  31264. * @apioption plotOptions.series.visible
  31265. */
  31266. /**
  31267. * Defines the Axis on which the zones are applied.
  31268. *
  31269. * @see [zones](#plotOptions.series.zones)
  31270. *
  31271. * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
  31272. * Zones on the X-Axis
  31273. * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
  31274. * Zones on the X-Axis
  31275. *
  31276. * @type {string}
  31277. * @default y
  31278. * @since 4.1.0
  31279. * @product highcharts highstock
  31280. * @apioption plotOptions.series.zoneAxis
  31281. */
  31282. /**
  31283. * General event handlers for the series items. These event hooks can
  31284. * also be attached to the series at run time using the
  31285. * `Highcharts.addEvent` function.
  31286. *
  31287. * @declare Highcharts.SeriesEventsOptionsObject
  31288. *
  31289. * @private
  31290. */
  31291. events: {},
  31292. /**
  31293. * Fires after the series has finished its initial animation, or in case
  31294. * animation is disabled, immediately as the series is displayed.
  31295. *
  31296. * @sample {highcharts} highcharts/plotoptions/series-events-afteranimate/
  31297. * Show label after animate
  31298. * @sample {highstock} highcharts/plotoptions/series-events-afteranimate/
  31299. * Show label after animate
  31300. *
  31301. * @type {Highcharts.SeriesAfterAnimateCallbackFunction}
  31302. * @since 4.0
  31303. * @product highcharts highstock gantt
  31304. * @context Highcharts.Series
  31305. * @apioption plotOptions.series.events.afterAnimate
  31306. */
  31307. /**
  31308. * Fires when the checkbox next to the series' name in the legend is
  31309. * clicked. One parameter, `event`, is passed to the function. The state
  31310. * of the checkbox is found by `event.checked`. The checked item is
  31311. * found by `event.item`. Return `false` to prevent the default action
  31312. * which is to toggle the select state of the series.
  31313. *
  31314. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  31315. * Alert checkbox status
  31316. *
  31317. * @type {Highcharts.SeriesCheckboxClickCallbackFunction}
  31318. * @since 1.2.0
  31319. * @context Highcharts.Series
  31320. * @apioption plotOptions.series.events.checkboxClick
  31321. */
  31322. /**
  31323. * Fires when the series is clicked. One parameter, `event`, is passed
  31324. * to the function, containing common event information. Additionally,
  31325. * `event.point` holds a pointer to the nearest point on the graph.
  31326. *
  31327. * @sample {highcharts} highcharts/plotoptions/series-events-click/
  31328. * Alert click info
  31329. * @sample {highstock} stock/plotoptions/series-events-click/
  31330. * Alert click info
  31331. * @sample {highmaps} maps/plotoptions/series-events-click/
  31332. * Display click info in subtitle
  31333. *
  31334. * @type {Highcharts.SeriesClickCallbackFunction}
  31335. * @context Highcharts.Series
  31336. * @apioption plotOptions.series.events.click
  31337. */
  31338. /**
  31339. * Fires when the series is hidden after chart generation time, either
  31340. * by clicking the legend item or by calling `.hide()`.
  31341. *
  31342. * @sample {highcharts} highcharts/plotoptions/series-events-hide/
  31343. * Alert when the series is hidden by clicking the legend item
  31344. *
  31345. * @type {Highcharts.SeriesHideCallbackFunction}
  31346. * @since 1.2.0
  31347. * @context Highcharts.Series
  31348. * @apioption plotOptions.series.events.hide
  31349. */
  31350. /**
  31351. * Fires when the legend item belonging to the series is clicked. One
  31352. * parameter, `event`, is passed to the function. The default action
  31353. * is to toggle the visibility of the series. This can be prevented
  31354. * by returning `false` or calling `event.preventDefault()`.
  31355. *
  31356. * @sample {highcharts} highcharts/plotoptions/series-events-legenditemclick/
  31357. * Confirm hiding and showing
  31358. *
  31359. * @type {Highcharts.SeriesLegendItemClickCallbackFunction}
  31360. * @context Highcharts.Series
  31361. * @apioption plotOptions.series.events.legendItemClick
  31362. */
  31363. /**
  31364. * Fires when the mouse leaves the graph. One parameter, `event`, is
  31365. * passed to the function, containing common event information. If the
  31366. * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
  31367. * doesn't happen before the mouse enters another graph or leaves the
  31368. * plot area.
  31369. *
  31370. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  31371. * With sticky tracking by default
  31372. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  31373. * Without sticky tracking
  31374. *
  31375. * @type {Highcharts.SeriesMouseOutCallbackFunction}
  31376. * @context Highcharts.Series
  31377. * @apioption plotOptions.series.events.mouseOut
  31378. */
  31379. /**
  31380. * Fires when the mouse enters the graph. One parameter, `event`, is
  31381. * passed to the function, containing common event information.
  31382. *
  31383. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  31384. * With sticky tracking by default
  31385. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  31386. * Without sticky tracking
  31387. *
  31388. * @type {Highcharts.SeriesMouseOverCallbackFunction}
  31389. * @context Highcharts.Series
  31390. * @apioption plotOptions.series.events.mouseOver
  31391. */
  31392. /**
  31393. * Fires when the series is shown after chart generation time, either
  31394. * by clicking the legend item or by calling `.show()`.
  31395. *
  31396. * @sample {highcharts} highcharts/plotoptions/series-events-show/
  31397. * Alert when the series is shown by clicking the legend item.
  31398. *
  31399. * @type {Highcharts.SeriesShowCallbackFunction}
  31400. * @since 1.2.0
  31401. * @context Highcharts.Series
  31402. * @apioption plotOptions.series.events.show
  31403. */
  31404. /**
  31405. * Options for the point markers of line-like series. Properties like
  31406. * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
  31407. * of the markers. Other series types, like column series, don't have
  31408. * markers, but have visual options on the series level instead.
  31409. *
  31410. * In styled mode, the markers can be styled with the
  31411. * `.highcharts-point`, `.highcharts-point-hover` and
  31412. * `.highcharts-point-select` class names.
  31413. *
  31414. * @declare Highcharts.PointMarkerOptionsObject
  31415. *
  31416. * @private
  31417. */
  31418. marker: {
  31419. /**
  31420. * Enable or disable the point marker. If `undefined`, the markers
  31421. * are hidden when the data is dense, and shown for more widespread
  31422. * data points.
  31423. *
  31424. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
  31425. * Disabled markers
  31426. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled-false/
  31427. * Disabled in normal state but enabled on hover
  31428. * @sample {highstock} stock/plotoptions/series-marker/
  31429. * Enabled markers
  31430. *
  31431. * @type {boolean}
  31432. * @default {highcharts} undefined
  31433. * @default {highstock} false
  31434. * @apioption plotOptions.series.marker.enabled
  31435. */
  31436. /**
  31437. * The threshold for how dense the point markers should be before
  31438. * they are hidden, given that `enabled` is not defined. The number
  31439. * indicates the horizontal distance between the two closest points
  31440. * in the series, as multiples of the `marker.radius`. In other
  31441. * words, the default value of 2 means points are hidden if
  31442. * overlapping horizontally.
  31443. *
  31444. * @sample highcharts/plotoptions/series-marker-enabledthreshold
  31445. * A higher threshold
  31446. *
  31447. * @since 6.0.5
  31448. */
  31449. enabledThreshold: 2,
  31450. /**
  31451. * The fill color of the point marker. When `undefined`, the series'
  31452. * or point's color is used.
  31453. *
  31454. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  31455. * White fill
  31456. *
  31457. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31458. * @apioption plotOptions.series.marker.fillColor
  31459. */
  31460. /**
  31461. * Image markers only. Set the image width explicitly. When using
  31462. * this option, a `width` must also be set.
  31463. *
  31464. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  31465. * Fixed width and height
  31466. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  31467. * Fixed width and height
  31468. *
  31469. * @type {number}
  31470. * @since 4.0.4
  31471. * @apioption plotOptions.series.marker.height
  31472. */
  31473. /**
  31474. * The color of the point marker's outline. When `undefined`, the
  31475. * series' or point's color is used.
  31476. *
  31477. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  31478. * Inherit from series color (undefined)
  31479. *
  31480. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31481. */
  31482. lineColor: '#ffffff',
  31483. /**
  31484. * The width of the point marker's outline.
  31485. *
  31486. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  31487. * 2px blue marker
  31488. */
  31489. lineWidth: 0,
  31490. /**
  31491. * The radius of the point marker.
  31492. *
  31493. * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
  31494. * Bigger markers
  31495. *
  31496. * @default {highstock} 2
  31497. */
  31498. radius: 4,
  31499. /**
  31500. * A predefined shape or symbol for the marker. When undefined, the
  31501. * symbol is pulled from options.symbols. Other possible values are
  31502. * `'circle'`, `'square'`,`'diamond'`, `'triangle'` and
  31503. * `'triangle-down'`.
  31504. *
  31505. * Additionally, the URL to a graphic can be given on this form:
  31506. * `'url(graphic.png)'`. Note that for the image to be applied to
  31507. * exported charts, its URL needs to be accessible by the export
  31508. * server.
  31509. *
  31510. * Custom callbacks for symbol path generation can also be added to
  31511. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  31512. * used by its method name, as shown in the demo.
  31513. *
  31514. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  31515. * Predefined, graphic and custom markers
  31516. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  31517. * Predefined, graphic and custom markers
  31518. *
  31519. * @type {string}
  31520. * @apioption plotOptions.series.marker.symbol
  31521. */
  31522. /**
  31523. * Image markers only. Set the image width explicitly. When using
  31524. * this option, a `height` must also be set.
  31525. *
  31526. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  31527. * Fixed width and height
  31528. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  31529. * Fixed width and height
  31530. *
  31531. * @type {number}
  31532. * @since 4.0.4
  31533. * @apioption plotOptions.series.marker.width
  31534. */
  31535. /**
  31536. * States for a single point marker.
  31537. *
  31538. * @declare Highcharts.PointStatesOptionsObject
  31539. */
  31540. states: {
  31541. /**
  31542. * The normal state of a single point marker. Currently only
  31543. * used for setting animation when returning to normal state
  31544. * from hover.
  31545. *
  31546. * @declare Highcharts.PointStatesNormalOptionsObject
  31547. */
  31548. normal: {
  31549. /**
  31550. * Animation when returning to normal state after hovering.
  31551. *
  31552. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  31553. */
  31554. animation: true
  31555. },
  31556. /**
  31557. * The hover state for a single point marker.
  31558. *
  31559. * @declare Highcharts.PointStatesHoverOptionsObject
  31560. */
  31561. hover: {
  31562. /**
  31563. * Animation when hovering over the marker.
  31564. *
  31565. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  31566. */
  31567. animation: {
  31568. /** @internal */
  31569. duration: 50
  31570. },
  31571. /**
  31572. * Enable or disable the point marker.
  31573. *
  31574. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-enabled/
  31575. * Disabled hover state
  31576. */
  31577. enabled: true,
  31578. /**
  31579. * The fill color of the marker in hover state. When
  31580. * `undefined`, the series' or point's fillColor for normal
  31581. * state is used.
  31582. *
  31583. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31584. * @apioption plotOptions.series.marker.states.hover.fillColor
  31585. */
  31586. /**
  31587. * The color of the point marker's outline. When
  31588. * `undefined`, the series' or point's lineColor for normal
  31589. * state is used.
  31590. *
  31591. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linecolor/
  31592. * White fill color, black line color
  31593. *
  31594. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31595. * @apioption plotOptions.series.marker.states.hover.lineColor
  31596. */
  31597. /**
  31598. * The width of the point marker's outline. When
  31599. * `undefined`, the series' or point's lineWidth for normal
  31600. * state is used.
  31601. *
  31602. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linewidth/
  31603. * 3px line width
  31604. *
  31605. * @type {number}
  31606. * @apioption plotOptions.series.marker.states.hover.lineWidth
  31607. */
  31608. /**
  31609. * The radius of the point marker. In hover state, it
  31610. * defaults to the normal state's radius + 2 as per the
  31611. * [radiusPlus](#plotOptions.series.marker.states.hover.radiusPlus)
  31612. * option.
  31613. *
  31614. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/
  31615. * 10px radius
  31616. *
  31617. * @type {number}
  31618. * @apioption plotOptions.series.marker.states.hover.radius
  31619. */
  31620. /**
  31621. * The number of pixels to increase the radius of the
  31622. * hovered point.
  31623. *
  31624. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  31625. * 5 pixels greater radius on hover
  31626. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  31627. * 5 pixels greater radius on hover
  31628. *
  31629. * @since 4.0.3
  31630. */
  31631. radiusPlus: 2,
  31632. /**
  31633. * The additional line width for a hovered point.
  31634. *
  31635. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  31636. * 2 pixels wider on hover
  31637. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  31638. * 2 pixels wider on hover
  31639. *
  31640. * @since 4.0.3
  31641. */
  31642. lineWidthPlus: 1
  31643. },
  31644. /**
  31645. * The appearance of the point marker when selected. In order to
  31646. * allow a point to be selected, set the
  31647. * `series.allowPointSelect` option to true.
  31648. *
  31649. * @declare Highcharts.PointStatesSelectOptionsObject
  31650. */
  31651. select: {
  31652. /**
  31653. * Enable or disable visible feedback for selection.
  31654. *
  31655. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
  31656. * Disabled select state
  31657. *
  31658. * @type {boolean}
  31659. * @default true
  31660. * @apioption plotOptions.series.marker.states.select.enabled
  31661. */
  31662. /**
  31663. * The radius of the point marker. In hover state, it
  31664. * defaults to the normal state's radius + 2.
  31665. *
  31666. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
  31667. * 10px radius for selected points
  31668. *
  31669. * @type {number}
  31670. * @apioption plotOptions.series.marker.states.select.radius
  31671. */
  31672. /**
  31673. * The fill color of the point marker.
  31674. *
  31675. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
  31676. * Solid red discs for selected points
  31677. *
  31678. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31679. */
  31680. fillColor: '#cccccc',
  31681. /**
  31682. * The color of the point marker's outline. When
  31683. * `undefined`, the series' or point's color is used.
  31684. *
  31685. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
  31686. * Red line color for selected points
  31687. *
  31688. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31689. */
  31690. lineColor: '#000000',
  31691. /**
  31692. * The width of the point marker's outline.
  31693. *
  31694. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
  31695. * 3px line width for selected points
  31696. */
  31697. lineWidth: 2
  31698. }
  31699. }
  31700. },
  31701. /**
  31702. * Properties for each single point.
  31703. *
  31704. * @declare Highcharts.PlotSeriesPointOptions
  31705. *
  31706. * @private
  31707. */
  31708. point: {
  31709. /**
  31710. * Fires when a point is clicked. One parameter, `event`, is passed
  31711. * to the function, containing common event information.
  31712. *
  31713. * If the `series.allowPointSelect` option is true, the default
  31714. * action for the point's click event is to toggle the point's
  31715. * select state. Returning `false` cancels this action.
  31716. *
  31717. * @sample {highcharts} highcharts/plotoptions/series-point-events-click/
  31718. * Click marker to alert values
  31719. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/
  31720. * Click column
  31721. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/
  31722. * Go to URL
  31723. * @sample {highmaps} maps/plotoptions/series-point-events-click/
  31724. * Click marker to display values
  31725. * @sample {highmaps} maps/plotoptions/series-point-events-click-url/
  31726. * Go to URL
  31727. *
  31728. * @type {Highcharts.PointClickCallbackFunction}
  31729. * @context Highcharts.Point
  31730. * @apioption plotOptions.series.point.events.click
  31731. */
  31732. /**
  31733. * Fires when the mouse leaves the area close to the point. One
  31734. * parameter, `event`, is passed to the function, containing common
  31735. * event information.
  31736. *
  31737. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  31738. * Show values in the chart's corner on mouse over
  31739. *
  31740. * @type {Highcharts.PointMouseOutCallbackFunction}
  31741. * @context Highcharts.Point
  31742. * @apioption plotOptions.series.point.events.mouseOut
  31743. */
  31744. /**
  31745. * Fires when the mouse enters the area close to the point. One
  31746. * parameter, `event`, is passed to the function, containing common
  31747. * event information.
  31748. *
  31749. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  31750. * Show values in the chart's corner on mouse over
  31751. *
  31752. * @type {Highcharts.PointMouseOverCallbackFunction}
  31753. * @context Highcharts.Point
  31754. * @apioption plotOptions.series.point.events.mouseOver
  31755. */
  31756. /**
  31757. * Fires when the point is removed using the `.remove()` method. One
  31758. * parameter, `event`, is passed to the function. Returning `false`
  31759. * cancels the operation.
  31760. *
  31761. * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/
  31762. * Remove point and confirm
  31763. *
  31764. * @type {Highcharts.PointRemoveCallbackFunction}
  31765. * @since 1.2.0
  31766. * @context Highcharts.Point
  31767. * @apioption plotOptions.series.point.events.remove
  31768. */
  31769. /**
  31770. * Fires when the point is selected either programmatically or
  31771. * following a click on the point. One parameter, `event`, is passed
  31772. * to the function. Returning `false` cancels the operation.
  31773. *
  31774. * @sample {highcharts} highcharts/plotoptions/series-point-events-select/
  31775. * Report the last selected point
  31776. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  31777. * Report select and unselect
  31778. *
  31779. * @type {Highcharts.PointSelectCallbackFunction}
  31780. * @since 1.2.0
  31781. * @context Highcharts.Point
  31782. * @apioption plotOptions.series.point.events.select
  31783. */
  31784. /**
  31785. * Fires when the point is unselected either programmatically or
  31786. * following a click on the point. One parameter, `event`, is passed
  31787. * to the function.
  31788. * Returning `false` cancels the operation.
  31789. *
  31790. * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/
  31791. * Report the last unselected point
  31792. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  31793. * Report select and unselect
  31794. *
  31795. * @type {Highcharts.PointUnselectCallbackFunction}
  31796. * @since 1.2.0
  31797. * @context Highcharts.Point
  31798. * @apioption plotOptions.series.point.events.unselect
  31799. */
  31800. /**
  31801. * Fires when the point is updated programmatically through the
  31802. * `.update()` method. One parameter, `event`, is passed to the
  31803. * function. The new point options can be accessed through
  31804. * `event.options`. Returning `false` cancels the operation.
  31805. *
  31806. * @sample {highcharts} highcharts/plotoptions/series-point-events-update/
  31807. * Confirm point updating
  31808. *
  31809. * @type {Highcharts.PointUpdateCallbackFunction}
  31810. * @since 1.2.0
  31811. * @context Highcharts.Point
  31812. * @apioption plotOptions.series.point.events.update
  31813. */
  31814. /**
  31815. * Events for each single point.
  31816. *
  31817. * @declare Highcharts.PointEventsOptionsObject
  31818. */
  31819. events: {}
  31820. },
  31821. /**
  31822. * Options for the series data labels, appearing next to each data
  31823. * point.
  31824. *
  31825. * Since v6.2.0, multiple data labels can be applied to each single
  31826. * point by defining them as an array of configs.
  31827. *
  31828. * In styled mode, the data labels can be styled with the
  31829. * `.highcharts-data-label-box` and `.highcharts-data-label` class names
  31830. * ([see example](https://www.highcharts.com/samples/highcharts/css/series-datalabels)).
  31831. *
  31832. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled
  31833. * Data labels enabled
  31834. * @sample {highcharts} highcharts/plotoptions/series-datalabels-multiple
  31835. * Multiple data labels on a bar series
  31836. * @sample {highcharts} highcharts/css/series-datalabels
  31837. * Style mode example
  31838. *
  31839. * @type {*|Array<*>}
  31840. * @product highcharts highstock highmaps gantt
  31841. *
  31842. * @private
  31843. */
  31844. dataLabels: {
  31845. /**
  31846. * Enable or disable the initial animation when a series is
  31847. * displayed for the `dataLabels`. The animation can also be set as
  31848. * a configuration object. Please note that this option only
  31849. * applies to the initial animation.
  31850. * For other animations, see [chart.animation](#chart.animation)
  31851. * and the animation parameter under the API methods.
  31852. * The following properties are supported:
  31853. *
  31854. * - `defer`: The animation delay time in milliseconds.
  31855. *
  31856. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  31857. * Animation defer settings
  31858. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  31859. * @since 8.2.0
  31860. * @apioption plotOptions.series.dataLabels.animation
  31861. */
  31862. animation: {},
  31863. /**
  31864. * The animation delay time in milliseconds.
  31865. * Set to `0` renders dataLabel immediately.
  31866. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  31867. *
  31868. * @type {number}
  31869. * @since 8.2.0
  31870. * @apioption plotOptions.series.dataLabels.animation.defer
  31871. */
  31872. /**
  31873. * The alignment of the data label compared to the point. If
  31874. * `right`, the right side of the label should be touching the
  31875. * point. For points with an extent, like columns, the alignments
  31876. * also dictates how to align it inside the box, as given with the
  31877. * [inside](#plotOptions.column.dataLabels.inside)
  31878. * option. Can be one of `left`, `center` or `right`.
  31879. *
  31880. * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/
  31881. * Left aligned
  31882. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  31883. * Data labels inside the bar
  31884. *
  31885. * @type {Highcharts.AlignValue|null}
  31886. */
  31887. align: 'center',
  31888. /**
  31889. * Whether to allow data labels to overlap. To make the labels less
  31890. * sensitive for overlapping, the
  31891. * [dataLabels.padding](#plotOptions.series.dataLabels.padding)
  31892. * can be set to 0.
  31893. *
  31894. * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/
  31895. * Don't allow overlap
  31896. *
  31897. * @type {boolean}
  31898. * @default false
  31899. * @since 4.1.0
  31900. * @apioption plotOptions.series.dataLabels.allowOverlap
  31901. */
  31902. /**
  31903. * The background color or gradient for the data label.
  31904. *
  31905. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  31906. * Data labels box options
  31907. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  31908. * Data labels box options
  31909. *
  31910. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31911. * @since 2.2.1
  31912. * @apioption plotOptions.series.dataLabels.backgroundColor
  31913. */
  31914. /**
  31915. * The border color for the data label. Defaults to `undefined`.
  31916. *
  31917. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  31918. * Data labels box options
  31919. *
  31920. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31921. * @since 2.2.1
  31922. * @apioption plotOptions.series.dataLabels.borderColor
  31923. */
  31924. /**
  31925. * The border radius in pixels for the data label.
  31926. *
  31927. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  31928. * Data labels box options
  31929. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  31930. * Data labels box options
  31931. *
  31932. * @type {number}
  31933. * @default 0
  31934. * @since 2.2.1
  31935. * @apioption plotOptions.series.dataLabels.borderRadius
  31936. */
  31937. /**
  31938. * The border width in pixels for the data label.
  31939. *
  31940. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  31941. * Data labels box options
  31942. *
  31943. * @type {number}
  31944. * @default 0
  31945. * @since 2.2.1
  31946. * @apioption plotOptions.series.dataLabels.borderWidth
  31947. */
  31948. /**
  31949. * A class name for the data label. Particularly in styled mode,
  31950. * this can be used to give each series' or point's data label
  31951. * unique styling. In addition to this option, a default color class
  31952. * name is added so that we can give the labels a contrast text
  31953. * shadow.
  31954. *
  31955. * @sample {highcharts} highcharts/css/data-label-contrast/
  31956. * Contrast text shadow
  31957. * @sample {highcharts} highcharts/css/series-datalabels/
  31958. * Styling by CSS
  31959. *
  31960. * @type {string}
  31961. * @since 5.0.0
  31962. * @apioption plotOptions.series.dataLabels.className
  31963. */
  31964. /**
  31965. * The text color for the data labels. Defaults to `undefined`. For
  31966. * certain series types, like column or map, the data labels can be
  31967. * drawn inside the points. In this case the data label will be
  31968. * drawn with maximum contrast by default. Additionally, it will be
  31969. * given a `text-outline` style with the opposite color, to further
  31970. * increase the contrast. This can be overridden by setting the
  31971. * `text-outline` style to `none` in the `dataLabels.style` option.
  31972. *
  31973. * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
  31974. * Red data labels
  31975. * @sample {highmaps} maps/demo/color-axis/
  31976. * White data labels
  31977. *
  31978. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31979. * @apioption plotOptions.series.dataLabels.color
  31980. */
  31981. /**
  31982. * Whether to hide data labels that are outside the plot area. By
  31983. * default, the data label is moved inside the plot area according
  31984. * to the
  31985. * [overflow](#plotOptions.series.dataLabels.overflow)
  31986. * option.
  31987. *
  31988. * @type {boolean}
  31989. * @default true
  31990. * @since 2.3.3
  31991. * @apioption plotOptions.series.dataLabels.crop
  31992. */
  31993. /**
  31994. * Whether to defer displaying the data labels until the initial
  31995. * series animation has finished. Setting to `false` renders the
  31996. * data label immediately. If set to `true` inherits the defer
  31997. * time set in [plotOptions.series.animation](#plotOptions.series.animation).
  31998. *
  31999. * @sample highcharts/plotoptions/animation-defer
  32000. * Set defer time
  32001. *
  32002. * @since 4.0.0
  32003. * @product highcharts highstock gantt
  32004. */
  32005. defer: true,
  32006. /**
  32007. * Enable or disable the data labels.
  32008. *
  32009. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/
  32010. * Data labels enabled
  32011. * @sample {highmaps} maps/demo/color-axis/
  32012. * Data labels enabled
  32013. *
  32014. * @type {boolean}
  32015. * @default false
  32016. * @apioption plotOptions.series.dataLabels.enabled
  32017. */
  32018. /**
  32019. * A declarative filter to control of which data labels to display.
  32020. * The declarative filter is designed for use when callback
  32021. * functions are not available, like when the chart options require
  32022. * a pure JSON structure or for use with graphical editors. For
  32023. * programmatic control, use the `formatter` instead, and return
  32024. * `undefined` to disable a single data label.
  32025. *
  32026. * @example
  32027. * filter: {
  32028. * property: 'percentage',
  32029. * operator: '>',
  32030. * value: 4
  32031. * }
  32032. *
  32033. * @sample {highcharts} highcharts/demo/pie-monochrome
  32034. * Data labels filtered by percentage
  32035. *
  32036. * @declare Highcharts.DataLabelsFilterOptionsObject
  32037. * @since 6.0.3
  32038. * @apioption plotOptions.series.dataLabels.filter
  32039. */
  32040. /**
  32041. * The operator to compare by. Can be one of `>`, `<`, `>=`, `<=`,
  32042. * `==`, and `===`.
  32043. *
  32044. * @type {string}
  32045. * @validvalue [">", "<", ">=", "<=", "==", "==="]
  32046. * @apioption plotOptions.series.dataLabels.filter.operator
  32047. */
  32048. /**
  32049. * The point property to filter by. Point options are passed
  32050. * directly to properties, additionally there are `y` value,
  32051. * `percentage` and others listed under {@link Highcharts.Point}
  32052. * members.
  32053. *
  32054. * @type {string}
  32055. * @apioption plotOptions.series.dataLabels.filter.property
  32056. */
  32057. /**
  32058. * The value to compare against.
  32059. *
  32060. * @type {number}
  32061. * @apioption plotOptions.series.dataLabels.filter.value
  32062. */
  32063. /**
  32064. * A
  32065. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  32066. * for the data label. Available variables are the same as for
  32067. * `formatter`.
  32068. *
  32069. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  32070. * Add a unit
  32071. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  32072. * Formatted value in the data label
  32073. *
  32074. * @type {string}
  32075. * @default y
  32076. * @default point.value
  32077. * @since 3.0
  32078. * @apioption plotOptions.series.dataLabels.format
  32079. */
  32080. // eslint-disable-next-line valid-jsdoc
  32081. /**
  32082. * Callback JavaScript function to format the data label. Note that
  32083. * if a `format` is defined, the format takes precedence and the
  32084. * formatter is ignored.
  32085. *
  32086. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  32087. * Formatted value
  32088. *
  32089. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  32090. */
  32091. formatter: function () {
  32092. var numberFormatter = this.series.chart.numberFormatter;
  32093. return typeof this.y !== 'number' ? '' : numberFormatter(this.y, -1);
  32094. },
  32095. /**
  32096. * For points with an extent, like columns or map areas, whether to
  32097. * align the data label inside the box or to the actual value point.
  32098. * Defaults to `false` in most cases, `true` in stacked columns.
  32099. *
  32100. * @type {boolean}
  32101. * @since 3.0
  32102. * @apioption plotOptions.series.dataLabels.inside
  32103. */
  32104. /**
  32105. * Format for points with the value of null. Works analogously to
  32106. * [format](#plotOptions.series.dataLabels.format). `nullFormat` can
  32107. * be applied only to series which support displaying null points.
  32108. *
  32109. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  32110. * Format data label and tooltip for null point.
  32111. *
  32112. * @type {boolean|string}
  32113. * @since 7.1.0
  32114. * @apioption plotOptions.series.dataLabels.nullFormat
  32115. */
  32116. /**
  32117. * Callback JavaScript function that defines formatting for points
  32118. * with the value of null. Works analogously to
  32119. * [formatter](#plotOptions.series.dataLabels.formatter).
  32120. * `nullPointFormatter` can be applied only to series which support
  32121. * displaying null points.
  32122. *
  32123. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  32124. * Format data label and tooltip for null point.
  32125. *
  32126. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  32127. * @since 7.1.0
  32128. * @apioption plotOptions.series.dataLabels.nullFormatter
  32129. */
  32130. /**
  32131. * How to handle data labels that flow outside the plot area. The
  32132. * default is `"justify"`, which aligns them inside the plot area.
  32133. * For columns and bars, this means it will be moved inside the bar.
  32134. * To display data labels outside the plot area, set `crop` to
  32135. * `false` and `overflow` to `"allow"`.
  32136. *
  32137. * @type {Highcharts.DataLabelsOverflowValue}
  32138. * @default justify
  32139. * @since 3.0.6
  32140. * @apioption plotOptions.series.dataLabels.overflow
  32141. */
  32142. /**
  32143. * When either the `borderWidth` or the `backgroundColor` is set,
  32144. * this is the padding within the box.
  32145. *
  32146. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  32147. * Data labels box options
  32148. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  32149. * Data labels box options
  32150. *
  32151. * @since 2.2.1
  32152. */
  32153. padding: 5,
  32154. /**
  32155. * Aligns data labels relative to points. If `center` alignment is
  32156. * not possible, it defaults to `right`.
  32157. *
  32158. * @type {Highcharts.AlignValue}
  32159. * @default center
  32160. * @apioption plotOptions.series.dataLabels.position
  32161. */
  32162. /**
  32163. * Text rotation in degrees. Note that due to a more complex
  32164. * structure, backgrounds, borders and padding will be lost on a
  32165. * rotated data label.
  32166. *
  32167. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  32168. * Vertical labels
  32169. *
  32170. * @type {number}
  32171. * @default 0
  32172. * @apioption plotOptions.series.dataLabels.rotation
  32173. */
  32174. /**
  32175. * The shadow of the box. Works best with `borderWidth` or
  32176. * `backgroundColor`. Since 2.3 the shadow can be an object
  32177. * configuration containing `color`, `offsetX`, `offsetY`, `opacity`
  32178. * and `width`.
  32179. *
  32180. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  32181. * Data labels box options
  32182. *
  32183. * @type {boolean|Highcharts.ShadowOptionsObject}
  32184. * @default false
  32185. * @since 2.2.1
  32186. * @apioption plotOptions.series.dataLabels.shadow
  32187. */
  32188. /**
  32189. * The name of a symbol to use for the border around the label.
  32190. * Symbols are predefined functions on the Renderer object.
  32191. *
  32192. * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/
  32193. * A callout for annotations
  32194. *
  32195. * @type {string}
  32196. * @default square
  32197. * @since 4.1.2
  32198. * @apioption plotOptions.series.dataLabels.shape
  32199. */
  32200. /**
  32201. * Styles for the label. The default `color` setting is
  32202. * `"contrast"`, which is a pseudo color that Highcharts picks up
  32203. * and applies the maximum contrast to the underlying point item,
  32204. * for example the bar in a bar chart.
  32205. *
  32206. * The `textOutline` is a pseudo property that applies an outline of
  32207. * the given width with the given color, which by default is the
  32208. * maximum contrast to the text. So a bright text color will result
  32209. * in a black text outline for maximum readability on a mixed
  32210. * background. In some cases, especially with grayscale text, the
  32211. * text outline doesn't work well, in which cases it can be disabled
  32212. * by setting it to `"none"`. When `useHTML` is true, the
  32213. * `textOutline` will not be picked up. In this, case, the same
  32214. * effect can be acheived through the `text-shadow` CSS property.
  32215. *
  32216. * For some series types, where each point has an extent, like for
  32217. * example tree maps, the data label may overflow the point. There
  32218. * are two strategies for handling overflow. By default, the text
  32219. * will wrap to multiple lines. The other strategy is to set
  32220. * `style.textOverflow` to `ellipsis`, which will keep the text on
  32221. * one line plus it will break inside long words.
  32222. *
  32223. * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
  32224. * Bold labels
  32225. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow/
  32226. * Long labels truncated with an ellipsis in a pie
  32227. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap/
  32228. * Long labels are wrapped in a pie
  32229. * @sample {highmaps} maps/demo/color-axis/
  32230. * Bold labels
  32231. *
  32232. * @type {Highcharts.CSSObject}
  32233. * @since 4.1.0
  32234. * @apioption plotOptions.series.dataLabels.style
  32235. */
  32236. style: {
  32237. /** @internal */
  32238. fontSize: '11px',
  32239. /** @internal */
  32240. fontWeight: 'bold',
  32241. /** @internal */
  32242. color: 'contrast',
  32243. /** @internal */
  32244. textOutline: '1px contrast'
  32245. },
  32246. /**
  32247. * Options for a label text which should follow marker's shape.
  32248. * Border and background are disabled for a label that follows a
  32249. * path.
  32250. *
  32251. * **Note:** Only SVG-based renderer supports this option. Setting
  32252. * `useHTML` to true will disable this option.
  32253. *
  32254. * @declare Highcharts.DataLabelsTextPathOptionsObject
  32255. * @since 7.1.0
  32256. * @apioption plotOptions.series.dataLabels.textPath
  32257. */
  32258. /**
  32259. * Presentation attributes for the text path.
  32260. *
  32261. * @type {Highcharts.SVGAttributes}
  32262. * @since 7.1.0
  32263. * @apioption plotOptions.series.dataLabels.textPath.attributes
  32264. */
  32265. /**
  32266. * Enable or disable `textPath` option for link's or marker's data
  32267. * labels.
  32268. *
  32269. * @type {boolean}
  32270. * @since 7.1.0
  32271. * @apioption plotOptions.series.dataLabels.textPath.enabled
  32272. */
  32273. /**
  32274. * Whether to
  32275. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  32276. * to render the labels.
  32277. *
  32278. * @type {boolean}
  32279. * @default false
  32280. * @apioption plotOptions.series.dataLabels.useHTML
  32281. */
  32282. /**
  32283. * The vertical alignment of a data label. Can be one of `top`,
  32284. * `middle` or `bottom`. The default value depends on the data, for
  32285. * instance in a column chart, the label is above positive values
  32286. * and below negative values.
  32287. *
  32288. * @type {Highcharts.VerticalAlignValue|null}
  32289. * @since 2.3.3
  32290. */
  32291. verticalAlign: 'bottom',
  32292. /**
  32293. * The x position offset of the label relative to the point in
  32294. * pixels.
  32295. *
  32296. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  32297. * Vertical and positioned
  32298. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  32299. * Data labels inside the bar
  32300. */
  32301. x: 0,
  32302. /**
  32303. * The Z index of the data labels. The default Z index puts it above
  32304. * the series. Use a Z index of 2 to display it behind the series.
  32305. *
  32306. * @type {number}
  32307. * @default 6
  32308. * @since 2.3.5
  32309. * @apioption plotOptions.series.dataLabels.z
  32310. */
  32311. /**
  32312. * The y position offset of the label relative to the point in
  32313. * pixels.
  32314. *
  32315. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  32316. * Vertical and positioned
  32317. */
  32318. y: 0
  32319. },
  32320. /**
  32321. * When the series contains less points than the crop threshold, all
  32322. * points are drawn, even if the points fall outside the visible plot
  32323. * area at the current zoom. The advantage of drawing all points
  32324. * (including markers and columns), is that animation is performed on
  32325. * updates. On the other hand, when the series contains more points than
  32326. * the crop threshold, the series data is cropped to only contain points
  32327. * that fall within the plot area. The advantage of cropping away
  32328. * invisible points is to increase performance on large series.
  32329. *
  32330. * @since 2.2
  32331. * @product highcharts highstock
  32332. *
  32333. * @private
  32334. */
  32335. cropThreshold: 300,
  32336. /**
  32337. * Opacity of a series parts: line, fill (e.g. area) and dataLabels.
  32338. *
  32339. * @see [states.inactive.opacity](#plotOptions.series.states.inactive.opacity)
  32340. *
  32341. * @since 7.1.0
  32342. *
  32343. * @private
  32344. */
  32345. opacity: 1,
  32346. /**
  32347. * The width of each point on the x axis. For example in a column chart
  32348. * with one value each day, the pointRange would be 1 day (= 24 * 3600
  32349. * * 1000 milliseconds). This is normally computed automatically, but
  32350. * this option can be used to override the automatic value.
  32351. *
  32352. * @product highstock
  32353. *
  32354. * @private
  32355. */
  32356. pointRange: 0,
  32357. /**
  32358. * When this is true, the series will not cause the Y axis to cross
  32359. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  32360. * unless the data actually crosses the plane.
  32361. *
  32362. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  32363. * 3 will make the Y axis show negative values according to the
  32364. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  32365. * at 0.
  32366. *
  32367. * @since 4.1.9
  32368. * @product highcharts highstock
  32369. *
  32370. * @private
  32371. */
  32372. softThreshold: true,
  32373. /**
  32374. * @declare Highcharts.SeriesStatesOptionsObject
  32375. *
  32376. * @private
  32377. */
  32378. states: {
  32379. /**
  32380. * The normal state of a series, or for point items in column, pie
  32381. * and similar series. Currently only used for setting animation
  32382. * when returning to normal state from hover.
  32383. *
  32384. * @declare Highcharts.SeriesStatesNormalOptionsObject
  32385. */
  32386. normal: {
  32387. /**
  32388. * Animation when returning to normal state after hovering.
  32389. *
  32390. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  32391. */
  32392. animation: true
  32393. },
  32394. /**
  32395. * Options for the hovered series. These settings override the
  32396. * normal state options when a series is moused over or touched.
  32397. *
  32398. * @declare Highcharts.SeriesStatesHoverOptionsObject
  32399. */
  32400. hover: {
  32401. /**
  32402. * Enable separate styles for the hovered series to visualize
  32403. * that the user hovers either the series itself or the legend.
  32404. *
  32405. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/
  32406. * Line
  32407. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/
  32408. * Column
  32409. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/
  32410. * Pie
  32411. *
  32412. * @type {boolean}
  32413. * @default true
  32414. * @since 1.2
  32415. * @apioption plotOptions.series.states.hover.enabled
  32416. */
  32417. /**
  32418. * Animation setting for hovering the graph in line-type series.
  32419. *
  32420. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  32421. * @since 5.0.8
  32422. * @product highcharts highstock
  32423. */
  32424. animation: {
  32425. /**
  32426. * The duration of the hover animation in milliseconds. By
  32427. * default the hover state animates quickly in, and slowly
  32428. * back to normal.
  32429. *
  32430. * @internal
  32431. */
  32432. duration: 50
  32433. },
  32434. /**
  32435. * Pixel width of the graph line. By default this property is
  32436. * undefined, and the `lineWidthPlus` property dictates how much
  32437. * to increase the linewidth from normal state.
  32438. *
  32439. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
  32440. * 5px line on hover
  32441. *
  32442. * @type {number}
  32443. * @product highcharts highstock
  32444. * @apioption plotOptions.series.states.hover.lineWidth
  32445. */
  32446. /**
  32447. * The additional line width for the graph of a hovered series.
  32448. *
  32449. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  32450. * 5 pixels wider
  32451. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  32452. * 5 pixels wider
  32453. *
  32454. * @since 4.0.3
  32455. * @product highcharts highstock
  32456. */
  32457. lineWidthPlus: 1,
  32458. /**
  32459. * In Highcharts 1.0, the appearance of all markers belonging
  32460. * to the hovered series. For settings on the hover state of the
  32461. * individual point, see
  32462. * [marker.states.hover](#plotOptions.series.marker.states.hover).
  32463. *
  32464. * @deprecated
  32465. *
  32466. * @extends plotOptions.series.marker
  32467. * @excluding states
  32468. * @product highcharts highstock
  32469. */
  32470. marker: {
  32471. // lineWidth: base + 1,
  32472. // radius: base + 1
  32473. },
  32474. /**
  32475. * Options for the halo appearing around the hovered point in
  32476. * line-type series as well as outside the hovered slice in pie
  32477. * charts. By default the halo is filled by the current point or
  32478. * series color with an opacity of 0.25\. The halo can be
  32479. * disabled by setting the `halo` option to `null`.
  32480. *
  32481. * In styled mode, the halo is styled with the
  32482. * `.highcharts-halo` class, with colors inherited from
  32483. * `.highcharts-color-{n}`.
  32484. *
  32485. * @sample {highcharts} highcharts/plotoptions/halo/
  32486. * Halo options
  32487. * @sample {highstock} highcharts/plotoptions/halo/
  32488. * Halo options
  32489. *
  32490. * @declare Highcharts.SeriesStatesHoverHaloOptionsObject
  32491. * @type {null|*}
  32492. * @since 4.0
  32493. * @product highcharts highstock
  32494. */
  32495. halo: {
  32496. /**
  32497. * A collection of SVG attributes to override the appearance
  32498. * of the halo, for example `fill`, `stroke` and
  32499. * `stroke-width`.
  32500. *
  32501. * @type {Highcharts.SVGAttributes}
  32502. * @since 4.0
  32503. * @product highcharts highstock
  32504. * @apioption plotOptions.series.states.hover.halo.attributes
  32505. */
  32506. /**
  32507. * The pixel size of the halo. For point markers this is the
  32508. * radius of the halo. For pie slices it is the width of the
  32509. * halo outside the slice. For bubbles it defaults to 5 and
  32510. * is the width of the halo outside the bubble.
  32511. *
  32512. * @since 4.0
  32513. * @product highcharts highstock
  32514. */
  32515. size: 10,
  32516. /**
  32517. * Opacity for the halo unless a specific fill is overridden
  32518. * using the `attributes` setting. Note that Highcharts is
  32519. * only able to apply opacity to colors of hex or rgb(a)
  32520. * formats.
  32521. *
  32522. * @since 4.0
  32523. * @product highcharts highstock
  32524. */
  32525. opacity: 0.25
  32526. }
  32527. },
  32528. /**
  32529. * Specific options for point in selected states, after being
  32530. * selected by
  32531. * [allowPointSelect](#plotOptions.series.allowPointSelect)
  32532. * or programmatically.
  32533. *
  32534. * @sample maps/plotoptions/series-allowpointselect/
  32535. * Allow point select demo
  32536. *
  32537. * @declare Highcharts.SeriesStatesSelectOptionsObject
  32538. * @extends plotOptions.series.states.hover
  32539. * @excluding brightness
  32540. */
  32541. select: {
  32542. animation: {
  32543. /** @internal */
  32544. duration: 0
  32545. }
  32546. },
  32547. /**
  32548. * The opposite state of a hover for series.
  32549. *
  32550. * @sample highcharts/plotoptions/series-states-inactive-disabled
  32551. * Disabled inactive state
  32552. *
  32553. * @declare Highcharts.SeriesStatesInactiveOptionsObject
  32554. */
  32555. inactive: {
  32556. /**
  32557. * Enable or disable the inactive state for a series
  32558. *
  32559. * @sample highcharts/plotoptions/series-states-inactive-disabled
  32560. * Disabled inactive state
  32561. *
  32562. * @type {boolean}
  32563. * @default true
  32564. * @apioption plotOptions.series.states.inactive.enabled
  32565. */
  32566. /**
  32567. * The animation for entering the inactive state.
  32568. *
  32569. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  32570. */
  32571. animation: {
  32572. /** @internal */
  32573. duration: 50
  32574. },
  32575. /**
  32576. * Opacity of series elements (dataLabels, line, area).
  32577. *
  32578. * @type {number}
  32579. */
  32580. opacity: 0.2
  32581. }
  32582. },
  32583. /**
  32584. * Sticky tracking of mouse events. When true, the `mouseOut` event on a
  32585. * series isn't triggered until the mouse moves over another series, or
  32586. * out of the plot area. When false, the `mouseOut` event on a series is
  32587. * triggered when the mouse leaves the area around the series' graph or
  32588. * markers. This also implies the tooltip when not shared. When
  32589. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  32590. * will be hidden when moving the mouse between series. Defaults to true
  32591. * for line and area type series, but to false for columns, pies etc.
  32592. *
  32593. * **Note:** The boost module will force this option because of
  32594. * technical limitations.
  32595. *
  32596. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
  32597. * True by default
  32598. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
  32599. * False
  32600. *
  32601. * @default {highcharts} true
  32602. * @default {highstock} true
  32603. * @default {highmaps} false
  32604. * @since 2.0
  32605. *
  32606. * @private
  32607. */
  32608. stickyTracking: true,
  32609. /**
  32610. * A configuration object for the tooltip rendering of each single
  32611. * series. Properties are inherited from [tooltip](#tooltip), but only
  32612. * the following properties can be defined on a series level.
  32613. *
  32614. * @declare Highcharts.SeriesTooltipOptionsObject
  32615. * @since 2.3
  32616. * @extends tooltip
  32617. * @excluding animation, backgroundColor, borderColor, borderRadius,
  32618. * borderWidth, className, crosshairs, enabled, formatter,
  32619. * headerShape, hideDelay, outside, padding, positioner,
  32620. * shadow, shape, shared, snap, split, style, useHTML
  32621. * @apioption plotOptions.series.tooltip
  32622. */
  32623. /**
  32624. * When a series contains a data array that is longer than this, only
  32625. * one dimensional arrays of numbers, or two dimensional arrays with
  32626. * x and y values are allowed. Also, only the first point is tested,
  32627. * and the rest are assumed to be the same format. This saves expensive
  32628. * data checking and indexing in long series. Set it to `0` disable.
  32629. *
  32630. * Note:
  32631. * In boost mode turbo threshold is forced. Only array of numbers or
  32632. * two dimensional arrays are allowed.
  32633. *
  32634. * @since 2.2
  32635. * @product highcharts highstock gantt
  32636. *
  32637. * @private
  32638. */
  32639. turboThreshold: 1000,
  32640. /**
  32641. * An array defining zones within a series. Zones can be applied to the
  32642. * X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
  32643. * option. The zone definitions have to be in ascending order regarding
  32644. * to the value.
  32645. *
  32646. * In styled mode, the color zones are styled with the
  32647. * `.highcharts-zone-{n}` class, or custom classed from the `className`
  32648. * option
  32649. * ([view live demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-zones/)).
  32650. *
  32651. * @see [zoneAxis](#plotOptions.series.zoneAxis)
  32652. *
  32653. * @sample {highcharts} highcharts/series/color-zones-simple/
  32654. * Color zones
  32655. * @sample {highstock} highcharts/series/color-zones-simple/
  32656. * Color zones
  32657. *
  32658. * @declare Highcharts.SeriesZonesOptionsObject
  32659. * @type {Array<*>}
  32660. * @since 4.1.0
  32661. * @product highcharts highstock
  32662. * @apioption plotOptions.series.zones
  32663. */
  32664. /**
  32665. * Styled mode only. A custom class name for the zone.
  32666. *
  32667. * @sample highcharts/css/color-zones/
  32668. * Zones styled by class name
  32669. *
  32670. * @type {string}
  32671. * @since 5.0.0
  32672. * @apioption plotOptions.series.zones.className
  32673. */
  32674. /**
  32675. * Defines the color of the series.
  32676. *
  32677. * @see [series color](#plotOptions.series.color)
  32678. *
  32679. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  32680. * @since 4.1.0
  32681. * @product highcharts highstock
  32682. * @apioption plotOptions.series.zones.color
  32683. */
  32684. /**
  32685. * A name for the dash style to use for the graph.
  32686. *
  32687. * @see [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  32688. *
  32689. * @sample {highcharts|highstock} highcharts/series/color-zones-dashstyle-dot/
  32690. * Dashed line indicates prognosis
  32691. *
  32692. * @type {Highcharts.DashStyleValue}
  32693. * @since 4.1.0
  32694. * @product highcharts highstock
  32695. * @apioption plotOptions.series.zones.dashStyle
  32696. */
  32697. /**
  32698. * Defines the fill color for the series (in area type series)
  32699. *
  32700. * @see [fillColor](#plotOptions.area.fillColor)
  32701. *
  32702. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  32703. * @since 4.1.0
  32704. * @product highcharts highstock
  32705. * @apioption plotOptions.series.zones.fillColor
  32706. */
  32707. /**
  32708. * The value up to where the zone extends, if undefined the zones
  32709. * stretches to the last value in the series.
  32710. *
  32711. * @type {number}
  32712. * @since 4.1.0
  32713. * @product highcharts highstock
  32714. * @apioption plotOptions.series.zones.value
  32715. */
  32716. /**
  32717. * When using dual or multiple color axes, this number defines which
  32718. * colorAxis the particular series is connected to. It refers to
  32719. * either the
  32720. * {@link #colorAxis.id|axis id}
  32721. * or the index of the axis in the colorAxis array, with 0 being the
  32722. * first. Set this option to false to prevent a series from connecting
  32723. * to the default color axis.
  32724. *
  32725. * Since v7.2.0 the option can also be an axis id or an axis index
  32726. * instead of a boolean flag.
  32727. *
  32728. * @sample highcharts/coloraxis/coloraxis-with-pie/
  32729. * Color axis with pie series
  32730. * @sample highcharts/coloraxis/multiple-coloraxis/
  32731. * Multiple color axis
  32732. *
  32733. * @type {number|string|boolean}
  32734. * @default 0
  32735. * @product highcharts highstock highmaps
  32736. * @apioption plotOptions.series.colorAxis
  32737. */
  32738. /**
  32739. * Determines what data value should be used to calculate point color
  32740. * if `colorAxis` is used. Requires to set `min` and `max` if some
  32741. * custom point property is used or if approximation for data grouping
  32742. * is set to `'sum'`.
  32743. *
  32744. * @sample highcharts/coloraxis/custom-color-key/
  32745. * Custom color key
  32746. * @sample highcharts/coloraxis/changed-default-color-key/
  32747. * Changed default color key
  32748. *
  32749. * @type {string}
  32750. * @default y
  32751. * @since 7.2.0
  32752. * @product highcharts highstock highmaps
  32753. * @apioption plotOptions.series.colorKey
  32754. */
  32755. /**
  32756. * Determines whether the series should look for the nearest point
  32757. * in both dimensions or just the x-dimension when hovering the series.
  32758. * Defaults to `'xy'` for scatter series and `'x'` for most other
  32759. * series. If the data has duplicate x-values, it is recommended to
  32760. * set this to `'xy'` to allow hovering over all points.
  32761. *
  32762. * Applies only to series types using nearest neighbor search (not
  32763. * direct hover) for tooltip.
  32764. *
  32765. * @sample {highcharts} highcharts/series/findnearestpointby/
  32766. * Different hover behaviors
  32767. * @sample {highstock} highcharts/series/findnearestpointby/
  32768. * Different hover behaviors
  32769. * @sample {highmaps} highcharts/series/findnearestpointby/
  32770. * Different hover behaviors
  32771. *
  32772. * @since 5.0.10
  32773. * @validvalue ["x", "xy"]
  32774. *
  32775. * @private
  32776. */
  32777. findNearestPointBy: 'x'
  32778. },
  32779. /* eslint-disable no-invalid-this, valid-jsdoc */
  32780. /** @lends Highcharts.Series.prototype */
  32781. {
  32782. axisTypes: ['xAxis', 'yAxis'],
  32783. coll: 'series',
  32784. colorCounter: 0,
  32785. cropShoulder: 1,
  32786. directTouch: false,
  32787. isCartesian: true,
  32788. // each point's x and y values are stored in this.xData and this.yData
  32789. parallelArrays: ['x', 'y'],
  32790. pointClass: Point,
  32791. requireSorting: true,
  32792. sorted: true,
  32793. init: function (chart, options) {
  32794. fireEvent(this, 'init', { options: options });
  32795. var series = this,
  32796. events,
  32797. chartSeries = chart.series,
  32798. lastSeries;
  32799. // A lookup over those events that are added by _options_ (not
  32800. // programmatically). These are updated through Series.update()
  32801. // (#10861).
  32802. this.eventOptions = this.eventOptions || {};
  32803. // The 'eventsToUnbind' property moved from prototype into the
  32804. // Series init to avoid reference to the same array between
  32805. // the different series and charts. #12959, #13937
  32806. this.eventsToUnbind = [];
  32807. /**
  32808. * Read only. The chart that the series belongs to.
  32809. *
  32810. * @name Highcharts.Series#chart
  32811. * @type {Highcharts.Chart}
  32812. */
  32813. series.chart = chart;
  32814. /**
  32815. * Read only. The series' type, like "line", "area", "column" etc.
  32816. * The type in the series options anc can be altered using
  32817. * {@link Series#update}.
  32818. *
  32819. * @name Highcharts.Series#type
  32820. * @type {string}
  32821. */
  32822. /**
  32823. * Read only. The series' current options. To update, use
  32824. * {@link Series#update}.
  32825. *
  32826. * @name Highcharts.Series#options
  32827. * @type {Highcharts.SeriesOptionsType}
  32828. */
  32829. series.options = options = series.setOptions(options);
  32830. series.linkedSeries = [];
  32831. // bind the axes
  32832. series.bindAxes();
  32833. // set some variables
  32834. extend(series, {
  32835. /**
  32836. * The series name as given in the options. Defaults to
  32837. * "Series {n}".
  32838. *
  32839. * @name Highcharts.Series#name
  32840. * @type {string}
  32841. */
  32842. name: options.name,
  32843. state: '',
  32844. /**
  32845. * Read only. The series' visibility state as set by {@link
  32846. * Series#show}, {@link Series#hide}, or in the initial
  32847. * configuration.
  32848. *
  32849. * @name Highcharts.Series#visible
  32850. * @type {boolean}
  32851. */
  32852. visible: options.visible !== false,
  32853. /**
  32854. * Read only. The series' selected state as set by {@link
  32855. * Highcharts.Series#select}.
  32856. *
  32857. * @name Highcharts.Series#selected
  32858. * @type {boolean}
  32859. */
  32860. selected: options.selected === true // false by default
  32861. });
  32862. // Register event listeners
  32863. events = options.events;
  32864. objectEach(events, function (event, eventType) {
  32865. if (isFunction(event)) {
  32866. // If event does not exist, or is changed by Series.update
  32867. if (series.eventOptions[eventType] !== event) {
  32868. // Remove existing if set by option
  32869. if (isFunction(series.eventOptions[eventType])) {
  32870. removeEvent(series, eventType, series.eventOptions[eventType]);
  32871. }
  32872. series.eventOptions[eventType] = event;
  32873. addEvent(series, eventType, event);
  32874. }
  32875. }
  32876. });
  32877. if ((events && events.click) ||
  32878. (options.point &&
  32879. options.point.events &&
  32880. options.point.events.click) ||
  32881. options.allowPointSelect) {
  32882. chart.runTrackerClick = true;
  32883. }
  32884. series.getColor();
  32885. series.getSymbol();
  32886. // Initialize the parallel data arrays
  32887. series.parallelArrays.forEach(function (key) {
  32888. if (!series[key + 'Data']) {
  32889. series[key + 'Data'] = [];
  32890. }
  32891. });
  32892. // Mark cartesian
  32893. if (series.isCartesian) {
  32894. chart.hasCartesianSeries = true;
  32895. }
  32896. // Get the index and register the series in the chart. The index is
  32897. // one more than the current latest series index (#5960).
  32898. if (chartSeries.length) {
  32899. lastSeries = chartSeries[chartSeries.length - 1];
  32900. }
  32901. series._i = pick(lastSeries && lastSeries._i, -1) + 1;
  32902. series.opacity = series.options.opacity;
  32903. // Insert the series and re-order all series above the insertion
  32904. // point.
  32905. chart.orderSeries(this.insert(chartSeries));
  32906. // Set options for series with sorting and set data later.
  32907. if (options.dataSorting && options.dataSorting.enabled) {
  32908. series.setDataSortingOptions();
  32909. }
  32910. else if (!series.points && !series.data) {
  32911. series.setData(options.data, false);
  32912. }
  32913. fireEvent(this, 'afterInit');
  32914. },
  32915. /**
  32916. * Check whether the series item is itself or inherits from a certain
  32917. * series type.
  32918. *
  32919. * @function Highcharts.Series#is
  32920. * @param {string} type The type of series to check for, can be either
  32921. * featured or custom series types. For example `column`, `pie`,
  32922. * `ohlc` etc.
  32923. *
  32924. * @return {boolean}
  32925. * True if this item is or inherits from the given type.
  32926. */
  32927. is: function (type) {
  32928. return seriesTypes[type] && this instanceof seriesTypes[type];
  32929. },
  32930. /**
  32931. * Insert the series in a collection with other series, either the chart
  32932. * series or yAxis series, in the correct order according to the index
  32933. * option. Used internally when adding series.
  32934. *
  32935. * @private
  32936. * @function Highcharts.Series#insert
  32937. * @param {Array<Highcharts.Series>} collection
  32938. * A collection of series, like `chart.series` or `xAxis.series`.
  32939. * @return {number}
  32940. * The index of the series in the collection.
  32941. */
  32942. insert: function (collection) {
  32943. var indexOption = this.options.index,
  32944. i;
  32945. // Insert by index option
  32946. if (isNumber(indexOption)) {
  32947. i = collection.length;
  32948. while (i--) {
  32949. // Loop down until the interted element has higher index
  32950. if (indexOption >=
  32951. pick(collection[i].options.index, collection[i]._i)) {
  32952. collection.splice(i + 1, 0, this);
  32953. break;
  32954. }
  32955. }
  32956. if (i === -1) {
  32957. collection.unshift(this);
  32958. }
  32959. i = i + 1;
  32960. // Or just push it to the end
  32961. }
  32962. else {
  32963. collection.push(this);
  32964. }
  32965. return pick(i, collection.length - 1);
  32966. },
  32967. /**
  32968. * Set the xAxis and yAxis properties of cartesian series, and register
  32969. * the series in the `axis.series` array.
  32970. *
  32971. * @private
  32972. * @function Highcharts.Series#bindAxes
  32973. * @return {void}
  32974. * @exception 18
  32975. */
  32976. bindAxes: function () {
  32977. var series = this,
  32978. seriesOptions = series.options,
  32979. chart = series.chart,
  32980. axisOptions;
  32981. fireEvent(this, 'bindAxes', null, function () {
  32982. // repeat for xAxis and yAxis
  32983. (series.axisTypes || []).forEach(function (AXIS) {
  32984. // loop through the chart's axis objects
  32985. chart[AXIS].forEach(function (axis) {
  32986. axisOptions = axis.options;
  32987. // apply if the series xAxis or yAxis option mathches
  32988. // the number of the axis, or if undefined, use the
  32989. // first axis
  32990. if (seriesOptions[AXIS] ===
  32991. axisOptions.index ||
  32992. (typeof seriesOptions[AXIS] !==
  32993. 'undefined' &&
  32994. seriesOptions[AXIS] === axisOptions.id) ||
  32995. (typeof seriesOptions[AXIS] ===
  32996. 'undefined' &&
  32997. axisOptions.index === 0)) {
  32998. // register this series in the axis.series lookup
  32999. series.insert(axis.series);
  33000. // set this series.xAxis or series.yAxis reference
  33001. /**
  33002. * Read only. The unique xAxis object associated
  33003. * with the series.
  33004. *
  33005. * @name Highcharts.Series#xAxis
  33006. * @type {Highcharts.Axis}
  33007. */
  33008. /**
  33009. * Read only. The unique yAxis object associated
  33010. * with the series.
  33011. *
  33012. * @name Highcharts.Series#yAxis
  33013. * @type {Highcharts.Axis}
  33014. */
  33015. series[AXIS] = axis;
  33016. // mark dirty for redraw
  33017. axis.isDirty = true;
  33018. }
  33019. });
  33020. // The series needs an X and an Y axis
  33021. if (!series[AXIS] &&
  33022. series.optionalAxis !== AXIS) {
  33023. error(18, true, chart);
  33024. }
  33025. });
  33026. });
  33027. fireEvent(this, 'afterBindAxes');
  33028. },
  33029. /**
  33030. * For simple series types like line and column, the data values are
  33031. * held in arrays like xData and yData for quick lookup to find extremes
  33032. * and more. For multidimensional series like bubble and map, this can
  33033. * be extended with arrays like zData and valueData by adding to the
  33034. * `series.parallelArrays` array.
  33035. *
  33036. * @private
  33037. * @function Highcharts.Series#updateParallelArrays
  33038. * @param {Highcharts.Point} point
  33039. * @param {number|string} i
  33040. * @return {void}
  33041. */
  33042. updateParallelArrays: function (point, i) {
  33043. var series = point.series,
  33044. args = arguments,
  33045. fn = isNumber(i) ?
  33046. // Insert the value in the given position
  33047. function (key) {
  33048. var val = key === 'y' && series.toYData ?
  33049. series.toYData(point) :
  33050. point[key];
  33051. series[key + 'Data'][i] = val;
  33052. } :
  33053. // Apply the method specified in i with the following
  33054. // arguments as arguments
  33055. function (key) {
  33056. Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
  33057. };
  33058. series.parallelArrays.forEach(fn);
  33059. },
  33060. /**
  33061. * Define hasData functions for series. These return true if there
  33062. * are data points on this series within the plot area.
  33063. *
  33064. * @private
  33065. * @function Highcharts.Series#hasData
  33066. * @return {boolean}
  33067. */
  33068. hasData: function () {
  33069. return ((this.visible &&
  33070. typeof this.dataMax !== 'undefined' &&
  33071. typeof this.dataMin !== 'undefined') || ( // #3703
  33072. this.visible &&
  33073. this.yData &&
  33074. this.yData.length > 0) // #9758
  33075. );
  33076. },
  33077. /**
  33078. * Return an auto incremented x value based on the pointStart and
  33079. * pointInterval options. This is only used if an x value is not given
  33080. * for the point that calls autoIncrement.
  33081. *
  33082. * @private
  33083. * @function Highcharts.Series#autoIncrement
  33084. * @return {number}
  33085. */
  33086. autoIncrement: function () {
  33087. var options = this.options,
  33088. xIncrement = this.xIncrement,
  33089. date,
  33090. pointInterval,
  33091. pointIntervalUnit = options.pointIntervalUnit,
  33092. time = this.chart.time;
  33093. xIncrement = pick(xIncrement, options.pointStart, 0);
  33094. this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
  33095. // Added code for pointInterval strings
  33096. if (pointIntervalUnit) {
  33097. date = new time.Date(xIncrement);
  33098. if (pointIntervalUnit === 'day') {
  33099. time.set('Date', date, time.get('Date', date) + pointInterval);
  33100. }
  33101. else if (pointIntervalUnit === 'month') {
  33102. time.set('Month', date, time.get('Month', date) + pointInterval);
  33103. }
  33104. else if (pointIntervalUnit === 'year') {
  33105. time.set('FullYear', date, time.get('FullYear', date) + pointInterval);
  33106. }
  33107. pointInterval = date.getTime() - xIncrement;
  33108. }
  33109. this.xIncrement = xIncrement + pointInterval;
  33110. return xIncrement;
  33111. },
  33112. /**
  33113. * Internal function to set properties for series if data sorting is
  33114. * enabled.
  33115. *
  33116. * @private
  33117. * @function Highcharts.Series#setDataSortingOptions
  33118. * @return {void}
  33119. */
  33120. setDataSortingOptions: function () {
  33121. var options = this.options;
  33122. extend(this, {
  33123. requireSorting: false,
  33124. sorted: false,
  33125. enabledDataSorting: true,
  33126. allowDG: false
  33127. });
  33128. // To allow unsorted data for column series.
  33129. if (!defined(options.pointRange)) {
  33130. options.pointRange = 1;
  33131. }
  33132. },
  33133. /**
  33134. * Set the series options by merging from the options tree. Called
  33135. * internally on initializing and updating series. This function will
  33136. * not redraw the series. For API usage, use {@link Series#update}.
  33137. * @private
  33138. * @function Highcharts.Series#setOptions
  33139. * @param {Highcharts.SeriesOptionsType} itemOptions
  33140. * The series options.
  33141. * @return {Highcharts.SeriesOptionsType}
  33142. * @fires Highcharts.Series#event:afterSetOptions
  33143. */
  33144. setOptions: function (itemOptions) {
  33145. var chart = this.chart,
  33146. chartOptions = chart.options,
  33147. plotOptions = chartOptions.plotOptions,
  33148. userOptions = chart.userOptions || {},
  33149. seriesUserOptions = merge(itemOptions),
  33150. options,
  33151. zones,
  33152. zone,
  33153. styledMode = chart.styledMode,
  33154. e = {
  33155. plotOptions: plotOptions,
  33156. userOptions: seriesUserOptions
  33157. };
  33158. fireEvent(this, 'setOptions', e);
  33159. // These may be modified by the event
  33160. var typeOptions = e.plotOptions[this.type],
  33161. userPlotOptions = (userOptions.plotOptions || {});
  33162. // use copy to prevent undetected changes (#9762)
  33163. /**
  33164. * Contains series options by the user without defaults.
  33165. * @name Highcharts.Series#userOptions
  33166. * @type {Highcharts.SeriesOptionsType}
  33167. */
  33168. this.userOptions = e.userOptions;
  33169. options = merge(typeOptions, plotOptions.series,
  33170. // #3881, chart instance plotOptions[type] should trump
  33171. // plotOptions.series
  33172. userOptions.plotOptions &&
  33173. userOptions.plotOptions[this.type], seriesUserOptions);
  33174. // The tooltip options are merged between global and series specific
  33175. // options. Importance order asscendingly:
  33176. // globals: (1)tooltip, (2)plotOptions.series,
  33177. // (3)plotOptions[this.type]
  33178. // init userOptions with possible later updates: 4-6 like 1-3 and
  33179. // (7)this series options
  33180. this.tooltipOptions = merge(defaultOptions.tooltip, // 1
  33181. defaultOptions.plotOptions.series &&
  33182. defaultOptions.plotOptions.series.tooltip, // 2
  33183. defaultOptions.plotOptions[this.type].tooltip, // 3
  33184. chartOptions.tooltip.userOptions, // 4
  33185. plotOptions.series &&
  33186. plotOptions.series.tooltip, // 5
  33187. plotOptions[this.type].tooltip, // 6
  33188. seriesUserOptions.tooltip // 7
  33189. );
  33190. // When shared tooltip, stickyTracking is true by default,
  33191. // unless user says otherwise.
  33192. this.stickyTracking = pick(seriesUserOptions.stickyTracking, userPlotOptions[this.type] &&
  33193. userPlotOptions[this.type].stickyTracking, userPlotOptions.series && userPlotOptions.series.stickyTracking, (this.tooltipOptions.shared && !this.noSharedTooltip ?
  33194. true :
  33195. options.stickyTracking));
  33196. // Delete marker object if not allowed (#1125)
  33197. if (typeOptions.marker === null) {
  33198. delete options.marker;
  33199. }
  33200. // Handle color zones
  33201. this.zoneAxis = options.zoneAxis;
  33202. zones = this.zones = (options.zones || []).slice();
  33203. if ((options.negativeColor || options.negativeFillColor) &&
  33204. !options.zones) {
  33205. zone = {
  33206. value: options[this.zoneAxis + 'Threshold'] ||
  33207. options.threshold ||
  33208. 0,
  33209. className: 'highcharts-negative'
  33210. };
  33211. if (!styledMode) {
  33212. zone.color = options.negativeColor;
  33213. zone.fillColor = options.negativeFillColor;
  33214. }
  33215. zones.push(zone);
  33216. }
  33217. if (zones.length) { // Push one extra zone for the rest
  33218. if (defined(zones[zones.length - 1].value)) {
  33219. zones.push(styledMode ? {} : {
  33220. color: this.color,
  33221. fillColor: this.fillColor
  33222. });
  33223. }
  33224. }
  33225. fireEvent(this, 'afterSetOptions', { options: options });
  33226. return options;
  33227. },
  33228. /**
  33229. * Return series name in "Series {Number}" format or the one defined by
  33230. * a user. This method can be simply overridden as series name format
  33231. * can vary (e.g. technical indicators).
  33232. *
  33233. * @function Highcharts.Series#getName
  33234. * @return {string}
  33235. * The series name.
  33236. */
  33237. getName: function () {
  33238. // #4119
  33239. return pick(this.options.name, 'Series ' + (this.index + 1));
  33240. },
  33241. /**
  33242. * @private
  33243. * @function Highcharts.Series#getCyclic
  33244. * @param {string} prop
  33245. * @param {*} [value]
  33246. * @param {Highcharts.Dictionary<any>} [defaults]
  33247. * @return {void}
  33248. */
  33249. getCyclic: function (prop, value, defaults) {
  33250. 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;
  33251. if (!value) {
  33252. // Pick up either the colorIndex option, or the _colorIndex
  33253. // after Series.update()
  33254. setting = pick(userOptions[indexName], userOptions['_' + indexName]);
  33255. if (defined(setting)) { // after Series.update()
  33256. i = setting;
  33257. }
  33258. else {
  33259. // #6138
  33260. if (!chart.series.length) {
  33261. chart[counterName] = 0;
  33262. }
  33263. userOptions['_' + indexName] = i =
  33264. chart[counterName] % len;
  33265. chart[counterName] += 1;
  33266. }
  33267. if (defaults) {
  33268. value = defaults[i];
  33269. }
  33270. }
  33271. // Set the colorIndex
  33272. if (typeof i !== 'undefined') {
  33273. this[indexName] = i;
  33274. }
  33275. this[prop] = value;
  33276. },
  33277. /**
  33278. * Get the series' color based on either the options or pulled from
  33279. * global options.
  33280. *
  33281. * @private
  33282. * @function Highcharts.Series#getColor
  33283. * @return {void}
  33284. */
  33285. getColor: function () {
  33286. if (this.chart.styledMode) {
  33287. this.getCyclic('color');
  33288. }
  33289. else if (this.options.colorByPoint) {
  33290. // #4359, selected slice got series.color even when colorByPoint
  33291. // was set.
  33292. this.options.color = null;
  33293. }
  33294. else {
  33295. this.getCyclic('color', this.options.color ||
  33296. defaultOptions.plotOptions[this.type].color, this.chart.options.colors);
  33297. }
  33298. },
  33299. /**
  33300. * Get all points' instances created for this series.
  33301. *
  33302. * @private
  33303. * @function Highcharts.Series#getPointsCollection
  33304. * @return {Array<Highcharts.Point>}
  33305. */
  33306. getPointsCollection: function () {
  33307. return (this.hasGroupedData ? this.points : this.data) || [];
  33308. },
  33309. /**
  33310. * Get the series' symbol based on either the options or pulled from
  33311. * global options.
  33312. *
  33313. * @private
  33314. * @function Highcharts.Series#getSymbol
  33315. * @return {void}
  33316. */
  33317. getSymbol: function () {
  33318. var seriesMarkerOption = this.options.marker;
  33319. this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
  33320. },
  33321. /**
  33322. * Finds the index of an existing point that matches the given point
  33323. * options.
  33324. *
  33325. * @private
  33326. * @function Highcharts.Series#findPointIndex
  33327. * @param {Highcharts.PointOptionsObject} optionsObject
  33328. * The options of the point.
  33329. * @param {number} fromIndex
  33330. * The index to start searching from, used for optimizing
  33331. * series with required sorting.
  33332. * @returns {number|undefined}
  33333. * Returns the index of a matching point, or undefined if no
  33334. * match is found.
  33335. */
  33336. findPointIndex: function (optionsObject, fromIndex) {
  33337. var id = optionsObject.id,
  33338. x = optionsObject.x,
  33339. oldData = this.points,
  33340. matchingPoint,
  33341. matchedById,
  33342. pointIndex,
  33343. matchKey,
  33344. dataSorting = this.options.dataSorting;
  33345. if (id) {
  33346. matchingPoint = this.chart.get(id);
  33347. }
  33348. else if (this.linkedParent || this.enabledDataSorting) {
  33349. matchKey = (dataSorting && dataSorting.matchByName) ?
  33350. 'name' : 'index';
  33351. matchingPoint = find(oldData, function (oldPoint) {
  33352. return !oldPoint.touched && oldPoint[matchKey] ===
  33353. optionsObject[matchKey];
  33354. });
  33355. // Add unmatched point as a new point
  33356. if (!matchingPoint) {
  33357. return void 0;
  33358. }
  33359. }
  33360. if (matchingPoint) {
  33361. pointIndex = matchingPoint && matchingPoint.index;
  33362. if (typeof pointIndex !== 'undefined') {
  33363. matchedById = true;
  33364. }
  33365. }
  33366. // Search for the same X in the existing data set
  33367. if (typeof pointIndex === 'undefined' && isNumber(x)) {
  33368. pointIndex = this.xData.indexOf(x, fromIndex);
  33369. }
  33370. // Reduce pointIndex if data is cropped
  33371. if (pointIndex !== -1 &&
  33372. typeof pointIndex !== 'undefined' &&
  33373. this.cropped) {
  33374. pointIndex = (pointIndex >= this.cropStart) ?
  33375. pointIndex - this.cropStart : pointIndex;
  33376. }
  33377. if (!matchedById &&
  33378. oldData[pointIndex] && oldData[pointIndex].touched) {
  33379. pointIndex = void 0;
  33380. }
  33381. return pointIndex;
  33382. },
  33383. /**
  33384. * @private
  33385. * @borrows LegendSymbolMixin.drawLineMarker as Highcharts.Series#drawLegendSymbol
  33386. */
  33387. drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
  33388. /**
  33389. * Internal function called from setData. If the point count is the same
  33390. * as is was, or if there are overlapping X values, just run
  33391. * Point.update which is cheaper, allows animation, and keeps references
  33392. * to points. This also allows adding or removing points if the X-es
  33393. * don't match.
  33394. *
  33395. * @private
  33396. * @function Highcharts.Series#updateData
  33397. *
  33398. * @param {Array<Highcharts.PointOptionsType>} data
  33399. *
  33400. * @return {boolean}
  33401. */
  33402. updateData: function (data, animation) {
  33403. var options = this.options,
  33404. dataSorting = options.dataSorting,
  33405. oldData = this.points,
  33406. pointsToAdd = [],
  33407. hasUpdatedByKey,
  33408. i,
  33409. point,
  33410. lastIndex,
  33411. requireSorting = this.requireSorting,
  33412. equalLength = data.length === oldData.length,
  33413. succeeded = true;
  33414. this.xIncrement = null;
  33415. // Iterate the new data
  33416. data.forEach(function (pointOptions, i) {
  33417. var id,
  33418. x,
  33419. pointIndex,
  33420. optionsObject = (defined(pointOptions) &&
  33421. this.pointClass.prototype.optionsToObject.call({ series: this },
  33422. pointOptions)) || {};
  33423. // Get the x of the new data point
  33424. x = optionsObject.x;
  33425. id = optionsObject.id;
  33426. if (id || isNumber(x)) {
  33427. pointIndex = this.findPointIndex(optionsObject, lastIndex);
  33428. // Matching X not found
  33429. // or used already due to ununique x values (#8995),
  33430. // add point (but later)
  33431. if (pointIndex === -1 ||
  33432. typeof pointIndex === 'undefined') {
  33433. pointsToAdd.push(pointOptions);
  33434. // Matching X found, update
  33435. }
  33436. else if (oldData[pointIndex] &&
  33437. pointOptions !== options.data[pointIndex]) {
  33438. oldData[pointIndex].update(pointOptions, false, null, false);
  33439. // Mark it touched, below we will remove all points that
  33440. // are not touched.
  33441. oldData[pointIndex].touched = true;
  33442. // Speed optimize by only searching after last known
  33443. // index. Performs ~20% bettor on large data sets.
  33444. if (requireSorting) {
  33445. lastIndex = pointIndex + 1;
  33446. }
  33447. // Point exists, no changes, don't remove it
  33448. }
  33449. else if (oldData[pointIndex]) {
  33450. oldData[pointIndex].touched = true;
  33451. }
  33452. // If the length is equal and some of the nodes had a
  33453. // match in the same position, we don't want to remove
  33454. // non-matches.
  33455. if (!equalLength ||
  33456. i !== pointIndex ||
  33457. (dataSorting && dataSorting.enabled) ||
  33458. this.hasDerivedData) {
  33459. hasUpdatedByKey = true;
  33460. }
  33461. }
  33462. else {
  33463. // Gather all points that are not matched
  33464. pointsToAdd.push(pointOptions);
  33465. }
  33466. }, this);
  33467. // Remove points that don't exist in the updated data set
  33468. if (hasUpdatedByKey) {
  33469. i = oldData.length;
  33470. while (i--) {
  33471. point = oldData[i];
  33472. if (point && !point.touched && point.remove) {
  33473. point.remove(false, animation);
  33474. }
  33475. }
  33476. // If we did not find keys (ids or x-values), and the length is the
  33477. // same, update one-to-one
  33478. }
  33479. else if (equalLength && (!dataSorting || !dataSorting.enabled)) {
  33480. data.forEach(function (point, i) {
  33481. // .update doesn't exist on a linked, hidden series (#3709)
  33482. // (#10187)
  33483. if (oldData[i].update && point !== oldData[i].y) {
  33484. oldData[i].update(point, false, null, false);
  33485. }
  33486. });
  33487. // Don't add new points since those configs are used above
  33488. pointsToAdd.length = 0;
  33489. // Did not succeed in updating data
  33490. }
  33491. else {
  33492. succeeded = false;
  33493. }
  33494. oldData.forEach(function (point) {
  33495. if (point) {
  33496. point.touched = false;
  33497. }
  33498. });
  33499. if (!succeeded) {
  33500. return false;
  33501. }
  33502. // Add new points
  33503. pointsToAdd.forEach(function (point) {
  33504. this.addPoint(point, false, null, null, false);
  33505. }, this);
  33506. if (this.xIncrement === null &&
  33507. this.xData &&
  33508. this.xData.length) {
  33509. this.xIncrement = arrayMax(this.xData);
  33510. this.autoIncrement();
  33511. }
  33512. return true;
  33513. },
  33514. /**
  33515. * Apply a new set of data to the series and optionally redraw it. The
  33516. * new data array is passed by reference (except in case of
  33517. * `updatePoints`), and may later be mutated when updating the chart
  33518. * data.
  33519. *
  33520. * Note the difference in behaviour when setting the same amount of
  33521. * points, or a different amount of points, as handled by the
  33522. * `updatePoints` parameter.
  33523. *
  33524. * @sample highcharts/members/series-setdata/
  33525. * Set new data from a button
  33526. * @sample highcharts/members/series-setdata-pie/
  33527. * Set data in a pie
  33528. * @sample stock/members/series-setdata/
  33529. * Set new data in Highstock
  33530. * @sample maps/members/series-setdata/
  33531. * Set new data in Highmaps
  33532. *
  33533. * @function Highcharts.Series#setData
  33534. *
  33535. * @param {Array<Highcharts.PointOptionsType>} data
  33536. * Takes an array of data in the same format as described under
  33537. * `series.{type}.data` for the given series type, for example a
  33538. * line series would take data in the form described under
  33539. * [series.line.data](https://api.highcharts.com/highcharts/series.line.data).
  33540. *
  33541. * @param {boolean} [redraw=true]
  33542. * Whether to redraw the chart after the series is altered. If
  33543. * doing more operations on the chart, it is a good idea to set
  33544. * redraw to false and call {@link Chart#redraw} after.
  33545. *
  33546. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  33547. * When the updated data is the same length as the existing data,
  33548. * points will be updated by default, and animation visualizes
  33549. * how the points are changed. Set false to disable animation, or
  33550. * a configuration object to set duration or easing.
  33551. *
  33552. * @param {boolean} [updatePoints=true]
  33553. * When this is true, points will be updated instead of replaced
  33554. * whenever possible. This occurs a) when the updated data is the
  33555. * same length as the existing data, b) when points are matched
  33556. * by their id's, or c) when points can be matched by X values.
  33557. * This allows updating with animation and performs better. In
  33558. * this case, the original array is not passed by reference. Set
  33559. * `false` to prevent.
  33560. *
  33561. * @return {void}
  33562. */
  33563. setData: function (data, redraw, animation, updatePoints) {
  33564. var series = this,
  33565. oldData = series.points,
  33566. oldDataLength = (oldData && oldData.length) || 0,
  33567. dataLength,
  33568. options = series.options,
  33569. chart = series.chart,
  33570. dataSorting = options.dataSorting,
  33571. firstPoint = null,
  33572. xAxis = series.xAxis,
  33573. i,
  33574. turboThreshold = options.turboThreshold,
  33575. pt,
  33576. xData = this.xData,
  33577. yData = this.yData,
  33578. pointArrayMap = series.pointArrayMap,
  33579. valueCount = pointArrayMap && pointArrayMap.length,
  33580. keys = options.keys,
  33581. indexOfX = 0,
  33582. indexOfY = 1,
  33583. updatedData;
  33584. data = data || [];
  33585. dataLength = data.length;
  33586. redraw = pick(redraw, true);
  33587. if (dataSorting && dataSorting.enabled) {
  33588. data = this.sortData(data);
  33589. }
  33590. // First try to run Point.update which is cheaper, allows animation,
  33591. // and keeps references to points.
  33592. if (updatePoints !== false &&
  33593. dataLength &&
  33594. oldDataLength &&
  33595. !series.cropped &&
  33596. !series.hasGroupedData &&
  33597. series.visible &&
  33598. // Soft updating has no benefit in boost, and causes JS error
  33599. // (#8355)
  33600. !series.isSeriesBoosting) {
  33601. updatedData = this.updateData(data, animation);
  33602. }
  33603. if (!updatedData) {
  33604. // Reset properties
  33605. series.xIncrement = null;
  33606. series.colorCounter = 0; // for series with colorByPoint (#1547)
  33607. // Update parallel arrays
  33608. this.parallelArrays.forEach(function (key) {
  33609. series[key + 'Data'].length = 0;
  33610. });
  33611. // In turbo mode, only one- or twodimensional arrays of numbers
  33612. // are allowed. The first value is tested, and we assume that
  33613. // all the rest are defined the same way. Although the 'for'
  33614. // loops are similar, they are repeated inside each if-else
  33615. // conditional for max performance.
  33616. if (turboThreshold && dataLength > turboThreshold) {
  33617. firstPoint = series.getFirstValidPoint(data);
  33618. if (isNumber(firstPoint)) { // assume all points are numbers
  33619. for (i = 0; i < dataLength; i++) {
  33620. xData[i] = this.autoIncrement();
  33621. yData[i] = data[i];
  33622. }
  33623. // Assume all points are arrays when first point is
  33624. }
  33625. else if (isArray(firstPoint)) {
  33626. if (valueCount) { // [x, low, high] or [x, o, h, l, c]
  33627. for (i = 0; i < dataLength; i++) {
  33628. pt = data[i];
  33629. xData[i] = pt[0];
  33630. yData[i] =
  33631. pt.slice(1, valueCount + 1);
  33632. }
  33633. }
  33634. else { // [x, y]
  33635. if (keys) {
  33636. indexOfX = keys.indexOf('x');
  33637. indexOfY = keys.indexOf('y');
  33638. indexOfX = indexOfX >= 0 ? indexOfX : 0;
  33639. indexOfY = indexOfY >= 0 ? indexOfY : 1;
  33640. }
  33641. for (i = 0; i < dataLength; i++) {
  33642. pt = data[i];
  33643. xData[i] = pt[indexOfX];
  33644. yData[i] = pt[indexOfY];
  33645. }
  33646. }
  33647. }
  33648. else {
  33649. // Highcharts expects configs to be numbers or arrays in
  33650. // turbo mode
  33651. error(12, false, chart);
  33652. }
  33653. }
  33654. else {
  33655. for (i = 0; i < dataLength; i++) {
  33656. // stray commas in oldIE:
  33657. if (typeof data[i] !== 'undefined') {
  33658. pt = { series: series };
  33659. series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
  33660. series.updateParallelArrays(pt, i);
  33661. }
  33662. }
  33663. }
  33664. // Forgetting to cast strings to numbers is a common caveat when
  33665. // handling CSV or JSON
  33666. if (yData && isString(yData[0])) {
  33667. error(14, true, chart);
  33668. }
  33669. series.data = [];
  33670. series.options.data = series.userOptions.data = data;
  33671. // destroy old points
  33672. i = oldDataLength;
  33673. while (i--) {
  33674. if (oldData[i] && oldData[i].destroy) {
  33675. oldData[i].destroy();
  33676. }
  33677. }
  33678. // reset minRange (#878)
  33679. if (xAxis) {
  33680. xAxis.minRange = xAxis.userMinRange;
  33681. }
  33682. // redraw
  33683. series.isDirty = chart.isDirtyBox = true;
  33684. series.isDirtyData = !!oldData;
  33685. animation = false;
  33686. }
  33687. // Typically for pie series, points need to be processed and
  33688. // generated prior to rendering the legend
  33689. if (options.legendType === 'point') {
  33690. this.processData();
  33691. this.generatePoints();
  33692. }
  33693. if (redraw) {
  33694. chart.redraw(animation);
  33695. }
  33696. },
  33697. /**
  33698. * Internal function to sort series data
  33699. *
  33700. * @private
  33701. * @function Highcharts.Series#sortData
  33702. * @param {Array<Highcharts.PointOptionsType>} data
  33703. * Force data grouping.
  33704. * @return {Array<Highcharts.PointOptionsObject>}
  33705. */
  33706. sortData: function (data) {
  33707. var series = this,
  33708. options = series.options,
  33709. dataSorting = options.dataSorting,
  33710. sortKey = dataSorting.sortKey || 'y',
  33711. sortedData,
  33712. getPointOptionsObject = function (series,
  33713. pointOptions) {
  33714. return (defined(pointOptions) &&
  33715. series.pointClass.prototype.optionsToObject.call({
  33716. series: series
  33717. },
  33718. pointOptions)) || {};
  33719. };
  33720. data.forEach(function (pointOptions, i) {
  33721. data[i] = getPointOptionsObject(series, pointOptions);
  33722. data[i].index = i;
  33723. }, this);
  33724. // Sorting
  33725. sortedData = data.concat().sort(function (a, b) {
  33726. var aValue = getNestedProperty(sortKey,
  33727. a);
  33728. var bValue = getNestedProperty(sortKey,
  33729. b);
  33730. return bValue < aValue ? -1 : bValue > aValue ? 1 : 0;
  33731. });
  33732. // Set x value depending on the position in the array
  33733. sortedData.forEach(function (point, i) {
  33734. point.x = i;
  33735. }, this);
  33736. // Set the same x for linked series points if they don't have their
  33737. // own sorting
  33738. if (series.linkedSeries) {
  33739. series.linkedSeries.forEach(function (linkedSeries) {
  33740. var options = linkedSeries.options,
  33741. seriesData = options.data;
  33742. if ((!options.dataSorting ||
  33743. !options.dataSorting.enabled) &&
  33744. seriesData) {
  33745. seriesData.forEach(function (pointOptions, i) {
  33746. seriesData[i] = getPointOptionsObject(linkedSeries, pointOptions);
  33747. if (data[i]) {
  33748. seriesData[i].x = data[i].x;
  33749. seriesData[i].index = i;
  33750. }
  33751. });
  33752. linkedSeries.setData(seriesData, false);
  33753. }
  33754. });
  33755. }
  33756. return data;
  33757. },
  33758. /**
  33759. * Internal function to process the data by cropping away unused data
  33760. * points if the series is longer than the crop threshold. This saves
  33761. * computing time for large series.
  33762. *
  33763. * @private
  33764. * @function Highcharts.Series#getProcessedData
  33765. * @param {boolean} [forceExtremesFromAll]
  33766. * Force getting extremes of a total series data range.
  33767. * @return {Highcharts.SeriesProcessedDataObject}
  33768. */
  33769. getProcessedData: function (forceExtremesFromAll) {
  33770. var series = this,
  33771. // copied during slice operation:
  33772. processedXData = series.xData,
  33773. processedYData = series.yData,
  33774. dataLength = processedXData.length,
  33775. croppedData,
  33776. cropStart = 0,
  33777. cropped,
  33778. distance,
  33779. closestPointRange,
  33780. xAxis = series.xAxis,
  33781. i, // loop variable
  33782. options = series.options,
  33783. cropThreshold = options.cropThreshold,
  33784. getExtremesFromAll = forceExtremesFromAll ||
  33785. series.getExtremesFromAll ||
  33786. options.getExtremesFromAll, // #4599
  33787. isCartesian = series.isCartesian,
  33788. xExtremes,
  33789. val2lin = xAxis && xAxis.val2lin,
  33790. isLog = !!(xAxis && xAxis.logarithmic),
  33791. throwOnUnsorted = series.requireSorting,
  33792. min,
  33793. max;
  33794. if (xAxis) {
  33795. // corrected for log axis (#3053)
  33796. xExtremes = xAxis.getExtremes();
  33797. min = xExtremes.min;
  33798. max = xExtremes.max;
  33799. }
  33800. // optionally filter out points outside the plot area
  33801. if (isCartesian &&
  33802. series.sorted &&
  33803. !getExtremesFromAll &&
  33804. (!cropThreshold ||
  33805. dataLength > cropThreshold ||
  33806. series.forceCrop)) {
  33807. // it's outside current extremes
  33808. if (processedXData[dataLength - 1] < min ||
  33809. processedXData[0] > max) {
  33810. processedXData = [];
  33811. processedYData = [];
  33812. // only crop if it's actually spilling out
  33813. }
  33814. else if (series.yData && (processedXData[0] < min ||
  33815. processedXData[dataLength - 1] > max)) {
  33816. croppedData = this.cropData(series.xData, series.yData, min, max);
  33817. processedXData = croppedData.xData;
  33818. processedYData = croppedData.yData;
  33819. cropStart = croppedData.start;
  33820. cropped = true;
  33821. }
  33822. }
  33823. // Find the closest distance between processed points
  33824. i = processedXData.length || 1;
  33825. while (--i) {
  33826. distance = (isLog ?
  33827. (val2lin(processedXData[i]) -
  33828. val2lin(processedXData[i - 1])) :
  33829. (processedXData[i] -
  33830. processedXData[i - 1]));
  33831. if (distance > 0 &&
  33832. (typeof closestPointRange === 'undefined' ||
  33833. distance < closestPointRange)) {
  33834. closestPointRange = distance;
  33835. // Unsorted data is not supported by the line tooltip, as well
  33836. // as data grouping and navigation in Stock charts (#725) and
  33837. // width calculation of columns (#1900)
  33838. }
  33839. else if (distance < 0 && throwOnUnsorted) {
  33840. error(15, false, series.chart);
  33841. throwOnUnsorted = false; // Only once
  33842. }
  33843. }
  33844. return {
  33845. xData: processedXData,
  33846. yData: processedYData,
  33847. cropped: cropped,
  33848. cropStart: cropStart,
  33849. closestPointRange: closestPointRange
  33850. };
  33851. },
  33852. /**
  33853. * Internal function to apply processed data.
  33854. * In Highstock, this function is extended to provide data grouping.
  33855. *
  33856. * @private
  33857. * @function Highcharts.Series#processData
  33858. * @param {boolean} [force]
  33859. * Force data grouping.
  33860. * @return {boolean|undefined}
  33861. */
  33862. processData: function (force) {
  33863. var series = this,
  33864. xAxis = series.xAxis,
  33865. processedData;
  33866. // If the series data or axes haven't changed, don't go through
  33867. // this. Return false to pass the message on to override methods
  33868. // like in data grouping.
  33869. if (series.isCartesian &&
  33870. !series.isDirty &&
  33871. !xAxis.isDirty &&
  33872. !series.yAxis.isDirty &&
  33873. !force) {
  33874. return false;
  33875. }
  33876. processedData = series.getProcessedData();
  33877. // Record the properties
  33878. series.cropped = processedData.cropped; // undefined or true
  33879. series.cropStart = processedData.cropStart;
  33880. series.processedXData = processedData.xData;
  33881. series.processedYData = processedData.yData;
  33882. series.closestPointRange =
  33883. series.basePointRange = processedData.closestPointRange;
  33884. },
  33885. /**
  33886. * Iterate over xData and crop values between min and max. Returns
  33887. * object containing crop start/end cropped xData with corresponding
  33888. * part of yData, dataMin and dataMax within the cropped range.
  33889. *
  33890. * @private
  33891. * @function Highcharts.Series#cropData
  33892. * @param {Array<number>} xData
  33893. * @param {Array<number>} yData
  33894. * @param {number} min
  33895. * @param {number} max
  33896. * @param {number} [cropShoulder]
  33897. * @return {Highcharts.SeriesCropDataObject}
  33898. */
  33899. cropData: function (xData, yData, min, max, cropShoulder) {
  33900. var dataLength = xData.length,
  33901. cropStart = 0,
  33902. cropEnd = dataLength,
  33903. i,
  33904. j;
  33905. // line-type series need one point outside
  33906. cropShoulder = pick(cropShoulder, this.cropShoulder);
  33907. // iterate up to find slice start
  33908. for (i = 0; i < dataLength; i++) {
  33909. if (xData[i] >= min) {
  33910. cropStart = Math.max(0, i - cropShoulder);
  33911. break;
  33912. }
  33913. }
  33914. // proceed to find slice end
  33915. for (j = i; j < dataLength; j++) {
  33916. if (xData[j] > max) {
  33917. cropEnd = j + cropShoulder;
  33918. break;
  33919. }
  33920. }
  33921. return {
  33922. xData: xData.slice(cropStart, cropEnd),
  33923. yData: yData.slice(cropStart, cropEnd),
  33924. start: cropStart,
  33925. end: cropEnd
  33926. };
  33927. },
  33928. /**
  33929. * Generate the data point after the data has been processed by cropping
  33930. * away unused points and optionally grouped in Highcharts Stock.
  33931. *
  33932. * @private
  33933. * @function Highcharts.Series#generatePoints
  33934. */
  33935. generatePoints: function () {
  33936. var series = this,
  33937. options = series.options,
  33938. dataOptions = options.data,
  33939. data = series.data,
  33940. dataLength,
  33941. processedXData = series.processedXData,
  33942. processedYData = series.processedYData,
  33943. PointClass = series.pointClass,
  33944. processedDataLength = processedXData.length,
  33945. cropStart = series.cropStart || 0,
  33946. cursor,
  33947. hasGroupedData = series.hasGroupedData,
  33948. keys = options.keys,
  33949. point,
  33950. points = [],
  33951. i;
  33952. if (!data && !hasGroupedData) {
  33953. var arr = [];
  33954. arr.length = dataOptions.length;
  33955. data = series.data = arr;
  33956. }
  33957. if (keys && hasGroupedData) {
  33958. // grouped data has already applied keys (#6590)
  33959. series.options.keys = false;
  33960. }
  33961. for (i = 0; i < processedDataLength; i++) {
  33962. cursor = cropStart + i;
  33963. if (!hasGroupedData) {
  33964. point = data[cursor];
  33965. // #970:
  33966. if (!point &&
  33967. typeof dataOptions[cursor] !== 'undefined') {
  33968. data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
  33969. }
  33970. }
  33971. else {
  33972. // splat the y data in case of ohlc data array
  33973. point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
  33974. /**
  33975. * Highstock only. If a point object is created by data
  33976. * grouping, it doesn't reflect actual points in the raw
  33977. * data. In this case, the `dataGroup` property holds
  33978. * information that points back to the raw data.
  33979. *
  33980. * - `dataGroup.start` is the index of the first raw data
  33981. * point in the group.
  33982. *
  33983. * - `dataGroup.length` is the amount of points in the
  33984. * group.
  33985. *
  33986. * @product highstock
  33987. *
  33988. * @name Highcharts.Point#dataGroup
  33989. * @type {Highcharts.DataGroupingInfoObject|undefined}
  33990. */
  33991. point.dataGroup = series.groupMap[i];
  33992. if (point.dataGroup.options) {
  33993. point.options = point.dataGroup.options;
  33994. extend(point, point.dataGroup.options);
  33995. // Collision of props and options (#9770)
  33996. delete point.dataLabels;
  33997. }
  33998. }
  33999. if (point) { // #6279
  34000. /**
  34001. * Contains the point's index in the `Series.points` array.
  34002. *
  34003. * @name Highcharts.Point#index
  34004. * @type {number}
  34005. * @readonly
  34006. */
  34007. point.index = cursor; // For faster access in Point.update
  34008. points[i] = point;
  34009. }
  34010. }
  34011. // restore keys options (#6590)
  34012. series.options.keys = keys;
  34013. // Hide cropped-away points - this only runs when the number of
  34014. // points is above cropThreshold, or when swithching view from
  34015. // non-grouped data to grouped data (#637)
  34016. if (data &&
  34017. (processedDataLength !== (dataLength = data.length) ||
  34018. hasGroupedData)) {
  34019. for (i = 0; i < dataLength; i++) {
  34020. // when has grouped data, clear all points
  34021. if (i === cropStart && !hasGroupedData) {
  34022. i += processedDataLength;
  34023. }
  34024. if (data[i]) {
  34025. data[i].destroyElements();
  34026. data[i].plotX = void 0; // #1003
  34027. }
  34028. }
  34029. }
  34030. /**
  34031. * Read only. An array containing those values converted to points.
  34032. * In case the series data length exceeds the `cropThreshold`, or if
  34033. * the data is grouped, `series.data` doesn't contain all the
  34034. * points. Also, in case a series is hidden, the `data` array may be
  34035. * empty. To access raw values, `series.options.data` will always be
  34036. * up to date. `Series.data` only contains the points that have been
  34037. * created on demand. To modify the data, use
  34038. * {@link Highcharts.Series#setData} or
  34039. * {@link Highcharts.Point#update}.
  34040. *
  34041. * @see Series.points
  34042. *
  34043. * @name Highcharts.Series#data
  34044. * @type {Array<Highcharts.Point>}
  34045. */
  34046. series.data = data;
  34047. /**
  34048. * An array containing all currently visible point objects. In case
  34049. * of cropping, the cropped-away points are not part of this array.
  34050. * The `series.points` array starts at `series.cropStart` compared
  34051. * to `series.data` and `series.options.data`. If however the series
  34052. * data is grouped, these can't be correlated one to one. To modify
  34053. * the data, use {@link Highcharts.Series#setData} or
  34054. * {@link Highcharts.Point#update}.
  34055. *
  34056. * @name Highcharts.Series#points
  34057. * @type {Array<Highcharts.Point>}
  34058. */
  34059. series.points = points;
  34060. fireEvent(this, 'afterGeneratePoints');
  34061. },
  34062. /**
  34063. * Get current X extremes for the visible data.
  34064. *
  34065. * @private
  34066. * @function Highcharts.Series#getXExtremes
  34067. *
  34068. * @param {Array<number>} xData
  34069. * The data to inspect. Defaults to the current data within the
  34070. * visible range.
  34071. * @return {Highcharts.RangeObject}
  34072. */
  34073. getXExtremes: function (xData) {
  34074. return {
  34075. min: arrayMin(xData),
  34076. max: arrayMax(xData)
  34077. };
  34078. },
  34079. /**
  34080. * Calculate Y extremes for the visible data. The result is returned
  34081. * as an object with `dataMin` and `dataMax` properties.
  34082. *
  34083. * @private
  34084. * @function Highcharts.Series#getExtremes
  34085. * @param {Array<number>} [yData]
  34086. * The data to inspect. Defaults to the current data within the
  34087. * visible range.
  34088. * @param {boolean} [forceExtremesFromAll]
  34089. * Force getting extremes of a total series data range.
  34090. * @return {Highcharts.DataExtremesObject}
  34091. */
  34092. getExtremes: function (yData, forceExtremesFromAll) {
  34093. var xAxis = this.xAxis,
  34094. yAxis = this.yAxis,
  34095. xData = this.processedXData || this.xData,
  34096. yDataLength,
  34097. activeYData = [],
  34098. activeCounter = 0,
  34099. // #2117, need to compensate for log X axis
  34100. xExtremes,
  34101. xMin = 0,
  34102. xMax = 0,
  34103. validValue,
  34104. withinRange,
  34105. // Handle X outside the viewed area. This does not work with
  34106. // non-sorted data like scatter (#7639).
  34107. shoulder = this.requireSorting ? this.cropShoulder : 0,
  34108. positiveValuesOnly = yAxis ? yAxis.positiveValuesOnly : false,
  34109. x,
  34110. y,
  34111. i,
  34112. j;
  34113. yData = yData || this.stackedYData || this.processedYData || [];
  34114. yDataLength = yData.length;
  34115. if (xAxis) {
  34116. xExtremes = xAxis.getExtremes();
  34117. xMin = xExtremes.min;
  34118. xMax = xExtremes.max;
  34119. }
  34120. for (i = 0; i < yDataLength; i++) {
  34121. x = xData[i];
  34122. y = yData[i];
  34123. // For points within the visible range, including the first
  34124. // point outside the visible range (#7061), consider y extremes.
  34125. validValue = ((isNumber(y) || isArray(y)) &&
  34126. ((y.length || y > 0) || !positiveValuesOnly));
  34127. withinRange = (forceExtremesFromAll ||
  34128. this.getExtremesFromAll ||
  34129. this.options.getExtremesFromAll ||
  34130. this.cropped ||
  34131. !xAxis || // for colorAxis support
  34132. ((xData[i + shoulder] || x) >= xMin &&
  34133. (xData[i - shoulder] || x) <= xMax));
  34134. if (validValue && withinRange) {
  34135. j = y.length;
  34136. if (j) { // array, like ohlc or range data
  34137. while (j--) {
  34138. if (isNumber(y[j])) { // #7380, #11513
  34139. activeYData[activeCounter++] = y[j];
  34140. }
  34141. }
  34142. }
  34143. else {
  34144. activeYData[activeCounter++] = y;
  34145. }
  34146. }
  34147. }
  34148. var dataExtremes = {
  34149. dataMin: arrayMin(activeYData),
  34150. dataMax: arrayMax(activeYData)
  34151. };
  34152. fireEvent(this, 'afterGetExtremes', { dataExtremes: dataExtremes });
  34153. return dataExtremes;
  34154. },
  34155. /**
  34156. * Set the current data extremes as `dataMin` and `dataMax` on the
  34157. * Series item. Use this only when the series properties should be
  34158. * updated.
  34159. *
  34160. * @private
  34161. * @function Highcharts.Series#applyExtremes
  34162. * @return {void}
  34163. */
  34164. applyExtremes: function () {
  34165. var dataExtremes = this.getExtremes();
  34166. /**
  34167. * Contains the minimum value of the series' data point. Some series
  34168. * types like `networkgraph` do not support this property as they
  34169. * lack a `y`-value.
  34170. * @name Highcharts.Series#dataMin
  34171. * @type {number|undefined}
  34172. * @readonly
  34173. */
  34174. this.dataMin = dataExtremes.dataMin;
  34175. /**
  34176. * Contains the maximum value of the series' data point. Some series
  34177. * types like `networkgraph` do not support this property as they
  34178. * lack a `y`-value.
  34179. * @name Highcharts.Series#dataMax
  34180. * @type {number|undefined}
  34181. * @readonly
  34182. */
  34183. this.dataMax = dataExtremes.dataMax;
  34184. return dataExtremes;
  34185. },
  34186. /**
  34187. * Find and return the first non null point in the data
  34188. *
  34189. * @private
  34190. * @function Highcharts.Series.getFirstValidPoint
  34191. * @param {Array<Highcharts.PointOptionsType>} data
  34192. * Array of options for points
  34193. *
  34194. * @return {Highcharts.PointOptionsType}
  34195. */
  34196. getFirstValidPoint: function (data) {
  34197. var firstPoint = null,
  34198. dataLength = data.length,
  34199. i = 0;
  34200. while (firstPoint === null && i < dataLength) {
  34201. firstPoint = data[i];
  34202. i++;
  34203. }
  34204. return firstPoint;
  34205. },
  34206. /**
  34207. * Translate data points from raw data values to chart specific
  34208. * positioning data needed later in the `drawPoints` and `drawGraph`
  34209. * functions. This function can be overridden in plugins and custom
  34210. * series type implementations.
  34211. *
  34212. * @function Highcharts.Series#translate
  34213. * @return {void}
  34214. * @fires Highcharts.Series#events:translate
  34215. */
  34216. translate: function () {
  34217. if (!this.processedXData) { // hidden series
  34218. this.processData();
  34219. }
  34220. this.generatePoints();
  34221. var series = this,
  34222. options = series.options,
  34223. stacking = options.stacking,
  34224. xAxis = series.xAxis,
  34225. categories = xAxis.categories,
  34226. enabledDataSorting = series.enabledDataSorting,
  34227. yAxis = series.yAxis,
  34228. points = series.points,
  34229. dataLength = points.length,
  34230. hasModifyValue = !!series.modifyValue,
  34231. i,
  34232. pointPlacement = series.pointPlacementToXValue(), // #7860
  34233. dynamicallyPlaced = Boolean(pointPlacement),
  34234. threshold = options.threshold,
  34235. stackThreshold = options.startFromThreshold ? threshold : 0,
  34236. plotX,
  34237. lastPlotX,
  34238. stackIndicator,
  34239. zoneAxis = this.zoneAxis || 'y',
  34240. closestPointRangePx = Number.MAX_VALUE;
  34241. /**
  34242. * Plotted coordinates need to be within a limited range. Drawing
  34243. * too far outside the viewport causes various rendering issues
  34244. * (#3201, #3923, #7555).
  34245. * @private
  34246. */
  34247. function limitedRange(val) {
  34248. return clamp(val, -1e5, 1e5);
  34249. }
  34250. // Translate each point
  34251. for (i = 0; i < dataLength; i++) {
  34252. var point = points[i],
  34253. xValue = point.x,
  34254. yValue = point.y,
  34255. yBottom = point.low,
  34256. stack = stacking && yAxis.stacking && yAxis.stacking.stacks[(series.negStacks &&
  34257. yValue <
  34258. (stackThreshold ? 0 : threshold) ?
  34259. '-' :
  34260. '') + series.stackKey],
  34261. pointStack,
  34262. stackValues;
  34263. if (yAxis.positiveValuesOnly && !yAxis.validatePositiveValue(yValue) ||
  34264. xAxis.positiveValuesOnly && !xAxis.validatePositiveValue(xValue)) {
  34265. point.isNull = true;
  34266. }
  34267. // Get the plotX translation
  34268. point.plotX = plotX = correctFloat(// #5236
  34269. limitedRange(xAxis.translate(// #3923
  34270. xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags')) // #3923
  34271. );
  34272. // Calculate the bottom y value for stacked series
  34273. if (stacking &&
  34274. series.visible &&
  34275. stack &&
  34276. stack[xValue]) {
  34277. stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
  34278. if (!point.isNull) {
  34279. pointStack = stack[xValue];
  34280. stackValues =
  34281. pointStack.points[stackIndicator.key];
  34282. }
  34283. }
  34284. if (isArray(stackValues)) {
  34285. yBottom = stackValues[0];
  34286. yValue = stackValues[1];
  34287. if (yBottom === stackThreshold &&
  34288. stackIndicator.key ===
  34289. stack[xValue].base) {
  34290. yBottom = pick((isNumber(threshold) && threshold), yAxis.min);
  34291. }
  34292. // #1200, #1232
  34293. if (yAxis.positiveValuesOnly && yBottom <= 0) {
  34294. yBottom = null;
  34295. }
  34296. point.total = point.stackTotal = pointStack.total;
  34297. point.percentage =
  34298. pointStack.total &&
  34299. (point.y / pointStack.total * 100);
  34300. point.stackY = yValue;
  34301. // Place the stack label
  34302. // in case of variwide series (where widths of points are
  34303. // different in most cases), stack labels are positioned
  34304. // wrongly, so the call of the setOffset is omited here and
  34305. // labels are correctly positioned later, at the end of the
  34306. // variwide's translate function (#10962)
  34307. if (!series.irregularWidths) {
  34308. pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
  34309. }
  34310. }
  34311. // Set translated yBottom or remove it
  34312. point.yBottom = defined(yBottom) ?
  34313. limitedRange(yAxis.translate(yBottom, 0, 1, 0, 1)) :
  34314. null;
  34315. // general hook, used for Highstock compare mode
  34316. if (hasModifyValue) {
  34317. yValue = series.modifyValue(yValue, point);
  34318. }
  34319. // Set the the plotY value, reset it for redraws
  34320. // #3201
  34321. point.plotY = ((typeof yValue === 'number' && yValue !== Infinity) ?
  34322. limitedRange(yAxis.translate(yValue, 0, 1, 0, 1)) :
  34323. void 0);
  34324. point.isInside = this.isPointInside(point);
  34325. // Set client related positions for mouse tracking
  34326. point.clientX = dynamicallyPlaced ?
  34327. correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) :
  34328. plotX; // #1514, #5383, #5518
  34329. // Negative points. For bubble charts, this means negative z
  34330. // values (#9728)
  34331. point.negative = point[zoneAxis] < (options[zoneAxis + 'Threshold'] ||
  34332. threshold ||
  34333. 0);
  34334. // some API data
  34335. point.category = (categories &&
  34336. typeof categories[point.x] !== 'undefined' ?
  34337. categories[point.x] :
  34338. point.x);
  34339. // Determine auto enabling of markers (#3635, #5099)
  34340. if (!point.isNull && point.visible !== false) {
  34341. if (typeof lastPlotX !== 'undefined') {
  34342. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
  34343. }
  34344. lastPlotX = plotX;
  34345. }
  34346. // Find point zone
  34347. point.zone = (this.zones.length && point.getZone());
  34348. // Animate new points with data sorting
  34349. if (!point.graphic && series.group && enabledDataSorting) {
  34350. point.isNew = true;
  34351. }
  34352. }
  34353. series.closestPointRangePx = closestPointRangePx;
  34354. fireEvent(this, 'afterTranslate');
  34355. },
  34356. /**
  34357. * Return the series points with null points filtered out.
  34358. *
  34359. * @function Highcharts.Series#getValidPoints
  34360. *
  34361. * @param {Array<Highcharts.Point>} [points]
  34362. * The points to inspect, defaults to {@link Series.points}.
  34363. *
  34364. * @param {boolean} [insideOnly=false]
  34365. * Whether to inspect only the points that are inside the visible
  34366. * view.
  34367. *
  34368. * @param {boolean} [allowNull=false]
  34369. * Whether to allow null points to pass as valid points.
  34370. *
  34371. * @return {Array<Highcharts.Point>}
  34372. * The valid points.
  34373. */
  34374. getValidPoints: function (points, insideOnly, allowNull) {
  34375. var chart = this.chart;
  34376. // #3916, #5029, #5085
  34377. return (points || this.points || []).filter(function isValidPoint(point) {
  34378. if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, chart.inverted)) {
  34379. return false;
  34380. }
  34381. return point.visible !== false &&
  34382. (allowNull || !point.isNull);
  34383. });
  34384. },
  34385. /**
  34386. * Get the clipping for the series. Could be called for a series to
  34387. * initiate animating the clip or to set the final clip (only width
  34388. * and x).
  34389. *
  34390. * @private
  34391. * @function Highcharts.Series#getClip
  34392. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  34393. * Initialize the animation.
  34394. * @param {boolean} [finalBox]
  34395. * Final size for the clip - end state for the animation.
  34396. * @return {Highcharts.Dictionary<number>}
  34397. */
  34398. getClipBox: function (animation, finalBox) {
  34399. var series = this,
  34400. options = series.options,
  34401. chart = series.chart,
  34402. inverted = chart.inverted,
  34403. xAxis = series.xAxis,
  34404. yAxis = xAxis && series.yAxis,
  34405. clipBox,
  34406. scrollablePlotAreaOptions = chart.options.chart.scrollablePlotArea || {};
  34407. if (animation && options.clip === false && yAxis) {
  34408. // support for not clipped series animation (#10450)
  34409. clipBox = inverted ? {
  34410. y: -chart.chartWidth + yAxis.len + yAxis.pos,
  34411. height: chart.chartWidth,
  34412. width: chart.chartHeight,
  34413. x: -chart.chartHeight + xAxis.len + xAxis.pos
  34414. } : {
  34415. y: -yAxis.pos,
  34416. height: chart.chartHeight,
  34417. width: chart.chartWidth,
  34418. x: -xAxis.pos
  34419. };
  34420. // x and width will be changed later when setting for animation
  34421. // initial state in Series.setClip
  34422. }
  34423. else {
  34424. clipBox = series.clipBox || chart.clipBox;
  34425. if (finalBox) {
  34426. clipBox.width = chart.plotSizeX;
  34427. clipBox.x = (chart.scrollablePixelsX || 0) *
  34428. (scrollablePlotAreaOptions.scrollPositionX || 0);
  34429. }
  34430. }
  34431. return !finalBox ? clipBox : {
  34432. width: clipBox.width,
  34433. x: clipBox.x
  34434. };
  34435. },
  34436. /**
  34437. * Set the clipping for the series. For animated series it is called
  34438. * twice, first to initiate animating the clip then the second time
  34439. * without the animation to set the final clip.
  34440. *
  34441. * @private
  34442. * @function Highcharts.Series#setClip
  34443. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  34444. */
  34445. setClip: function (animation) {
  34446. var chart = this.chart, options = this.options, renderer = chart.renderer, inverted = chart.inverted, seriesClipBox = this.clipBox, clipBox = this.getClipBox(animation), sharedClipKey = this.sharedClipKey ||
  34447. [
  34448. '_sharedClip',
  34449. animation && animation.duration,
  34450. animation && animation.easing,
  34451. clipBox.height,
  34452. options.xAxis,
  34453. options.yAxis
  34454. ].join(','), // #4526
  34455. clipRect = chart[sharedClipKey], markerClipRect = chart[sharedClipKey + 'm'];
  34456. if (animation) {
  34457. clipBox.width = 0;
  34458. if (inverted) {
  34459. clipBox.x = chart.plotHeight +
  34460. (options.clip !== false ? 0 : chart.plotTop);
  34461. }
  34462. }
  34463. // If a clipping rectangle with the same properties is currently
  34464. // present in the chart, use that.
  34465. if (!clipRect) {
  34466. // When animation is set, prepare the initial positions
  34467. if (animation) {
  34468. chart[sharedClipKey + 'm'] = markerClipRect =
  34469. renderer.clipRect(
  34470. // include the width of the first marker
  34471. inverted ? chart.plotSizeX + 99 : -99, inverted ? -chart.plotLeft : -chart.plotTop, 99, inverted ? chart.chartWidth : chart.chartHeight);
  34472. }
  34473. chart[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
  34474. // Create hashmap for series indexes
  34475. clipRect.count = { length: 0 };
  34476. // When the series is rendered again before starting animating, in
  34477. // compliance to a responsive rule
  34478. }
  34479. else if (!chart.hasLoaded) {
  34480. clipRect.attr(clipBox);
  34481. }
  34482. if (animation) {
  34483. if (!clipRect.count[this.index]) {
  34484. clipRect.count[this.index] = true;
  34485. clipRect.count.length += 1;
  34486. }
  34487. }
  34488. if (options.clip !== false || animation) {
  34489. this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
  34490. this.markerGroup.clip(markerClipRect);
  34491. this.sharedClipKey = sharedClipKey;
  34492. }
  34493. // Remove the shared clipping rectangle when all series are shown
  34494. if (!animation) {
  34495. if (clipRect.count[this.index]) {
  34496. delete clipRect.count[this.index];
  34497. clipRect.count.length -= 1;
  34498. }
  34499. if (clipRect.count.length === 0 &&
  34500. sharedClipKey &&
  34501. chart[sharedClipKey]) {
  34502. if (!seriesClipBox) {
  34503. chart[sharedClipKey] =
  34504. chart[sharedClipKey].destroy();
  34505. }
  34506. if (chart[sharedClipKey + 'm']) {
  34507. chart[sharedClipKey + 'm'] =
  34508. chart[sharedClipKey + 'm'].destroy();
  34509. }
  34510. }
  34511. }
  34512. },
  34513. /**
  34514. * Animate in the series. Called internally twice. First with the `init`
  34515. * parameter set to true, which sets up the initial state of the
  34516. * animation. Then when ready, it is called with the `init` parameter
  34517. * undefined, in order to perform the actual animation. After the
  34518. * second run, the function is removed.
  34519. *
  34520. * @function Highcharts.Series#animate
  34521. *
  34522. * @param {boolean} [init]
  34523. * Initialize the animation.
  34524. */
  34525. animate: function (init) {
  34526. var series = this,
  34527. chart = series.chart,
  34528. animation = animObject(series.options.animation),
  34529. clipRect,
  34530. sharedClipKey,
  34531. finalBox;
  34532. // Initialize the animation. Set up the clipping rectangle.
  34533. if (!chart.hasRendered) {
  34534. if (init) {
  34535. series.setClip(animation);
  34536. // Run the animation
  34537. }
  34538. else {
  34539. sharedClipKey = this.sharedClipKey;
  34540. clipRect = chart[sharedClipKey];
  34541. finalBox = series.getClipBox(animation, true);
  34542. if (clipRect) {
  34543. clipRect.animate(finalBox, animation);
  34544. }
  34545. if (chart[sharedClipKey + 'm']) {
  34546. chart[sharedClipKey + 'm'].animate({
  34547. width: finalBox.width + 99,
  34548. x: finalBox.x - (chart.inverted ? 0 : 99)
  34549. }, animation);
  34550. }
  34551. }
  34552. }
  34553. },
  34554. /**
  34555. * This runs after animation to land on the final plot clipping.
  34556. *
  34557. * @private
  34558. * @function Highcharts.Series#afterAnimate
  34559. * @fires Highcharts.Series#event:afterAnimate
  34560. */
  34561. afterAnimate: function () {
  34562. this.setClip();
  34563. fireEvent(this, 'afterAnimate');
  34564. this.finishedAnimating = true;
  34565. },
  34566. /**
  34567. * Draw the markers for line-like series types, and columns or other
  34568. * graphical representation for {@link Point} objects for other series
  34569. * types. The resulting element is typically stored as
  34570. * {@link Point.graphic}, and is created on the first call and updated
  34571. * and moved on subsequent calls.
  34572. *
  34573. * @function Highcharts.Series#drawPoints
  34574. */
  34575. drawPoints: function () {
  34576. var series = this,
  34577. points = series.points,
  34578. chart = series.chart,
  34579. i,
  34580. point,
  34581. graphic,
  34582. verb,
  34583. options = series.options,
  34584. seriesMarkerOptions = options.marker,
  34585. pointMarkerOptions,
  34586. hasPointMarker,
  34587. markerGroup = (series[series.specialGroup] ||
  34588. series.markerGroup),
  34589. xAxis = series.xAxis,
  34590. markerAttribs,
  34591. globallyEnabled = pick(seriesMarkerOptions.enabled, !xAxis || xAxis.isRadial ? true : null,
  34592. // Use larger or equal as radius is null in bubbles (#6321)
  34593. series.closestPointRangePx >= (seriesMarkerOptions.enabledThreshold *
  34594. seriesMarkerOptions.radius));
  34595. if (seriesMarkerOptions.enabled !== false ||
  34596. series._hasPointMarkers) {
  34597. for (i = 0; i < points.length; i++) {
  34598. point = points[i];
  34599. graphic = point.graphic;
  34600. verb = graphic ? 'animate' : 'attr';
  34601. pointMarkerOptions = point.marker || {};
  34602. hasPointMarker = !!point.marker;
  34603. var shouldDrawMarker = ((globallyEnabled &&
  34604. typeof pointMarkerOptions.enabled === 'undefined') || pointMarkerOptions.enabled) && !point.isNull && point.visible !== false;
  34605. // only draw the point if y is defined
  34606. if (shouldDrawMarker) {
  34607. // Shortcuts
  34608. var symbol = pick(pointMarkerOptions.symbol,
  34609. series.symbol);
  34610. markerAttribs = series.markerAttribs(point, (point.selected && 'select'));
  34611. // Set starting position for point sliding animation.
  34612. if (series.enabledDataSorting) {
  34613. point.startXPos = xAxis.reversed ?
  34614. -markerAttribs.width :
  34615. xAxis.width;
  34616. }
  34617. var isInside = point.isInside !== false;
  34618. if (graphic) { // update
  34619. // Since the marker group isn't clipped, each
  34620. // individual marker must be toggled
  34621. graphic[isInside ? 'show' : 'hide'](isInside)
  34622. .animate(markerAttribs);
  34623. }
  34624. else if (isInside &&
  34625. (markerAttribs.width > 0 || point.hasImage)) {
  34626. /**
  34627. * The graphic representation of the point.
  34628. * Typically this is a simple shape, like a `rect`
  34629. * for column charts or `path` for line markers, but
  34630. * for some complex series types like boxplot or 3D
  34631. * charts, the graphic may be a `g` element
  34632. * containing other shapes. The graphic is generated
  34633. * the first time {@link Series#drawPoints} runs,
  34634. * and updated and moved on subsequent runs.
  34635. *
  34636. * @name Point#graphic
  34637. * @type {SVGElement}
  34638. */
  34639. point.graphic = graphic = chart.renderer
  34640. .symbol(symbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height, hasPointMarker ?
  34641. pointMarkerOptions :
  34642. seriesMarkerOptions)
  34643. .add(markerGroup);
  34644. // Sliding animation for new points
  34645. if (series.enabledDataSorting &&
  34646. chart.hasRendered) {
  34647. graphic.attr({
  34648. x: point.startXPos
  34649. });
  34650. verb = 'animate';
  34651. }
  34652. }
  34653. if (graphic && verb === 'animate') { // update
  34654. // Since the marker group isn't clipped, each
  34655. // individual marker must be toggled
  34656. graphic[isInside ? 'show' : 'hide'](isInside)
  34657. .animate(markerAttribs);
  34658. }
  34659. // Presentational attributes
  34660. if (graphic && !chart.styledMode) {
  34661. graphic[verb](series.pointAttribs(point, (point.selected && 'select')));
  34662. }
  34663. if (graphic) {
  34664. graphic.addClass(point.getClassName(), true);
  34665. }
  34666. }
  34667. else if (graphic) {
  34668. point.graphic = graphic.destroy(); // #1269
  34669. }
  34670. }
  34671. }
  34672. },
  34673. /**
  34674. * Get non-presentational attributes for a point. Used internally for
  34675. * both styled mode and classic. Can be overridden for different series
  34676. * types.
  34677. *
  34678. * @see Series#pointAttribs
  34679. *
  34680. * @function Highcharts.Series#markerAttribs
  34681. *
  34682. * @param {Highcharts.Point} point
  34683. * The Point to inspect.
  34684. *
  34685. * @param {string} [state]
  34686. * The state, can be either `hover`, `select` or undefined.
  34687. *
  34688. * @return {Highcharts.SVGAttributes}
  34689. * A hash containing those attributes that are not settable from
  34690. * CSS.
  34691. */
  34692. markerAttribs: function (point, state) {
  34693. var seriesOptions = this.options,
  34694. seriesMarkerOptions = seriesOptions.marker,
  34695. seriesStateOptions,
  34696. pointMarkerOptions = point.marker || {},
  34697. symbol = (pointMarkerOptions.symbol ||
  34698. seriesMarkerOptions.symbol),
  34699. pointStateOptions,
  34700. radius = pick(pointMarkerOptions.radius,
  34701. seriesMarkerOptions.radius),
  34702. attribs;
  34703. // Handle hover and select states
  34704. if (state) {
  34705. seriesStateOptions = seriesMarkerOptions.states[state];
  34706. pointStateOptions = pointMarkerOptions.states &&
  34707. pointMarkerOptions.states[state];
  34708. radius = pick(pointStateOptions && pointStateOptions.radius, seriesStateOptions && seriesStateOptions.radius, radius + (seriesStateOptions && seriesStateOptions.radiusPlus ||
  34709. 0));
  34710. }
  34711. point.hasImage = symbol && symbol.indexOf('url') === 0;
  34712. if (point.hasImage) {
  34713. radius = 0; // and subsequently width and height is not set
  34714. }
  34715. attribs = {
  34716. // Math.floor for #1843:
  34717. x: seriesOptions.crisp ?
  34718. Math.floor(point.plotX) - radius :
  34719. point.plotX - radius,
  34720. y: point.plotY - radius
  34721. };
  34722. if (radius) {
  34723. attribs.width = attribs.height = 2 * radius;
  34724. }
  34725. return attribs;
  34726. },
  34727. /**
  34728. * Internal function to get presentational attributes for each point.
  34729. * Unlike {@link Series#markerAttribs}, this function should return
  34730. * those attributes that can also be set in CSS. In styled mode,
  34731. * `pointAttribs` won't be called.
  34732. *
  34733. * @private
  34734. * @function Highcharts.Series#pointAttribs
  34735. *
  34736. * @param {Highcharts.Point} [point]
  34737. * The point instance to inspect.
  34738. *
  34739. * @param {string} [state]
  34740. * The point state, can be either `hover`, `select` or 'normal'.
  34741. * If undefined, normal state is assumed.
  34742. *
  34743. * @return {Highcharts.SVGAttributes}
  34744. * The presentational attributes to be set on the point.
  34745. */
  34746. pointAttribs: function (point, state) {
  34747. var seriesMarkerOptions = this.options.marker,
  34748. seriesStateOptions,
  34749. pointOptions = point && point.options,
  34750. pointMarkerOptions = ((pointOptions && pointOptions.marker) || {}),
  34751. pointStateOptions,
  34752. color = this.color,
  34753. pointColorOption = pointOptions && pointOptions.color,
  34754. pointColor = point && point.color,
  34755. strokeWidth = pick(pointMarkerOptions.lineWidth,
  34756. seriesMarkerOptions.lineWidth),
  34757. zoneColor = point && point.zone && point.zone.color,
  34758. fill,
  34759. stroke,
  34760. opacity = 1;
  34761. color = (pointColorOption ||
  34762. zoneColor ||
  34763. pointColor ||
  34764. color);
  34765. fill = (pointMarkerOptions.fillColor ||
  34766. seriesMarkerOptions.fillColor ||
  34767. color);
  34768. stroke = (pointMarkerOptions.lineColor ||
  34769. seriesMarkerOptions.lineColor ||
  34770. color);
  34771. // Handle hover and select states
  34772. state = state || 'normal';
  34773. if (state) {
  34774. seriesStateOptions = seriesMarkerOptions.states[state];
  34775. pointStateOptions = (pointMarkerOptions.states &&
  34776. pointMarkerOptions.states[state]) || {};
  34777. strokeWidth = pick(pointStateOptions.lineWidth, seriesStateOptions.lineWidth, strokeWidth + pick(pointStateOptions.lineWidthPlus, seriesStateOptions.lineWidthPlus, 0));
  34778. fill = (pointStateOptions.fillColor ||
  34779. seriesStateOptions.fillColor ||
  34780. fill);
  34781. stroke = (pointStateOptions.lineColor ||
  34782. seriesStateOptions.lineColor ||
  34783. stroke);
  34784. opacity = pick(pointStateOptions.opacity, seriesStateOptions.opacity, opacity);
  34785. }
  34786. return {
  34787. 'stroke': stroke,
  34788. 'stroke-width': strokeWidth,
  34789. 'fill': fill,
  34790. 'opacity': opacity
  34791. };
  34792. },
  34793. /**
  34794. * Clear DOM objects and free up memory.
  34795. *
  34796. * @private
  34797. * @function Highcharts.Series#destroy
  34798. * @param {boolean} [keepEventsForUpdate]
  34799. * @return {void}
  34800. * @fires Highcharts.Series#event:destroy
  34801. */
  34802. destroy: function (keepEventsForUpdate) {
  34803. var series = this,
  34804. chart = series.chart,
  34805. issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
  34806. destroy,
  34807. i,
  34808. data = series.data || [],
  34809. point,
  34810. axis;
  34811. // add event hook
  34812. fireEvent(series, 'destroy');
  34813. // remove events
  34814. this.removeEvents(keepEventsForUpdate);
  34815. // erase from axes
  34816. (series.axisTypes || []).forEach(function (AXIS) {
  34817. axis = series[AXIS];
  34818. if (axis && axis.series) {
  34819. erase(axis.series, series);
  34820. axis.isDirty = axis.forceRedraw = true;
  34821. }
  34822. });
  34823. // remove legend items
  34824. if (series.legendItem) {
  34825. series.chart.legend.destroyItem(series);
  34826. }
  34827. // destroy all points with their elements
  34828. i = data.length;
  34829. while (i--) {
  34830. point = data[i];
  34831. if (point && point.destroy) {
  34832. point.destroy();
  34833. }
  34834. }
  34835. series.points = null;
  34836. // Clear the animation timeout if we are destroying the series
  34837. // during initial animation
  34838. U.clearTimeout(series.animationTimeout);
  34839. // Destroy all SVGElements associated to the series
  34840. objectEach(series, function (val, prop) {
  34841. // Survive provides a hook for not destroying
  34842. if (val instanceof SVGElement && !val.survive) {
  34843. // issue 134 workaround
  34844. destroy = issue134 && prop === 'group' ?
  34845. 'hide' :
  34846. 'destroy';
  34847. val[destroy]();
  34848. }
  34849. });
  34850. // remove from hoverSeries
  34851. if (chart.hoverSeries === series) {
  34852. chart.hoverSeries = null;
  34853. }
  34854. erase(chart.series, series);
  34855. chart.orderSeries();
  34856. // clear all members
  34857. objectEach(series, function (val, prop) {
  34858. if (!keepEventsForUpdate || prop !== 'hcEvents') {
  34859. delete series[prop];
  34860. }
  34861. });
  34862. },
  34863. /**
  34864. * Get the graph path.
  34865. *
  34866. * @private
  34867. * @function Highcharts.Series#getGraphPath
  34868. * @param {Array<Highcharts.Point>} points
  34869. * @param {boolean} [nullsAsZeroes]
  34870. * @param {boolean} [connectCliffs]
  34871. * @return {Highcharts.SVGPathArray}
  34872. */
  34873. getGraphPath: function (points, nullsAsZeroes, connectCliffs) {
  34874. var series = this,
  34875. options = series.options,
  34876. step = options.step,
  34877. reversed,
  34878. graphPath = [],
  34879. xMap = [],
  34880. gap;
  34881. points = points || series.points;
  34882. // Bottom of a stack is reversed
  34883. reversed = points.reversed;
  34884. if (reversed) {
  34885. points.reverse();
  34886. }
  34887. // Reverse the steps (#5004)
  34888. step = {
  34889. right: 1,
  34890. center: 2
  34891. }[step] || (step && 3);
  34892. if (step && reversed) {
  34893. step = 4 - step;
  34894. }
  34895. // Remove invalid points, especially in spline (#5015)
  34896. points = this.getValidPoints(points, false, !(options.connectNulls && !nullsAsZeroes && !connectCliffs));
  34897. // Build the line
  34898. points.forEach(function (point, i) {
  34899. var plotX = point.plotX,
  34900. plotY = point.plotY,
  34901. lastPoint = points[i - 1],
  34902. // the path to this point from the previous
  34903. pathToPoint;
  34904. if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) &&
  34905. !connectCliffs) {
  34906. gap = true; // ... and continue
  34907. }
  34908. // Line series, nullsAsZeroes is not handled
  34909. if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
  34910. gap = !options.connectNulls;
  34911. // Area series, nullsAsZeroes is set
  34912. }
  34913. else if (point.isNull && !nullsAsZeroes) {
  34914. gap = true;
  34915. }
  34916. else {
  34917. if (i === 0 || gap) {
  34918. pathToPoint = [[
  34919. 'M',
  34920. point.plotX,
  34921. point.plotY
  34922. ]];
  34923. // Generate the spline as defined in the SplineSeries object
  34924. }
  34925. else if (series.getPointSpline) {
  34926. pathToPoint = [series.getPointSpline(points, point, i)];
  34927. }
  34928. else if (step) {
  34929. if (step === 1) { // right
  34930. pathToPoint = [[
  34931. 'L',
  34932. lastPoint.plotX,
  34933. plotY
  34934. ]];
  34935. }
  34936. else if (step === 2) { // center
  34937. pathToPoint = [[
  34938. 'L',
  34939. (lastPoint.plotX + plotX) / 2,
  34940. lastPoint.plotY
  34941. ], [
  34942. 'L',
  34943. (lastPoint.plotX + plotX) / 2,
  34944. plotY
  34945. ]];
  34946. }
  34947. else {
  34948. pathToPoint = [[
  34949. 'L',
  34950. plotX,
  34951. lastPoint.plotY
  34952. ]];
  34953. }
  34954. pathToPoint.push([
  34955. 'L',
  34956. plotX,
  34957. plotY
  34958. ]);
  34959. }
  34960. else {
  34961. // normal line to next point
  34962. pathToPoint = [[
  34963. 'L',
  34964. plotX,
  34965. plotY
  34966. ]];
  34967. }
  34968. // Prepare for animation. When step is enabled, there are
  34969. // two path nodes for each x value.
  34970. xMap.push(point.x);
  34971. if (step) {
  34972. xMap.push(point.x);
  34973. if (step === 2) { // step = center (#8073)
  34974. xMap.push(point.x);
  34975. }
  34976. }
  34977. graphPath.push.apply(graphPath, pathToPoint);
  34978. gap = false;
  34979. }
  34980. });
  34981. graphPath.xMap = xMap;
  34982. series.graphPath = graphPath;
  34983. return graphPath;
  34984. },
  34985. /**
  34986. * Draw the graph. Called internally when rendering line-like series
  34987. * types. The first time it generates the `series.graph` item and
  34988. * optionally other series-wide items like `series.area` for area
  34989. * charts. On subsequent calls these items are updated with new
  34990. * positions and attributes.
  34991. *
  34992. * @function Highcharts.Series#drawGraph
  34993. */
  34994. drawGraph: function () {
  34995. var series = this,
  34996. options = this.options,
  34997. graphPath = (this.gappedPath || this.getGraphPath).call(this),
  34998. styledMode = this.chart.styledMode,
  34999. props = [[
  35000. 'graph',
  35001. 'highcharts-graph'
  35002. ]];
  35003. // Presentational properties
  35004. if (!styledMode) {
  35005. props[0].push((options.lineColor ||
  35006. this.color ||
  35007. '#cccccc' // when colorByPoint = true
  35008. ), options.dashStyle);
  35009. }
  35010. props = series.getZonesGraphs(props);
  35011. // Draw the graph
  35012. props.forEach(function (prop, i) {
  35013. var graphKey = prop[0],
  35014. graph = series[graphKey],
  35015. verb = graph ? 'animate' : 'attr',
  35016. attribs;
  35017. if (graph) {
  35018. graph.endX = series.preventGraphAnimation ?
  35019. null :
  35020. graphPath.xMap;
  35021. graph.animate({ d: graphPath });
  35022. }
  35023. else if (graphPath.length) { // #1487
  35024. /**
  35025. * SVG element of area-based charts. Can be used for styling
  35026. * purposes. If zones are configured, this element will be
  35027. * hidden and replaced by multiple zone areas, accessible
  35028. * via `series['zone-area-x']` (where x is a number,
  35029. * starting with 0).
  35030. *
  35031. * @name Highcharts.Series#area
  35032. * @type {Highcharts.SVGElement|undefined}
  35033. */
  35034. /**
  35035. * SVG element of line-based charts. Can be used for styling
  35036. * purposes. If zones are configured, this element will be
  35037. * hidden and replaced by multiple zone lines, accessible
  35038. * via `series['zone-graph-x']` (where x is a number,
  35039. * starting with 0).
  35040. *
  35041. * @name Highcharts.Series#graph
  35042. * @type {Highcharts.SVGElement|undefined}
  35043. */
  35044. series[graphKey] = graph = series.chart.renderer
  35045. .path(graphPath)
  35046. .addClass(prop[1])
  35047. .attr({ zIndex: 1 }) // #1069
  35048. .add(series.group);
  35049. }
  35050. if (graph && !styledMode) {
  35051. attribs = {
  35052. 'stroke': prop[2],
  35053. 'stroke-width': options.lineWidth,
  35054. // Polygon series use filled graph
  35055. 'fill': (series.fillGraph && series.color) || 'none'
  35056. };
  35057. if (prop[3]) {
  35058. attribs.dashstyle = prop[3];
  35059. }
  35060. else if (options.linecap !== 'square') {
  35061. attribs['stroke-linecap'] =
  35062. attribs['stroke-linejoin'] = 'round';
  35063. }
  35064. graph[verb](attribs)
  35065. // Add shadow to normal series (0) or to first
  35066. // zone (1) #3932
  35067. .shadow((i < 2) && options.shadow);
  35068. }
  35069. // Helpers for animation
  35070. if (graph) {
  35071. graph.startX = graphPath.xMap;
  35072. graph.isArea = graphPath.isArea; // For arearange animation
  35073. }
  35074. });
  35075. },
  35076. /**
  35077. * Get zones properties for building graphs. Extendable by series with
  35078. * multiple lines within one series.
  35079. *
  35080. * @private
  35081. * @function Highcharts.Series#getZonesGraphs
  35082. *
  35083. * @param {Array<Array<string>>} props
  35084. *
  35085. * @return {Array<Array<string>>}
  35086. */
  35087. getZonesGraphs: function (props) {
  35088. // Add the zone properties if any
  35089. this.zones.forEach(function (zone, i) {
  35090. var propset = [
  35091. 'zone-graph-' + i,
  35092. 'highcharts-graph highcharts-zone-graph-' + i + ' ' +
  35093. (zone.className || '')
  35094. ];
  35095. if (!this.chart.styledMode) {
  35096. propset.push((zone.color || this.color), (zone.dashStyle || this.options.dashStyle));
  35097. }
  35098. props.push(propset);
  35099. }, this);
  35100. return props;
  35101. },
  35102. /**
  35103. * Clip the graphs into zones for colors and styling.
  35104. *
  35105. * @private
  35106. * @function Highcharts.Series#applyZones
  35107. * @return {void}
  35108. */
  35109. applyZones: function () {
  35110. var series = this,
  35111. chart = this.chart,
  35112. renderer = chart.renderer,
  35113. zones = this.zones,
  35114. translatedFrom,
  35115. translatedTo,
  35116. clips = (this.clips || []),
  35117. clipAttr,
  35118. graph = this.graph,
  35119. area = this.area,
  35120. chartSizeMax = Math.max(chart.chartWidth,
  35121. chart.chartHeight),
  35122. axis = this[(this.zoneAxis || 'y') + 'Axis'],
  35123. extremes,
  35124. reversed,
  35125. inverted = chart.inverted,
  35126. horiz,
  35127. pxRange,
  35128. pxPosMin,
  35129. pxPosMax,
  35130. ignoreZones = false,
  35131. zoneArea,
  35132. zoneGraph;
  35133. if (zones.length &&
  35134. (graph || area) &&
  35135. axis &&
  35136. typeof axis.min !== 'undefined') {
  35137. reversed = axis.reversed;
  35138. horiz = axis.horiz;
  35139. // The use of the Color Threshold assumes there are no gaps
  35140. // so it is safe to hide the original graph and area
  35141. // unless it is not waterfall series, then use showLine property
  35142. // to set lines between columns to be visible (#7862)
  35143. if (graph && !this.showLine) {
  35144. graph.hide();
  35145. }
  35146. if (area) {
  35147. area.hide();
  35148. }
  35149. // Create the clips
  35150. extremes = axis.getExtremes();
  35151. zones.forEach(function (threshold, i) {
  35152. translatedFrom = reversed ?
  35153. (horiz ? chart.plotWidth : 0) :
  35154. (horiz ? 0 : (axis.toPixels(extremes.min) || 0));
  35155. translatedFrom = clamp(pick(translatedTo, translatedFrom), 0, chartSizeMax);
  35156. translatedTo = clamp(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true) || 0), 0, chartSizeMax);
  35157. if (ignoreZones) {
  35158. translatedFrom = translatedTo =
  35159. axis.toPixels(extremes.max);
  35160. }
  35161. pxRange = Math.abs(translatedFrom - translatedTo);
  35162. pxPosMin = Math.min(translatedFrom, translatedTo);
  35163. pxPosMax = Math.max(translatedFrom, translatedTo);
  35164. if (axis.isXAxis) {
  35165. clipAttr = {
  35166. x: inverted ? pxPosMax : pxPosMin,
  35167. y: 0,
  35168. width: pxRange,
  35169. height: chartSizeMax
  35170. };
  35171. if (!horiz) {
  35172. clipAttr.x = chart.plotHeight - clipAttr.x;
  35173. }
  35174. }
  35175. else {
  35176. clipAttr = {
  35177. x: 0,
  35178. y: inverted ? pxPosMax : pxPosMin,
  35179. width: chartSizeMax,
  35180. height: pxRange
  35181. };
  35182. if (horiz) {
  35183. clipAttr.y = chart.plotWidth - clipAttr.y;
  35184. }
  35185. }
  35186. // VML SUPPPORT
  35187. if (inverted && renderer.isVML) {
  35188. if (axis.isXAxis) {
  35189. clipAttr = {
  35190. x: 0,
  35191. y: reversed ? pxPosMin : pxPosMax,
  35192. height: clipAttr.width,
  35193. width: chart.chartWidth
  35194. };
  35195. }
  35196. else {
  35197. clipAttr = {
  35198. x: (clipAttr.y -
  35199. chart.plotLeft -
  35200. chart.spacingBox.x),
  35201. y: 0,
  35202. width: clipAttr.height,
  35203. height: chart.chartHeight
  35204. };
  35205. }
  35206. }
  35207. // END OF VML SUPPORT
  35208. if (clips[i]) {
  35209. clips[i].animate(clipAttr);
  35210. }
  35211. else {
  35212. clips[i] = renderer.clipRect(clipAttr);
  35213. }
  35214. // when no data, graph zone is not applied and after setData
  35215. // clip was ignored. As a result, it should be applied each
  35216. // time.
  35217. zoneArea = series['zone-area-' + i];
  35218. zoneGraph = series['zone-graph-' + i];
  35219. if (graph && zoneGraph) {
  35220. zoneGraph.clip(clips[i]);
  35221. }
  35222. if (area && zoneArea) {
  35223. zoneArea.clip(clips[i]);
  35224. }
  35225. // if this zone extends out of the axis, ignore the others
  35226. ignoreZones = threshold.value > extremes.max;
  35227. // Clear translatedTo for indicators
  35228. if (series.resetZones && translatedTo === 0) {
  35229. translatedTo = void 0;
  35230. }
  35231. });
  35232. this.clips = clips;
  35233. }
  35234. else if (series.visible) {
  35235. // If zones were removed, restore graph and area
  35236. if (graph) {
  35237. graph.show(true);
  35238. }
  35239. if (area) {
  35240. area.show(true);
  35241. }
  35242. }
  35243. },
  35244. /**
  35245. * Initialize and perform group inversion on series.group and
  35246. * series.markerGroup.
  35247. *
  35248. * @private
  35249. * @function Highcharts.Series#invertGroups
  35250. * @param {boolean} [inverted]
  35251. * @return {void}
  35252. */
  35253. invertGroups: function (inverted) {
  35254. var series = this,
  35255. chart = series.chart;
  35256. /**
  35257. * @private
  35258. */
  35259. function setInvert() {
  35260. ['group', 'markerGroup'].forEach(function (groupName) {
  35261. if (series[groupName]) {
  35262. // VML/HTML needs explicit attributes for flipping
  35263. if (chart.renderer.isVML) {
  35264. series[groupName].attr({
  35265. width: series.yAxis.len,
  35266. height: series.xAxis.len
  35267. });
  35268. }
  35269. series[groupName].width = series.yAxis.len;
  35270. series[groupName].height = series.xAxis.len;
  35271. // If inverted polar, don't invert series group
  35272. series[groupName].invert(series.isRadialSeries ? false : inverted);
  35273. }
  35274. });
  35275. }
  35276. // Pie, go away (#1736)
  35277. if (!series.xAxis) {
  35278. return;
  35279. }
  35280. // A fixed size is needed for inversion to work
  35281. series.eventsToUnbind.push(addEvent(chart, 'resize', setInvert));
  35282. // Do it now
  35283. setInvert();
  35284. // On subsequent render and redraw, just do setInvert without
  35285. // setting up events again
  35286. series.invertGroups = setInvert;
  35287. },
  35288. /**
  35289. * General abstraction for creating plot groups like series.group,
  35290. * series.dataLabelsGroup and series.markerGroup. On subsequent calls,
  35291. * the group will only be adjusted to the updated plot size.
  35292. *
  35293. * @private
  35294. * @function Highcharts.Series#plotGroup
  35295. * @param {string} prop
  35296. * @param {string} name
  35297. * @param {string} visibility
  35298. * @param {number} [zIndex]
  35299. * @param {Highcharts.SVGElement} [parent]
  35300. * @return {Highcharts.SVGElement}
  35301. */
  35302. plotGroup: function (prop, name, visibility, zIndex, parent) {
  35303. var group = this[prop],
  35304. isNew = !group,
  35305. attrs = {
  35306. visibility: visibility,
  35307. zIndex: zIndex || 0.1 // IE8 and pointer logic use this
  35308. };
  35309. // Avoid setting undefined opacity, or in styled mode
  35310. if (typeof this.opacity !== 'undefined' &&
  35311. !this.chart.styledMode && this.state !== 'inactive' // #13719
  35312. ) {
  35313. attrs.opacity = this.opacity;
  35314. }
  35315. // Generate it on first call
  35316. if (isNew) {
  35317. this[prop] = group = this.chart.renderer
  35318. .g()
  35319. .add(parent);
  35320. }
  35321. // Add the class names, and replace existing ones as response to
  35322. // Series.update (#6660)
  35323. group.addClass(('highcharts-' + name +
  35324. ' highcharts-series-' + this.index +
  35325. ' highcharts-' + this.type + '-series ' +
  35326. (defined(this.colorIndex) ?
  35327. 'highcharts-color-' + this.colorIndex + ' ' :
  35328. '') +
  35329. (this.options.className || '') +
  35330. (group.hasClass('highcharts-tracker') ?
  35331. ' highcharts-tracker' :
  35332. '')), true);
  35333. // Place it on first and subsequent (redraw) calls
  35334. group.attr(attrs)[isNew ? 'attr' : 'animate'](this.getPlotBox());
  35335. return group;
  35336. },
  35337. /**
  35338. * Get the translation and scale for the plot area of this series.
  35339. *
  35340. * @function Highcharts.Series#getPlotBox
  35341. *
  35342. * @return {Highcharts.SeriesPlotBoxObject}
  35343. */
  35344. getPlotBox: function () {
  35345. var chart = this.chart,
  35346. xAxis = this.xAxis,
  35347. yAxis = this.yAxis;
  35348. // Swap axes for inverted (#2339)
  35349. if (chart.inverted) {
  35350. xAxis = yAxis;
  35351. yAxis = this.xAxis;
  35352. }
  35353. return {
  35354. translateX: xAxis ? xAxis.left : chart.plotLeft,
  35355. translateY: yAxis ? yAxis.top : chart.plotTop,
  35356. scaleX: 1,
  35357. scaleY: 1
  35358. };
  35359. },
  35360. /**
  35361. * Removes the event handlers attached previously with addEvents.
  35362. *
  35363. * @private
  35364. * @function Highcharts.Series#removeEvents
  35365. * @param {boolean} [keepEventsForUpdate]
  35366. * @return {void}
  35367. */
  35368. removeEvents: function (keepEventsForUpdate) {
  35369. var series = this;
  35370. if (!keepEventsForUpdate) {
  35371. // remove all events
  35372. removeEvent(series);
  35373. }
  35374. else if (series.eventsToUnbind.length) {
  35375. // remove only internal events for proper update
  35376. // #12355 - solves problem with multiple destroy events
  35377. series.eventsToUnbind.forEach(function (unbind) {
  35378. unbind();
  35379. });
  35380. series.eventsToUnbind.length = 0;
  35381. }
  35382. },
  35383. /**
  35384. * Render the graph and markers. Called internally when first rendering
  35385. * and later when redrawing the chart. This function can be extended in
  35386. * plugins, but normally shouldn't be called directly.
  35387. *
  35388. * @function Highcharts.Series#render
  35389. *
  35390. * @return {void}
  35391. *
  35392. * @fires Highcharts.Series#event:afterRender
  35393. */
  35394. render: function () {
  35395. var series = this,
  35396. chart = series.chart,
  35397. group,
  35398. options = series.options,
  35399. animOptions = animObject(options.animation),
  35400. // Animation doesn't work in IE8 quirks when the group div is
  35401. // hidden, and looks bad in other oldIE
  35402. animDuration = (!series.finishedAnimating &&
  35403. chart.renderer.isSVG &&
  35404. animOptions.duration),
  35405. visibility = series.visible ? 'inherit' : 'hidden', // #2597
  35406. zIndex = options.zIndex,
  35407. hasRendered = series.hasRendered,
  35408. chartSeriesGroup = chart.seriesGroup,
  35409. inverted = chart.inverted;
  35410. fireEvent(this, 'render');
  35411. // the group
  35412. group = series.plotGroup('group', 'series', visibility, zIndex, chartSeriesGroup);
  35413. series.markerGroup = series.plotGroup('markerGroup', 'markers', visibility, zIndex, chartSeriesGroup);
  35414. // initiate the animation
  35415. if (animDuration && series.animate) {
  35416. series.animate(true);
  35417. }
  35418. // SVGRenderer needs to know this before drawing elements (#1089,
  35419. // #1795)
  35420. group.inverted = series.isCartesian || series.invertable ?
  35421. inverted : false;
  35422. // Draw the graph if any
  35423. if (series.drawGraph) {
  35424. series.drawGraph();
  35425. series.applyZones();
  35426. }
  35427. // Draw the points
  35428. if (series.visible) {
  35429. series.drawPoints();
  35430. }
  35431. /* series.points.forEach(function (point) {
  35432. if (point.redraw) {
  35433. point.redraw();
  35434. }
  35435. }); */
  35436. // Draw the data labels
  35437. if (series.drawDataLabels) {
  35438. series.drawDataLabels();
  35439. }
  35440. // In pie charts, slices are added to the DOM, but actual rendering
  35441. // is postponed until labels reserved their space
  35442. if (series.redrawPoints) {
  35443. series.redrawPoints();
  35444. }
  35445. // draw the mouse tracking area
  35446. if (series.drawTracker &&
  35447. series.options.enableMouseTracking !== false) {
  35448. series.drawTracker();
  35449. }
  35450. // Handle inverted series and tracker groups
  35451. series.invertGroups(inverted);
  35452. // Initial clipping, must be defined after inverting groups for VML.
  35453. // Applies to columns etc. (#3839).
  35454. if (options.clip !== false &&
  35455. !series.sharedClipKey &&
  35456. !hasRendered) {
  35457. group.clip(chart.clipRect);
  35458. }
  35459. // Run the animation
  35460. if (animDuration && series.animate) {
  35461. series.animate();
  35462. }
  35463. // Call the afterAnimate function on animation complete (but don't
  35464. // overwrite the animation.complete option which should be available
  35465. // to the user).
  35466. if (!hasRendered) {
  35467. // Additional time if defer is defined before afterAnimate
  35468. // will be triggered
  35469. if (animDuration && animOptions.defer) {
  35470. animDuration += animOptions.defer;
  35471. }
  35472. series.animationTimeout = syncTimeout(function () {
  35473. series.afterAnimate();
  35474. }, animDuration || 0);
  35475. }
  35476. // Means data is in accordance with what you see
  35477. series.isDirty = false;
  35478. // (See #322) series.isDirty = series.isDirtyData = false; // means
  35479. // data is in accordance with what you see
  35480. series.hasRendered = true;
  35481. fireEvent(series, 'afterRender');
  35482. },
  35483. /**
  35484. * Redraw the series. This function is called internally from
  35485. * `chart.redraw` and normally shouldn't be called directly.
  35486. *
  35487. * @private
  35488. * @function Highcharts.Series#redraw
  35489. * @return {void}
  35490. */
  35491. redraw: function () {
  35492. var series = this,
  35493. chart = series.chart,
  35494. // cache it here as it is set to false in render, but used after
  35495. wasDirty = series.isDirty || series.isDirtyData,
  35496. group = series.group,
  35497. xAxis = series.xAxis,
  35498. yAxis = series.yAxis;
  35499. // reposition on resize
  35500. if (group) {
  35501. if (chart.inverted) {
  35502. group.attr({
  35503. width: chart.plotWidth,
  35504. height: chart.plotHeight
  35505. });
  35506. }
  35507. group.animate({
  35508. translateX: pick(xAxis && xAxis.left, chart.plotLeft),
  35509. translateY: pick(yAxis && yAxis.top, chart.plotTop)
  35510. });
  35511. }
  35512. series.translate();
  35513. series.render();
  35514. if (wasDirty) { // #3868, #3945
  35515. delete this.kdTree;
  35516. }
  35517. },
  35518. kdAxisArray: ['clientX', 'plotY'],
  35519. /**
  35520. * @private
  35521. * @function Highcharts.Series#searchPoint
  35522. * @param {Highcharts.PointerEventObject} e
  35523. * @param {boolean} [compareX]
  35524. * @return {Highcharts.Point}
  35525. */
  35526. searchPoint: function (e, compareX) {
  35527. var series = this,
  35528. xAxis = series.xAxis,
  35529. yAxis = series.yAxis,
  35530. inverted = series.chart.inverted;
  35531. return this.searchKDTree({
  35532. clientX: inverted ?
  35533. xAxis.len - e.chartY + xAxis.pos :
  35534. e.chartX - xAxis.pos,
  35535. plotY: inverted ?
  35536. yAxis.len - e.chartX + yAxis.pos :
  35537. e.chartY - yAxis.pos
  35538. }, compareX, e);
  35539. },
  35540. /**
  35541. * Build the k-d-tree that is used by mouse and touch interaction to get
  35542. * the closest point. Line-like series typically have a one-dimensional
  35543. * tree where points are searched along the X axis, while scatter-like
  35544. * series typically search in two dimensions, X and Y.
  35545. *
  35546. * @private
  35547. * @function Highcharts.Series#buildKDTree
  35548. * @param {Highcharts.PointerEventObject} [e]
  35549. * @return {void}
  35550. */
  35551. buildKDTree: function (e) {
  35552. // Prevent multiple k-d-trees from being built simultaneously
  35553. // (#6235)
  35554. this.buildingKdTree = true;
  35555. var series = this,
  35556. dimensions = series.options.findNearestPointBy
  35557. .indexOf('y') > -1 ? 2 : 1;
  35558. /**
  35559. * Internal function
  35560. * @private
  35561. */
  35562. function _kdtree(points, depth, dimensions) {
  35563. var axis,
  35564. median,
  35565. length = points && points.length;
  35566. if (length) {
  35567. // alternate between the axis
  35568. axis = series.kdAxisArray[depth % dimensions];
  35569. // sort point array
  35570. points.sort(function (a, b) {
  35571. return a[axis] - b[axis];
  35572. });
  35573. median = Math.floor(length / 2);
  35574. // build and return nod
  35575. return {
  35576. point: points[median],
  35577. left: _kdtree(points.slice(0, median), depth + 1, dimensions),
  35578. right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
  35579. };
  35580. }
  35581. }
  35582. /**
  35583. * Start the recursive build process with a clone of the points
  35584. * array and null points filtered out. (#3873)
  35585. * @private
  35586. */
  35587. function startRecursive() {
  35588. series.kdTree = _kdtree(series.getValidPoints(null,
  35589. // For line-type series restrict to plot area, but
  35590. // column-type series not (#3916, #4511)
  35591. !series.directTouch), dimensions, dimensions);
  35592. series.buildingKdTree = false;
  35593. }
  35594. delete series.kdTree;
  35595. // For testing tooltips, don't build async. Also if touchstart, we
  35596. // may be dealing with click events on mobile, so don't delay
  35597. // (#6817).
  35598. syncTimeout(startRecursive, series.options.kdNow || (e && e.type === 'touchstart') ? 0 : 1);
  35599. },
  35600. /**
  35601. * @private
  35602. * @function Highcharts.Series#searchKDTree
  35603. * @param {Highcharts.KDPointSearchObject} point
  35604. * @param {boolean} [compareX]
  35605. * @param {Highcharts.PointerEventObject} [e]
  35606. * @return {Highcharts.Point|undefined}
  35607. */
  35608. searchKDTree: function (point, compareX, e) {
  35609. var series = this,
  35610. kdX = this.kdAxisArray[0],
  35611. kdY = this.kdAxisArray[1],
  35612. kdComparer = compareX ? 'distX' : 'dist',
  35613. kdDimensions = series.options.findNearestPointBy
  35614. .indexOf('y') > -1 ? 2 : 1;
  35615. /**
  35616. * Set the one and two dimensional distance on the point object.
  35617. * @private
  35618. */
  35619. function setDistance(p1, p2) {
  35620. var x = (defined(p1[kdX]) &&
  35621. defined(p2[kdX])) ?
  35622. Math.pow(p1[kdX] - p2[kdX], 2) :
  35623. null,
  35624. y = (defined(p1[kdY]) &&
  35625. defined(p2[kdY])) ?
  35626. Math.pow(p1[kdY] - p2[kdY], 2) :
  35627. null,
  35628. r = (x || 0) + (y || 0);
  35629. p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
  35630. p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
  35631. }
  35632. /**
  35633. * @private
  35634. */
  35635. function _search(search, tree, depth, dimensions) {
  35636. var point = tree.point,
  35637. axis = series.kdAxisArray[depth % dimensions],
  35638. tdist,
  35639. sideA,
  35640. sideB,
  35641. ret = point,
  35642. nPoint1,
  35643. nPoint2;
  35644. setDistance(search, point);
  35645. // Pick side based on distance to splitting point
  35646. tdist = search[axis] - point[axis];
  35647. sideA = tdist < 0 ? 'left' : 'right';
  35648. sideB = tdist < 0 ? 'right' : 'left';
  35649. // End of tree
  35650. if (tree[sideA]) {
  35651. nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
  35652. ret = (nPoint1[kdComparer] <
  35653. ret[kdComparer] ?
  35654. nPoint1 :
  35655. point);
  35656. }
  35657. if (tree[sideB]) {
  35658. // compare distance to current best to splitting point to
  35659. // decide wether to check side B or not
  35660. if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
  35661. nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
  35662. ret = (nPoint2[kdComparer] <
  35663. ret[kdComparer] ?
  35664. nPoint2 :
  35665. ret);
  35666. }
  35667. }
  35668. return ret;
  35669. }
  35670. if (!this.kdTree && !this.buildingKdTree) {
  35671. this.buildKDTree(e);
  35672. }
  35673. if (this.kdTree) {
  35674. return _search(point, this.kdTree, kdDimensions, kdDimensions);
  35675. }
  35676. },
  35677. /**
  35678. * @private
  35679. * @function Highcharts.Series#pointPlacementToXValue
  35680. * @return {number}
  35681. */
  35682. pointPlacementToXValue: function () {
  35683. var _a = this,
  35684. _b = _a.options,
  35685. pointPlacement = _b.pointPlacement,
  35686. pointRange = _b.pointRange,
  35687. axis = _a.xAxis;
  35688. var factor = pointPlacement;
  35689. // Point placement is relative to each series pointRange (#5889)
  35690. if (factor === 'between') {
  35691. factor = axis.reversed ? -0.5 : 0.5; // #11955
  35692. }
  35693. return isNumber(factor) ?
  35694. factor * pick(pointRange, axis.pointRange) :
  35695. 0;
  35696. },
  35697. /**
  35698. * @private
  35699. * @function Highcharts.Series#isPointInside
  35700. * @param {Highcharts.Point} point
  35701. * @return {boolean}
  35702. */
  35703. isPointInside: function (point) {
  35704. var isInside = typeof point.plotY !== 'undefined' &&
  35705. typeof point.plotX !== 'undefined' &&
  35706. point.plotY >= 0 &&
  35707. point.plotY <= this.yAxis.len && // #3519
  35708. point.plotX >= 0 &&
  35709. point.plotX <= this.xAxis.len;
  35710. return isInside;
  35711. }
  35712. }); // end Series prototype
  35713. /**
  35714. * A line series displays information as a series of data points connected by
  35715. * straight line segments.
  35716. *
  35717. * @sample {highcharts} highcharts/demo/line-basic/
  35718. * Line chart
  35719. * @sample {highstock} stock/demo/basic-line/
  35720. * Line chart
  35721. *
  35722. * @extends plotOptions.series
  35723. * @product highcharts highstock
  35724. * @apioption plotOptions.line
  35725. */
  35726. /**
  35727. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  35728. * of a line graph. Round means that lines are rounded in the ends and
  35729. * bends.
  35730. *
  35731. * @type {Highcharts.SeriesLinecapValue}
  35732. * @default round
  35733. * @since 3.0.7
  35734. * @apioption plotOptions.line.linecap
  35735. */
  35736. /**
  35737. * A `line` series. If the [type](#series.line.type) option is not
  35738. * specified, it is inherited from [chart.type](#chart.type).
  35739. *
  35740. * @extends series,plotOptions.line
  35741. * @excluding dataParser,dataURL
  35742. * @product highcharts highstock
  35743. * @apioption series.line
  35744. */
  35745. /**
  35746. * An array of data points for the series. For the `line` series type,
  35747. * points can be given in the following ways:
  35748. *
  35749. * 1. An array of numerical values. In this case, the numerical values will be
  35750. * interpreted as `y` options. The `x` values will be automatically
  35751. * calculated, either starting at 0 and incremented by 1, or from
  35752. * `pointStart` and `pointInterval` given in the series options. If the axis
  35753. * has categories, these will be used. Example:
  35754. * ```js
  35755. * data: [0, 5, 3, 5]
  35756. * ```
  35757. *
  35758. * 2. An array of arrays with 2 values. In this case, the values correspond to
  35759. * `x,y`. If the first value is a string, it is applied as the name of the
  35760. * point, and the `x` value is inferred.
  35761. * ```js
  35762. * data: [
  35763. * [0, 1],
  35764. * [1, 2],
  35765. * [2, 8]
  35766. * ]
  35767. * ```
  35768. *
  35769. * 3. An array of objects with named values. The following snippet shows only a
  35770. * few settings, see the complete options set below. If the total number of
  35771. * data points exceeds the series'
  35772. * [turboThreshold](#series.line.turboThreshold),
  35773. * this option is not available.
  35774. * ```js
  35775. * data: [{
  35776. * x: 1,
  35777. * y: 9,
  35778. * name: "Point2",
  35779. * color: "#00FF00"
  35780. * }, {
  35781. * x: 1,
  35782. * y: 6,
  35783. * name: "Point1",
  35784. * color: "#FF00FF"
  35785. * }]
  35786. * ```
  35787. *
  35788. * **Note:** In TypeScript you have to extend `PointOptionsObject` with an
  35789. * additional declaration to allow custom data types:
  35790. * ```ts
  35791. * declare module `highcharts` {
  35792. * interface PointOptionsObject {
  35793. * custom: Record<string, (boolean|number|string)>;
  35794. * }
  35795. * }
  35796. * ```
  35797. *
  35798. * @sample {highcharts} highcharts/chart/reflow-true/
  35799. * Numerical values
  35800. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  35801. * Arrays of numeric x and y
  35802. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  35803. * Arrays of datetime x and y
  35804. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  35805. * Arrays of point.name and y
  35806. * @sample {highcharts} highcharts/series/data-array-of-objects/
  35807. * Config objects
  35808. *
  35809. * @declare Highcharts.PointOptionsObject
  35810. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  35811. * @apioption series.line.data
  35812. */
  35813. /**
  35814. * An additional, individual class name for the data point's graphic
  35815. * representation.
  35816. *
  35817. * @type {string}
  35818. * @since 5.0.0
  35819. * @product highcharts gantt
  35820. * @apioption series.line.data.className
  35821. */
  35822. /**
  35823. * Individual color for the point. By default the color is pulled from
  35824. * the global `colors` array.
  35825. *
  35826. * In styled mode, the `color` option doesn't take effect. Instead, use
  35827. * `colorIndex`.
  35828. *
  35829. * @sample {highcharts} highcharts/point/color/
  35830. * Mark the highest point
  35831. *
  35832. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  35833. * @product highcharts highstock gantt
  35834. * @apioption series.line.data.color
  35835. */
  35836. /**
  35837. * A specific color index to use for the point, so its graphic representations
  35838. * are given the class name `highcharts-color-{n}`. In styled mode this will
  35839. * change the color of the graphic. In non-styled mode, the color by is set by
  35840. * the `fill` attribute, so the change in class name won't have a visual effect
  35841. * by default.
  35842. *
  35843. * @type {number}
  35844. * @since 5.0.0
  35845. * @product highcharts gantt
  35846. * @apioption series.line.data.colorIndex
  35847. */
  35848. /**
  35849. * A reserved subspace to store options and values for customized functionality.
  35850. * Here you can add additional data for your own event callbacks and formatter
  35851. * callbacks.
  35852. *
  35853. * @sample {highcharts} highcharts/point/custom/
  35854. * Point and series with custom data
  35855. *
  35856. * @type {Highcharts.Dictionary<*>}
  35857. * @apioption series.line.data.custom
  35858. */
  35859. /**
  35860. * Individual data label for each point. The options are the same as
  35861. * the ones for [plotOptions.series.dataLabels](
  35862. * #plotOptions.series.dataLabels).
  35863. *
  35864. * @sample highcharts/point/datalabels/
  35865. * Show a label for the last value
  35866. *
  35867. * @declare Highcharts.DataLabelsOptions
  35868. * @extends plotOptions.line.dataLabels
  35869. * @product highcharts highstock gantt
  35870. * @apioption series.line.data.dataLabels
  35871. */
  35872. /**
  35873. * A description of the point to add to the screen reader information
  35874. * about the point.
  35875. *
  35876. * @type {string}
  35877. * @since 5.0.0
  35878. * @requires modules/accessibility
  35879. * @apioption series.line.data.description
  35880. */
  35881. /**
  35882. * An id for the point. This can be used after render time to get a
  35883. * pointer to the point object through `chart.get()`.
  35884. *
  35885. * @sample {highcharts} highcharts/point/id/
  35886. * Remove an id'd point
  35887. *
  35888. * @type {string}
  35889. * @since 1.2.0
  35890. * @product highcharts highstock gantt
  35891. * @apioption series.line.data.id
  35892. */
  35893. /**
  35894. * The rank for this point's data label in case of collision. If two
  35895. * data labels are about to overlap, only the one with the highest `labelrank`
  35896. * will be drawn.
  35897. *
  35898. * @type {number}
  35899. * @apioption series.line.data.labelrank
  35900. */
  35901. /**
  35902. * The name of the point as shown in the legend, tooltip, dataLabels, etc.
  35903. *
  35904. * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
  35905. *
  35906. * @sample {highcharts} highcharts/series/data-array-of-objects/
  35907. * Point names
  35908. *
  35909. * @type {string}
  35910. * @apioption series.line.data.name
  35911. */
  35912. /**
  35913. * Whether the data point is selected initially.
  35914. *
  35915. * @type {boolean}
  35916. * @default false
  35917. * @product highcharts highstock gantt
  35918. * @apioption series.line.data.selected
  35919. */
  35920. /**
  35921. * The x value of the point. For datetime axes, the X value is the timestamp
  35922. * in milliseconds since 1970.
  35923. *
  35924. * @type {number}
  35925. * @product highcharts highstock
  35926. * @apioption series.line.data.x
  35927. */
  35928. /**
  35929. * The y value of the point.
  35930. *
  35931. * @type {number|null}
  35932. * @product highcharts highstock
  35933. * @apioption series.line.data.y
  35934. */
  35935. /**
  35936. * The individual point events.
  35937. *
  35938. * @extends plotOptions.series.point.events
  35939. * @product highcharts highstock gantt
  35940. * @apioption series.line.data.events
  35941. */
  35942. /**
  35943. * Options for the point markers of line-like series.
  35944. *
  35945. * @declare Highcharts.PointMarkerOptionsObject
  35946. * @extends plotOptions.series.marker
  35947. * @product highcharts highstock
  35948. * @apioption series.line.data.marker
  35949. */
  35950. ''; // include precedent doclets in transpilat
  35951. });
  35952. _registerModule(_modules, 'Extensions/Stacking.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Axis/StackingAxis.js'], _modules['Core/Utilities.js']], function (Axis, Chart, H, StackingAxis, U) {
  35953. /* *
  35954. *
  35955. * (c) 2010-2020 Torstein Honsi
  35956. *
  35957. * License: www.highcharts.com/license
  35958. *
  35959. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  35960. *
  35961. * */
  35962. var correctFloat = U.correctFloat,
  35963. defined = U.defined,
  35964. destroyObjectProperties = U.destroyObjectProperties,
  35965. format = U.format,
  35966. isNumber = U.isNumber,
  35967. pick = U.pick;
  35968. /**
  35969. * Stack of data points
  35970. *
  35971. * @product highcharts
  35972. *
  35973. * @interface Highcharts.StackItemObject
  35974. */ /**
  35975. * Alignment settings
  35976. * @name Highcharts.StackItemObject#alignOptions
  35977. * @type {Highcharts.AlignObject}
  35978. */ /**
  35979. * Related axis
  35980. * @name Highcharts.StackItemObject#axis
  35981. * @type {Highcharts.Axis}
  35982. */ /**
  35983. * Cumulative value of the stacked data points
  35984. * @name Highcharts.StackItemObject#cumulative
  35985. * @type {number}
  35986. */ /**
  35987. * True if on the negative side
  35988. * @name Highcharts.StackItemObject#isNegative
  35989. * @type {boolean}
  35990. */ /**
  35991. * Related SVG element
  35992. * @name Highcharts.StackItemObject#label
  35993. * @type {Highcharts.SVGElement}
  35994. */ /**
  35995. * Related stack options
  35996. * @name Highcharts.StackItemObject#options
  35997. * @type {Highcharts.YAxisStackLabelsOptions}
  35998. */ /**
  35999. * Total value of the stacked data points
  36000. * @name Highcharts.StackItemObject#total
  36001. * @type {number}
  36002. */ /**
  36003. * Shared x value of the stack
  36004. * @name Highcharts.StackItemObject#x
  36005. * @type {number}
  36006. */
  36007. ''; // detached doclets above
  36008. var Series = H.Series;
  36009. /* eslint-disable no-invalid-this, valid-jsdoc */
  36010. /**
  36011. * The class for stacks. Each stack, on a specific X value and either negative
  36012. * or positive, has its own stack item.
  36013. *
  36014. * @private
  36015. * @class
  36016. * @name Highcharts.StackItem
  36017. * @param {Highcharts.Axis} axis
  36018. * @param {Highcharts.YAxisStackLabelsOptions} options
  36019. * @param {boolean} isNegative
  36020. * @param {number} x
  36021. * @param {Highcharts.OptionsStackingValue} [stackOption]
  36022. */
  36023. var StackItem = /** @class */ (function () {
  36024. function StackItem(axis, options, isNegative, x, stackOption) {
  36025. var inverted = axis.chart.inverted;
  36026. this.axis = axis;
  36027. // Tells if the stack is negative
  36028. this.isNegative = isNegative;
  36029. // Save the options to be able to style the label
  36030. this.options = options = options || {};
  36031. // Save the x value to be able to position the label later
  36032. this.x = x;
  36033. // Initialize total value
  36034. this.total = null;
  36035. // This will keep each points' extremes stored by series.index and point
  36036. // index
  36037. this.points = {};
  36038. this.hasValidPoints = false;
  36039. // Save the stack option on the series configuration object,
  36040. // and whether to treat it as percent
  36041. this.stack = stackOption;
  36042. this.leftCliff = 0;
  36043. this.rightCliff = 0;
  36044. // The align options and text align varies on whether the stack is
  36045. // negative and if the chart is inverted or not.
  36046. // First test the user supplied value, then use the dynamic.
  36047. this.alignOptions = {
  36048. align: options.align ||
  36049. (inverted ? (isNegative ? 'left' : 'right') : 'center'),
  36050. verticalAlign: options.verticalAlign ||
  36051. (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
  36052. y: options.y,
  36053. x: options.x
  36054. };
  36055. this.textAlign = options.textAlign ||
  36056. (inverted ? (isNegative ? 'right' : 'left') : 'center');
  36057. }
  36058. /**
  36059. * @private
  36060. * @function Highcharts.StackItem#destroy
  36061. */
  36062. StackItem.prototype.destroy = function () {
  36063. destroyObjectProperties(this, this.axis);
  36064. };
  36065. /**
  36066. * Renders the stack total label and adds it to the stack label group.
  36067. *
  36068. * @private
  36069. * @function Highcharts.StackItem#render
  36070. * @param {Highcharts.SVGElement} group
  36071. */
  36072. StackItem.prototype.render = function (group) {
  36073. var chart = this.axis.chart,
  36074. options = this.options,
  36075. formatOption = options.format,
  36076. attr = {},
  36077. str = formatOption ? // format the text in the label
  36078. format(formatOption,
  36079. this,
  36080. chart) :
  36081. options.formatter.call(this);
  36082. // Change the text to reflect the new total and set visibility to hidden
  36083. // in case the serie is hidden
  36084. if (this.label) {
  36085. this.label.attr({ text: str, visibility: 'hidden' });
  36086. }
  36087. else {
  36088. // Create new label
  36089. this.label = chart.renderer
  36090. .label(str, null, null, options.shape, null, null, options.useHTML, false, 'stack-labels');
  36091. attr = {
  36092. r: options.borderRadius || 0,
  36093. text: str,
  36094. rotation: options.rotation,
  36095. padding: pick(options.padding, 5),
  36096. visibility: 'hidden' // hidden until setOffset is called
  36097. };
  36098. if (!chart.styledMode) {
  36099. attr.fill = options.backgroundColor;
  36100. attr.stroke = options.borderColor;
  36101. attr['stroke-width'] = options.borderWidth;
  36102. this.label.css(options.style);
  36103. }
  36104. this.label.attr(attr);
  36105. if (!this.label.added) {
  36106. this.label.add(group); // add to the labels-group
  36107. }
  36108. }
  36109. // Rank it higher than data labels (#8742)
  36110. this.label.labelrank = chart.plotHeight;
  36111. };
  36112. /**
  36113. * Sets the offset that the stack has from the x value and repositions the
  36114. * label.
  36115. *
  36116. * @private
  36117. * @function Highcarts.StackItem#setOffset
  36118. * @param {number} xOffset
  36119. * @param {number} xWidth
  36120. * @param {number} [boxBottom]
  36121. * @param {number} [boxTop]
  36122. * @param {number} [defaultX]
  36123. */
  36124. StackItem.prototype.setOffset = function (xOffset, xWidth, boxBottom, boxTop, defaultX) {
  36125. var stackItem = this,
  36126. axis = stackItem.axis,
  36127. chart = axis.chart,
  36128. // stack value translated mapped to chart coordinates
  36129. y = axis.translate(axis.stacking.usePercentage ?
  36130. 100 :
  36131. (boxTop ?
  36132. boxTop :
  36133. stackItem.total), 0, 0, 0, 1),
  36134. yZero = axis.translate(boxBottom ? boxBottom : 0), // stack origin
  36135. // stack height:
  36136. h = defined(y) && Math.abs(y - yZero),
  36137. // x position:
  36138. x = pick(defaultX,
  36139. chart.xAxis[0].translate(stackItem.x)) +
  36140. xOffset,
  36141. stackBox = defined(y) && stackItem.getStackBox(chart,
  36142. stackItem,
  36143. x,
  36144. y,
  36145. xWidth,
  36146. h,
  36147. axis),
  36148. label = stackItem.label,
  36149. isNegative = stackItem.isNegative,
  36150. isJustify = pick(stackItem.options.overflow, 'justify') === 'justify',
  36151. textAlign = stackItem.textAlign,
  36152. visible;
  36153. if (label && stackBox) {
  36154. var bBox = label.getBBox(),
  36155. padding = label.padding,
  36156. boxOffsetX,
  36157. boxOffsetY;
  36158. if (textAlign === 'left') {
  36159. boxOffsetX = chart.inverted ? -padding : padding;
  36160. }
  36161. else if (textAlign === 'right') {
  36162. boxOffsetX = bBox.width;
  36163. }
  36164. else {
  36165. if (chart.inverted && textAlign === 'center') {
  36166. boxOffsetX = bBox.width / 2;
  36167. }
  36168. else {
  36169. boxOffsetX = chart.inverted ?
  36170. (isNegative ? bBox.width + padding : -padding) : bBox.width / 2;
  36171. }
  36172. }
  36173. boxOffsetY = chart.inverted ?
  36174. bBox.height / 2 : (isNegative ? -padding : bBox.height);
  36175. // Reset alignOptions property after justify #12337
  36176. stackItem.alignOptions.x = pick(stackItem.options.x, 0);
  36177. stackItem.alignOptions.y = pick(stackItem.options.y, 0);
  36178. // Set the stackBox position
  36179. stackBox.x -= boxOffsetX;
  36180. stackBox.y -= boxOffsetY;
  36181. // Align the label to the box
  36182. label.align(stackItem.alignOptions, null, stackBox);
  36183. // Check if label is inside the plotArea #12294
  36184. if (chart.isInsidePlot(label.alignAttr.x + boxOffsetX - stackItem.alignOptions.x, label.alignAttr.y + boxOffsetY - stackItem.alignOptions.y)) {
  36185. label.show();
  36186. }
  36187. else {
  36188. // Move label away to avoid the overlapping issues
  36189. label.alignAttr.y = -9999;
  36190. isJustify = false;
  36191. }
  36192. if (isJustify) {
  36193. // Justify stackLabel into the stackBox
  36194. Series.prototype.justifyDataLabel.call(this.axis, label, stackItem.alignOptions, label.alignAttr, bBox, stackBox);
  36195. }
  36196. label.attr({
  36197. x: label.alignAttr.x,
  36198. y: label.alignAttr.y
  36199. });
  36200. if (pick(!isJustify && stackItem.options.crop, true)) {
  36201. visible =
  36202. isNumber(label.x) &&
  36203. isNumber(label.y) &&
  36204. chart.isInsidePlot(label.x - padding + label.width, label.y) &&
  36205. chart.isInsidePlot(label.x + padding, label.y);
  36206. if (!visible) {
  36207. label.hide();
  36208. }
  36209. }
  36210. }
  36211. };
  36212. /**
  36213. * @private
  36214. * @function Highcharts.StackItem#getStackBox
  36215. *
  36216. * @param {Highcharts.Chart} chart
  36217. *
  36218. * @param {Highcharts.StackItem} stackItem
  36219. *
  36220. * @param {number} x
  36221. *
  36222. * @param {number} y
  36223. *
  36224. * @param {number} xWidth
  36225. *
  36226. * @param {number} h
  36227. *
  36228. * @param {Highcharts.Axis} axis
  36229. *
  36230. * @return {Highcharts.BBoxObject}
  36231. */
  36232. StackItem.prototype.getStackBox = function (chart, stackItem, x, y, xWidth, h, axis) {
  36233. var reversed = stackItem.axis.reversed,
  36234. inverted = chart.inverted,
  36235. axisPos = axis.height + axis.pos -
  36236. (inverted ? chart.plotLeft : chart.plotTop),
  36237. neg = (stackItem.isNegative && !reversed) ||
  36238. (!stackItem.isNegative && reversed); // #4056
  36239. return {
  36240. x: inverted ? (neg ? y - axis.right : y - h + axis.pos - chart.plotLeft) :
  36241. x + chart.xAxis[0].transB - chart.plotLeft,
  36242. y: inverted ?
  36243. axis.height - x - xWidth :
  36244. (neg ?
  36245. (axisPos - y - h) :
  36246. axisPos - y),
  36247. width: inverted ? h : xWidth,
  36248. height: inverted ? xWidth : h
  36249. };
  36250. };
  36251. return StackItem;
  36252. }());
  36253. /**
  36254. * Generate stacks for each series and calculate stacks total values
  36255. *
  36256. * @private
  36257. * @function Highcharts.Chart#getStacks
  36258. */
  36259. Chart.prototype.getStacks = function () {
  36260. var chart = this,
  36261. inverted = chart.inverted;
  36262. // reset stacks for each yAxis
  36263. chart.yAxis.forEach(function (axis) {
  36264. if (axis.stacking && axis.stacking.stacks && axis.hasVisibleSeries) {
  36265. axis.stacking.oldStacks = axis.stacking.stacks;
  36266. }
  36267. });
  36268. chart.series.forEach(function (series) {
  36269. var xAxisOptions = series.xAxis && series.xAxis.options || {};
  36270. if (series.options.stacking &&
  36271. (series.visible === true ||
  36272. chart.options.chart.ignoreHiddenSeries === false)) {
  36273. series.stackKey = [
  36274. series.type,
  36275. pick(series.options.stack, ''),
  36276. inverted ? xAxisOptions.top : xAxisOptions.left,
  36277. inverted ? xAxisOptions.height : xAxisOptions.width
  36278. ].join(',');
  36279. }
  36280. });
  36281. };
  36282. // Stacking methods defined on the Axis prototype
  36283. StackingAxis.compose(Axis);
  36284. // Stacking methods defined for Series prototype
  36285. /**
  36286. * Set grouped points in a stack-like object. When `centerInCategory` is true,
  36287. * and `stacking` is not enabled, we need a pseudo (horizontal) stack in order
  36288. * to handle grouping of points within the same category.
  36289. *
  36290. * @private
  36291. * @function Highcharts.Series#setStackedPoints
  36292. * @return {void}
  36293. */
  36294. Series.prototype.setGroupedPoints = function () {
  36295. if (this.options.centerInCategory &&
  36296. (this.is('column') || this.is('columnrange')) &&
  36297. // With stacking enabled, we already have stacks that we can compute
  36298. // from
  36299. !this.options.stacking &&
  36300. // With only one series, we don't need to consider centerInCategory
  36301. this.chart.series.length > 1) {
  36302. Series.prototype.setStackedPoints.call(this, 'group');
  36303. }
  36304. };
  36305. /**
  36306. * Adds series' points value to corresponding stack
  36307. *
  36308. * @private
  36309. * @function Highcharts.Series#setStackedPoints
  36310. */
  36311. Series.prototype.setStackedPoints = function (stackingParam) {
  36312. var stacking = stackingParam || this.options.stacking;
  36313. if (!stacking ||
  36314. (this.visible !== true &&
  36315. this.chart.options.chart.ignoreHiddenSeries !== false)) {
  36316. return;
  36317. }
  36318. 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;
  36319. yAxis.stacking.stacksTouched += 1;
  36320. // loop over the non-null y values and read them into a local array
  36321. for (i = 0; i < yDataLength; i++) {
  36322. x = xData[i];
  36323. y = yData[i];
  36324. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index);
  36325. pointKey = stackIndicator.key;
  36326. // Read stacked values into a stack based on the x value,
  36327. // the sign of y and the stack key. Stacking is also handled for null
  36328. // values (#739)
  36329. isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
  36330. key = isNegative ? negKey : stackKey;
  36331. // Create empty object for this stack if it doesn't exist yet
  36332. if (!stacks[key]) {
  36333. stacks[key] =
  36334. {};
  36335. }
  36336. // Initialize StackItem for this x
  36337. if (!stacks[key][x]) {
  36338. if (oldStacks[key] &&
  36339. oldStacks[key][x]) {
  36340. stacks[key][x] = oldStacks[key][x];
  36341. stacks[key][x].total = null;
  36342. }
  36343. else {
  36344. stacks[key][x] = new StackItem(yAxis, yAxis.options.stackLabels, isNegative, x, stackOption);
  36345. }
  36346. }
  36347. // If the StackItem doesn't exist, create it first
  36348. stack = stacks[key][x];
  36349. if (y !== null) {
  36350. stack.points[pointKey] = stack.points[series.index] =
  36351. [pick(stack.cumulative, stackThreshold)];
  36352. // Record the base of the stack
  36353. if (!defined(stack.cumulative)) {
  36354. stack.base = pointKey;
  36355. }
  36356. stack.touched = yAxis.stacking.stacksTouched;
  36357. // In area charts, if there are multiple points on the same X value,
  36358. // let the area fill the full span of those points
  36359. if (stackIndicator.index > 0 && series.singleStacks === false) {
  36360. stack.points[pointKey][0] =
  36361. stack.points[series.index + ',' + x + ',0'][0];
  36362. }
  36363. // When updating to null, reset the point stack (#7493)
  36364. }
  36365. else {
  36366. stack.points[pointKey] = stack.points[series.index] =
  36367. null;
  36368. }
  36369. // Add value to the stack total
  36370. if (stacking === 'percent') {
  36371. // Percent stacked column, totals are the same for the positive and
  36372. // negative stacks
  36373. other = isNegative ? stackKey : negKey;
  36374. if (negStacks && stacks[other] && stacks[other][x]) {
  36375. other = stacks[other][x];
  36376. stack.total = other.total =
  36377. Math.max(other.total, stack.total) +
  36378. Math.abs(y) ||
  36379. 0;
  36380. // Percent stacked areas
  36381. }
  36382. else {
  36383. stack.total =
  36384. correctFloat(stack.total + (Math.abs(y) || 0));
  36385. }
  36386. }
  36387. else if (stacking === 'group') {
  36388. // In this stack, the total is the number of valid points
  36389. if (y !== null) {
  36390. stack.total = (stack.total || 0) + 1;
  36391. }
  36392. }
  36393. else {
  36394. stack.total = correctFloat(stack.total + (y || 0));
  36395. }
  36396. if (stacking === 'group') {
  36397. // This point's index within the stack, pushed to stack.points[1]
  36398. stack.cumulative = (stack.total || 1) - 1;
  36399. }
  36400. else {
  36401. stack.cumulative =
  36402. pick(stack.cumulative, stackThreshold) + (y || 0);
  36403. }
  36404. if (y !== null) {
  36405. stack.points[pointKey].push(stack.cumulative);
  36406. stackedYData[i] = stack.cumulative;
  36407. stack.hasValidPoints = true;
  36408. }
  36409. }
  36410. if (stacking === 'percent') {
  36411. yAxis.stacking.usePercentage = true;
  36412. }
  36413. if (stacking !== 'group') {
  36414. this.stackedYData = stackedYData; // To be used in getExtremes
  36415. }
  36416. // Reset old stacks
  36417. yAxis.stacking.oldStacks = {};
  36418. };
  36419. /**
  36420. * Iterate over all stacks and compute the absolute values to percent
  36421. *
  36422. * @private
  36423. * @function Highcharts.Series#modifyStacks
  36424. */
  36425. Series.prototype.modifyStacks = function () {
  36426. var series = this,
  36427. yAxis = series.yAxis,
  36428. stackKey = series.stackKey,
  36429. stacks = yAxis.stacking.stacks,
  36430. processedXData = series.processedXData,
  36431. stackIndicator,
  36432. stacking = series.options.stacking;
  36433. if (series[stacking + 'Stacker']) { // Modifier function exists
  36434. [stackKey, '-' + stackKey].forEach(function (key) {
  36435. var i = processedXData.length,
  36436. x,
  36437. stack,
  36438. pointExtremes;
  36439. while (i--) {
  36440. x = processedXData[i];
  36441. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index, key);
  36442. stack = stacks[key] && stacks[key][x];
  36443. pointExtremes =
  36444. stack && stack.points[stackIndicator.key];
  36445. if (pointExtremes) {
  36446. series[stacking + 'Stacker'](pointExtremes, stack, i);
  36447. }
  36448. }
  36449. });
  36450. }
  36451. };
  36452. /**
  36453. * Modifier function for percent stacks. Blows up the stack to 100%.
  36454. *
  36455. * @private
  36456. * @function Highcharts.Series#percentStacker
  36457. * @param {Array<number>} pointExtremes
  36458. * @param {Highcharts.StackItem} stack
  36459. * @param {number} i
  36460. */
  36461. Series.prototype.percentStacker = function (pointExtremes, stack, i) {
  36462. var totalFactor = stack.total ? 100 / stack.total : 0;
  36463. // Y bottom value
  36464. pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
  36465. // Y value
  36466. pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
  36467. this.stackedYData[i] = pointExtremes[1];
  36468. };
  36469. /**
  36470. * Get stack indicator, according to it's x-value, to determine points with the
  36471. * same x-value
  36472. *
  36473. * @private
  36474. * @function Highcharts.Series#getStackIndicator
  36475. * @param {Highcharts.StackItemIndicatorObject|undefined} stackIndicator
  36476. * @param {number} x
  36477. * @param {number} index
  36478. * @param {string} [key]
  36479. * @return {Highcharts.StackItemIndicatorObject}
  36480. */
  36481. Series.prototype.getStackIndicator = function (stackIndicator, x, index, key) {
  36482. // Update stack indicator, when:
  36483. // first point in a stack || x changed || stack type (negative vs positive)
  36484. // changed:
  36485. if (!defined(stackIndicator) ||
  36486. stackIndicator.x !== x ||
  36487. (key && stackIndicator.key !== key)) {
  36488. stackIndicator = {
  36489. x: x,
  36490. index: 0,
  36491. key: key
  36492. };
  36493. }
  36494. else {
  36495. (stackIndicator).index++;
  36496. }
  36497. stackIndicator.key =
  36498. [index, x, stackIndicator.index].join(',');
  36499. return stackIndicator;
  36500. };
  36501. H.StackItem = StackItem;
  36502. return H.StackItem;
  36503. });
  36504. _registerModule(_modules, 'Core/Dynamics.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (Axis, Chart, H, O, Point, Time, U) {
  36505. /* *
  36506. *
  36507. * (c) 2010-2020 Torstein Honsi
  36508. *
  36509. * License: www.highcharts.com/license
  36510. *
  36511. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  36512. *
  36513. * */
  36514. var time = O.time;
  36515. var addEvent = U.addEvent,
  36516. animate = U.animate,
  36517. createElement = U.createElement,
  36518. css = U.css,
  36519. defined = U.defined,
  36520. erase = U.erase,
  36521. error = U.error,
  36522. extend = U.extend,
  36523. fireEvent = U.fireEvent,
  36524. isArray = U.isArray,
  36525. isNumber = U.isNumber,
  36526. isObject = U.isObject,
  36527. isString = U.isString,
  36528. merge = U.merge,
  36529. objectEach = U.objectEach,
  36530. pick = U.pick,
  36531. relativeLength = U.relativeLength,
  36532. setAnimation = U.setAnimation,
  36533. splat = U.splat;
  36534. var Series = H.Series,
  36535. seriesTypes = H.seriesTypes;
  36536. /* eslint-disable valid-jsdoc */
  36537. /**
  36538. * Remove settings that have not changed, to avoid unnecessary rendering or
  36539. * computing (#9197).
  36540. * @private
  36541. */
  36542. H.cleanRecursively = function (newer, older) {
  36543. var result = {};
  36544. objectEach(newer, function (val, key) {
  36545. var ob;
  36546. // Dive into objects (except DOM nodes)
  36547. if (isObject(newer[key], true) &&
  36548. !newer.nodeType && // #10044
  36549. older[key]) {
  36550. ob = H.cleanRecursively(newer[key], older[key]);
  36551. if (Object.keys(ob).length) {
  36552. result[key] = ob;
  36553. }
  36554. // Arrays, primitives and DOM nodes are copied directly
  36555. }
  36556. else if (isObject(newer[key]) ||
  36557. newer[key] !== older[key]) {
  36558. result[key] = newer[key];
  36559. }
  36560. });
  36561. return result;
  36562. };
  36563. // Extend the Chart prototype for dynamic methods
  36564. extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ {
  36565. /**
  36566. * Add a series to the chart after render time. Note that this method should
  36567. * never be used when adding data synchronously at chart render time, as it
  36568. * adds expense to the calculations and rendering. When adding data at the
  36569. * same time as the chart is initialized, add the series as a configuration
  36570. * option instead. With multiple axes, the `offset` is dynamically adjusted.
  36571. *
  36572. * @sample highcharts/members/chart-addseries/
  36573. * Add a series from a button
  36574. * @sample stock/members/chart-addseries/
  36575. * Add a series in Highstock
  36576. *
  36577. * @function Highcharts.Chart#addSeries
  36578. *
  36579. * @param {Highcharts.SeriesOptionsType} options
  36580. * The config options for the series.
  36581. *
  36582. * @param {boolean} [redraw=true]
  36583. * Whether to redraw the chart after adding.
  36584. *
  36585. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  36586. * Whether to apply animation, and optionally animation
  36587. * configuration.
  36588. *
  36589. * @return {Highcharts.Series}
  36590. * The newly created series object.
  36591. *
  36592. * @fires Highcharts.Chart#event:addSeries
  36593. * @fires Highcharts.Chart#event:afterAddSeries
  36594. */
  36595. addSeries: function (options, redraw, animation) {
  36596. var series,
  36597. chart = this;
  36598. if (options) { // <- not necessary
  36599. redraw = pick(redraw, true); // defaults to true
  36600. fireEvent(chart, 'addSeries', { options: options }, function () {
  36601. series = chart.initSeries(options);
  36602. chart.isDirtyLegend = true;
  36603. chart.linkSeries();
  36604. if (series.enabledDataSorting) {
  36605. // We need to call `setData` after `linkSeries`
  36606. series.setData(options.data, false);
  36607. }
  36608. fireEvent(chart, 'afterAddSeries', { series: series });
  36609. if (redraw) {
  36610. chart.redraw(animation);
  36611. }
  36612. });
  36613. }
  36614. return series;
  36615. },
  36616. /**
  36617. * Add an axis to the chart after render time. Note that this method should
  36618. * never be used when adding data synchronously at chart render time, as it
  36619. * adds expense to the calculations and rendering. When adding data at the
  36620. * same time as the chart is initialized, add the axis as a configuration
  36621. * option instead.
  36622. *
  36623. * @sample highcharts/members/chart-addaxis/
  36624. * Add and remove axes
  36625. *
  36626. * @function Highcharts.Chart#addAxis
  36627. *
  36628. * @param {Highcharts.AxisOptions} options
  36629. * The axis options.
  36630. *
  36631. * @param {boolean} [isX=false]
  36632. * Whether it is an X axis or a value axis.
  36633. *
  36634. * @param {boolean} [redraw=true]
  36635. * Whether to redraw the chart after adding.
  36636. *
  36637. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  36638. * Whether and how to apply animation in the redraw.
  36639. *
  36640. * @return {Highcharts.Axis}
  36641. * The newly generated Axis object.
  36642. */
  36643. addAxis: function (options, isX, redraw, animation) {
  36644. return this.createAxis(isX ? 'xAxis' : 'yAxis', { axis: options, redraw: redraw, animation: animation });
  36645. },
  36646. /**
  36647. * Add a color axis to the chart after render time. Note that this method
  36648. * should never be used when adding data synchronously at chart render time,
  36649. * as it adds expense to the calculations and rendering. When adding data at
  36650. * the same time as the chart is initialized, add the axis as a
  36651. * configuration option instead.
  36652. *
  36653. * @sample highcharts/members/chart-addaxis/
  36654. * Add and remove axes
  36655. *
  36656. * @function Highcharts.Chart#addColorAxis
  36657. *
  36658. * @param {Highcharts.ColorAxisOptions} options
  36659. * The axis options.
  36660. *
  36661. * @param {boolean} [redraw=true]
  36662. * Whether to redraw the chart after adding.
  36663. *
  36664. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  36665. * Whether and how to apply animation in the redraw.
  36666. *
  36667. * @return {Highcharts.ColorAxis}
  36668. * The newly generated Axis object.
  36669. */
  36670. addColorAxis: function (options, redraw, animation) {
  36671. return this.createAxis('colorAxis', { axis: options, redraw: redraw, animation: animation });
  36672. },
  36673. /**
  36674. * Factory for creating different axis types.
  36675. *
  36676. * @private
  36677. * @function Highcharts.Chart#createAxis
  36678. *
  36679. * @param {string} type
  36680. * An axis type.
  36681. *
  36682. * @param {...Array<*>} arguments
  36683. * All arguments for the constructor.
  36684. *
  36685. * @return {Highcharts.Axis | Highcharts.ColorAxis}
  36686. * The newly generated Axis object.
  36687. */
  36688. createAxis: function (type, options) {
  36689. var chartOptions = this.options,
  36690. isColorAxis = type === 'colorAxis',
  36691. axisOptions = options.axis,
  36692. redraw = options.redraw,
  36693. animation = options.animation,
  36694. userOptions = merge(axisOptions, {
  36695. index: this[type].length,
  36696. isX: type === 'xAxis'
  36697. }),
  36698. axis;
  36699. if (isColorAxis) {
  36700. axis = new H.ColorAxis(this, userOptions);
  36701. }
  36702. else {
  36703. axis = new Axis(this, userOptions);
  36704. }
  36705. // Push the new axis options to the chart options
  36706. chartOptions[type] = splat(chartOptions[type] || {});
  36707. chartOptions[type].push(userOptions);
  36708. if (isColorAxis) {
  36709. this.isDirtyLegend = true;
  36710. // Clear before 'bindAxes' (#11924)
  36711. this.axes.forEach(function (axis) {
  36712. axis.series = [];
  36713. });
  36714. this.series.forEach(function (series) {
  36715. series.bindAxes();
  36716. series.isDirtyData = true;
  36717. });
  36718. }
  36719. if (pick(redraw, true)) {
  36720. this.redraw(animation);
  36721. }
  36722. return axis;
  36723. },
  36724. /**
  36725. * Dim the chart and show a loading text or symbol. Options for the loading
  36726. * screen are defined in {@link
  36727. * https://api.highcharts.com/highcharts/loading|the loading options}.
  36728. *
  36729. * @sample highcharts/members/chart-hideloading/
  36730. * Show and hide loading from a button
  36731. * @sample highcharts/members/chart-showloading/
  36732. * Apply different text labels
  36733. * @sample stock/members/chart-show-hide-loading/
  36734. * Toggle loading in Highstock
  36735. *
  36736. * @function Highcharts.Chart#showLoading
  36737. *
  36738. * @param {string} [str]
  36739. * An optional text to show in the loading label instead of the
  36740. * default one. The default text is set in
  36741. * [lang.loading](https://api.highcharts.com/highcharts/lang.loading).
  36742. */
  36743. showLoading: function (str) {
  36744. var chart = this,
  36745. options = chart.options,
  36746. loadingDiv = chart.loadingDiv,
  36747. loadingOptions = options.loading,
  36748. setLoadingSize = function () {
  36749. if (loadingDiv) {
  36750. css(loadingDiv, {
  36751. left: chart.plotLeft + 'px',
  36752. top: chart.plotTop + 'px',
  36753. width: chart.plotWidth + 'px',
  36754. height: chart.plotHeight + 'px'
  36755. });
  36756. }
  36757. };
  36758. // create the layer at the first call
  36759. if (!loadingDiv) {
  36760. chart.loadingDiv = loadingDiv = createElement('div', {
  36761. className: 'highcharts-loading highcharts-loading-hidden'
  36762. }, null, chart.container);
  36763. chart.loadingSpan = createElement('span', { className: 'highcharts-loading-inner' }, null, loadingDiv);
  36764. addEvent(chart, 'redraw', setLoadingSize); // #1080
  36765. }
  36766. loadingDiv.className = 'highcharts-loading';
  36767. // Update text
  36768. chart.loadingSpan.innerHTML =
  36769. pick(str, options.lang.loading, '');
  36770. if (!chart.styledMode) {
  36771. // Update visuals
  36772. css(loadingDiv, extend(loadingOptions.style, {
  36773. zIndex: 10
  36774. }));
  36775. css(chart.loadingSpan, loadingOptions.labelStyle);
  36776. // Show it
  36777. if (!chart.loadingShown) {
  36778. css(loadingDiv, {
  36779. opacity: 0,
  36780. display: ''
  36781. });
  36782. animate(loadingDiv, {
  36783. opacity: loadingOptions.style.opacity || 0.5
  36784. }, {
  36785. duration: loadingOptions.showDuration || 0
  36786. });
  36787. }
  36788. }
  36789. chart.loadingShown = true;
  36790. setLoadingSize();
  36791. },
  36792. /**
  36793. * Hide the loading layer.
  36794. *
  36795. * @see Highcharts.Chart#showLoading
  36796. *
  36797. * @sample highcharts/members/chart-hideloading/
  36798. * Show and hide loading from a button
  36799. * @sample stock/members/chart-show-hide-loading/
  36800. * Toggle loading in Highstock
  36801. *
  36802. * @function Highcharts.Chart#hideLoading
  36803. */
  36804. hideLoading: function () {
  36805. var options = this.options,
  36806. loadingDiv = this.loadingDiv;
  36807. if (loadingDiv) {
  36808. loadingDiv.className =
  36809. 'highcharts-loading highcharts-loading-hidden';
  36810. if (!this.styledMode) {
  36811. animate(loadingDiv, {
  36812. opacity: 0
  36813. }, {
  36814. duration: options.loading.hideDuration || 100,
  36815. complete: function () {
  36816. css(loadingDiv, { display: 'none' });
  36817. }
  36818. });
  36819. }
  36820. }
  36821. this.loadingShown = false;
  36822. },
  36823. /**
  36824. * These properties cause isDirtyBox to be set to true when updating. Can be
  36825. * extended from plugins.
  36826. */
  36827. propsRequireDirtyBox: [
  36828. 'backgroundColor',
  36829. 'borderColor',
  36830. 'borderWidth',
  36831. 'borderRadius',
  36832. 'plotBackgroundColor',
  36833. 'plotBackgroundImage',
  36834. 'plotBorderColor',
  36835. 'plotBorderWidth',
  36836. 'plotShadow',
  36837. 'shadow'
  36838. ],
  36839. /**
  36840. * These properties require a full reflow of chart elements, best
  36841. * implemented through running `Chart.setSize` internally (#8190).
  36842. * @type {Array}
  36843. */
  36844. propsRequireReflow: [
  36845. 'margin',
  36846. 'marginTop',
  36847. 'marginRight',
  36848. 'marginBottom',
  36849. 'marginLeft',
  36850. 'spacing',
  36851. 'spacingTop',
  36852. 'spacingRight',
  36853. 'spacingBottom',
  36854. 'spacingLeft'
  36855. ],
  36856. /**
  36857. * These properties cause all series to be updated when updating. Can be
  36858. * extended from plugins.
  36859. */
  36860. propsRequireUpdateSeries: [
  36861. 'chart.inverted',
  36862. 'chart.polar',
  36863. 'chart.ignoreHiddenSeries',
  36864. 'chart.type',
  36865. 'colors',
  36866. 'plotOptions',
  36867. 'time',
  36868. 'tooltip'
  36869. ],
  36870. /**
  36871. * These collections (arrays) implement update() methods with support for
  36872. * one-to-one option.
  36873. */
  36874. collectionsWithUpdate: [
  36875. 'xAxis',
  36876. 'yAxis',
  36877. 'zAxis',
  36878. 'series'
  36879. ],
  36880. /**
  36881. * A generic function to update any element of the chart. Elements can be
  36882. * enabled and disabled, moved, re-styled, re-formatted etc.
  36883. *
  36884. * A special case is configuration objects that take arrays, for example
  36885. * [xAxis](https://api.highcharts.com/highcharts/xAxis),
  36886. * [yAxis](https://api.highcharts.com/highcharts/yAxis) or
  36887. * [series](https://api.highcharts.com/highcharts/series). For these
  36888. * collections, an `id` option is used to map the new option set to an
  36889. * existing object. If an existing object of the same id is not found, the
  36890. * corresponding item is updated. So for example, running `chart.update`
  36891. * with a series item without an id, will cause the existing chart's series
  36892. * with the same index in the series array to be updated. When the
  36893. * `oneToOne` parameter is true, `chart.update` will also take care of
  36894. * adding and removing items from the collection. Read more under the
  36895. * parameter description below.
  36896. *
  36897. * Note that when changing series data, `chart.update` may mutate the passed
  36898. * data options.
  36899. *
  36900. * See also the
  36901. * [responsive option set](https://api.highcharts.com/highcharts/responsive).
  36902. * Switching between `responsive.rules` basically runs `chart.update` under
  36903. * the hood.
  36904. *
  36905. * @sample highcharts/members/chart-update/
  36906. * Update chart geometry
  36907. *
  36908. * @function Highcharts.Chart#update
  36909. *
  36910. * @param {Highcharts.Options} options
  36911. * A configuration object for the new chart options.
  36912. *
  36913. * @param {boolean} [redraw=true]
  36914. * Whether to redraw the chart.
  36915. *
  36916. * @param {boolean} [oneToOne=false]
  36917. * When `true`, the `series`, `xAxis`, `yAxis` and `annotations`
  36918. * collections will be updated one to one, and items will be either
  36919. * added or removed to match the new updated options. For example,
  36920. * if the chart has two series and we call `chart.update` with a
  36921. * configuration containing three series, one will be added. If we
  36922. * call `chart.update` with one series, one will be removed. Setting
  36923. * an empty `series` array will remove all series, but leaving out
  36924. * the`series` property will leave all series untouched. If the
  36925. * series have id's, the new series options will be matched by id,
  36926. * and the remaining ones removed.
  36927. *
  36928. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  36929. * Whether to apply animation, and optionally animation
  36930. * configuration.
  36931. *
  36932. * @fires Highcharts.Chart#event:update
  36933. * @fires Highcharts.Chart#event:afterUpdate
  36934. */
  36935. update: function (options, redraw, oneToOne, animation) {
  36936. var chart = this,
  36937. adders = {
  36938. credits: 'addCredits',
  36939. title: 'setTitle',
  36940. subtitle: 'setSubtitle',
  36941. caption: 'setCaption'
  36942. },
  36943. optionsChart,
  36944. updateAllAxes,
  36945. updateAllSeries,
  36946. newWidth,
  36947. newHeight,
  36948. runSetSize,
  36949. isResponsiveOptions = options.isResponsiveOptions,
  36950. itemsForRemoval = [];
  36951. fireEvent(chart, 'update', { options: options });
  36952. // If there are responsive rules in action, undo the responsive rules
  36953. // before we apply the updated options and replay the responsive rules
  36954. // on top from the chart.redraw function (#9617).
  36955. if (!isResponsiveOptions) {
  36956. chart.setResponsive(false, true);
  36957. }
  36958. options = H.cleanRecursively(options, chart.options);
  36959. merge(true, chart.userOptions, options);
  36960. // If the top-level chart option is present, some special updates are
  36961. // required
  36962. optionsChart = options.chart;
  36963. if (optionsChart) {
  36964. merge(true, chart.options.chart, optionsChart);
  36965. // Setter function
  36966. if ('className' in optionsChart) {
  36967. chart.setClassName(optionsChart.className);
  36968. }
  36969. if ('reflow' in optionsChart) {
  36970. chart.setReflow(optionsChart.reflow);
  36971. }
  36972. if ('inverted' in optionsChart ||
  36973. 'polar' in optionsChart ||
  36974. 'type' in optionsChart) {
  36975. // Parse options.chart.inverted and options.chart.polar together
  36976. // with the available series.
  36977. chart.propFromSeries();
  36978. updateAllAxes = true;
  36979. }
  36980. if ('alignTicks' in optionsChart) { // #6452
  36981. updateAllAxes = true;
  36982. }
  36983. objectEach(optionsChart, function (val, key) {
  36984. if (chart.propsRequireUpdateSeries.indexOf('chart.' + key) !==
  36985. -1) {
  36986. updateAllSeries = true;
  36987. }
  36988. // Only dirty box
  36989. if (chart.propsRequireDirtyBox.indexOf(key) !== -1) {
  36990. chart.isDirtyBox = true;
  36991. }
  36992. // Chart setSize
  36993. if (chart.propsRequireReflow.indexOf(key) !== -1) {
  36994. if (isResponsiveOptions) {
  36995. chart.isDirtyBox = true;
  36996. }
  36997. else {
  36998. runSetSize = true;
  36999. }
  37000. }
  37001. });
  37002. if (!chart.styledMode && 'style' in optionsChart) {
  37003. chart.renderer.setStyle(optionsChart.style);
  37004. }
  37005. }
  37006. // Moved up, because tooltip needs updated plotOptions (#6218)
  37007. if (!chart.styledMode && options.colors) {
  37008. this.options.colors = options.colors;
  37009. }
  37010. if (options.plotOptions) {
  37011. merge(true, this.options.plotOptions, options.plotOptions);
  37012. }
  37013. // Maintaining legacy global time. If the chart is instanciated first
  37014. // with global time, then updated with time options, we need to create a
  37015. // new Time instance to avoid mutating the global time (#10536).
  37016. if (options.time && this.time === time) {
  37017. this.time = new Time(options.time);
  37018. }
  37019. // Some option stuctures correspond one-to-one to chart objects that
  37020. // have update methods, for example
  37021. // options.credits => chart.credits
  37022. // options.legend => chart.legend
  37023. // options.title => chart.title
  37024. // options.tooltip => chart.tooltip
  37025. // options.subtitle => chart.subtitle
  37026. // options.mapNavigation => chart.mapNavigation
  37027. // options.navigator => chart.navigator
  37028. // options.scrollbar => chart.scrollbar
  37029. objectEach(options, function (val, key) {
  37030. if (chart[key] &&
  37031. typeof chart[key].update === 'function') {
  37032. chart[key].update(val, false);
  37033. // If a one-to-one object does not exist, look for an adder function
  37034. }
  37035. else if (typeof chart[adders[key]] === 'function') {
  37036. chart[adders[key]](val);
  37037. }
  37038. if (key !== 'chart' &&
  37039. chart.propsRequireUpdateSeries.indexOf(key) !== -1) {
  37040. updateAllSeries = true;
  37041. }
  37042. });
  37043. // Setters for collections. For axes and series, each item is referred
  37044. // by an id. If the id is not found, it defaults to the corresponding
  37045. // item in the collection, so setting one series without an id, will
  37046. // update the first series in the chart. Setting two series without
  37047. // an id will update the first and the second respectively (#6019)
  37048. // chart.update and responsive.
  37049. this.collectionsWithUpdate.forEach(function (coll) {
  37050. var indexMap;
  37051. if (options[coll]) {
  37052. // In stock charts, the navigator series are also part of the
  37053. // chart.series array, but those series should not be handled
  37054. // here (#8196).
  37055. if (coll === 'series') {
  37056. indexMap = [];
  37057. chart[coll].forEach(function (s, i) {
  37058. if (!s.options.isInternal) {
  37059. indexMap.push(pick(s.options.index, i));
  37060. }
  37061. });
  37062. }
  37063. splat(options[coll]).forEach(function (newOptions, i) {
  37064. var hasId = defined(newOptions.id);
  37065. var item;
  37066. // Match by id
  37067. if (hasId) {
  37068. item = chart.get(newOptions.id);
  37069. }
  37070. // No match by id found, match by index instead
  37071. if (!item) {
  37072. item = chart[coll][indexMap ? indexMap[i] : i];
  37073. // Check if we grabbed an item with an exising but
  37074. // different id (#13541)
  37075. if (item && hasId && defined(item.options.id)) {
  37076. item = void 0;
  37077. }
  37078. }
  37079. if (item && item.coll === coll) {
  37080. item.update(newOptions, false);
  37081. if (oneToOne) {
  37082. item.touched = true;
  37083. }
  37084. }
  37085. // If oneToOne and no matching item is found, add one
  37086. if (!item && oneToOne && chart.collectionsWithInit[coll]) {
  37087. chart.collectionsWithInit[coll][0].apply(chart,
  37088. // [newOptions, ...extraArguments, redraw=false]
  37089. [
  37090. newOptions
  37091. ].concat(
  37092. // Not all initializers require extra args
  37093. chart.collectionsWithInit[coll][1] || []).concat([
  37094. false
  37095. ])).touched = true;
  37096. }
  37097. });
  37098. // Add items for removal
  37099. if (oneToOne) {
  37100. chart[coll].forEach(function (item) {
  37101. if (!item.touched && !item.options.isInternal) {
  37102. itemsForRemoval.push(item);
  37103. }
  37104. else {
  37105. delete item.touched;
  37106. }
  37107. });
  37108. }
  37109. }
  37110. });
  37111. itemsForRemoval.forEach(function (item) {
  37112. if (item.remove) {
  37113. item.remove(false);
  37114. }
  37115. });
  37116. if (updateAllAxes) {
  37117. chart.axes.forEach(function (axis) {
  37118. axis.update({}, false);
  37119. });
  37120. }
  37121. // Certain options require the whole series structure to be thrown away
  37122. // and rebuilt
  37123. if (updateAllSeries) {
  37124. chart.getSeriesOrderByLinks().forEach(function (series) {
  37125. // Avoid removed navigator series
  37126. if (series.chart) {
  37127. series.update({}, false);
  37128. }
  37129. }, this);
  37130. }
  37131. // For loading, just update the options, do not redraw
  37132. if (options.loading) {
  37133. merge(true, chart.options.loading, options.loading);
  37134. }
  37135. // Update size. Redraw is forced.
  37136. newWidth = optionsChart && optionsChart.width;
  37137. newHeight = optionsChart && optionsChart.height;
  37138. if (isString(newHeight)) {
  37139. newHeight = relativeLength(newHeight, newWidth || chart.chartWidth);
  37140. }
  37141. if (
  37142. // In this case, run chart.setSize with newWidth and newHeight which
  37143. // are undefined, only for reflowing chart elements because margin
  37144. // or spacing has been set (#8190)
  37145. runSetSize ||
  37146. // In this case, the size is actually set
  37147. (isNumber(newWidth) && newWidth !== chart.chartWidth) ||
  37148. (isNumber(newHeight) && newHeight !== chart.chartHeight)) {
  37149. chart.setSize(newWidth, newHeight, animation);
  37150. }
  37151. else if (pick(redraw, true)) {
  37152. chart.redraw(animation);
  37153. }
  37154. fireEvent(chart, 'afterUpdate', {
  37155. options: options,
  37156. redraw: redraw,
  37157. animation: animation
  37158. });
  37159. },
  37160. /**
  37161. * Shortcut to set the subtitle options. This can also be done from {@link
  37162. * Chart#update} or {@link Chart#setTitle}.
  37163. *
  37164. * @function Highcharts.Chart#setSubtitle
  37165. *
  37166. * @param {Highcharts.SubtitleOptions} options
  37167. * New subtitle options. The subtitle text itself is set by the
  37168. * `options.text` property.
  37169. */
  37170. setSubtitle: function (options, redraw) {
  37171. this.applyDescription('subtitle', options);
  37172. this.layOutTitles(redraw);
  37173. },
  37174. /**
  37175. * Set the caption options. This can also be done from {@link
  37176. * Chart#update}.
  37177. *
  37178. * @function Highcharts.Chart#setCaption
  37179. *
  37180. * @param {Highcharts.CaptionOptions} options
  37181. * New caption options. The caption text itself is set by the
  37182. * `options.text` property.
  37183. */
  37184. setCaption: function (options, redraw) {
  37185. this.applyDescription('caption', options);
  37186. this.layOutTitles(redraw);
  37187. }
  37188. });
  37189. /**
  37190. * These collections (arrays) implement `Chart.addSomethig` method used in
  37191. * chart.update() to create new object in the collection. Equivalent for
  37192. * deleting is resolved by simple `Somethig.remove()`.
  37193. *
  37194. * Note: We need to define these references after initializers are bound to
  37195. * chart's prototype.
  37196. */
  37197. Chart.prototype.collectionsWithInit = {
  37198. // collectionName: [ initializingMethod, [extraArguments] ]
  37199. xAxis: [Chart.prototype.addAxis, [true]],
  37200. yAxis: [Chart.prototype.addAxis, [false]],
  37201. series: [Chart.prototype.addSeries]
  37202. };
  37203. // extend the Point prototype for dynamic methods
  37204. extend(Point.prototype, /** @lends Highcharts.Point.prototype */ {
  37205. /**
  37206. * Update point with new options (typically x/y data) and optionally redraw
  37207. * the series.
  37208. *
  37209. * @sample highcharts/members/point-update-column/
  37210. * Update column value
  37211. * @sample highcharts/members/point-update-pie/
  37212. * Update pie slice
  37213. * @sample maps/members/point-update/
  37214. * Update map area value in Highmaps
  37215. *
  37216. * @function Highcharts.Point#update
  37217. *
  37218. * @param {Highcharts.PointOptionsType} options
  37219. * The point options. Point options are handled as described under
  37220. * the `series.type.data` item for each series type. For example
  37221. * for a line series, if options is a single number, the point will
  37222. * be given that number as the marin y value. If it is an array, it
  37223. * will be interpreted as x and y values respectively. If it is an
  37224. * object, advanced options are applied.
  37225. *
  37226. * @param {boolean} [redraw=true]
  37227. * Whether to redraw the chart after the point is updated. If doing
  37228. * more operations on the chart, it is best practice to set
  37229. * `redraw` to false and call `chart.redraw()` after.
  37230. *
  37231. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  37232. * Whether to apply animation, and optionally animation
  37233. * configuration.
  37234. *
  37235. * @return {void}
  37236. *
  37237. * @fires Highcharts.Point#event:update
  37238. */
  37239. update: function (options, redraw, animation, runEvent) {
  37240. var point = this,
  37241. series = point.series,
  37242. graphic = point.graphic,
  37243. i,
  37244. chart = series.chart,
  37245. seriesOptions = series.options;
  37246. redraw = pick(redraw, true);
  37247. /**
  37248. * @private
  37249. */
  37250. function update() {
  37251. point.applyOptions(options);
  37252. // Update visuals, #4146
  37253. // Handle dummy graphic elements for a11y, #12718
  37254. var hasDummyGraphic = graphic && point.hasDummyGraphic;
  37255. var shouldDestroyGraphic = point.y === null ? !hasDummyGraphic : hasDummyGraphic;
  37256. if (graphic && shouldDestroyGraphic) {
  37257. point.graphic = graphic.destroy();
  37258. delete point.hasDummyGraphic;
  37259. }
  37260. if (isObject(options, true)) {
  37261. // Destroy so we can get new elements
  37262. if (graphic && graphic.element) {
  37263. // "null" is also a valid symbol
  37264. if (options &&
  37265. options.marker &&
  37266. typeof options.marker.symbol !== 'undefined') {
  37267. point.graphic = graphic.destroy();
  37268. }
  37269. }
  37270. if (options && options.dataLabels && point.dataLabel) {
  37271. point.dataLabel = point.dataLabel.destroy(); // #2468
  37272. }
  37273. if (point.connector) {
  37274. point.connector = point.connector.destroy(); // #7243
  37275. }
  37276. }
  37277. // record changes in the parallel arrays
  37278. i = point.index;
  37279. series.updateParallelArrays(point, i);
  37280. // Record the options to options.data. If the old or the new config
  37281. // is an object, use point options, otherwise use raw options
  37282. // (#4701, #4916).
  37283. seriesOptions.data[i] = (isObject(seriesOptions.data[i], true) ||
  37284. isObject(options, true)) ?
  37285. point.options :
  37286. pick(options, seriesOptions.data[i]);
  37287. // redraw
  37288. series.isDirty = series.isDirtyData = true;
  37289. if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
  37290. chart.isDirtyBox = true;
  37291. }
  37292. if (seriesOptions.legendType === 'point') { // #1831, #1885
  37293. chart.isDirtyLegend = true;
  37294. }
  37295. if (redraw) {
  37296. chart.redraw(animation);
  37297. }
  37298. }
  37299. // Fire the event with a default handler of doing the update
  37300. if (runEvent === false) { // When called from setData
  37301. update();
  37302. }
  37303. else {
  37304. point.firePointEvent('update', { options: options }, update);
  37305. }
  37306. },
  37307. /**
  37308. * Remove a point and optionally redraw the series and if necessary the axes
  37309. *
  37310. * @sample highcharts/plotoptions/series-point-events-remove/
  37311. * Remove point and confirm
  37312. * @sample highcharts/members/point-remove/
  37313. * Remove pie slice
  37314. * @sample maps/members/point-remove/
  37315. * Remove selected points in Highmaps
  37316. *
  37317. * @function Highcharts.Point#remove
  37318. *
  37319. * @param {boolean} [redraw=true]
  37320. * Whether to redraw the chart or wait for an explicit call. When
  37321. * doing more operations on the chart, for example running
  37322. * `point.remove()` in a loop, it is best practice to set `redraw`
  37323. * to false and call `chart.redraw()` after.
  37324. *
  37325. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=false]
  37326. * Whether to apply animation, and optionally animation
  37327. * configuration.
  37328. *
  37329. * @return {void}
  37330. */
  37331. remove: function (redraw, animation) {
  37332. this.series.removePoint(this.series.data.indexOf(this), redraw, animation);
  37333. }
  37334. });
  37335. // Extend the series prototype for dynamic methods
  37336. extend(Series.prototype, /** @lends Series.prototype */ {
  37337. /**
  37338. * Add a point to the series after render time. The point can be added at
  37339. * the end, or by giving it an X value, to the start or in the middle of the
  37340. * series.
  37341. *
  37342. * @sample highcharts/members/series-addpoint-append/
  37343. * Append point
  37344. * @sample highcharts/members/series-addpoint-append-and-shift/
  37345. * Append and shift
  37346. * @sample highcharts/members/series-addpoint-x-and-y/
  37347. * Both X and Y values given
  37348. * @sample highcharts/members/series-addpoint-pie/
  37349. * Append pie slice
  37350. * @sample stock/members/series-addpoint/
  37351. * Append 100 points in Highstock
  37352. * @sample stock/members/series-addpoint-shift/
  37353. * Append and shift in Highstock
  37354. * @sample maps/members/series-addpoint/
  37355. * Add a point in Highmaps
  37356. *
  37357. * @function Highcharts.Series#addPoint
  37358. *
  37359. * @param {Highcharts.PointOptionsType} options
  37360. * The point options. If options is a single number, a point with
  37361. * that y value is appended to the series. If it is an array, it will
  37362. * be interpreted as x and y values respectively. If it is an
  37363. * object, advanced options as outlined under `series.data` are
  37364. * applied.
  37365. *
  37366. * @param {boolean} [redraw=true]
  37367. * Whether to redraw the chart after the point is added. When adding
  37368. * more than one point, it is highly recommended that the redraw
  37369. * option be set to false, and instead {@link Chart#redraw} is
  37370. * explicitly called after the adding of points is finished.
  37371. * Otherwise, the chart will redraw after adding each point.
  37372. *
  37373. * @param {boolean} [shift=false]
  37374. * If true, a point is shifted off the start of the series as one is
  37375. * appended to the end.
  37376. *
  37377. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  37378. * Whether to apply animation, and optionally animation
  37379. * configuration.
  37380. *
  37381. * @param {boolean} [withEvent=true]
  37382. * Used internally, whether to fire the series `addPoint` event.
  37383. *
  37384. * @return {void}
  37385. *
  37386. * @fires Highcharts.Series#event:addPoint
  37387. */
  37388. addPoint: function (options, redraw, shift, animation, withEvent) {
  37389. var series = this,
  37390. seriesOptions = series.options,
  37391. data = series.data,
  37392. chart = series.chart,
  37393. xAxis = series.xAxis,
  37394. names = xAxis && xAxis.hasNames && xAxis.names,
  37395. dataOptions = seriesOptions.data,
  37396. point,
  37397. xData = series.xData,
  37398. isInTheMiddle,
  37399. i,
  37400. x;
  37401. // Optional redraw, defaults to true
  37402. redraw = pick(redraw, true);
  37403. // Get options and push the point to xData, yData and series.options. In
  37404. // series.generatePoints the Point instance will be created on demand
  37405. // and pushed to the series.data array.
  37406. point = { series: series };
  37407. series.pointClass.prototype.applyOptions.apply(point, [options]);
  37408. x = point.x;
  37409. // Get the insertion point
  37410. i = xData.length;
  37411. if (series.requireSorting && x < xData[i - 1]) {
  37412. isInTheMiddle = true;
  37413. while (i && xData[i - 1] > x) {
  37414. i--;
  37415. }
  37416. }
  37417. // Insert undefined item
  37418. series.updateParallelArrays(point, 'splice', i, 0, 0);
  37419. // Update it
  37420. series.updateParallelArrays(point, i);
  37421. if (names && point.name) {
  37422. names[x] = point.name;
  37423. }
  37424. dataOptions.splice(i, 0, options);
  37425. if (isInTheMiddle) {
  37426. series.data.splice(i, 0, null);
  37427. series.processData();
  37428. }
  37429. // Generate points to be added to the legend (#1329)
  37430. if (seriesOptions.legendType === 'point') {
  37431. series.generatePoints();
  37432. }
  37433. // Shift the first point off the parallel arrays
  37434. if (shift) {
  37435. if (data[0] && data[0].remove) {
  37436. data[0].remove(false);
  37437. }
  37438. else {
  37439. data.shift();
  37440. series.updateParallelArrays(point, 'shift');
  37441. dataOptions.shift();
  37442. }
  37443. }
  37444. // Fire event
  37445. if (withEvent !== false) {
  37446. fireEvent(series, 'addPoint', { point: point });
  37447. }
  37448. // redraw
  37449. series.isDirty = true;
  37450. series.isDirtyData = true;
  37451. if (redraw) {
  37452. chart.redraw(animation); // Animation is set anyway on redraw, #5665
  37453. }
  37454. },
  37455. /**
  37456. * Remove a point from the series. Unlike the
  37457. * {@link Highcharts.Point#remove} method, this can also be done on a point
  37458. * that is not instanciated because it is outside the view or subject to
  37459. * Highstock data grouping.
  37460. *
  37461. * @sample highcharts/members/series-removepoint/
  37462. * Remove cropped point
  37463. *
  37464. * @function Highcharts.Series#removePoint
  37465. *
  37466. * @param {number} i
  37467. * The index of the point in the {@link Highcharts.Series.data|data}
  37468. * array.
  37469. *
  37470. * @param {boolean} [redraw=true]
  37471. * Whether to redraw the chart after the point is added. When
  37472. * removing more than one point, it is highly recommended that the
  37473. * `redraw` option be set to `false`, and instead {@link
  37474. * Highcharts.Chart#redraw} is explicitly called after the adding of
  37475. * points is finished.
  37476. *
  37477. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  37478. * Whether and optionally how the series should be animated.
  37479. *
  37480. * @return {void}
  37481. *
  37482. * @fires Highcharts.Point#event:remove
  37483. */
  37484. removePoint: function (i, redraw, animation) {
  37485. var series = this,
  37486. data = series.data,
  37487. point = data[i],
  37488. points = series.points,
  37489. chart = series.chart,
  37490. remove = function () {
  37491. if (points && points.length === data.length) { // #4935
  37492. points.splice(i, 1);
  37493. }
  37494. data.splice(i, 1);
  37495. series.options.data.splice(i, 1);
  37496. series.updateParallelArrays(point || { series: series }, 'splice', i, 1);
  37497. if (point) {
  37498. point.destroy();
  37499. }
  37500. // redraw
  37501. series.isDirty = true;
  37502. series.isDirtyData = true;
  37503. if (redraw) {
  37504. chart.redraw();
  37505. }
  37506. };
  37507. setAnimation(animation, chart);
  37508. redraw = pick(redraw, true);
  37509. // Fire the event with a default handler of removing the point
  37510. if (point) {
  37511. point.firePointEvent('remove', null, remove);
  37512. }
  37513. else {
  37514. remove();
  37515. }
  37516. },
  37517. /**
  37518. * Remove a series and optionally redraw the chart.
  37519. *
  37520. * @sample highcharts/members/series-remove/
  37521. * Remove first series from a button
  37522. *
  37523. * @function Highcharts.Series#remove
  37524. *
  37525. * @param {boolean} [redraw=true]
  37526. * Whether to redraw the chart or wait for an explicit call to
  37527. * {@link Highcharts.Chart#redraw}.
  37528. *
  37529. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  37530. * Whether to apply animation, and optionally animation
  37531. * configuration.
  37532. *
  37533. * @param {boolean} [withEvent=true]
  37534. * Used internally, whether to fire the series `remove` event.
  37535. *
  37536. * @return {void}
  37537. *
  37538. * @fires Highcharts.Series#event:remove
  37539. */
  37540. remove: function (redraw, animation, withEvent, keepEvents) {
  37541. var series = this,
  37542. chart = series.chart;
  37543. /**
  37544. * @private
  37545. */
  37546. function remove() {
  37547. // Destroy elements
  37548. series.destroy(keepEvents);
  37549. series.remove = null; // Prevent from doing again (#9097)
  37550. // Redraw
  37551. chart.isDirtyLegend = chart.isDirtyBox = true;
  37552. chart.linkSeries();
  37553. if (pick(redraw, true)) {
  37554. chart.redraw(animation);
  37555. }
  37556. }
  37557. // Fire the event with a default handler of removing the point
  37558. if (withEvent !== false) {
  37559. fireEvent(series, 'remove', null, remove);
  37560. }
  37561. else {
  37562. remove();
  37563. }
  37564. },
  37565. /**
  37566. * Update the series with a new set of options. For a clean and precise
  37567. * handling of new options, all methods and elements from the series are
  37568. * removed, and it is initialized from scratch. Therefore, this method is
  37569. * more performance expensive than some other utility methods like {@link
  37570. * Series#setData} or {@link Series#setVisible}.
  37571. *
  37572. * Note that `Series.update` may mutate the passed `data` options.
  37573. *
  37574. * @sample highcharts/members/series-update/
  37575. * Updating series options
  37576. * @sample maps/members/series-update/
  37577. * Update series options in Highmaps
  37578. *
  37579. * @function Highcharts.Series#update
  37580. *
  37581. * @param {Highcharts.SeriesOptionsType} options
  37582. * New options that will be merged with the series' existing options.
  37583. *
  37584. * @param {boolean} [redraw=true]
  37585. * Whether to redraw the chart after the series is altered. If doing
  37586. * more operations on the chart, it is a good idea to set redraw to
  37587. * false and call {@link Chart#redraw} after.
  37588. *
  37589. * @return {void}
  37590. *
  37591. * @fires Highcharts.Series#event:update
  37592. * @fires Highcharts.Series#event:afterUpdate
  37593. */
  37594. update: function (options, redraw) {
  37595. options = H.cleanRecursively(options, this.userOptions);
  37596. fireEvent(this, 'update', { options: options });
  37597. var series = this,
  37598. chart = series.chart,
  37599. // must use user options when changing type because series.options
  37600. // is merged in with type specific plotOptions
  37601. oldOptions = series.userOptions,
  37602. seriesOptions,
  37603. initialType = series.initialType || series.type,
  37604. newType = (options.type ||
  37605. oldOptions.type ||
  37606. chart.options.chart.type),
  37607. keepPoints = !(
  37608. // Indicators, histograms etc recalculate the data. It should be
  37609. // possible to omit this.
  37610. this.hasDerivedData ||
  37611. // Changes to data grouping requires new points in new groups
  37612. options.dataGrouping ||
  37613. // New type requires new point classes
  37614. (newType && newType !== this.type) ||
  37615. // New options affecting how the data points are built
  37616. typeof options.pointStart !== 'undefined' ||
  37617. options.pointInterval ||
  37618. options.pointIntervalUnit ||
  37619. options.keys),
  37620. initialSeriesProto = seriesTypes[initialType].prototype,
  37621. n,
  37622. groups = [
  37623. 'group',
  37624. 'markerGroup',
  37625. 'dataLabelsGroup',
  37626. 'transformGroup'
  37627. ],
  37628. preserve = [
  37629. 'eventOptions',
  37630. 'navigatorSeries',
  37631. 'baseSeries'
  37632. ],
  37633. // Animation must be enabled when calling update before the initial
  37634. // animation has first run. This happens when calling update
  37635. // directly after chart initialization, or when applying responsive
  37636. // rules (#6912).
  37637. animation = series.finishedAnimating && { animation: false },
  37638. kinds = {};
  37639. if (keepPoints) {
  37640. preserve.push('data', 'isDirtyData', 'points', 'processedXData', 'processedYData', 'xIncrement', 'cropped', '_hasPointMarkers', '_hasPointLabels',
  37641. // Map specific, consider moving it to series-specific preserve-
  37642. // properties (#10617)
  37643. 'mapMap', 'mapData', 'minY', 'maxY', 'minX', 'maxX');
  37644. if (options.visible !== false) {
  37645. preserve.push('area', 'graph');
  37646. }
  37647. series.parallelArrays.forEach(function (key) {
  37648. preserve.push(key + 'Data');
  37649. });
  37650. if (options.data) {
  37651. // setData uses dataSorting options so we need to update them
  37652. // earlier
  37653. if (options.dataSorting) {
  37654. extend(series.options.dataSorting, options.dataSorting);
  37655. }
  37656. this.setData(options.data, false);
  37657. }
  37658. }
  37659. // Do the merge, with some forced options
  37660. options = merge(oldOptions, animation, {
  37661. // When oldOptions.index is null it should't be cleared.
  37662. // Otherwise navigator series will have wrong indexes (#10193).
  37663. index: typeof oldOptions.index === 'undefined' ?
  37664. series.index : oldOptions.index,
  37665. pointStart: pick(
  37666. // when updating from blank (#7933)
  37667. oldOptions.pointStart,
  37668. // when updating after addPoint
  37669. series.xData[0])
  37670. }, (!keepPoints && { data: series.options.data }), options);
  37671. // Merge does not merge arrays, but replaces them. Since points were
  37672. // updated, `series.options.data` has correct merged options, use it:
  37673. if (keepPoints && options.data) {
  37674. options.data = series.options.data;
  37675. }
  37676. // Make sure preserved properties are not destroyed (#3094)
  37677. preserve = groups.concat(preserve);
  37678. preserve.forEach(function (prop) {
  37679. preserve[prop] = series[prop];
  37680. delete series[prop];
  37681. });
  37682. // Destroy the series and delete all properties. Reinsert all
  37683. // methods and properties from the new type prototype (#2270,
  37684. // #3719).
  37685. series.remove(false, null, false, true);
  37686. for (n in initialSeriesProto) { // eslint-disable-line guard-for-in
  37687. series[n] = void 0;
  37688. }
  37689. if (seriesTypes[newType || initialType]) {
  37690. extend(series, seriesTypes[newType || initialType].prototype);
  37691. }
  37692. else {
  37693. error(17, true, chart, { missingModuleFor: (newType || initialType) });
  37694. }
  37695. // Re-register groups (#3094) and other preserved properties
  37696. preserve.forEach(function (prop) {
  37697. series[prop] = preserve[prop];
  37698. });
  37699. series.init(chart, options);
  37700. // Remove particular elements of the points. Check `series.options`
  37701. // because we need to consider the options being set on plotOptions as
  37702. // well.
  37703. if (keepPoints && this.points) {
  37704. seriesOptions = series.options;
  37705. // What kind of elements to destroy
  37706. if (seriesOptions.visible === false) {
  37707. kinds.graphic = 1;
  37708. kinds.dataLabel = 1;
  37709. }
  37710. else if (!series._hasPointLabels) {
  37711. var marker = seriesOptions.marker,
  37712. dataLabels = seriesOptions.dataLabels;
  37713. if (marker && (marker.enabled === false ||
  37714. 'symbol' in marker // #10870
  37715. )) {
  37716. kinds.graphic = 1;
  37717. }
  37718. if (dataLabels &&
  37719. dataLabels.enabled === false) {
  37720. kinds.dataLabel = 1;
  37721. }
  37722. }
  37723. this.points.forEach(function (point) {
  37724. if (point && point.series) {
  37725. point.resolveColor();
  37726. // Destroy elements in order to recreate based on updated
  37727. // series options.
  37728. if (Object.keys(kinds).length) {
  37729. point.destroyElements(kinds);
  37730. }
  37731. if (seriesOptions.showInLegend === false &&
  37732. point.legendItem) {
  37733. chart.legend.destroyItem(point);
  37734. }
  37735. }
  37736. }, this);
  37737. }
  37738. series.initialType = initialType;
  37739. chart.linkSeries(); // Links are lost in series.remove (#3028)
  37740. fireEvent(this, 'afterUpdate');
  37741. if (pick(redraw, true)) {
  37742. chart.redraw(keepPoints ? void 0 : false);
  37743. }
  37744. },
  37745. /**
  37746. * Used from within series.update
  37747. *
  37748. * @private
  37749. * @function Highcharts.Series#setName
  37750. *
  37751. * @param {string} name
  37752. *
  37753. * @return {void}
  37754. */
  37755. setName: function (name) {
  37756. this.name = this.options.name = this.userOptions.name = name;
  37757. this.chart.isDirtyLegend = true;
  37758. }
  37759. });
  37760. // Extend the Axis.prototype for dynamic methods
  37761. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  37762. /**
  37763. * Update an axis object with a new set of options. The options are merged
  37764. * with the existing options, so only new or altered options need to be
  37765. * specified.
  37766. *
  37767. * @sample highcharts/members/axis-update/
  37768. * Axis update demo
  37769. *
  37770. * @function Highcharts.Axis#update
  37771. *
  37772. * @param {Highcharts.AxisOptions} options
  37773. * The new options that will be merged in with existing options on
  37774. * the axis.
  37775. *
  37776. * @param {boolean} [redraw=true]
  37777. * Whether to redraw the chart after the axis is altered. If doing
  37778. * more operations on the chart, it is a good idea to set redraw to
  37779. * false and call {@link Chart#redraw} after.
  37780. *
  37781. * @return {void}
  37782. */
  37783. update: function (options, redraw) {
  37784. var chart = this.chart,
  37785. newEvents = ((options && options.events) || {});
  37786. options = merge(this.userOptions, options);
  37787. // Color Axis is not an array,
  37788. // This change is applied in the ColorAxis wrapper
  37789. if (chart.options[this.coll].indexOf) {
  37790. // Don't use this.options.index,
  37791. // StockChart has Axes in navigator too
  37792. chart.options[this.coll][chart.options[this.coll].indexOf(this.userOptions)] = options;
  37793. }
  37794. // Remove old events, if no new exist (#8161)
  37795. objectEach(chart.options[this.coll].events, function (fn, ev) {
  37796. if (typeof newEvents[ev] === 'undefined') {
  37797. newEvents[ev] = void 0;
  37798. }
  37799. });
  37800. this.destroy(true);
  37801. this.init(chart, extend(options, { events: newEvents }));
  37802. chart.isDirtyBox = true;
  37803. if (pick(redraw, true)) {
  37804. chart.redraw();
  37805. }
  37806. },
  37807. /**
  37808. * Remove the axis from the chart.
  37809. *
  37810. * @sample highcharts/members/chart-addaxis/
  37811. * Add and remove axes
  37812. *
  37813. * @function Highcharts.Axis#remove
  37814. *
  37815. * @param {boolean} [redraw=true]
  37816. * Whether to redraw the chart following the remove.
  37817. *
  37818. * @return {void}
  37819. */
  37820. remove: function (redraw) {
  37821. var chart = this.chart,
  37822. key = this.coll, // xAxis or yAxis
  37823. axisSeries = this.series,
  37824. i = axisSeries.length;
  37825. // Remove associated series (#2687)
  37826. while (i--) {
  37827. if (axisSeries[i]) {
  37828. axisSeries[i].remove(false);
  37829. }
  37830. }
  37831. // Remove the axis
  37832. erase(chart.axes, this);
  37833. erase(chart[key], this);
  37834. if (isArray(chart.options[key])) {
  37835. chart.options[key].splice(this.options.index, 1);
  37836. }
  37837. else { // color axis, #6488
  37838. delete chart.options[key];
  37839. }
  37840. chart[key].forEach(function (axis, i) {
  37841. // Re-index, #1706, #8075
  37842. axis.options.index = axis.userOptions.index = i;
  37843. });
  37844. this.destroy();
  37845. chart.isDirtyBox = true;
  37846. if (pick(redraw, true)) {
  37847. chart.redraw();
  37848. }
  37849. },
  37850. /**
  37851. * Update the axis title by options after render time.
  37852. *
  37853. * @sample highcharts/members/axis-settitle/
  37854. * Set a new Y axis title
  37855. *
  37856. * @function Highcharts.Axis#setTitle
  37857. *
  37858. * @param {Highcharts.AxisTitleOptions} titleOptions
  37859. * The additional title options.
  37860. *
  37861. * @param {boolean} [redraw=true]
  37862. * Whether to redraw the chart after setting the title.
  37863. *
  37864. * @return {void}
  37865. */
  37866. setTitle: function (titleOptions, redraw) {
  37867. this.update({ title: titleOptions }, redraw);
  37868. },
  37869. /**
  37870. * Set new axis categories and optionally redraw.
  37871. *
  37872. * @sample highcharts/members/axis-setcategories/
  37873. * Set categories by click on a button
  37874. *
  37875. * @function Highcharts.Axis#setCategories
  37876. *
  37877. * @param {Array<string>} categories
  37878. * The new categories.
  37879. *
  37880. * @param {boolean} [redraw=true]
  37881. * Whether to redraw the chart.
  37882. *
  37883. * @return {void}
  37884. */
  37885. setCategories: function (categories, redraw) {
  37886. this.update({ categories: categories }, redraw);
  37887. }
  37888. });
  37889. });
  37890. _registerModule(_modules, 'Series/AreaSeries.js', [_modules['Core/Globals.js'], _modules['Core/Color.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Utilities.js']], function (H, Color, LegendSymbolMixin, U) {
  37891. /* *
  37892. *
  37893. * (c) 2010-2020 Torstein Honsi
  37894. *
  37895. * License: www.highcharts.com/license
  37896. *
  37897. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37898. *
  37899. * */
  37900. var color = Color.parse;
  37901. var objectEach = U.objectEach,
  37902. pick = U.pick,
  37903. seriesType = U.seriesType;
  37904. var Series = H.Series;
  37905. /**
  37906. * Area series type.
  37907. *
  37908. * @private
  37909. * @class
  37910. * @name Highcharts.seriesTypes.area
  37911. *
  37912. * @augments Highcharts.Series
  37913. */
  37914. seriesType('area', 'line',
  37915. /**
  37916. * The area series type.
  37917. *
  37918. * @sample {highcharts} highcharts/demo/area-basic/
  37919. * Area chart
  37920. * @sample {highstock} stock/demo/area/
  37921. * Area chart
  37922. *
  37923. * @extends plotOptions.line
  37924. * @excluding useOhlcData
  37925. * @product highcharts highstock
  37926. * @optionparent plotOptions.area
  37927. */
  37928. {
  37929. /**
  37930. * Fill color or gradient for the area. When `null`, the series' `color`
  37931. * is used with the series' `fillOpacity`.
  37932. *
  37933. * In styled mode, the fill color can be set with the `.highcharts-area`
  37934. * class name.
  37935. *
  37936. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-default/
  37937. * Null by default
  37938. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-gradient/
  37939. * Gradient
  37940. *
  37941. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37942. * @product highcharts highstock
  37943. * @apioption plotOptions.area.fillColor
  37944. */
  37945. /**
  37946. * Fill opacity for the area. When you set an explicit `fillColor`,
  37947. * the `fillOpacity` is not applied. Instead, you should define the
  37948. * opacity in the `fillColor` with an rgba color definition. The
  37949. * `fillOpacity` setting, also the default setting, overrides the alpha
  37950. * component of the `color` setting.
  37951. *
  37952. * In styled mode, the fill opacity can be set with the
  37953. * `.highcharts-area` class name.
  37954. *
  37955. * @sample {highcharts} highcharts/plotoptions/area-fillopacity/
  37956. * Automatic fill color and fill opacity of 0.1
  37957. *
  37958. * @type {number}
  37959. * @default {highcharts} 0.75
  37960. * @default {highstock} 0.75
  37961. * @product highcharts highstock
  37962. * @apioption plotOptions.area.fillOpacity
  37963. */
  37964. /**
  37965. * A separate color for the graph line. By default the line takes the
  37966. * `color` of the series, but the lineColor setting allows setting a
  37967. * separate color for the line without altering the `fillColor`.
  37968. *
  37969. * In styled mode, the line stroke can be set with the
  37970. * `.highcharts-graph` class name.
  37971. *
  37972. * @sample {highcharts} highcharts/plotoptions/area-linecolor/
  37973. * Dark gray line
  37974. *
  37975. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37976. * @product highcharts highstock
  37977. * @apioption plotOptions.area.lineColor
  37978. */
  37979. /**
  37980. * A separate color for the negative part of the area.
  37981. *
  37982. * In styled mode, a negative color is set with the
  37983. * `.highcharts-negative` class name.
  37984. *
  37985. * @see [negativeColor](#plotOptions.area.negativeColor)
  37986. *
  37987. * @sample {highcharts} highcharts/css/series-negative-color/
  37988. * Negative color in styled mode
  37989. *
  37990. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37991. * @since 3.0
  37992. * @product highcharts
  37993. * @apioption plotOptions.area.negativeFillColor
  37994. */
  37995. /**
  37996. * Whether the whole area or just the line should respond to mouseover
  37997. * tooltips and other mouse or touch events.
  37998. *
  37999. * @sample {highcharts|highstock} highcharts/plotoptions/area-trackbyarea/
  38000. * Display the tooltip when the area is hovered
  38001. *
  38002. * @type {boolean}
  38003. * @default false
  38004. * @since 1.1.6
  38005. * @product highcharts highstock
  38006. * @apioption plotOptions.area.trackByArea
  38007. */
  38008. /**
  38009. * The Y axis value to serve as the base for the area, for
  38010. * distinguishing between values above and below a threshold. The area
  38011. * between the graph and the threshold is filled.
  38012. *
  38013. * * If a number is given, the Y axis will scale to the threshold.
  38014. * * If `null`, the scaling behaves like a line series with fill between
  38015. * the graph and the Y axis minimum.
  38016. * * If `Infinity` or `-Infinity`, the area between the graph and the
  38017. * corresponding Y axis extreme is filled (since v6.1.0).
  38018. *
  38019. * @sample {highcharts} highcharts/plotoptions/area-threshold/
  38020. * A threshold of 100
  38021. * @sample {highcharts} highcharts/plotoptions/area-threshold-infinity/
  38022. * A threshold of Infinity
  38023. *
  38024. * @type {number|null}
  38025. * @since 2.0
  38026. * @product highcharts highstock
  38027. */
  38028. threshold: 0
  38029. },
  38030. /* eslint-disable valid-jsdoc */
  38031. /**
  38032. * @lends seriesTypes.area.prototype
  38033. */
  38034. {
  38035. singleStacks: false,
  38036. /**
  38037. * Return an array of stacked points, where null and missing points are
  38038. * replaced by dummy points in order for gaps to be drawn correctly in
  38039. * stacks.
  38040. * @private
  38041. */
  38042. getStackPoints: function (points) {
  38043. var series = this,
  38044. segment = [],
  38045. keys = [],
  38046. xAxis = this.xAxis,
  38047. yAxis = this.yAxis,
  38048. stack = yAxis.stacking.stacks[this.stackKey],
  38049. pointMap = {},
  38050. seriesIndex = series.index,
  38051. yAxisSeries = yAxis.series,
  38052. seriesLength = yAxisSeries.length,
  38053. visibleSeries,
  38054. upOrDown = pick(yAxis.options.reversedStacks,
  38055. true) ? 1 : -1,
  38056. i;
  38057. points = points || this.points;
  38058. if (this.options.stacking) {
  38059. for (i = 0; i < points.length; i++) {
  38060. // Reset after point update (#7326)
  38061. points[i].leftNull = points[i].rightNull = void 0;
  38062. // Create a map where we can quickly look up the points by
  38063. // their X values.
  38064. pointMap[points[i].x] = points[i];
  38065. }
  38066. // Sort the keys (#1651)
  38067. objectEach(stack, function (stackX, x) {
  38068. // nulled after switching between
  38069. // grouping and not (#1651, #2336)
  38070. if (stackX.total !== null) {
  38071. keys.push(x);
  38072. }
  38073. });
  38074. keys.sort(function (a, b) {
  38075. return a - b;
  38076. });
  38077. visibleSeries = yAxisSeries.map(function (s) {
  38078. return s.visible;
  38079. });
  38080. keys.forEach(function (x, idx) {
  38081. var y = 0,
  38082. stackPoint,
  38083. stackedValues;
  38084. if (pointMap[x] && !pointMap[x].isNull) {
  38085. segment.push(pointMap[x]);
  38086. // Find left and right cliff. -1 goes left, 1 goes
  38087. // right.
  38088. [-1, 1].forEach(function (direction) {
  38089. var nullName = direction === 1 ?
  38090. 'rightNull' :
  38091. 'leftNull',
  38092. cliffName = direction === 1 ?
  38093. 'rightCliff' :
  38094. 'leftCliff',
  38095. cliff = 0,
  38096. otherStack = stack[keys[idx + direction]];
  38097. // If there is a stack next to this one,
  38098. // to the left or to the right...
  38099. if (otherStack) {
  38100. i = seriesIndex;
  38101. // Can go either up or down,
  38102. // depending on reversedStacks
  38103. while (i >= 0 && i < seriesLength) {
  38104. stackPoint = otherStack.points[i];
  38105. if (!stackPoint) {
  38106. // If the next point in this series
  38107. // is missing, mark the point
  38108. // with point.leftNull or
  38109. // point.rightNull = true.
  38110. if (i === seriesIndex) {
  38111. pointMap[x][nullName] =
  38112. true;
  38113. // If there are missing points in
  38114. // the next stack in any of the
  38115. // series below this one, we need
  38116. // to substract the missing values
  38117. // and add a hiatus to the left or
  38118. // right.
  38119. }
  38120. else if (visibleSeries[i]) {
  38121. stackedValues =
  38122. stack[x].points[i];
  38123. if (stackedValues) {
  38124. cliff -=
  38125. stackedValues[1] -
  38126. stackedValues[0];
  38127. }
  38128. }
  38129. }
  38130. // When reversedStacks is true, loop up,
  38131. // else loop down
  38132. i += upOrDown;
  38133. }
  38134. }
  38135. pointMap[x][cliffName] = cliff;
  38136. });
  38137. // There is no point for this X value in this series, so we
  38138. // insert a dummy point in order for the areas to be drawn
  38139. // correctly.
  38140. }
  38141. else {
  38142. // Loop down the stack to find the series below this
  38143. // one that has a value (#1991)
  38144. i = seriesIndex;
  38145. while (i >= 0 && i < seriesLength) {
  38146. stackPoint = stack[x].points[i];
  38147. if (stackPoint) {
  38148. y = stackPoint[1];
  38149. break;
  38150. }
  38151. // When reversedStacks is true, loop up, else loop
  38152. // down
  38153. i += upOrDown;
  38154. }
  38155. y = yAxis.translate(// #6272
  38156. y, 0, 1, 0, 1);
  38157. segment.push({
  38158. isNull: true,
  38159. plotX: xAxis.translate(// #6272
  38160. x, 0, 0, 0, 1),
  38161. x: x,
  38162. plotY: y,
  38163. yBottom: y
  38164. });
  38165. }
  38166. });
  38167. }
  38168. return segment;
  38169. },
  38170. /**
  38171. * @private
  38172. */
  38173. getGraphPath: function (points) {
  38174. var getGraphPath = Series.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
  38175. yAxis.getThreshold(options.threshold)), isNull, yBottom, connectNulls = pick(// #10574
  38176. options.connectNulls, stacking === 'percent'),
  38177. // To display null points in underlying stacked series, this
  38178. // series graph must be broken, and the area also fall down to
  38179. // fill the gap left by the null point. #2069
  38180. addDummyPoints = function (i, otherI, side) {
  38181. var point = points[i], stackedValues = stacking &&
  38182. stacks[point.x].points[seriesIndex], nullVal = point[side + 'Null'] || 0, cliffVal = point[side + 'Cliff'] || 0, top, bottom, isNull = true;
  38183. if (cliffVal || nullVal) {
  38184. top = (nullVal ?
  38185. stackedValues[0] :
  38186. stackedValues[1]) + cliffVal;
  38187. bottom = stackedValues[0] + cliffVal;
  38188. isNull = !!nullVal;
  38189. }
  38190. else if (!stacking &&
  38191. points[otherI] &&
  38192. points[otherI].isNull) {
  38193. top = bottom = threshold;
  38194. }
  38195. // Add to the top and bottom line of the area
  38196. if (typeof top !== 'undefined') {
  38197. graphPoints.push({
  38198. plotX: plotX,
  38199. plotY: top === null ?
  38200. translatedThreshold :
  38201. yAxis.getThreshold(top),
  38202. isNull: isNull,
  38203. isCliff: true
  38204. });
  38205. bottomPoints.push({
  38206. plotX: plotX,
  38207. plotY: bottom === null ?
  38208. translatedThreshold :
  38209. yAxis.getThreshold(bottom),
  38210. doCurve: false // #1041, gaps in areaspline areas
  38211. });
  38212. }
  38213. };
  38214. // Find what points to use
  38215. points = points || this.points;
  38216. // Fill in missing points
  38217. if (stacking) {
  38218. points = this.getStackPoints(points);
  38219. }
  38220. for (i = 0; i < points.length; i++) {
  38221. // Reset after series.update of stacking property (#12033)
  38222. if (!stacking) {
  38223. points[i].leftCliff = points[i].rightCliff =
  38224. points[i].leftNull = points[i].rightNull = void 0;
  38225. }
  38226. isNull = points[i].isNull;
  38227. plotX = pick(points[i].rectPlotX, points[i].plotX);
  38228. yBottom = stacking ? points[i].yBottom : translatedThreshold;
  38229. if (!isNull || connectNulls) {
  38230. if (!connectNulls) {
  38231. addDummyPoints(i, i - 1, 'left');
  38232. }
  38233. // Skip null point when stacking is false and connectNulls
  38234. // true
  38235. if (!(isNull && !stacking && connectNulls)) {
  38236. graphPoints.push(points[i]);
  38237. bottomPoints.push({
  38238. x: i,
  38239. plotX: plotX,
  38240. plotY: yBottom
  38241. });
  38242. }
  38243. if (!connectNulls) {
  38244. addDummyPoints(i, i + 1, 'right');
  38245. }
  38246. }
  38247. }
  38248. topPath = getGraphPath.call(this, graphPoints, true, true);
  38249. bottomPoints.reversed = true;
  38250. bottomPath = getGraphPath.call(this, bottomPoints, true, true);
  38251. var firstBottomPoint = bottomPath[0];
  38252. if (firstBottomPoint && firstBottomPoint[0] === 'M') {
  38253. bottomPath[0] = ['L', firstBottomPoint[1], firstBottomPoint[2]];
  38254. }
  38255. areaPath = topPath.concat(bottomPath);
  38256. // TODO: don't set leftCliff and rightCliff when connectNulls?
  38257. graphPath = getGraphPath
  38258. .call(this, graphPoints, false, connectNulls);
  38259. areaPath.xMap = topPath.xMap;
  38260. this.areaPath = areaPath;
  38261. return graphPath;
  38262. },
  38263. /**
  38264. * Draw the graph and the underlying area. This method calls the Series
  38265. * base function and adds the area. The areaPath is calculated in the
  38266. * getSegmentPath method called from Series.prototype.drawGraph.
  38267. * @private
  38268. */
  38269. drawGraph: function () {
  38270. // Define or reset areaPath
  38271. this.areaPath = [];
  38272. // Call the base method
  38273. Series.prototype.drawGraph.apply(this);
  38274. // Define local variables
  38275. var series = this,
  38276. areaPath = this.areaPath,
  38277. options = this.options,
  38278. zones = this.zones,
  38279. props = [[
  38280. 'area',
  38281. 'highcharts-area',
  38282. this.color,
  38283. options.fillColor
  38284. ]]; // area name, main color, fill color
  38285. zones.forEach(function (zone,
  38286. i) {
  38287. props.push([
  38288. 'zone-area-' + i,
  38289. 'highcharts-area highcharts-zone-area-' + i + ' ' +
  38290. zone.className,
  38291. zone.color || series.color,
  38292. zone.fillColor || options.fillColor
  38293. ]);
  38294. });
  38295. props.forEach(function (prop) {
  38296. var areaKey = prop[0],
  38297. area = series[areaKey],
  38298. verb = area ? 'animate' : 'attr',
  38299. attribs = {};
  38300. // Create or update the area
  38301. if (area) { // update
  38302. area.endX = series.preventGraphAnimation ?
  38303. null :
  38304. areaPath.xMap;
  38305. area.animate({ d: areaPath });
  38306. }
  38307. else { // create
  38308. attribs.zIndex = 0; // #1069
  38309. area = series[areaKey] = series.chart.renderer
  38310. .path(areaPath)
  38311. .addClass(prop[1])
  38312. .add(series.group);
  38313. area.isArea = true;
  38314. }
  38315. if (!series.chart.styledMode) {
  38316. attribs.fill = pick(prop[3], color(prop[2])
  38317. .setOpacity(pick(options.fillOpacity, 0.75))
  38318. .get());
  38319. }
  38320. area[verb](attribs);
  38321. area.startX = areaPath.xMap;
  38322. area.shiftUnit = options.step ? 2 : 1;
  38323. });
  38324. },
  38325. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  38326. });
  38327. /* eslint-enable valid-jsdoc */
  38328. /**
  38329. * A `area` series. If the [type](#series.area.type) option is not
  38330. * specified, it is inherited from [chart.type](#chart.type).
  38331. *
  38332. * @extends series,plotOptions.area
  38333. * @excluding dataParser, dataURL, useOhlcData
  38334. * @product highcharts highstock
  38335. * @apioption series.area
  38336. */
  38337. /**
  38338. * An array of data points for the series. For the `area` series type,
  38339. * points can be given in the following ways:
  38340. *
  38341. * 1. An array of numerical values. In this case, the numerical values will be
  38342. * interpreted as `y` options. The `x` values will be automatically
  38343. * calculated, either starting at 0 and incremented by 1, or from
  38344. * `pointStart` * and `pointInterval` given in the series options. If the
  38345. * axis has categories, these will be used. Example:
  38346. * ```js
  38347. * data: [0, 5, 3, 5]
  38348. * ```
  38349. *
  38350. * 2. An array of arrays with 2 values. In this case, the values correspond to
  38351. * `x,y`. If the first value is a string, it is applied as the name of the
  38352. * point, and the `x` value is inferred.
  38353. * ```js
  38354. * data: [
  38355. * [0, 9],
  38356. * [1, 7],
  38357. * [2, 6]
  38358. * ]
  38359. * ```
  38360. *
  38361. * 3. An array of objects with named values. The following snippet shows only a
  38362. * few settings, see the complete options set below. If the total number of
  38363. * data points exceeds the series'
  38364. * [turboThreshold](#series.area.turboThreshold), this option is not
  38365. * available.
  38366. * ```js
  38367. * data: [{
  38368. * x: 1,
  38369. * y: 9,
  38370. * name: "Point2",
  38371. * color: "#00FF00"
  38372. * }, {
  38373. * x: 1,
  38374. * y: 6,
  38375. * name: "Point1",
  38376. * color: "#FF00FF"
  38377. * }]
  38378. * ```
  38379. *
  38380. * @sample {highcharts} highcharts/chart/reflow-true/
  38381. * Numerical values
  38382. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  38383. * Arrays of numeric x and y
  38384. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  38385. * Arrays of datetime x and y
  38386. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  38387. * Arrays of point.name and y
  38388. * @sample {highcharts} highcharts/series/data-array-of-objects/
  38389. * Config objects
  38390. *
  38391. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  38392. * @extends series.line.data
  38393. * @product highcharts highstock
  38394. * @apioption series.area.data
  38395. */
  38396. ''; // adds doclets above to transpilat
  38397. });
  38398. _registerModule(_modules, 'Series/SplineSeries.js', [_modules['Core/Utilities.js']], function (U) {
  38399. /* *
  38400. *
  38401. * (c) 2010-2020 Torstein Honsi
  38402. *
  38403. * License: www.highcharts.com/license
  38404. *
  38405. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38406. *
  38407. * */
  38408. var pick = U.pick,
  38409. seriesType = U.seriesType;
  38410. /**
  38411. * Spline series type.
  38412. *
  38413. * @private
  38414. * @class
  38415. * @name Highcharts.seriesTypes.spline
  38416. *
  38417. * @augments Highcarts.Series
  38418. */
  38419. seriesType('spline', 'line',
  38420. /**
  38421. * A spline series is a special type of line series, where the segments
  38422. * between the data points are smoothed.
  38423. *
  38424. * @sample {highcharts} highcharts/demo/spline-irregular-time/
  38425. * Spline chart
  38426. * @sample {highstock} stock/demo/spline/
  38427. * Spline chart
  38428. *
  38429. * @extends plotOptions.series
  38430. * @excluding step, boostThreshold, boostBlending
  38431. * @product highcharts highstock
  38432. * @optionparent plotOptions.spline
  38433. */
  38434. {},
  38435. /**
  38436. * @lends seriesTypes.spline.prototype
  38437. */
  38438. {
  38439. /* eslint-disable valid-jsdoc */
  38440. /**
  38441. * Get the spline segment from a given point's previous neighbour to the
  38442. * given point.
  38443. *
  38444. * @private
  38445. * @function Highcharts.seriesTypes.spline#getPointSpline
  38446. *
  38447. * @param {Array<Highcharts.Point>}
  38448. *
  38449. * @param {Highcharts.Point} point
  38450. *
  38451. * @param {number} i
  38452. *
  38453. * @return {Highcharts.SVGPathArray}
  38454. */
  38455. getPointSpline: function (points, point, i) {
  38456. var
  38457. // 1 means control points midway between points, 2 means 1/3
  38458. // from the point, 3 is 1/4 etc
  38459. smoothing = 1.5,
  38460. denom = smoothing + 1,
  38461. plotX = point.plotX || 0,
  38462. plotY = point.plotY || 0,
  38463. lastPoint = points[i - 1],
  38464. nextPoint = points[i + 1],
  38465. leftContX,
  38466. leftContY,
  38467. rightContX,
  38468. rightContY,
  38469. ret;
  38470. /**
  38471. * @private
  38472. */
  38473. function doCurve(otherPoint) {
  38474. return otherPoint &&
  38475. !otherPoint.isNull &&
  38476. otherPoint.doCurve !== false &&
  38477. // #6387, area splines next to null:
  38478. !point.isCliff;
  38479. }
  38480. // Find control points
  38481. if (doCurve(lastPoint) && doCurve(nextPoint)) {
  38482. var lastX = lastPoint.plotX || 0,
  38483. lastY = lastPoint.plotY || 0,
  38484. nextX = nextPoint.plotX || 0,
  38485. nextY = nextPoint.plotY || 0,
  38486. correction = 0;
  38487. leftContX = (smoothing * plotX + lastX) / denom;
  38488. leftContY = (smoothing * plotY + lastY) / denom;
  38489. rightContX = (smoothing * plotX + nextX) / denom;
  38490. rightContY = (smoothing * plotY + nextY) / denom;
  38491. // Have the two control points make a straight line through main
  38492. // point
  38493. if (rightContX !== leftContX) { // #5016, division by zero
  38494. correction = (((rightContY - leftContY) *
  38495. (rightContX - plotX)) /
  38496. (rightContX - leftContX) + plotY - rightContY);
  38497. }
  38498. leftContY += correction;
  38499. rightContY += correction;
  38500. // to prevent false extremes, check that control points are
  38501. // between neighbouring points' y values
  38502. if (leftContY > lastY && leftContY > plotY) {
  38503. leftContY = Math.max(lastY, plotY);
  38504. // mirror of left control point
  38505. rightContY = 2 * plotY - leftContY;
  38506. }
  38507. else if (leftContY < lastY && leftContY < plotY) {
  38508. leftContY = Math.min(lastY, plotY);
  38509. rightContY = 2 * plotY - leftContY;
  38510. }
  38511. if (rightContY > nextY && rightContY > plotY) {
  38512. rightContY = Math.max(nextY, plotY);
  38513. leftContY = 2 * plotY - rightContY;
  38514. }
  38515. else if (rightContY < nextY && rightContY < plotY) {
  38516. rightContY = Math.min(nextY, plotY);
  38517. leftContY = 2 * plotY - rightContY;
  38518. }
  38519. // record for drawing in next point
  38520. point.rightContX = rightContX;
  38521. point.rightContY = rightContY;
  38522. }
  38523. // Visualize control points for debugging
  38524. /*
  38525. if (leftContX) {
  38526. this.chart.renderer.circle(
  38527. leftContX + this.chart.plotLeft,
  38528. leftContY + this.chart.plotTop,
  38529. 2
  38530. )
  38531. .attr({
  38532. stroke: 'red',
  38533. 'stroke-width': 2,
  38534. fill: 'none',
  38535. zIndex: 9
  38536. })
  38537. .add();
  38538. this.chart.renderer.path(['M', leftContX + this.chart.plotLeft,
  38539. leftContY + this.chart.plotTop,
  38540. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  38541. .attr({
  38542. stroke: 'red',
  38543. 'stroke-width': 2,
  38544. zIndex: 9
  38545. })
  38546. .add();
  38547. }
  38548. if (rightContX) {
  38549. this.chart.renderer.circle(
  38550. rightContX + this.chart.plotLeft,
  38551. rightContY + this.chart.plotTop,
  38552. 2
  38553. )
  38554. .attr({
  38555. stroke: 'green',
  38556. 'stroke-width': 2,
  38557. fill: 'none',
  38558. zIndex: 9
  38559. })
  38560. .add();
  38561. this.chart.renderer.path(['M', rightContX + this.chart.plotLeft,
  38562. rightContY + this.chart.plotTop,
  38563. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  38564. .attr({
  38565. stroke: 'green',
  38566. 'stroke-width': 2,
  38567. zIndex: 9
  38568. })
  38569. .add();
  38570. }
  38571. // */
  38572. ret = [
  38573. 'C',
  38574. pick(lastPoint.rightContX, lastPoint.plotX, 0),
  38575. pick(lastPoint.rightContY, lastPoint.plotY, 0),
  38576. pick(leftContX, plotX, 0),
  38577. pick(leftContY, plotY, 0),
  38578. plotX,
  38579. plotY
  38580. ];
  38581. // reset for updating series later
  38582. lastPoint.rightContX = lastPoint.rightContY = void 0;
  38583. return ret;
  38584. }
  38585. /* eslint-enable valid-jsdoc */
  38586. });
  38587. /**
  38588. * A `spline` series. If the [type](#series.spline.type) option is
  38589. * not specified, it is inherited from [chart.type](#chart.type).
  38590. *
  38591. * @extends series,plotOptions.spline
  38592. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  38593. * @product highcharts highstock
  38594. * @apioption series.spline
  38595. */
  38596. /**
  38597. * An array of data points for the series. For the `spline` series type,
  38598. * points can be given in the following ways:
  38599. *
  38600. * 1. An array of numerical values. In this case, the numerical values will be
  38601. * interpreted as `y` options. The `x` values will be automatically
  38602. * calculated, either starting at 0 and incremented by 1, or from
  38603. * `pointStart` and `pointInterval` given in the series options. If the axis
  38604. * has categories, these will be used. Example:
  38605. * ```js
  38606. * data: [0, 5, 3, 5]
  38607. * ```
  38608. *
  38609. * 2. An array of arrays with 2 values. In this case, the values correspond to
  38610. * `x,y`. If the first value is a string, it is applied as the name of the
  38611. * point, and the `x` value is inferred.
  38612. * ```js
  38613. * data: [
  38614. * [0, 9],
  38615. * [1, 2],
  38616. * [2, 8]
  38617. * ]
  38618. * ```
  38619. *
  38620. * 3. An array of objects with named values. The following snippet shows only a
  38621. * few settings, see the complete options set below. If the total number of
  38622. * data points exceeds the series'
  38623. * [turboThreshold](#series.spline.turboThreshold),
  38624. * this option is not available.
  38625. * ```js
  38626. * data: [{
  38627. * x: 1,
  38628. * y: 9,
  38629. * name: "Point2",
  38630. * color: "#00FF00"
  38631. * }, {
  38632. * x: 1,
  38633. * y: 0,
  38634. * name: "Point1",
  38635. * color: "#FF00FF"
  38636. * }]
  38637. * ```
  38638. *
  38639. * @sample {highcharts} highcharts/chart/reflow-true/
  38640. * Numerical values
  38641. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  38642. * Arrays of numeric x and y
  38643. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  38644. * Arrays of datetime x and y
  38645. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  38646. * Arrays of point.name and y
  38647. * @sample {highcharts} highcharts/series/data-array-of-objects/
  38648. * Config objects
  38649. *
  38650. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  38651. * @extends series.line.data
  38652. * @product highcharts highstock
  38653. * @apioption series.spline.data
  38654. */
  38655. ''; // adds doclets above intro transpilat
  38656. });
  38657. _registerModule(_modules, 'Series/AreaSplineSeries.js', [_modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Options.js'], _modules['Core/Utilities.js']], function (H, LegendSymbolMixin, O, U) {
  38658. /* *
  38659. *
  38660. * (c) 2010-2020 Torstein Honsi
  38661. *
  38662. * License: www.highcharts.com/license
  38663. *
  38664. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38665. *
  38666. * */
  38667. var defaultOptions = O.defaultOptions;
  38668. var seriesType = U.seriesType;
  38669. var areaProto = H.seriesTypes.area.prototype;
  38670. /**
  38671. * AreaSpline series type.
  38672. *
  38673. * @private
  38674. * @class
  38675. * @name Highcharts.seriesTypes.areaspline
  38676. *
  38677. * @augments Highcharts.Series
  38678. */
  38679. seriesType('areaspline', 'spline',
  38680. /**
  38681. * The area spline series is an area series where the graph between the
  38682. * points is smoothed into a spline.
  38683. *
  38684. * @sample {highcharts} highcharts/demo/areaspline/
  38685. * Area spline chart
  38686. * @sample {highstock} stock/demo/areaspline/
  38687. * Area spline chart
  38688. *
  38689. * @extends plotOptions.area
  38690. * @excluding step, boostThreshold, boostBlending
  38691. * @product highcharts highstock
  38692. * @apioption plotOptions.areaspline
  38693. */
  38694. defaultOptions.plotOptions.area, {
  38695. getStackPoints: areaProto.getStackPoints,
  38696. getGraphPath: areaProto.getGraphPath,
  38697. drawGraph: areaProto.drawGraph,
  38698. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  38699. });
  38700. /**
  38701. * A `areaspline` series. If the [type](#series.areaspline.type) option
  38702. * is not specified, it is inherited from [chart.type](#chart.type).
  38703. *
  38704. *
  38705. * @extends series,plotOptions.areaspline
  38706. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  38707. * @product highcharts highstock
  38708. * @apioption series.areaspline
  38709. */
  38710. /**
  38711. * An array of data points for the series. For the `areaspline` series
  38712. * type, points can be given in the following ways:
  38713. *
  38714. * 1. An array of numerical values. In this case, the numerical values will be
  38715. * interpreted as `y` options. The `x` values will be automatically
  38716. * calculated, either starting at 0 and incremented by 1, or from
  38717. * `pointStart` and `pointInterval` given in the series options. If the axis
  38718. * has categories, these will be used. Example:
  38719. * ```js
  38720. * data: [0, 5, 3, 5]
  38721. * ```
  38722. *
  38723. * 2. An array of arrays with 2 values. In this case, the values correspond to
  38724. * `x,y`. If the first value is a string, it is applied as the name of the
  38725. * point, and the `x` value is inferred.
  38726. * ```js
  38727. * data: [
  38728. * [0, 10],
  38729. * [1, 9],
  38730. * [2, 3]
  38731. * ]
  38732. * ```
  38733. *
  38734. * 3. An array of objects with named values. The following snippet shows only a
  38735. * few settings, see the complete options set below. If the total number of
  38736. * data points exceeds the series'
  38737. * [turboThreshold](#series.areaspline.turboThreshold), this option is not
  38738. * available.
  38739. * ```js
  38740. * data: [{
  38741. * x: 1,
  38742. * y: 4,
  38743. * name: "Point2",
  38744. * color: "#00FF00"
  38745. * }, {
  38746. * x: 1,
  38747. * y: 4,
  38748. * name: "Point1",
  38749. * color: "#FF00FF"
  38750. * }]
  38751. * ```
  38752. *
  38753. * @sample {highcharts} highcharts/chart/reflow-true/
  38754. * Numerical values
  38755. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  38756. * Arrays of numeric x and y
  38757. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  38758. * Arrays of datetime x and y
  38759. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  38760. * Arrays of point.name and y
  38761. * @sample {highcharts} highcharts/series/data-array-of-objects/
  38762. * Config objects
  38763. *
  38764. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  38765. * @extends series.line.data
  38766. * @product highcharts highstock
  38767. * @apioption series.areaspline.data
  38768. */
  38769. ''; // adds doclets above into transpilat
  38770. });
  38771. _registerModule(_modules, 'Series/ColumnSeries.js', [_modules['Core/Globals.js'], _modules['Core/Color.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Utilities.js']], function (H, Color, LegendSymbolMixin, U) {
  38772. /* *
  38773. *
  38774. * (c) 2010-2020 Torstein Honsi
  38775. *
  38776. * License: www.highcharts.com/license
  38777. *
  38778. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38779. *
  38780. * */
  38781. /**
  38782. * Adjusted width and x offset of the columns for grouping.
  38783. *
  38784. * @private
  38785. * @interface Highcharts.ColumnMetricsObject
  38786. */ /**
  38787. * Width of the columns.
  38788. * @name Highcharts.ColumnMetricsObject#width
  38789. * @type {number}
  38790. */ /**
  38791. * Offset of the columns.
  38792. * @name Highcharts.ColumnMetricsObject#offset
  38793. * @type {number}
  38794. */
  38795. ''; // detach doclets above
  38796. var color = Color.parse;
  38797. var animObject = U.animObject,
  38798. clamp = U.clamp,
  38799. defined = U.defined,
  38800. extend = U.extend,
  38801. isNumber = U.isNumber,
  38802. merge = U.merge,
  38803. pick = U.pick,
  38804. seriesType = U.seriesType,
  38805. objectEach = U.objectEach;
  38806. var noop = H.noop,
  38807. Series = H.Series,
  38808. svg = H.svg;
  38809. /**
  38810. * The column series type.
  38811. *
  38812. * @private
  38813. * @class
  38814. * @name Highcharts.seriesTypes.column
  38815. *
  38816. * @augments Highcharts.Series
  38817. */
  38818. seriesType('column', 'line',
  38819. /**
  38820. * Column series display one column per value along an X axis.
  38821. *
  38822. * @sample {highcharts} highcharts/demo/column-basic/
  38823. * Column chart
  38824. * @sample {highstock} stock/demo/column/
  38825. * Column chart
  38826. *
  38827. * @extends plotOptions.line
  38828. * @excluding connectEnds, connectNulls, gapSize, gapUnit, linecap,
  38829. * lineWidth, marker, step, useOhlcData
  38830. * @product highcharts highstock
  38831. * @optionparent plotOptions.column
  38832. */
  38833. {
  38834. /**
  38835. * The corner radius of the border surrounding each column or bar.
  38836. *
  38837. * @sample {highcharts} highcharts/plotoptions/column-borderradius/
  38838. * Rounded columns
  38839. *
  38840. * @product highcharts highstock gantt
  38841. *
  38842. * @private
  38843. */
  38844. borderRadius: 0,
  38845. /**
  38846. * When using automatic point colors pulled from the global
  38847. * [colors](colors) or series-specific
  38848. * [plotOptions.column.colors](series.colors) collections, this option
  38849. * determines whether the chart should receive one color per series or
  38850. * one color per point.
  38851. *
  38852. * In styled mode, the `colors` or `series.colors` arrays are not
  38853. * supported, and instead this option gives the points individual color
  38854. * class names on the form `highcharts-color-{n}`.
  38855. *
  38856. * @see [series colors](#plotOptions.column.colors)
  38857. *
  38858. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-false/
  38859. * False by default
  38860. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-true/
  38861. * True
  38862. *
  38863. * @type {boolean}
  38864. * @default false
  38865. * @since 2.0
  38866. * @product highcharts highstock gantt
  38867. * @apioption plotOptions.column.colorByPoint
  38868. */
  38869. /**
  38870. * A series specific or series type specific color set to apply instead
  38871. * of the global [colors](#colors) when [colorByPoint](
  38872. * #plotOptions.column.colorByPoint) is true.
  38873. *
  38874. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  38875. * @since 3.0
  38876. * @product highcharts highstock gantt
  38877. * @apioption plotOptions.column.colors
  38878. */
  38879. /**
  38880. * When `true`, the columns will center in the category, ignoring null
  38881. * or missing points. When `false`, space will be reserved for null or
  38882. * missing points.
  38883. *
  38884. * @sample {highcharts} highcharts/series-column/centerincategory/
  38885. * Center in category
  38886. *
  38887. * @since 8.0.1
  38888. * @product highcharts highstock gantt
  38889. */
  38890. centerInCategory: false,
  38891. /**
  38892. * Padding between each value groups, in x axis units.
  38893. *
  38894. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-default/
  38895. * 0.2 by default
  38896. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-none/
  38897. * No group padding - all columns are evenly spaced
  38898. *
  38899. * @product highcharts highstock gantt
  38900. *
  38901. * @private
  38902. */
  38903. groupPadding: 0.2,
  38904. /**
  38905. * Whether to group non-stacked columns or to let them render
  38906. * independent of each other. Non-grouped columns will be laid out
  38907. * individually and overlap each other.
  38908. *
  38909. * @sample {highcharts} highcharts/plotoptions/column-grouping-false/
  38910. * Grouping disabled
  38911. * @sample {highstock} highcharts/plotoptions/column-grouping-false/
  38912. * Grouping disabled
  38913. *
  38914. * @type {boolean}
  38915. * @default true
  38916. * @since 2.3.0
  38917. * @product highcharts highstock gantt
  38918. * @apioption plotOptions.column.grouping
  38919. */
  38920. /**
  38921. * @ignore-option
  38922. * @private
  38923. */
  38924. marker: null,
  38925. /**
  38926. * The maximum allowed pixel width for a column, translated to the
  38927. * height of a bar in a bar chart. This prevents the columns from
  38928. * becoming too wide when there is a small number of points in the
  38929. * chart.
  38930. *
  38931. * @see [pointWidth](#plotOptions.column.pointWidth)
  38932. *
  38933. * @sample {highcharts} highcharts/plotoptions/column-maxpointwidth-20/
  38934. * Limited to 50
  38935. * @sample {highstock} highcharts/plotoptions/column-maxpointwidth-20/
  38936. * Limited to 50
  38937. *
  38938. * @type {number}
  38939. * @since 4.1.8
  38940. * @product highcharts highstock gantt
  38941. * @apioption plotOptions.column.maxPointWidth
  38942. */
  38943. /**
  38944. * Padding between each column or bar, in x axis units.
  38945. *
  38946. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-default/
  38947. * 0.1 by default
  38948. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-025/
  38949. * 0.25
  38950. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-none/
  38951. * 0 for tightly packed columns
  38952. *
  38953. * @product highcharts highstock gantt
  38954. *
  38955. * @private
  38956. */
  38957. pointPadding: 0.1,
  38958. /**
  38959. * A pixel value specifying a fixed width for each column or bar point.
  38960. * When `null`, the width is calculated from the `pointPadding` and
  38961. * `groupPadding`. The width effects the dimension that is not based on
  38962. * the point value. For column series it is the hoizontal length and for
  38963. * bar series it is the vertical length.
  38964. *
  38965. * @see [maxPointWidth](#plotOptions.column.maxPointWidth)
  38966. *
  38967. * @sample {highcharts} highcharts/plotoptions/column-pointwidth-20/
  38968. * 20px wide columns regardless of chart width or the amount of
  38969. * data points
  38970. *
  38971. * @type {number}
  38972. * @since 1.2.5
  38973. * @product highcharts highstock gantt
  38974. * @apioption plotOptions.column.pointWidth
  38975. */
  38976. /**
  38977. * A pixel value specifying a fixed width for the column or bar.
  38978. * Overrides pointWidth on the series.
  38979. *
  38980. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  38981. *
  38982. * @type {number}
  38983. * @default undefined
  38984. * @since 7.0.0
  38985. * @product highcharts highstock gantt
  38986. * @apioption series.column.data.pointWidth
  38987. */
  38988. /**
  38989. * The minimal height for a column or width for a bar. By default,
  38990. * 0 values are not shown. To visualize a 0 (or close to zero) point,
  38991. * set the minimal point length to a pixel value like 3\. In stacked
  38992. * column charts, minPointLength might not be respected for tightly
  38993. * packed values.
  38994. *
  38995. * @sample {highcharts} highcharts/plotoptions/column-minpointlength/
  38996. * Zero base value
  38997. * @sample {highcharts} highcharts/plotoptions/column-minpointlength-pos-and-neg/
  38998. * Positive and negative close to zero values
  38999. *
  39000. * @product highcharts highstock gantt
  39001. *
  39002. * @private
  39003. */
  39004. minPointLength: 0,
  39005. /**
  39006. * When the series contains less points than the crop threshold, all
  39007. * points are drawn, event if the points fall outside the visible plot
  39008. * area at the current zoom. The advantage of drawing all points
  39009. * (including markers and columns), is that animation is performed on
  39010. * updates. On the other hand, when the series contains more points than
  39011. * the crop threshold, the series data is cropped to only contain points
  39012. * that fall within the plot area. The advantage of cropping away
  39013. * invisible points is to increase performance on large series.
  39014. *
  39015. * @product highcharts highstock gantt
  39016. *
  39017. * @private
  39018. */
  39019. cropThreshold: 50,
  39020. /**
  39021. * The X axis range that each point is valid for. This determines the
  39022. * width of the column. On a categorized axis, the range will be 1
  39023. * by default (one category unit). On linear and datetime axes, the
  39024. * range will be computed as the distance between the two closest data
  39025. * points.
  39026. *
  39027. * The default `null` means it is computed automatically, but this
  39028. * option can be used to override the automatic value.
  39029. *
  39030. * This option is set by default to 1 if data sorting is enabled.
  39031. *
  39032. * @sample {highcharts} highcharts/plotoptions/column-pointrange/
  39033. * Set the point range to one day on a data set with one week
  39034. * between the points
  39035. *
  39036. * @type {number|null}
  39037. * @since 2.3
  39038. * @product highcharts highstock gantt
  39039. *
  39040. * @private
  39041. */
  39042. pointRange: null,
  39043. states: {
  39044. /**
  39045. * Options for the hovered point. These settings override the normal
  39046. * state options when a point is moused over or touched.
  39047. *
  39048. * @extends plotOptions.series.states.hover
  39049. * @excluding halo, lineWidth, lineWidthPlus, marker
  39050. * @product highcharts highstock gantt
  39051. */
  39052. hover: {
  39053. /** @ignore-option */
  39054. halo: false,
  39055. /**
  39056. * A specific border color for the hovered point. Defaults to
  39057. * inherit the normal state border color.
  39058. *
  39059. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39060. * @product highcharts gantt
  39061. * @apioption plotOptions.column.states.hover.borderColor
  39062. */
  39063. /**
  39064. * A specific color for the hovered point.
  39065. *
  39066. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39067. * @product highcharts gantt
  39068. * @apioption plotOptions.column.states.hover.color
  39069. */
  39070. /**
  39071. * How much to brighten the point on interaction. Requires the
  39072. * main color to be defined in hex or rgb(a) format.
  39073. *
  39074. * In styled mode, the hover brightening is by default replaced
  39075. * with a fill-opacity set in the `.highcharts-point:hover`
  39076. * rule.
  39077. *
  39078. * @sample {highcharts} highcharts/plotoptions/column-states-hover-brightness/
  39079. * Brighten by 0.5
  39080. *
  39081. * @product highcharts highstock gantt
  39082. */
  39083. brightness: 0.1
  39084. },
  39085. /**
  39086. * Options for the selected point. These settings override the
  39087. * normal state options when a point is selected.
  39088. *
  39089. * @extends plotOptions.series.states.select
  39090. * @excluding halo, lineWidth, lineWidthPlus, marker
  39091. * @product highcharts highstock gantt
  39092. */
  39093. select: {
  39094. /**
  39095. * A specific color for the selected point.
  39096. *
  39097. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39098. * @default #cccccc
  39099. * @product highcharts highstock gantt
  39100. */
  39101. color: '#cccccc',
  39102. /**
  39103. * A specific border color for the selected point.
  39104. *
  39105. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39106. * @default #000000
  39107. * @product highcharts highstock gantt
  39108. */
  39109. borderColor: '#000000'
  39110. }
  39111. },
  39112. dataLabels: {
  39113. align: void 0,
  39114. verticalAlign: void 0,
  39115. /**
  39116. * The y position offset of the label relative to the point in
  39117. * pixels.
  39118. *
  39119. * @type {number}
  39120. */
  39121. y: void 0
  39122. },
  39123. // false doesn't work well: https://jsfiddle.net/highcharts/hz8fopan/14/
  39124. /**
  39125. * @ignore-option
  39126. * @private
  39127. */
  39128. startFromThreshold: true,
  39129. stickyTracking: false,
  39130. tooltip: {
  39131. distance: 6
  39132. },
  39133. /**
  39134. * The Y axis value to serve as the base for the columns, for
  39135. * distinguishing between values above and below a threshold. If `null`,
  39136. * the columns extend from the padding Y axis minimum.
  39137. *
  39138. * @type {number|null}
  39139. * @since 2.0
  39140. * @product highcharts
  39141. *
  39142. * @private
  39143. */
  39144. threshold: 0,
  39145. /**
  39146. * The width of the border surrounding each column or bar. Defaults to
  39147. * `1` when there is room for a border, but to `0` when the columns are
  39148. * so dense that a border would cover the next column.
  39149. *
  39150. * In styled mode, the stroke width can be set with the
  39151. * `.highcharts-point` rule.
  39152. *
  39153. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  39154. * 2px black border
  39155. *
  39156. * @type {number}
  39157. * @default undefined
  39158. * @product highcharts highstock gantt
  39159. * @apioption plotOptions.column.borderWidth
  39160. */
  39161. /**
  39162. * The color of the border surrounding each column or bar.
  39163. *
  39164. * In styled mode, the border stroke can be set with the
  39165. * `.highcharts-point` rule.
  39166. *
  39167. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  39168. * Dark gray border
  39169. *
  39170. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39171. * @default #ffffff
  39172. * @product highcharts highstock gantt
  39173. *
  39174. * @private
  39175. */
  39176. borderColor: '#ffffff'
  39177. },
  39178. /**
  39179. * @lends seriesTypes.column.prototype
  39180. */
  39181. {
  39182. cropShoulder: 0,
  39183. // When tooltip is not shared, this series (and derivatives) requires
  39184. // direct touch/hover. KD-tree does not apply.
  39185. directTouch: true,
  39186. trackerGroups: ['group', 'dataLabelsGroup'],
  39187. // use separate negative stacks, unlike area stacks where a negative
  39188. // point is substracted from previous (#1910)
  39189. negStacks: true,
  39190. /* eslint-disable valid-jsdoc */
  39191. /**
  39192. * Initialize the series. Extends the basic Series.init method by
  39193. * marking other series of the same type as dirty.
  39194. *
  39195. * @private
  39196. * @function Highcharts.seriesTypes.column#init
  39197. * @return {void}
  39198. */
  39199. init: function () {
  39200. Series.prototype.init.apply(this, arguments);
  39201. var series = this,
  39202. chart = series.chart;
  39203. // if the series is added dynamically, force redraw of other
  39204. // series affected by a new column
  39205. if (chart.hasRendered) {
  39206. chart.series.forEach(function (otherSeries) {
  39207. if (otherSeries.type === series.type) {
  39208. otherSeries.isDirty = true;
  39209. }
  39210. });
  39211. }
  39212. },
  39213. /**
  39214. * Return the width and x offset of the columns adjusted for grouping,
  39215. * groupPadding, pointPadding, pointWidth etc.
  39216. *
  39217. * @private
  39218. * @function Highcharts.seriesTypes.column#getColumnMetrics
  39219. * @return {Highcharts.ColumnMetricsObject}
  39220. */
  39221. getColumnMetrics: function () {
  39222. var series = this,
  39223. options = series.options,
  39224. xAxis = series.xAxis,
  39225. yAxis = series.yAxis,
  39226. reversedStacks = xAxis.options.reversedStacks,
  39227. // Keep backward compatibility: reversed xAxis had reversed
  39228. // stacks
  39229. reverseStacks = (xAxis.reversed && !reversedStacks) ||
  39230. (!xAxis.reversed && reversedStacks),
  39231. stackKey,
  39232. stackGroups = {},
  39233. columnCount = 0;
  39234. // Get the total number of column type series. This is called on
  39235. // every series. Consider moving this logic to a chart.orderStacks()
  39236. // function and call it on init, addSeries and removeSeries
  39237. if (options.grouping === false) {
  39238. columnCount = 1;
  39239. }
  39240. else {
  39241. series.chart.series.forEach(function (otherSeries) {
  39242. var otherYAxis = otherSeries.yAxis,
  39243. otherOptions = otherSeries.options,
  39244. columnIndex;
  39245. if (otherSeries.type === series.type &&
  39246. (otherSeries.visible ||
  39247. !series.chart.options.chart
  39248. .ignoreHiddenSeries) &&
  39249. yAxis.len === otherYAxis.len &&
  39250. yAxis.pos === otherYAxis.pos) { // #642, #2086
  39251. if (otherOptions.stacking && otherOptions.stacking !== 'group') {
  39252. stackKey = otherSeries.stackKey;
  39253. if (typeof stackGroups[stackKey] ===
  39254. 'undefined') {
  39255. stackGroups[stackKey] = columnCount++;
  39256. }
  39257. columnIndex = stackGroups[stackKey];
  39258. }
  39259. else if (otherOptions.grouping !== false) { // #1162
  39260. columnIndex = columnCount++;
  39261. }
  39262. otherSeries.columnIndex = columnIndex;
  39263. }
  39264. });
  39265. }
  39266. var categoryWidth = Math.min(Math.abs(xAxis.transA) * ((xAxis.ordinal && xAxis.ordinal.slope) ||
  39267. options.pointRange ||
  39268. xAxis.closestPointRange ||
  39269. xAxis.tickInterval ||
  39270. 1), // #2610
  39271. xAxis.len // #1535
  39272. ),
  39273. groupPadding = categoryWidth * options.groupPadding,
  39274. groupWidth = categoryWidth - 2 * groupPadding,
  39275. pointOffsetWidth = groupWidth / (columnCount || 1),
  39276. pointWidth = Math.min(options.maxPointWidth || xAxis.len,
  39277. pick(options.pointWidth,
  39278. pointOffsetWidth * (1 - 2 * options.pointPadding))),
  39279. pointPadding = (pointOffsetWidth - pointWidth) / 2,
  39280. // #1251, #3737
  39281. colIndex = (series.columnIndex || 0) + (reverseStacks ? 1 : 0),
  39282. pointXOffset = pointPadding +
  39283. (groupPadding +
  39284. colIndex * pointOffsetWidth -
  39285. (categoryWidth / 2)) * (reverseStacks ? -1 : 1);
  39286. // Save it for reading in linked series (Error bars particularly)
  39287. series.columnMetrics = {
  39288. width: pointWidth,
  39289. offset: pointXOffset,
  39290. paddedWidth: pointOffsetWidth,
  39291. columnCount: columnCount
  39292. };
  39293. return series.columnMetrics;
  39294. },
  39295. /**
  39296. * Make the columns crisp. The edges are rounded to the nearest full
  39297. * pixel.
  39298. *
  39299. * @private
  39300. * @function Highcharts.seriesTypes.column#crispCol
  39301. * @param {number} x
  39302. * @param {number} y
  39303. * @param {number} w
  39304. * @param {number} h
  39305. * @return {Highcharts.BBoxObject}
  39306. */
  39307. crispCol: function (x, y, w, h) {
  39308. var chart = this.chart,
  39309. borderWidth = this.borderWidth,
  39310. xCrisp = -(borderWidth % 2 ? 0.5 : 0),
  39311. yCrisp = borderWidth % 2 ? 0.5 : 1,
  39312. right,
  39313. bottom,
  39314. fromTop;
  39315. if (chart.inverted && chart.renderer.isVML) {
  39316. yCrisp += 1;
  39317. }
  39318. // Horizontal. We need to first compute the exact right edge, then
  39319. // round it and compute the width from there.
  39320. if (this.options.crisp) {
  39321. right = Math.round(x + w) + xCrisp;
  39322. x = Math.round(x) + xCrisp;
  39323. w = right - x;
  39324. }
  39325. // Vertical
  39326. bottom = Math.round(y + h) + yCrisp;
  39327. fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
  39328. y = Math.round(y) + yCrisp;
  39329. h = bottom - y;
  39330. // Top edges are exceptions
  39331. if (fromTop && h) { // #5146
  39332. y -= 1;
  39333. h += 1;
  39334. }
  39335. return {
  39336. x: x,
  39337. y: y,
  39338. width: w,
  39339. height: h
  39340. };
  39341. },
  39342. /**
  39343. * Adjust for missing columns, according to the `centerInCategory`
  39344. * option. Missing columns are either single points or stacks where the
  39345. * point or points are either missing or null.
  39346. *
  39347. * @private
  39348. * @function Highcharts.seriesTypes.column#adjustForMissingColumns
  39349. * @param {number} x
  39350. * The x coordinate of the column, left side
  39351. * @param {number} pointWidth
  39352. * The pointWidth, already computed upstream
  39353. * @param {Highcharts.ColumnPoint} point
  39354. * The point instance
  39355. * @param {Highcharts.ColumnMetricsObject} metrics
  39356. * The series-wide column metrics
  39357. * @return {number}
  39358. * The adjusted x position, or the original if not adjusted
  39359. */
  39360. adjustForMissingColumns: function (x, pointWidth, point, metrics) {
  39361. var _this = this;
  39362. var stacking = this.options.stacking;
  39363. if (!point.isNull && metrics.columnCount > 1) {
  39364. var indexInCategory_1 = 0;
  39365. var totalInCategory_1 = 0;
  39366. // Loop over all the stacks on the Y axis. When stacking is
  39367. // enabled, these are real point stacks. When stacking is not
  39368. // enabled, but `centerInCategory` is true, there is one stack
  39369. // handling the grouping of points in each category. This is
  39370. // done in the `setGroupedPoints` function.
  39371. objectEach(this.yAxis.stacking && this.yAxis.stacking.stacks, function (stack) {
  39372. if (typeof point.x === 'number') {
  39373. var stackItem = stack[point.x.toString()];
  39374. if (stackItem) {
  39375. var pointValues = stackItem.points[_this.index],
  39376. total = stackItem.total;
  39377. // If true `stacking` is enabled, count the
  39378. // total number of non-null stacks in the
  39379. // category, and note which index this point is
  39380. // within those stacks.
  39381. if (stacking) {
  39382. if (pointValues) {
  39383. indexInCategory_1 = totalInCategory_1;
  39384. }
  39385. if (stackItem.hasValidPoints) {
  39386. totalInCategory_1++;
  39387. }
  39388. // If `stacking` is not enabled, look for the
  39389. // index and total of the `group` stack.
  39390. }
  39391. else if (H.isArray(pointValues)) {
  39392. indexInCategory_1 = pointValues[1];
  39393. totalInCategory_1 = total || 0;
  39394. }
  39395. }
  39396. }
  39397. });
  39398. // Compute the adjusted x position
  39399. var boxWidth = (totalInCategory_1 - 1) * metrics.paddedWidth +
  39400. pointWidth;
  39401. x = (point.plotX || 0) + boxWidth / 2 - pointWidth -
  39402. indexInCategory_1 * metrics.paddedWidth;
  39403. }
  39404. return x;
  39405. },
  39406. /**
  39407. * Translate each point to the plot area coordinate system and find
  39408. * shape positions
  39409. *
  39410. * @private
  39411. * @function Highcharts.seriesTypes.column#translate
  39412. */
  39413. translate: function () {
  39414. var series = this,
  39415. chart = series.chart,
  39416. options = series.options,
  39417. dense = series.dense =
  39418. series.closestPointRange * series.xAxis.transA < 2,
  39419. borderWidth = series.borderWidth = pick(options.borderWidth,
  39420. dense ? 0 : 1 // #3635
  39421. ),
  39422. xAxis = series.xAxis,
  39423. yAxis = series.yAxis,
  39424. threshold = options.threshold,
  39425. translatedThreshold = series.translatedThreshold =
  39426. yAxis.getThreshold(threshold),
  39427. minPointLength = pick(options.minPointLength, 5),
  39428. metrics = series.getColumnMetrics(),
  39429. seriesPointWidth = metrics.width,
  39430. // postprocessed for border width
  39431. seriesBarW = series.barW =
  39432. Math.max(seriesPointWidth, 1 + 2 * borderWidth),
  39433. seriesXOffset = series.pointXOffset = metrics.offset,
  39434. dataMin = series.dataMin,
  39435. dataMax = series.dataMax;
  39436. if (chart.inverted) {
  39437. translatedThreshold -= 0.5; // #3355
  39438. }
  39439. // When the pointPadding is 0, we want the columns to be packed
  39440. // tightly, so we allow individual columns to have individual sizes.
  39441. // When pointPadding is greater, we strive for equal-width columns
  39442. // (#2694).
  39443. if (options.pointPadding) {
  39444. seriesBarW = Math.ceil(seriesBarW);
  39445. }
  39446. Series.prototype.translate.apply(series);
  39447. // Record the new values
  39448. series.points.forEach(function (point) {
  39449. var yBottom = pick(point.yBottom,
  39450. translatedThreshold),
  39451. safeDistance = 999 + Math.abs(yBottom),
  39452. pointWidth = seriesPointWidth,
  39453. plotX = point.plotX || 0,
  39454. // Don't draw too far outside plot area (#1303, #2241,
  39455. // #4264)
  39456. plotY = clamp(point.plotY, -safeDistance,
  39457. yAxis.len + safeDistance),
  39458. barX = plotX + seriesXOffset,
  39459. barW = seriesBarW,
  39460. barY = Math.min(plotY,
  39461. yBottom),
  39462. up,
  39463. barH = Math.max(plotY,
  39464. yBottom) - barY;
  39465. // Handle options.minPointLength
  39466. if (minPointLength && Math.abs(barH) < minPointLength) {
  39467. barH = minPointLength;
  39468. up = (!yAxis.reversed && !point.negative) ||
  39469. (yAxis.reversed && point.negative);
  39470. // Reverse zeros if there's no positive value in the series
  39471. // in visible range (#7046)
  39472. if (isNumber(threshold) &&
  39473. isNumber(dataMax) &&
  39474. point.y === threshold &&
  39475. dataMax <= threshold &&
  39476. // and if there's room for it (#7311)
  39477. (yAxis.min || 0) < threshold &&
  39478. // if all points are the same value (i.e zero) not draw
  39479. // as negative points (#10646)
  39480. dataMin !== dataMax) {
  39481. up = !up;
  39482. }
  39483. // If stacked...
  39484. barY = (Math.abs(barY - translatedThreshold) > minPointLength ?
  39485. // ...keep position
  39486. yBottom - minPointLength :
  39487. // #1485, #4051
  39488. translatedThreshold -
  39489. (up ? minPointLength : 0));
  39490. }
  39491. // Handle point.options.pointWidth
  39492. // @todo Handle grouping/stacking too. Calculate offset properly
  39493. if (defined(point.options.pointWidth)) {
  39494. pointWidth = barW =
  39495. Math.ceil(point.options.pointWidth);
  39496. barX -= Math.round((pointWidth - seriesPointWidth) / 2);
  39497. }
  39498. // Adjust for null or missing points
  39499. if (options.centerInCategory) {
  39500. barX = series.adjustForMissingColumns(barX, pointWidth, point, metrics);
  39501. }
  39502. // Cache for access in polar
  39503. point.barX = barX;
  39504. point.pointWidth = pointWidth;
  39505. // Fix the tooltip on center of grouped columns (#1216, #424,
  39506. // #3648)
  39507. point.tooltipPos = chart.inverted ?
  39508. [
  39509. yAxis.len + yAxis.pos - chart.plotLeft - plotY,
  39510. xAxis.len + xAxis.pos - chart.plotTop - (plotX || 0) - seriesXOffset - barW / 2,
  39511. barH
  39512. ] :
  39513. [barX + barW / 2, plotY + yAxis.pos -
  39514. chart.plotTop, barH];
  39515. // Register shape type and arguments to be used in drawPoints
  39516. // Allow shapeType defined on pointClass level
  39517. point.shapeType =
  39518. series.pointClass.prototype.shapeType || 'rect';
  39519. point.shapeArgs = series.crispCol.apply(series, point.isNull ?
  39520. // #3169, drilldown from null must have a position to work
  39521. // from #6585, dataLabel should be placed on xAxis, not
  39522. // floating in the middle of the chart
  39523. [barX, translatedThreshold, barW, 0] :
  39524. [barX, barY, barW, barH]);
  39525. });
  39526. },
  39527. getSymbol: noop,
  39528. /**
  39529. * Use a solid rectangle like the area series types
  39530. *
  39531. * @private
  39532. * @function Highcharts.seriesTypes.column#drawLegendSymbol
  39533. *
  39534. * @param {Highcharts.Legend} legend
  39535. * The legend object
  39536. *
  39537. * @param {Highcharts.Series|Highcharts.Point} item
  39538. * The series (this) or point
  39539. */
  39540. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  39541. /**
  39542. * Columns have no graph
  39543. *
  39544. * @private
  39545. * @function Highcharts.seriesTypes.column#drawGraph
  39546. */
  39547. drawGraph: function () {
  39548. this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
  39549. },
  39550. /**
  39551. * Get presentational attributes
  39552. *
  39553. * @private
  39554. * @function Highcharts.seriesTypes.column#pointAttribs
  39555. *
  39556. * @param {Highcharts.ColumnPoint} point
  39557. *
  39558. * @param {string} state
  39559. *
  39560. * @return {Highcharts.SVGAttributes}
  39561. */
  39562. pointAttribs: function (point, state) {
  39563. var options = this.options, stateOptions, ret, p2o = this.pointAttrToOptions || {}, strokeOption = p2o.stroke || 'borderColor', strokeWidthOption = p2o['stroke-width'] || 'borderWidth', fill = (point && point.color) || this.color,
  39564. // set to fill when borderColor null:
  39565. stroke = ((point && point[strokeOption]) ||
  39566. options[strokeOption] ||
  39567. this.color ||
  39568. fill), strokeWidth = (point && point[strokeWidthOption]) ||
  39569. options[strokeWidthOption] ||
  39570. this[strokeWidthOption] || 0, dashstyle = (point && point.options.dashStyle) || options.dashStyle, opacity = pick(point && point.opacity, options.opacity, 1), zone, brightness;
  39571. // Handle zone colors
  39572. if (point && this.zones.length) {
  39573. zone = point.getZone();
  39574. // When zones are present, don't use point.color (#4267).
  39575. // Changed order (#6527), added support for colorAxis (#10670)
  39576. fill = (point.options.color ||
  39577. (zone && (zone.color || point.nonZonedColor)) ||
  39578. this.color);
  39579. if (zone) {
  39580. stroke = zone.borderColor || stroke;
  39581. dashstyle = zone.dashStyle || dashstyle;
  39582. strokeWidth = zone.borderWidth || strokeWidth;
  39583. }
  39584. }
  39585. // Select or hover states
  39586. if (state && point) {
  39587. stateOptions = merge(options.states[state],
  39588. // #6401
  39589. point.options.states &&
  39590. point.options.states[state] ||
  39591. {});
  39592. brightness = stateOptions.brightness;
  39593. fill =
  39594. stateOptions.color || (typeof brightness !== 'undefined' &&
  39595. color(fill)
  39596. .brighten(stateOptions.brightness)
  39597. .get()) || fill;
  39598. stroke = stateOptions[strokeOption] || stroke;
  39599. strokeWidth =
  39600. stateOptions[strokeWidthOption] || strokeWidth;
  39601. dashstyle = stateOptions.dashStyle || dashstyle;
  39602. opacity = pick(stateOptions.opacity, opacity);
  39603. }
  39604. ret = {
  39605. fill: fill,
  39606. stroke: stroke,
  39607. 'stroke-width': strokeWidth,
  39608. opacity: opacity
  39609. };
  39610. if (dashstyle) {
  39611. ret.dashstyle = dashstyle;
  39612. }
  39613. return ret;
  39614. },
  39615. /**
  39616. * Draw the columns. For bars, the series.group is rotated, so the same
  39617. * coordinates apply for columns and bars. This method is inherited by
  39618. * scatter series.
  39619. *
  39620. * @private
  39621. * @function Highcharts.seriesTypes.column#drawPoints
  39622. */
  39623. drawPoints: function () {
  39624. var series = this,
  39625. chart = this.chart,
  39626. options = series.options,
  39627. renderer = chart.renderer,
  39628. animationLimit = options.animationLimit || 250,
  39629. shapeArgs;
  39630. // draw the columns
  39631. series.points.forEach(function (point) {
  39632. var plotY = point.plotY,
  39633. graphic = point.graphic,
  39634. hasGraphic = !!graphic,
  39635. verb = graphic && chart.pointCount < animationLimit ?
  39636. 'animate' : 'attr';
  39637. if (isNumber(plotY) && point.y !== null) {
  39638. shapeArgs = point.shapeArgs;
  39639. // When updating a series between 2d and 3d or cartesian and
  39640. // polar, the shape type changes.
  39641. if (graphic && point.hasNewShapeType()) {
  39642. graphic = graphic.destroy();
  39643. }
  39644. // Set starting position for point sliding animation.
  39645. if (series.enabledDataSorting) {
  39646. point.startXPos = series.xAxis.reversed ?
  39647. -(shapeArgs ? shapeArgs.width : 0) :
  39648. series.xAxis.width;
  39649. }
  39650. if (!graphic) {
  39651. point.graphic = graphic =
  39652. renderer[point.shapeType](shapeArgs)
  39653. .add(point.group || series.group);
  39654. if (graphic &&
  39655. series.enabledDataSorting &&
  39656. chart.hasRendered &&
  39657. chart.pointCount < animationLimit) {
  39658. graphic.attr({
  39659. x: point.startXPos
  39660. });
  39661. hasGraphic = true;
  39662. verb = 'animate';
  39663. }
  39664. }
  39665. if (graphic && hasGraphic) { // update
  39666. graphic[verb](merge(shapeArgs));
  39667. }
  39668. // Border radius is not stylable (#6900)
  39669. if (options.borderRadius) {
  39670. graphic[verb]({
  39671. r: options.borderRadius
  39672. });
  39673. }
  39674. // Presentational
  39675. if (!chart.styledMode) {
  39676. graphic[verb](series.pointAttribs(point, (point.selected && 'select')))
  39677. .shadow(point.allowShadow !== false && options.shadow, null, options.stacking && !options.borderRadius);
  39678. }
  39679. graphic.addClass(point.getClassName(), true);
  39680. }
  39681. else if (graphic) {
  39682. point.graphic = graphic.destroy(); // #1269
  39683. }
  39684. });
  39685. },
  39686. /**
  39687. * Animate the column heights one by one from zero.
  39688. *
  39689. * @private
  39690. * @function Highcharts.seriesTypes.column#animate
  39691. *
  39692. * @param {boolean} init
  39693. * Whether to initialize the animation or run it
  39694. */
  39695. animate: function (init) {
  39696. var series = this,
  39697. yAxis = this.yAxis,
  39698. options = series.options,
  39699. inverted = this.chart.inverted,
  39700. attr = {},
  39701. translateProp = inverted ? 'translateX' : 'translateY',
  39702. translateStart,
  39703. translatedThreshold;
  39704. if (init) {
  39705. attr.scaleY = 0.001;
  39706. translatedThreshold = clamp(yAxis.toPixels(options.threshold), yAxis.pos, yAxis.pos + yAxis.len);
  39707. if (inverted) {
  39708. attr.translateX = translatedThreshold - yAxis.len;
  39709. }
  39710. else {
  39711. attr.translateY = translatedThreshold;
  39712. }
  39713. // apply finnal clipping (used in Highstock) (#7083)
  39714. // animation is done by scaleY, so cliping is for panes
  39715. if (series.clipBox) {
  39716. series.setClip();
  39717. }
  39718. series.group.attr(attr);
  39719. }
  39720. else { // run the animation
  39721. translateStart = series.group.attr(translateProp);
  39722. series.group.animate({ scaleY: 1 }, extend(animObject(series.options.animation), {
  39723. // Do the scale synchronously to ensure smooth
  39724. // updating (#5030, #7228)
  39725. step: function (val, fx) {
  39726. if (series.group) {
  39727. attr[translateProp] = translateStart +
  39728. fx.pos * (yAxis.pos - translateStart);
  39729. series.group.attr(attr);
  39730. }
  39731. }
  39732. }));
  39733. }
  39734. },
  39735. /**
  39736. * Remove this series from the chart
  39737. *
  39738. * @private
  39739. * @function Highcharts.seriesTypes.column#remove
  39740. */
  39741. remove: function () {
  39742. var series = this,
  39743. chart = series.chart;
  39744. // column and bar series affects other series of the same type
  39745. // as they are either stacked or grouped
  39746. if (chart.hasRendered) {
  39747. chart.series.forEach(function (otherSeries) {
  39748. if (otherSeries.type === series.type) {
  39749. otherSeries.isDirty = true;
  39750. }
  39751. });
  39752. }
  39753. Series.prototype.remove.apply(series, arguments);
  39754. }
  39755. });
  39756. /* eslint-enable valid-jsdoc */
  39757. /**
  39758. * A `column` series. If the [type](#series.column.type) option is
  39759. * not specified, it is inherited from [chart.type](#chart.type).
  39760. *
  39761. * @extends series,plotOptions.column
  39762. * @excluding connectNulls, dataParser, dataURL, gapSize, gapUnit, linecap,
  39763. * lineWidth, marker, connectEnds, step
  39764. * @product highcharts highstock
  39765. * @apioption series.column
  39766. */
  39767. /**
  39768. * An array of data points for the series. For the `column` series type,
  39769. * points can be given in the following ways:
  39770. *
  39771. * 1. An array of numerical values. In this case, the numerical values will be
  39772. * interpreted as `y` options. The `x` values will be automatically
  39773. * calculated, either starting at 0 and incremented by 1, or from
  39774. * `pointStart` and `pointInterval` given in the series options. If the axis
  39775. * has categories, these will be used. Example:
  39776. * ```js
  39777. * data: [0, 5, 3, 5]
  39778. * ```
  39779. *
  39780. * 2. An array of arrays with 2 values. In this case, the values correspond to
  39781. * `x,y`. If the first value is a string, it is applied as the name of the
  39782. * point, and the `x` value is inferred.
  39783. * ```js
  39784. * data: [
  39785. * [0, 6],
  39786. * [1, 2],
  39787. * [2, 6]
  39788. * ]
  39789. * ```
  39790. *
  39791. * 3. An array of objects with named values. The following snippet shows only a
  39792. * few settings, see the complete options set below. If the total number of
  39793. * data points exceeds the series'
  39794. * [turboThreshold](#series.column.turboThreshold), this option is not
  39795. * available.
  39796. * ```js
  39797. * data: [{
  39798. * x: 1,
  39799. * y: 9,
  39800. * name: "Point2",
  39801. * color: "#00FF00"
  39802. * }, {
  39803. * x: 1,
  39804. * y: 6,
  39805. * name: "Point1",
  39806. * color: "#FF00FF"
  39807. * }]
  39808. * ```
  39809. *
  39810. * @sample {highcharts} highcharts/chart/reflow-true/
  39811. * Numerical values
  39812. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  39813. * Arrays of numeric x and y
  39814. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  39815. * Arrays of datetime x and y
  39816. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  39817. * Arrays of point.name and y
  39818. * @sample {highcharts} highcharts/series/data-array-of-objects/
  39819. * Config objects
  39820. *
  39821. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  39822. * @extends series.line.data
  39823. * @excluding marker
  39824. * @product highcharts highstock
  39825. * @apioption series.column.data
  39826. */
  39827. /**
  39828. * The color of the border surrounding the column or bar.
  39829. *
  39830. * In styled mode, the border stroke can be set with the `.highcharts-point`
  39831. * rule.
  39832. *
  39833. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  39834. * Dark gray border
  39835. *
  39836. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39837. * @product highcharts highstock
  39838. * @apioption series.column.data.borderColor
  39839. */
  39840. /**
  39841. * The width of the border surrounding the column or bar.
  39842. *
  39843. * In styled mode, the stroke width can be set with the `.highcharts-point`
  39844. * rule.
  39845. *
  39846. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  39847. * 2px black border
  39848. *
  39849. * @type {number}
  39850. * @product highcharts highstock
  39851. * @apioption series.column.data.borderWidth
  39852. */
  39853. /**
  39854. * A name for the dash style to use for the column or bar. Overrides
  39855. * dashStyle on the series.
  39856. *
  39857. * In styled mode, the stroke dash-array can be set with the same classes as
  39858. * listed under [data.color](#series.column.data.color).
  39859. *
  39860. * @see [series.pointWidth](#plotOptions.column.dashStyle)
  39861. *
  39862. * @type {Highcharts.DashStyleValue}
  39863. * @apioption series.column.data.dashStyle
  39864. */
  39865. /**
  39866. * A pixel value specifying a fixed width for the column or bar. Overrides
  39867. * pointWidth on the series. The width effects the dimension that is not based
  39868. * on the point value.
  39869. *
  39870. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  39871. *
  39872. * @type {number}
  39873. * @apioption series.column.data.pointWidth
  39874. */
  39875. /**
  39876. * @excluding halo, lineWidth, lineWidthPlus, marker
  39877. * @product highcharts highstock
  39878. * @apioption series.column.states.hover
  39879. */
  39880. /**
  39881. * @excluding halo, lineWidth, lineWidthPlus, marker
  39882. * @product highcharts highstock
  39883. * @apioption series.column.states.select
  39884. */
  39885. ''; // includes above doclets in transpilat
  39886. });
  39887. _registerModule(_modules, 'Series/BarSeries.js', [_modules['Core/Utilities.js']], function (U) {
  39888. /* *
  39889. *
  39890. * (c) 2010-2020 Torstein Honsi
  39891. *
  39892. * License: www.highcharts.com/license
  39893. *
  39894. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39895. *
  39896. * */
  39897. var seriesType = U.seriesType;
  39898. /**
  39899. * Bar series type.
  39900. *
  39901. * @private
  39902. * @class
  39903. * @name Highcharts.seriesTypes.bar
  39904. *
  39905. * @augments Highcharts.Series
  39906. */
  39907. seriesType('bar', 'column',
  39908. /**
  39909. * A bar series is a special type of column series where the columns are
  39910. * horizontal.
  39911. *
  39912. * @sample highcharts/demo/bar-basic/
  39913. * Bar chart
  39914. *
  39915. * @extends plotOptions.column
  39916. * @product highcharts
  39917. * @apioption plotOptions.bar
  39918. */
  39919. /**
  39920. * @ignore
  39921. */
  39922. null, {
  39923. inverted: true
  39924. });
  39925. /**
  39926. * A `bar` series. If the [type](#series.bar.type) option is not specified,
  39927. * it is inherited from [chart.type](#chart.type).
  39928. *
  39929. * @extends series,plotOptions.bar
  39930. * @excluding connectNulls, dashStyle, dataParser, dataURL, gapSize, gapUnit,
  39931. * linecap, lineWidth, marker, connectEnds, step
  39932. * @product highcharts
  39933. * @apioption series.bar
  39934. */
  39935. /**
  39936. * An array of data points for the series. For the `bar` series type,
  39937. * points can be given in the following ways:
  39938. *
  39939. * 1. An array of numerical values. In this case, the numerical values will be
  39940. * interpreted as `y` options. The `x` values will be automatically
  39941. * calculated, either starting at 0 and incremented by 1, or from
  39942. * `pointStart` and `pointInterval` given in the series options. If the axis
  39943. * has categories, these will be used. Example:
  39944. * ```js
  39945. * data: [0, 5, 3, 5]
  39946. * ```
  39947. *
  39948. * 2. An array of arrays with 2 values. In this case, the values correspond to
  39949. * `x,y`. If the first value is a string, it is applied as the name of the
  39950. * point, and the `x` value is inferred.
  39951. * ```js
  39952. * data: [
  39953. * [0, 5],
  39954. * [1, 10],
  39955. * [2, 3]
  39956. * ]
  39957. * ```
  39958. *
  39959. * 3. An array of objects with named values. The following snippet shows only a
  39960. * few settings, see the complete options set below. If the total number of
  39961. * data points exceeds the series'
  39962. * [turboThreshold](#series.bar.turboThreshold), this option is not
  39963. * available.
  39964. * ```js
  39965. * data: [{
  39966. * x: 1,
  39967. * y: 1,
  39968. * name: "Point2",
  39969. * color: "#00FF00"
  39970. * }, {
  39971. * x: 1,
  39972. * y: 10,
  39973. * name: "Point1",
  39974. * color: "#FF00FF"
  39975. * }]
  39976. * ```
  39977. *
  39978. * @sample {highcharts} highcharts/chart/reflow-true/
  39979. * Numerical values
  39980. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  39981. * Arrays of numeric x and y
  39982. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  39983. * Arrays of datetime x and y
  39984. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  39985. * Arrays of point.name and y
  39986. * @sample {highcharts} highcharts/series/data-array-of-objects/
  39987. * Config objects
  39988. *
  39989. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  39990. * @extends series.column.data
  39991. * @product highcharts
  39992. * @apioption series.bar.data
  39993. */
  39994. /**
  39995. * @excluding halo,lineWidth,lineWidthPlus,marker
  39996. * @product highcharts highstock
  39997. * @apioption series.bar.states.hover
  39998. */
  39999. /**
  40000. * @excluding halo,lineWidth,lineWidthPlus,marker
  40001. * @product highcharts highstock
  40002. * @apioption series.bar.states.select
  40003. */
  40004. ''; // gets doclets above into transpilat
  40005. });
  40006. _registerModule(_modules, 'Series/ScatterSeries.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  40007. /* *
  40008. *
  40009. * (c) 2010-2020 Torstein Honsi
  40010. *
  40011. * License: www.highcharts.com/license
  40012. *
  40013. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40014. *
  40015. * */
  40016. var addEvent = U.addEvent,
  40017. seriesType = U.seriesType;
  40018. var Series = H.Series;
  40019. /**
  40020. * Scatter series type.
  40021. *
  40022. * @private
  40023. * @class
  40024. * @name Highcharts.seriesTypes.scatter
  40025. *
  40026. * @augments Highcharts.Series
  40027. */
  40028. seriesType('scatter', 'line',
  40029. /**
  40030. * A scatter plot uses cartesian coordinates to display values for two
  40031. * variables for a set of data.
  40032. *
  40033. * @sample {highcharts} highcharts/demo/scatter/
  40034. * Scatter plot
  40035. *
  40036. * @extends plotOptions.line
  40037. * @excluding cropThreshold, pointPlacement, shadow, useOhlcData
  40038. * @product highcharts highstock
  40039. * @optionparent plotOptions.scatter
  40040. */
  40041. {
  40042. /**
  40043. * The width of the line connecting the data points.
  40044. *
  40045. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-none/
  40046. * 0 by default
  40047. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-1/
  40048. * 1px
  40049. *
  40050. * @product highcharts highstock
  40051. */
  40052. lineWidth: 0,
  40053. findNearestPointBy: 'xy',
  40054. /**
  40055. * Apply a jitter effect for the rendered markers. When plotting
  40056. * discrete values, a little random noise may help telling the points
  40057. * apart. The jitter setting applies a random displacement of up to `n`
  40058. * axis units in either direction. So for example on a horizontal X
  40059. * axis, setting the `jitter.x` to 0.24 will render the point in a
  40060. * random position between 0.24 units to the left and 0.24 units to the
  40061. * right of the true axis position. On a category axis, setting it to
  40062. * 0.5 will fill up the bin and make the data appear continuous.
  40063. *
  40064. * When rendered on top of a box plot or a column series, a jitter value
  40065. * of 0.24 will correspond to the underlying series' default
  40066. * [groupPadding](
  40067. * https://api.highcharts.com/highcharts/plotOptions.column.groupPadding)
  40068. * and [pointPadding](
  40069. * https://api.highcharts.com/highcharts/plotOptions.column.pointPadding)
  40070. * settings.
  40071. *
  40072. * @sample {highcharts} highcharts/series-scatter/jitter
  40073. * Jitter on a scatter plot
  40074. *
  40075. * @sample {highcharts} highcharts/series-scatter/jitter-boxplot
  40076. * Jittered scatter plot on top of a box plot
  40077. *
  40078. * @product highcharts highstock
  40079. * @since 7.0.2
  40080. */
  40081. jitter: {
  40082. /**
  40083. * The maximal X offset for the random jitter effect.
  40084. */
  40085. x: 0,
  40086. /**
  40087. * The maximal Y offset for the random jitter effect.
  40088. */
  40089. y: 0
  40090. },
  40091. marker: {
  40092. enabled: true // Overrides auto-enabling in line series (#3647)
  40093. },
  40094. /**
  40095. * Sticky tracking of mouse events. When true, the `mouseOut` event
  40096. * on a series isn't triggered until the mouse moves over another
  40097. * series, or out of the plot area. When false, the `mouseOut` event on
  40098. * a series is triggered when the mouse leaves the area around the
  40099. * series' graph or markers. This also implies the tooltip. When
  40100. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  40101. * will be hidden when moving the mouse between series.
  40102. *
  40103. * @type {boolean}
  40104. * @default false
  40105. * @product highcharts highstock
  40106. * @apioption plotOptions.scatter.stickyTracking
  40107. */
  40108. /**
  40109. * A configuration object for the tooltip rendering of each single
  40110. * series. Properties are inherited from [tooltip](#tooltip).
  40111. * Overridable properties are `headerFormat`, `pointFormat`,
  40112. * `yDecimals`, `xDateFormat`, `yPrefix` and `ySuffix`. Unlike other
  40113. * series, in a scatter plot the series.name by default shows in the
  40114. * headerFormat and point.x and point.y in the pointFormat.
  40115. *
  40116. * @product highcharts highstock
  40117. */
  40118. tooltip: {
  40119. headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  40120. '<span style="font-size: 10px"> {series.name}</span><br/>',
  40121. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
  40122. }
  40123. // Prototype members
  40124. }, {
  40125. sorted: false,
  40126. requireSorting: false,
  40127. noSharedTooltip: true,
  40128. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  40129. takeOrdinalPosition: false,
  40130. /* eslint-disable valid-jsdoc */
  40131. /**
  40132. * @private
  40133. * @function Highcharts.seriesTypes.scatter#drawGraph
  40134. */
  40135. drawGraph: function () {
  40136. if (this.options.lineWidth) {
  40137. Series.prototype.drawGraph.call(this);
  40138. }
  40139. },
  40140. // Optionally add the jitter effect
  40141. applyJitter: function () {
  40142. var series = this,
  40143. jitter = this.options.jitter,
  40144. len = this.points.length;
  40145. /**
  40146. * Return a repeatable, pseudo-random number based on an integer
  40147. * seed.
  40148. * @private
  40149. */
  40150. function unrandom(seed) {
  40151. var rand = Math.sin(seed) * 10000;
  40152. return rand - Math.floor(rand);
  40153. }
  40154. if (jitter) {
  40155. this.points.forEach(function (point, i) {
  40156. ['x', 'y'].forEach(function (dim, j) {
  40157. var axis,
  40158. plotProp = 'plot' + dim.toUpperCase(),
  40159. min,
  40160. max,
  40161. translatedJitter;
  40162. if (jitter[dim] && !point.isNull) {
  40163. axis = series[dim + 'Axis'];
  40164. translatedJitter =
  40165. jitter[dim] * axis.transA;
  40166. if (axis && !axis.isLog) {
  40167. // Identify the outer bounds of the jitter range
  40168. min = Math.max(0, point[plotProp] - translatedJitter);
  40169. max = Math.min(axis.len, point[plotProp] + translatedJitter);
  40170. // Find a random position within this range
  40171. point[plotProp] = min +
  40172. (max - min) * unrandom(i + j * len);
  40173. // Update clientX for the tooltip k-d-tree
  40174. if (dim === 'x') {
  40175. point.clientX = point.plotX;
  40176. }
  40177. }
  40178. }
  40179. });
  40180. });
  40181. }
  40182. }
  40183. /* eslint-enable valid-jsdoc */
  40184. });
  40185. /* eslint-disable no-invalid-this */
  40186. addEvent(Series, 'afterTranslate', function () {
  40187. if (this.applyJitter) {
  40188. this.applyJitter();
  40189. }
  40190. });
  40191. /* eslint-enable no-invalid-this */
  40192. /**
  40193. * A `scatter` series. If the [type](#series.scatter.type) option is
  40194. * not specified, it is inherited from [chart.type](#chart.type).
  40195. *
  40196. * @extends series,plotOptions.scatter
  40197. * @excluding cropThreshold, dataParser, dataURL, useOhlcData
  40198. * @product highcharts highstock
  40199. * @apioption series.scatter
  40200. */
  40201. /**
  40202. * An array of data points for the series. For the `scatter` series
  40203. * type, points can be given in the following ways:
  40204. *
  40205. * 1. An array of numerical values. In this case, the numerical values will be
  40206. * interpreted as `y` options. The `x` values will be automatically
  40207. * calculated, either starting at 0 and incremented by 1, or from
  40208. * `pointStart` and `pointInterval` given in the series options. If the axis
  40209. * has categories, these will be used. Example:
  40210. * ```js
  40211. * data: [0, 5, 3, 5]
  40212. * ```
  40213. *
  40214. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40215. * `x,y`. If the first value is a string, it is applied as the name of the
  40216. * point, and the `x` value is inferred.
  40217. * ```js
  40218. * data: [
  40219. * [0, 0],
  40220. * [1, 8],
  40221. * [2, 9]
  40222. * ]
  40223. * ```
  40224. *
  40225. * 3. An array of objects with named values. The following snippet shows only a
  40226. * few settings, see the complete options set below. If the total number of
  40227. * data points exceeds the series'
  40228. * [turboThreshold](#series.scatter.turboThreshold), this option is not
  40229. * available.
  40230. * ```js
  40231. * data: [{
  40232. * x: 1,
  40233. * y: 2,
  40234. * name: "Point2",
  40235. * color: "#00FF00"
  40236. * }, {
  40237. * x: 1,
  40238. * y: 4,
  40239. * name: "Point1",
  40240. * color: "#FF00FF"
  40241. * }]
  40242. * ```
  40243. *
  40244. * @sample {highcharts} highcharts/chart/reflow-true/
  40245. * Numerical values
  40246. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40247. * Arrays of numeric x and y
  40248. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40249. * Arrays of datetime x and y
  40250. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40251. * Arrays of point.name and y
  40252. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40253. * Config objects
  40254. *
  40255. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40256. * @extends series.line.data
  40257. * @product highcharts highstock
  40258. * @apioption series.scatter.data
  40259. */
  40260. ''; // adds doclets above to transpilat
  40261. });
  40262. _registerModule(_modules, 'Mixins/CenteredSeries.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  40263. /* *
  40264. *
  40265. * (c) 2010-2020 Torstein Honsi
  40266. *
  40267. * License: www.highcharts.com/license
  40268. *
  40269. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40270. *
  40271. * */
  40272. /**
  40273. * @private
  40274. * @interface Highcharts.RadianAngles
  40275. */ /**
  40276. * @name Highcharts.RadianAngles#end
  40277. * @type {number}
  40278. */ /**
  40279. * @name Highcharts.RadianAngles#start
  40280. * @type {number}
  40281. */
  40282. var isNumber = U.isNumber,
  40283. pick = U.pick,
  40284. relativeLength = U.relativeLength;
  40285. var deg2rad = H.deg2rad;
  40286. /* eslint-disable valid-jsdoc */
  40287. /**
  40288. * @private
  40289. * @mixin Highcharts.CenteredSeriesMixin
  40290. */
  40291. var centeredSeriesMixin = H.CenteredSeriesMixin = {
  40292. /**
  40293. * Get the center of the pie based on the size and center options relative
  40294. * to the plot area. Borrowed by the polar and gauge series types.
  40295. *
  40296. * @private
  40297. * @function Highcharts.CenteredSeriesMixin.getCenter
  40298. *
  40299. * @return {Array<number>}
  40300. */
  40301. getCenter: function () {
  40302. var options = this.options,
  40303. chart = this.chart,
  40304. slicingRoom = 2 * (options.slicedOffset || 0),
  40305. handleSlicingRoom,
  40306. plotWidth = chart.plotWidth - 2 * slicingRoom,
  40307. plotHeight = chart.plotHeight - 2 * slicingRoom,
  40308. centerOption = options.center,
  40309. smallestSize = Math.min(plotWidth,
  40310. plotHeight),
  40311. size = options.size,
  40312. innerSize = options.innerSize || 0,
  40313. positions,
  40314. i,
  40315. value;
  40316. if (typeof size === 'string') {
  40317. size = parseFloat(size);
  40318. }
  40319. if (typeof innerSize === 'string') {
  40320. innerSize = parseFloat(innerSize);
  40321. }
  40322. positions = [
  40323. pick(centerOption[0], '50%'),
  40324. pick(centerOption[1], '50%'),
  40325. // Prevent from negative values
  40326. pick(size && size < 0 ? void 0 : options.size, '100%'),
  40327. pick(innerSize && innerSize < 0 ? void 0 : options.innerSize || 0, '0%')
  40328. ];
  40329. // No need for inner size in angular (gauges) series but still required
  40330. // for pie series
  40331. if (chart.angular && !(this instanceof H.Series)) {
  40332. positions[3] = 0;
  40333. }
  40334. for (i = 0; i < 4; ++i) {
  40335. value = positions[i];
  40336. handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
  40337. // i == 0: centerX, relative to width
  40338. // i == 1: centerY, relative to height
  40339. // i == 2: size, relative to smallestSize
  40340. // i == 3: innerSize, relative to size
  40341. positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) + (handleSlicingRoom ? slicingRoom : 0);
  40342. }
  40343. // innerSize cannot be larger than size (#3632)
  40344. if (positions[3] > positions[2]) {
  40345. positions[3] = positions[2];
  40346. }
  40347. return positions;
  40348. },
  40349. /**
  40350. * getStartAndEndRadians - Calculates start and end angles in radians.
  40351. * Used in series types such as pie and sunburst.
  40352. *
  40353. * @private
  40354. * @function Highcharts.CenteredSeriesMixin.getStartAndEndRadians
  40355. *
  40356. * @param {number} [start]
  40357. * Start angle in degrees.
  40358. *
  40359. * @param {number} [end]
  40360. * Start angle in degrees.
  40361. *
  40362. * @return {Highcharts.RadianAngles}
  40363. * Returns an object containing start and end angles as radians.
  40364. */
  40365. getStartAndEndRadians: function (start, end) {
  40366. var startAngle = isNumber(start) ? start : 0, // must be a number
  40367. endAngle = ((isNumber(end) && // must be a number
  40368. end > startAngle && // must be larger than the start angle
  40369. // difference must be less than 360 degrees
  40370. (end - startAngle) < 360) ?
  40371. end :
  40372. startAngle + 360),
  40373. correction = -90;
  40374. return {
  40375. start: deg2rad * (startAngle + correction),
  40376. end: deg2rad * (endAngle + correction)
  40377. };
  40378. }
  40379. };
  40380. return centeredSeriesMixin;
  40381. });
  40382. _registerModule(_modules, 'Series/PieSeries.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js'], _modules['Mixins/CenteredSeries.js']], function (H, SVGRenderer, LegendSymbolMixin, Point, U, centeredSeriesMixin) {
  40383. /* *
  40384. *
  40385. * (c) 2010-2020 Torstein Honsi
  40386. *
  40387. * License: www.highcharts.com/license
  40388. *
  40389. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40390. *
  40391. * */
  40392. var addEvent = U.addEvent,
  40393. clamp = U.clamp,
  40394. defined = U.defined,
  40395. fireEvent = U.fireEvent,
  40396. isNumber = U.isNumber,
  40397. merge = U.merge,
  40398. pick = U.pick,
  40399. relativeLength = U.relativeLength,
  40400. seriesType = U.seriesType,
  40401. setAnimation = U.setAnimation;
  40402. var getStartAndEndRadians = centeredSeriesMixin.getStartAndEndRadians,
  40403. noop = H.noop,
  40404. Series = H.Series,
  40405. seriesTypes = H.seriesTypes;
  40406. /**
  40407. * Pie series type.
  40408. *
  40409. * @private
  40410. * @class
  40411. * @name Highcharts.seriesTypes.pie
  40412. *
  40413. * @augments Highcharts.Series
  40414. */
  40415. seriesType('pie', 'line',
  40416. /**
  40417. * A pie chart is a circular graphic which is divided into slices to
  40418. * illustrate numerical proportion.
  40419. *
  40420. * @sample highcharts/demo/pie-basic/
  40421. * Pie chart
  40422. *
  40423. * @extends plotOptions.line
  40424. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  40425. * cropThreshold, dashStyle, dataSorting, dragDrop,
  40426. * findNearestPointBy, getExtremesFromAll, label, lineWidth,
  40427. * marker, negativeColor, pointInterval, pointIntervalUnit,
  40428. * pointPlacement, pointStart, softThreshold, stacking, step,
  40429. * threshold, turboThreshold, zoneAxis, zones, dataSorting,
  40430. * boostBlending
  40431. * @product highcharts
  40432. * @optionparent plotOptions.pie
  40433. */
  40434. {
  40435. /**
  40436. * @excluding legendItemClick
  40437. * @apioption plotOptions.pie.events
  40438. */
  40439. /**
  40440. * Fires when the checkbox next to the point name in the legend is
  40441. * clicked. One parameter, event, is passed to the function. The state
  40442. * of the checkbox is found by event.checked. The checked item is found
  40443. * by event.item. Return false to prevent the default action which is to
  40444. * toggle the select state of the series.
  40445. *
  40446. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  40447. * Alert checkbox status
  40448. *
  40449. * @type {Function}
  40450. * @since 1.2.0
  40451. * @product highcharts
  40452. * @context Highcharts.Point
  40453. * @apioption plotOptions.pie.events.checkboxClick
  40454. */
  40455. /**
  40456. * Fires when the legend item belonging to the pie point (slice) is
  40457. * clicked. The `this` keyword refers to the point itself. One
  40458. * parameter, `event`, is passed to the function, containing common
  40459. * event information. The default action is to toggle the visibility of
  40460. * the point. This can be prevented by calling `event.preventDefault()`.
  40461. *
  40462. * @sample {highcharts} highcharts/plotoptions/pie-point-events-legenditemclick/
  40463. * Confirm toggle visibility
  40464. *
  40465. * @type {Highcharts.PointLegendItemClickCallbackFunction}
  40466. * @since 1.2.0
  40467. * @product highcharts
  40468. * @apioption plotOptions.pie.point.events.legendItemClick
  40469. */
  40470. /**
  40471. * The center of the pie chart relative to the plot area. Can be
  40472. * percentages or pixel values. The default behaviour (as of 3.0) is to
  40473. * center the pie so that all slices and data labels are within the plot
  40474. * area. As a consequence, the pie may actually jump around in a chart
  40475. * with dynamic values, as the data labels move. In that case, the
  40476. * center should be explicitly set, for example to `["50%", "50%"]`.
  40477. *
  40478. * @sample {highcharts} highcharts/plotoptions/pie-center/
  40479. * Centered at 100, 100
  40480. *
  40481. * @type {Array<(number|string|null),(number|string|null)>}
  40482. * @default [null, null]
  40483. * @product highcharts
  40484. *
  40485. * @private
  40486. */
  40487. center: [null, null],
  40488. /**
  40489. * The color of the pie series. A pie series is represented as an empty
  40490. * circle if the total sum of its values is 0. Use this property to
  40491. * define the color of its border.
  40492. *
  40493. * In styled mode, the color can be defined by the
  40494. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  40495. * color can be set with the `.highcharts-series`,
  40496. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  40497. * `.highcharts-series-{n}` class, or individual classes given by the
  40498. * `className` option.
  40499. *
  40500. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  40501. * Empty pie series
  40502. *
  40503. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40504. * @default #cccccc
  40505. * @apioption plotOptions.pie.color
  40506. */
  40507. /**
  40508. * @product highcharts
  40509. *
  40510. * @private
  40511. */
  40512. clip: false,
  40513. /**
  40514. * @ignore-option
  40515. *
  40516. * @private
  40517. */
  40518. colorByPoint: true,
  40519. /**
  40520. * A series specific or series type specific color set to use instead
  40521. * of the global [colors](#colors).
  40522. *
  40523. * @sample {highcharts} highcharts/demo/pie-monochrome/
  40524. * Set default colors for all pies
  40525. *
  40526. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  40527. * @since 3.0
  40528. * @product highcharts
  40529. * @apioption plotOptions.pie.colors
  40530. */
  40531. /**
  40532. * @declare Highcharts.SeriesPieDataLabelsOptionsObject
  40533. * @extends plotOptions.series.dataLabels
  40534. * @excluding align, allowOverlap, inside, staggerLines, step
  40535. * @private
  40536. */
  40537. dataLabels: {
  40538. /**
  40539. * Alignment method for data labels. Possible values are:
  40540. *
  40541. * - `toPlotEdges`: Each label touches the nearest vertical edge of
  40542. * the plot area.
  40543. *
  40544. * - `connectors`: Connectors have the same x position and the
  40545. * widest label of each half (left & right) touches the nearest
  40546. * vertical edge of the plot area.
  40547. *
  40548. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-connectors/
  40549. * alignTo: connectors
  40550. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-plotedges/
  40551. * alignTo: plotEdges
  40552. *
  40553. * @type {string}
  40554. * @since 7.0.0
  40555. * @product highcharts
  40556. * @apioption plotOptions.pie.dataLabels.alignTo
  40557. */
  40558. allowOverlap: true,
  40559. /**
  40560. * The color of the line connecting the data label to the pie slice.
  40561. * The default color is the same as the point's color.
  40562. *
  40563. * In styled mode, the connector stroke is given in the
  40564. * `.highcharts-data-label-connector` class.
  40565. *
  40566. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorcolor/
  40567. * Blue connectors
  40568. * @sample {highcharts} highcharts/css/pie-point/
  40569. * Styled connectors
  40570. *
  40571. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40572. * @since 2.1
  40573. * @product highcharts
  40574. * @apioption plotOptions.pie.dataLabels.connectorColor
  40575. */
  40576. /**
  40577. * The distance from the data label to the connector. Note that
  40578. * data labels also have a default `padding`, so in order for the
  40579. * connector to touch the text, the `padding` must also be 0.
  40580. *
  40581. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorpadding/
  40582. * No padding
  40583. *
  40584. * @since 2.1
  40585. * @product highcharts
  40586. */
  40587. connectorPadding: 5,
  40588. /**
  40589. * Specifies the method that is used to generate the connector path.
  40590. * Highcharts provides 3 built-in connector shapes: `'fixedOffset'`
  40591. * (default), `'straight'` and `'crookedLine'`. Using
  40592. * `'crookedLine'` has the most sense (in most of the cases) when
  40593. * `'alignTo'` is set.
  40594. *
  40595. * Users can provide their own method by passing a function instead
  40596. * of a String. 3 arguments are passed to the callback:
  40597. *
  40598. * - Object that holds the information about the coordinates of the
  40599. * label (`x` & `y` properties) and how the label is located in
  40600. * relation to the pie (`alignment` property). `alignment` can by
  40601. * one of the following:
  40602. * `'left'` (pie on the left side of the data label),
  40603. * `'right'` (pie on the right side of the data label) or
  40604. * `'center'` (data label overlaps the pie).
  40605. *
  40606. * - Object that holds the information about the position of the
  40607. * connector. Its `touchingSliceAt` porperty tells the position
  40608. * of the place where the connector touches the slice.
  40609. *
  40610. * - Data label options
  40611. *
  40612. * The function has to return an SVG path definition in array form
  40613. * (see the example).
  40614. *
  40615. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-string/
  40616. * connectorShape is a String
  40617. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-function/
  40618. * connectorShape is a function
  40619. *
  40620. * @type {string|Function}
  40621. * @since 7.0.0
  40622. * @product highcharts
  40623. */
  40624. connectorShape: 'fixedOffset',
  40625. /**
  40626. * The width of the line connecting the data label to the pie slice.
  40627. *
  40628. * In styled mode, the connector stroke width is given in the
  40629. * `.highcharts-data-label-connector` class.
  40630. *
  40631. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorwidth-disabled/
  40632. * Disable the connector
  40633. * @sample {highcharts} highcharts/css/pie-point/
  40634. * Styled connectors
  40635. *
  40636. * @type {number}
  40637. * @default 1
  40638. * @since 2.1
  40639. * @product highcharts
  40640. * @apioption plotOptions.pie.dataLabels.connectorWidth
  40641. */
  40642. /**
  40643. * Works only if `connectorShape` is `'crookedLine'`. It defines how
  40644. * far from the vertical plot edge the coonnector path should be
  40645. * crooked.
  40646. *
  40647. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-crookdistance/
  40648. * crookDistance set to 90%
  40649. *
  40650. * @since 7.0.0
  40651. * @product highcharts
  40652. */
  40653. crookDistance: '70%',
  40654. /**
  40655. * The distance of the data label from the pie's edge. Negative
  40656. * numbers put the data label on top of the pie slices. Can also be
  40657. * defined as a percentage of pie's radius. Connectors are only
  40658. * shown for data labels outside the pie.
  40659. *
  40660. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-distance/
  40661. * Data labels on top of the pie
  40662. *
  40663. * @type {number|string}
  40664. * @since 2.1
  40665. * @product highcharts
  40666. */
  40667. distance: 30,
  40668. enabled: true,
  40669. formatter: function () {
  40670. return this.point.isNull ? void 0 : this.point.name;
  40671. },
  40672. /**
  40673. * Whether to render the connector as a soft arc or a line with
  40674. * sharp break. Works only if `connectorShape` equals to
  40675. * `fixedOffset`.
  40676. *
  40677. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-true/
  40678. * Soft
  40679. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-false/
  40680. * Non soft
  40681. *
  40682. * @since 2.1.7
  40683. * @product highcharts
  40684. */
  40685. softConnector: true,
  40686. /**
  40687. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow
  40688. * Long labels truncated with an ellipsis
  40689. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap
  40690. * Long labels are wrapped
  40691. *
  40692. * @type {Highcharts.CSSObject}
  40693. * @apioption plotOptions.pie.dataLabels.style
  40694. */
  40695. x: 0
  40696. },
  40697. /**
  40698. * If the total sum of the pie's values is 0, the series is represented
  40699. * as an empty circle . The `fillColor` option defines the color of that
  40700. * circle. Use [pie.borderWidth](#plotOptions.pie.borderWidth) to set
  40701. * the border thickness.
  40702. *
  40703. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  40704. * Empty pie series
  40705. *
  40706. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40707. * @private
  40708. */
  40709. fillColor: void 0,
  40710. /**
  40711. * The end angle of the pie in degrees where 0 is top and 90 is right.
  40712. * Defaults to `startAngle` plus 360.
  40713. *
  40714. * @sample {highcharts} highcharts/demo/pie-semi-circle/
  40715. * Semi-circle donut
  40716. *
  40717. * @type {number}
  40718. * @since 1.3.6
  40719. * @product highcharts
  40720. * @apioption plotOptions.pie.endAngle
  40721. */
  40722. /**
  40723. * Equivalent to [chart.ignoreHiddenSeries](#chart.ignoreHiddenSeries),
  40724. * this option tells whether the series shall be redrawn as if the
  40725. * hidden point were `null`.
  40726. *
  40727. * The default value changed from `false` to `true` with Highcharts
  40728. * 3.0.
  40729. *
  40730. * @sample {highcharts} highcharts/plotoptions/pie-ignorehiddenpoint/
  40731. * True, the hiddden point is ignored
  40732. *
  40733. * @since 2.3.0
  40734. * @product highcharts
  40735. *
  40736. * @private
  40737. */
  40738. ignoreHiddenPoint: true,
  40739. /**
  40740. * @ignore-option
  40741. *
  40742. * @private
  40743. */
  40744. inactiveOtherPoints: true,
  40745. /**
  40746. * The size of the inner diameter for the pie. A size greater than 0
  40747. * renders a donut chart. Can be a percentage or pixel value.
  40748. * Percentages are relative to the pie size. Pixel values are given as
  40749. * integers.
  40750. *
  40751. *
  40752. * Note: in Highcharts < 4.1.2, the percentage was relative to the plot
  40753. * area, not the pie size.
  40754. *
  40755. * @sample {highcharts} highcharts/plotoptions/pie-innersize-80px/
  40756. * 80px inner size
  40757. * @sample {highcharts} highcharts/plotoptions/pie-innersize-50percent/
  40758. * 50% of the plot area
  40759. * @sample {highcharts} highcharts/demo/3d-pie-donut/
  40760. * 3D donut
  40761. *
  40762. * @type {number|string}
  40763. * @default 0
  40764. * @since 2.0
  40765. * @product highcharts
  40766. * @apioption plotOptions.pie.innerSize
  40767. */
  40768. /**
  40769. * @ignore-option
  40770. *
  40771. * @private
  40772. */
  40773. legendType: 'point',
  40774. /**
  40775. * @ignore-option
  40776. *
  40777. * @private
  40778. */
  40779. marker: null,
  40780. /**
  40781. * The minimum size for a pie in response to auto margins. The pie will
  40782. * try to shrink to make room for data labels in side the plot area,
  40783. * but only to this size.
  40784. *
  40785. * @type {number|string}
  40786. * @default 80
  40787. * @since 3.0
  40788. * @product highcharts
  40789. * @apioption plotOptions.pie.minSize
  40790. */
  40791. /**
  40792. * The diameter of the pie relative to the plot area. Can be a
  40793. * percentage or pixel value. Pixel values are given as integers. The
  40794. * default behaviour (as of 3.0) is to scale to the plot area and give
  40795. * room for data labels within the plot area.
  40796. * [slicedOffset](#plotOptions.pie.slicedOffset) is also included in the
  40797. * default size calculation. As a consequence, the size of the pie may
  40798. * vary when points are updated and data labels more around. In that
  40799. * case it is best to set a fixed value, for example `"75%"`.
  40800. *
  40801. * @sample {highcharts} highcharts/plotoptions/pie-size/
  40802. * Smaller pie
  40803. *
  40804. * @type {number|string|null}
  40805. * @product highcharts
  40806. *
  40807. * @private
  40808. */
  40809. size: null,
  40810. /**
  40811. * Whether to display this particular series or series type in the
  40812. * legend. Since 2.1, pies are not shown in the legend by default.
  40813. *
  40814. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  40815. * One series in the legend, one hidden
  40816. *
  40817. * @product highcharts
  40818. *
  40819. * @private
  40820. */
  40821. showInLegend: false,
  40822. /**
  40823. * If a point is sliced, moved out from the center, how many pixels
  40824. * should it be moved?.
  40825. *
  40826. * @sample {highcharts} highcharts/plotoptions/pie-slicedoffset-20/
  40827. * 20px offset
  40828. *
  40829. * @product highcharts
  40830. *
  40831. * @private
  40832. */
  40833. slicedOffset: 10,
  40834. /**
  40835. * The start angle of the pie slices in degrees where 0 is top and 90
  40836. * right.
  40837. *
  40838. * @sample {highcharts} highcharts/plotoptions/pie-startangle-90/
  40839. * Start from right
  40840. *
  40841. * @type {number}
  40842. * @default 0
  40843. * @since 2.3.4
  40844. * @product highcharts
  40845. * @apioption plotOptions.pie.startAngle
  40846. */
  40847. /**
  40848. * Sticky tracking of mouse events. When true, the `mouseOut` event
  40849. * on a series isn't triggered until the mouse moves over another
  40850. * series, or out of the plot area. When false, the `mouseOut` event on
  40851. * a series is triggered when the mouse leaves the area around the
  40852. * series' graph or markers. This also implies the tooltip. When
  40853. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  40854. * will be hidden when moving the mouse between series.
  40855. *
  40856. * @product highcharts
  40857. *
  40858. * @private
  40859. */
  40860. stickyTracking: false,
  40861. tooltip: {
  40862. followPointer: true
  40863. },
  40864. /**
  40865. * The color of the border surrounding each slice. When `null`, the
  40866. * border takes the same color as the slice fill. This can be used
  40867. * together with a `borderWidth` to fill drawing gaps created by
  40868. * antialiazing artefacts in borderless pies.
  40869. *
  40870. * In styled mode, the border stroke is given in the `.highcharts-point`
  40871. * class.
  40872. *
  40873. * @sample {highcharts} highcharts/plotoptions/pie-bordercolor-black/
  40874. * Black border
  40875. *
  40876. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40877. * @default #ffffff
  40878. * @product highcharts
  40879. *
  40880. * @private
  40881. */
  40882. borderColor: '#ffffff',
  40883. /**
  40884. * The width of the border surrounding each slice.
  40885. *
  40886. * When setting the border width to 0, there may be small gaps between
  40887. * the slices due to SVG antialiasing artefacts. To work around this,
  40888. * keep the border width at 0.5 or 1, but set the `borderColor` to
  40889. * `null` instead.
  40890. *
  40891. * In styled mode, the border stroke width is given in the
  40892. * `.highcharts-point` class.
  40893. *
  40894. * @sample {highcharts} highcharts/plotoptions/pie-borderwidth/
  40895. * 3px border
  40896. *
  40897. * @product highcharts
  40898. *
  40899. * @private
  40900. */
  40901. borderWidth: 1,
  40902. /**
  40903. * @ignore-options
  40904. * @private
  40905. */
  40906. lineWidth: void 0,
  40907. states: {
  40908. /**
  40909. * @extends plotOptions.series.states.hover
  40910. * @excluding marker, lineWidth, lineWidthPlus
  40911. * @product highcharts
  40912. */
  40913. hover: {
  40914. /**
  40915. * How much to brighten the point on interaction. Requires the
  40916. * main color to be defined in hex or rgb(a) format.
  40917. *
  40918. * In styled mode, the hover brightness is by default replaced
  40919. * by a fill-opacity given in the `.highcharts-point-hover`
  40920. * class.
  40921. *
  40922. * @sample {highcharts} highcharts/plotoptions/pie-states-hover-brightness/
  40923. * Brightened by 0.5
  40924. *
  40925. * @product highcharts
  40926. */
  40927. brightness: 0.1
  40928. }
  40929. }
  40930. },
  40931. /* eslint-disable valid-jsdoc */
  40932. /**
  40933. * @lends seriesTypes.pie.prototype
  40934. */
  40935. {
  40936. isCartesian: false,
  40937. requireSorting: false,
  40938. directTouch: true,
  40939. noSharedTooltip: true,
  40940. trackerGroups: ['group', 'dataLabelsGroup'],
  40941. axisTypes: [],
  40942. pointAttribs: seriesTypes.column.prototype.pointAttribs,
  40943. /**
  40944. * Animate the pies in
  40945. *
  40946. * @private
  40947. * @function Highcharts.seriesTypes.pie#animate
  40948. *
  40949. * @param {boolean} [init=false]
  40950. */
  40951. animate: function (init) {
  40952. var series = this,
  40953. points = series.points,
  40954. startAngleRad = series.startAngleRad;
  40955. if (!init) {
  40956. points.forEach(function (point) {
  40957. var graphic = point.graphic,
  40958. args = point.shapeArgs;
  40959. if (graphic && args) {
  40960. // start values
  40961. graphic.attr({
  40962. // animate from inner radius (#779)
  40963. r: pick(point.startR, (series.center && series.center[3] / 2)),
  40964. start: startAngleRad,
  40965. end: startAngleRad
  40966. });
  40967. // animate
  40968. graphic.animate({
  40969. r: args.r,
  40970. start: args.start,
  40971. end: args.end
  40972. }, series.options.animation);
  40973. }
  40974. });
  40975. }
  40976. },
  40977. // Define hasData function for non-cartesian series.
  40978. // Returns true if the series has points at all.
  40979. hasData: function () {
  40980. return !!this.processedXData.length; // != 0
  40981. },
  40982. /**
  40983. * Recompute total chart sum and update percentages of points.
  40984. *
  40985. * @private
  40986. * @function Highcharts.seriesTypes.pie#updateTotals
  40987. * @return {void}
  40988. */
  40989. updateTotals: function () {
  40990. var i,
  40991. total = 0,
  40992. points = this.points,
  40993. len = points.length,
  40994. point,
  40995. ignoreHiddenPoint = this.options.ignoreHiddenPoint;
  40996. // Get the total sum
  40997. for (i = 0; i < len; i++) {
  40998. point = points[i];
  40999. total += (ignoreHiddenPoint && !point.visible) ?
  41000. 0 :
  41001. point.isNull ?
  41002. 0 :
  41003. point.y;
  41004. }
  41005. this.total = total;
  41006. // Set each point's properties
  41007. for (i = 0; i < len; i++) {
  41008. point = points[i];
  41009. point.percentage =
  41010. (total > 0 && (point.visible || !ignoreHiddenPoint)) ?
  41011. point.y / total * 100 :
  41012. 0;
  41013. point.total = total;
  41014. }
  41015. },
  41016. /**
  41017. * Extend the generatePoints method by adding total and percentage
  41018. * properties to each point
  41019. *
  41020. * @private
  41021. * @function Highcharts.seriesTypes.pie#generatePoints
  41022. * @return {void}
  41023. */
  41024. generatePoints: function () {
  41025. Series.prototype.generatePoints.call(this);
  41026. this.updateTotals();
  41027. },
  41028. /**
  41029. * Utility for getting the x value from a given y, used for
  41030. * anticollision logic in data labels. Added point for using specific
  41031. * points' label distance.
  41032. * @private
  41033. */
  41034. getX: function (y, left, point) {
  41035. var center = this.center,
  41036. // Variable pie has individual radius
  41037. radius = this.radii ?
  41038. this.radii[point.index] :
  41039. center[2] / 2,
  41040. angle,
  41041. x;
  41042. angle = Math.asin(clamp((y - center[1]) / (radius + point.labelDistance), -1, 1));
  41043. x = center[0] +
  41044. (left ? -1 : 1) *
  41045. (Math.cos(angle) * (radius + point.labelDistance)) +
  41046. (point.labelDistance > 0 ?
  41047. (left ? -1 : 1) * this.options.dataLabels.padding :
  41048. 0);
  41049. return x;
  41050. },
  41051. /**
  41052. * Do translation for pie slices
  41053. *
  41054. * @private
  41055. * @function Highcharts.seriesTypes.pie#translate
  41056. * @param {Array<number>} [positions]
  41057. * @return {void}
  41058. */
  41059. translate: function (positions) {
  41060. this.generatePoints();
  41061. var series = this,
  41062. cumulative = 0,
  41063. precision = 1000, // issue #172
  41064. options = series.options,
  41065. slicedOffset = options.slicedOffset,
  41066. connectorOffset = slicedOffset + (options.borderWidth || 0),
  41067. finalConnectorOffset,
  41068. start,
  41069. end,
  41070. angle,
  41071. radians = getStartAndEndRadians(options.startAngle,
  41072. options.endAngle),
  41073. startAngleRad = series.startAngleRad = radians.start,
  41074. endAngleRad = series.endAngleRad = radians.end,
  41075. circ = endAngleRad - startAngleRad, // 2 * Math.PI,
  41076. points = series.points,
  41077. // the x component of the radius vector for a given point
  41078. radiusX,
  41079. radiusY,
  41080. labelDistance = options.dataLabels.distance,
  41081. ignoreHiddenPoint = options.ignoreHiddenPoint,
  41082. i,
  41083. len = points.length,
  41084. point;
  41085. // Get positions - either an integer or a percentage string must be
  41086. // given. If positions are passed as a parameter, we're in a
  41087. // recursive loop for adjusting space for data labels.
  41088. if (!positions) {
  41089. series.center = positions = series.getCenter();
  41090. }
  41091. // Calculate the geometry for each point
  41092. for (i = 0; i < len; i++) {
  41093. point = points[i];
  41094. // set start and end angle
  41095. start = startAngleRad + (cumulative * circ);
  41096. if (!ignoreHiddenPoint || point.visible) {
  41097. cumulative += point.percentage / 100;
  41098. }
  41099. end = startAngleRad + (cumulative * circ);
  41100. // set the shape
  41101. point.shapeType = 'arc';
  41102. point.shapeArgs = {
  41103. x: positions[0],
  41104. y: positions[1],
  41105. r: positions[2] / 2,
  41106. innerR: positions[3] / 2,
  41107. start: Math.round(start * precision) / precision,
  41108. end: Math.round(end * precision) / precision
  41109. };
  41110. // Used for distance calculation for specific point.
  41111. point.labelDistance = pick((point.options.dataLabels &&
  41112. point.options.dataLabels.distance), labelDistance);
  41113. // Compute point.labelDistance if it's defined as percentage
  41114. // of slice radius (#8854)
  41115. point.labelDistance = relativeLength(point.labelDistance, point.shapeArgs.r);
  41116. // Saved for later dataLabels distance calculation.
  41117. series.maxLabelDistance = Math.max(series.maxLabelDistance || 0, point.labelDistance);
  41118. // The angle must stay within -90 and 270 (#2645)
  41119. angle = (end + start) / 2;
  41120. if (angle > 1.5 * Math.PI) {
  41121. angle -= 2 * Math.PI;
  41122. }
  41123. else if (angle < -Math.PI / 2) {
  41124. angle += 2 * Math.PI;
  41125. }
  41126. // Center for the sliced out slice
  41127. point.slicedTranslation = {
  41128. translateX: Math.round(Math.cos(angle) * slicedOffset),
  41129. translateY: Math.round(Math.sin(angle) * slicedOffset)
  41130. };
  41131. // set the anchor point for tooltips
  41132. radiusX = Math.cos(angle) * positions[2] / 2;
  41133. radiusY = Math.sin(angle) * positions[2] / 2;
  41134. point.tooltipPos = [
  41135. positions[0] + radiusX * 0.7,
  41136. positions[1] + radiusY * 0.7
  41137. ];
  41138. point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ?
  41139. 1 :
  41140. 0;
  41141. point.angle = angle;
  41142. // Set the anchor point for data labels. Use point.labelDistance
  41143. // instead of labelDistance // #1174
  41144. // finalConnectorOffset - not override connectorOffset value.
  41145. finalConnectorOffset = Math.min(connectorOffset, point.labelDistance / 5); // #1678
  41146. point.labelPosition = {
  41147. natural: {
  41148. // initial position of the data label - it's utilized for
  41149. // finding the final position for the label
  41150. x: positions[0] + radiusX + Math.cos(angle) *
  41151. point.labelDistance,
  41152. y: positions[1] + radiusY + Math.sin(angle) *
  41153. point.labelDistance
  41154. },
  41155. 'final': {
  41156. // used for generating connector path -
  41157. // initialized later in drawDataLabels function
  41158. // x: undefined,
  41159. // y: undefined
  41160. },
  41161. // left - pie on the left side of the data label
  41162. // right - pie on the right side of the data label
  41163. // center - data label overlaps the pie
  41164. alignment: point.labelDistance < 0 ?
  41165. 'center' : point.half ? 'right' : 'left',
  41166. connectorPosition: {
  41167. breakAt: {
  41168. x: positions[0] + radiusX + Math.cos(angle) *
  41169. finalConnectorOffset,
  41170. y: positions[1] + radiusY + Math.sin(angle) *
  41171. finalConnectorOffset
  41172. },
  41173. touchingSliceAt: {
  41174. x: positions[0] + radiusX,
  41175. y: positions[1] + radiusY
  41176. }
  41177. }
  41178. };
  41179. }
  41180. fireEvent(series, 'afterTranslate');
  41181. },
  41182. /**
  41183. * Called internally to draw auxiliary graph in pie-like series in
  41184. * situtation when the default graph is not sufficient enough to present
  41185. * the data well. Auxiliary graph is saved in the same object as
  41186. * regular graph.
  41187. *
  41188. * @private
  41189. * @function Highcharts.seriesTypes.pie#drawEmpty
  41190. */
  41191. drawEmpty: function () {
  41192. var centerX,
  41193. centerY,
  41194. start = this.startAngleRad,
  41195. end = this.endAngleRad,
  41196. options = this.options;
  41197. // Draw auxiliary graph if there're no visible points.
  41198. if (this.total === 0 && this.center) {
  41199. centerX = this.center[0];
  41200. centerY = this.center[1];
  41201. if (!this.graph) {
  41202. this.graph = this.chart.renderer
  41203. .arc(centerX, centerY, this.center[1] / 2, 0, start, end)
  41204. .addClass('highcharts-empty-series')
  41205. .add(this.group);
  41206. }
  41207. this.graph.attr({
  41208. d: SVGRenderer.prototype.symbols.arc(centerX, centerY, this.center[2] / 2, 0, {
  41209. start: start,
  41210. end: end,
  41211. innerR: this.center[3] / 2
  41212. })
  41213. });
  41214. if (!this.chart.styledMode) {
  41215. this.graph.attr({
  41216. 'stroke-width': options.borderWidth,
  41217. fill: options.fillColor || 'none',
  41218. stroke: options.color ||
  41219. '#cccccc'
  41220. });
  41221. }
  41222. }
  41223. else if (this.graph) { // Destroy the graph object.
  41224. this.graph = this.graph.destroy();
  41225. }
  41226. },
  41227. /**
  41228. * Draw the data points
  41229. *
  41230. * @private
  41231. * @function Highcharts.seriesTypes.pie#drawPoints
  41232. * @return {void}
  41233. */
  41234. redrawPoints: function () {
  41235. var series = this,
  41236. chart = series.chart,
  41237. renderer = chart.renderer,
  41238. groupTranslation,
  41239. graphic,
  41240. pointAttr,
  41241. shapeArgs,
  41242. shadow = series.options.shadow;
  41243. this.drawEmpty();
  41244. if (shadow && !series.shadowGroup && !chart.styledMode) {
  41245. series.shadowGroup = renderer.g('shadow')
  41246. .attr({ zIndex: -1 })
  41247. .add(series.group);
  41248. }
  41249. // draw the slices
  41250. series.points.forEach(function (point) {
  41251. var animateTo = {};
  41252. graphic = point.graphic;
  41253. if (!point.isNull && graphic) {
  41254. shapeArgs = point.shapeArgs;
  41255. // If the point is sliced, use special translation, else use
  41256. // plot area translation
  41257. groupTranslation = point.getTranslate();
  41258. if (!chart.styledMode) {
  41259. // Put the shadow behind all points
  41260. var shadowGroup = point.shadowGroup;
  41261. if (shadow && !shadowGroup) {
  41262. shadowGroup = point.shadowGroup = renderer
  41263. .g('shadow')
  41264. .add(series.shadowGroup);
  41265. }
  41266. if (shadowGroup) {
  41267. shadowGroup.attr(groupTranslation);
  41268. }
  41269. pointAttr = series.pointAttribs(point, (point.selected && 'select'));
  41270. }
  41271. // Draw the slice
  41272. if (!point.delayedRendering) {
  41273. graphic
  41274. .setRadialReference(series.center);
  41275. if (!chart.styledMode) {
  41276. merge(true, animateTo, pointAttr);
  41277. }
  41278. merge(true, animateTo, shapeArgs, groupTranslation);
  41279. graphic.animate(animateTo);
  41280. }
  41281. else {
  41282. graphic
  41283. .setRadialReference(series.center)
  41284. .attr(shapeArgs)
  41285. .attr(groupTranslation);
  41286. if (!chart.styledMode) {
  41287. graphic
  41288. .attr(pointAttr)
  41289. .attr({ 'stroke-linejoin': 'round' })
  41290. .shadow(shadow, shadowGroup);
  41291. }
  41292. point.delayedRendering = false;
  41293. }
  41294. graphic.attr({
  41295. visibility: point.visible ? 'inherit' : 'hidden'
  41296. });
  41297. graphic.addClass(point.getClassName());
  41298. }
  41299. else if (graphic) {
  41300. point.graphic = graphic.destroy();
  41301. }
  41302. });
  41303. },
  41304. /**
  41305. * Slices in pie chart are initialized in DOM, but it's shapes and
  41306. * animations are normally run in `drawPoints()`.
  41307. * @private
  41308. */
  41309. drawPoints: function () {
  41310. var renderer = this.chart.renderer;
  41311. this.points.forEach(function (point) {
  41312. // When updating a series between 2d and 3d or cartesian and
  41313. // polar, the shape type changes.
  41314. if (point.graphic && point.hasNewShapeType()) {
  41315. point.graphic = point.graphic.destroy();
  41316. }
  41317. if (!point.graphic) {
  41318. point.graphic = renderer[point.shapeType](point.shapeArgs)
  41319. .add(point.series.group);
  41320. point.delayedRendering = true;
  41321. }
  41322. });
  41323. },
  41324. /**
  41325. * @private
  41326. * @deprecated
  41327. * @function Highcharts.seriesTypes.pie#searchPoint
  41328. */
  41329. searchPoint: noop,
  41330. /**
  41331. * Utility for sorting data labels
  41332. *
  41333. * @private
  41334. * @function Highcharts.seriesTypes.pie#sortByAngle
  41335. * @param {Array<Highcharts.Point>} points
  41336. * @param {number} sign
  41337. * @return {void}
  41338. */
  41339. sortByAngle: function (points, sign) {
  41340. points.sort(function (a, b) {
  41341. return ((typeof a.angle !== 'undefined') &&
  41342. (b.angle - a.angle) * sign);
  41343. });
  41344. },
  41345. /**
  41346. * Use a simple symbol from LegendSymbolMixin.
  41347. *
  41348. * @private
  41349. * @borrows Highcharts.LegendSymbolMixin.drawRectangle as Highcharts.seriesTypes.pie#drawLegendSymbol
  41350. */
  41351. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  41352. /**
  41353. * Use the getCenter method from drawLegendSymbol.
  41354. *
  41355. * @private
  41356. * @borrows Highcharts.CenteredSeriesMixin.getCenter as Highcharts.seriesTypes.pie#getCenter
  41357. */
  41358. getCenter: centeredSeriesMixin.getCenter,
  41359. /**
  41360. * Pies don't have point marker symbols.
  41361. *
  41362. * @deprecated
  41363. * @private
  41364. * @function Highcharts.seriesTypes.pie#getSymbol
  41365. */
  41366. getSymbol: noop,
  41367. /**
  41368. * @private
  41369. * @type {null}
  41370. */
  41371. drawGraph: null
  41372. },
  41373. /**
  41374. * @lends seriesTypes.pie.prototype.pointClass.prototype
  41375. */
  41376. {
  41377. /**
  41378. * Initialize the pie slice
  41379. *
  41380. * @private
  41381. * @function Highcharts.seriesTypes.pie#pointClass#init
  41382. * @return {Highcharts.Point}
  41383. */
  41384. init: function () {
  41385. Point.prototype.init.apply(this, arguments);
  41386. var point = this,
  41387. toggleSlice;
  41388. point.name = pick(point.name, 'Slice');
  41389. // add event listener for select
  41390. toggleSlice = function (e) {
  41391. point.slice(e.type === 'select');
  41392. };
  41393. addEvent(point, 'select', toggleSlice);
  41394. addEvent(point, 'unselect', toggleSlice);
  41395. return point;
  41396. },
  41397. /**
  41398. * Negative points are not valid (#1530, #3623, #5322)
  41399. *
  41400. * @private
  41401. * @function Highcharts.seriesTypes.pie#pointClass#isValid
  41402. * @return {boolean}
  41403. */
  41404. isValid: function () {
  41405. return isNumber(this.y) && this.y >= 0;
  41406. },
  41407. /**
  41408. * Toggle the visibility of the pie slice
  41409. *
  41410. * @private
  41411. * @function Highcharts.seriesTypes.pie#pointClass#setVisible
  41412. * @param {boolean} vis
  41413. * Whether to show the slice or not. If undefined, the visibility
  41414. * is toggled.
  41415. * @param {boolean} [redraw=false]
  41416. * @return {void}
  41417. */
  41418. setVisible: function (vis, redraw) {
  41419. var point = this,
  41420. series = point.series,
  41421. chart = series.chart,
  41422. ignoreHiddenPoint = series.options.ignoreHiddenPoint;
  41423. redraw = pick(redraw, ignoreHiddenPoint);
  41424. if (vis !== point.visible) {
  41425. // If called without an argument, toggle visibility
  41426. point.visible = point.options.visible = vis =
  41427. typeof vis === 'undefined' ? !point.visible : vis;
  41428. // update userOptions.data
  41429. series.options.data[series.data.indexOf(point)] =
  41430. point.options;
  41431. // Show and hide associated elements. This is performed
  41432. // regardless of redraw or not, because chart.redraw only
  41433. // handles full series.
  41434. ['graphic', 'dataLabel', 'connector', 'shadowGroup'].forEach(function (key) {
  41435. if (point[key]) {
  41436. point[key][vis ? 'show' : 'hide'](true);
  41437. }
  41438. });
  41439. if (point.legendItem) {
  41440. chart.legend.colorizeItem(point, vis);
  41441. }
  41442. // #4170, hide halo after hiding point
  41443. if (!vis && point.state === 'hover') {
  41444. point.setState('');
  41445. }
  41446. // Handle ignore hidden slices
  41447. if (ignoreHiddenPoint) {
  41448. series.isDirty = true;
  41449. }
  41450. if (redraw) {
  41451. chart.redraw();
  41452. }
  41453. }
  41454. },
  41455. /**
  41456. * Set or toggle whether the slice is cut out from the pie
  41457. *
  41458. * @private
  41459. * @function Highcharts.seriesTypes.pie#pointClass#slice
  41460. * @param {boolean} sliced
  41461. * When undefined, the slice state is toggled.
  41462. * @param {boolean} redraw
  41463. * Whether to redraw the chart. True by default.
  41464. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>}
  41465. * Animation options.
  41466. * @return {void}
  41467. */
  41468. slice: function (sliced, redraw, animation) {
  41469. var point = this,
  41470. series = point.series,
  41471. chart = series.chart;
  41472. setAnimation(animation, chart);
  41473. // redraw is true by default
  41474. redraw = pick(redraw, true);
  41475. /**
  41476. * Pie series only. Whether to display a slice offset from the
  41477. * center.
  41478. * @name Highcharts.Point#sliced
  41479. * @type {boolean|undefined}
  41480. */
  41481. // if called without an argument, toggle
  41482. point.sliced = point.options.sliced = sliced =
  41483. defined(sliced) ? sliced : !point.sliced;
  41484. // update userOptions.data
  41485. series.options.data[series.data.indexOf(point)] =
  41486. point.options;
  41487. if (point.graphic) {
  41488. point.graphic.animate(this.getTranslate());
  41489. }
  41490. if (point.shadowGroup) {
  41491. point.shadowGroup.animate(this.getTranslate());
  41492. }
  41493. },
  41494. /**
  41495. * @private
  41496. * @function Highcharts.seriesTypes.pie#pointClass#getTranslate
  41497. * @return {Highcharts.TranslationAttributes}
  41498. */
  41499. getTranslate: function () {
  41500. return this.sliced ? this.slicedTranslation : {
  41501. translateX: 0,
  41502. translateY: 0
  41503. };
  41504. },
  41505. /**
  41506. * @private
  41507. * @function Highcharts.seriesTypes.pie#pointClass#haloPath
  41508. * @param {number} size
  41509. * @return {Highcharts.SVGPathArray}
  41510. */
  41511. haloPath: function (size) {
  41512. var shapeArgs = this.shapeArgs;
  41513. return this.sliced || !this.visible ?
  41514. [] :
  41515. this.series.chart.renderer.symbols.arc(shapeArgs.x, shapeArgs.y, shapeArgs.r + size, shapeArgs.r + size, {
  41516. // Substract 1px to ensure the background is not bleeding
  41517. // through between the halo and the slice (#7495).
  41518. innerR: shapeArgs.r - 1,
  41519. start: shapeArgs.start,
  41520. end: shapeArgs.end
  41521. });
  41522. },
  41523. connectorShapes: {
  41524. // only one available before v7.0.0
  41525. fixedOffset: function (labelPosition, connectorPosition, options) {
  41526. var breakAt = connectorPosition.breakAt,
  41527. touchingSliceAt = connectorPosition.touchingSliceAt,
  41528. lineSegment = options.softConnector ? [
  41529. 'C',
  41530. // 1st control point (of the curve)
  41531. labelPosition.x +
  41532. // 5 gives the connector a little horizontal bend
  41533. (labelPosition.alignment === 'left' ? -5 : 5),
  41534. labelPosition.y,
  41535. 2 * breakAt.x - touchingSliceAt.x,
  41536. 2 * breakAt.y - touchingSliceAt.y,
  41537. breakAt.x,
  41538. breakAt.y //
  41539. ] : [
  41540. 'L',
  41541. breakAt.x,
  41542. breakAt.y
  41543. ];
  41544. // assemble the path
  41545. return ([
  41546. ['M', labelPosition.x, labelPosition.y],
  41547. lineSegment,
  41548. ['L', touchingSliceAt.x, touchingSliceAt.y]
  41549. ]);
  41550. },
  41551. straight: function (labelPosition, connectorPosition) {
  41552. var touchingSliceAt = connectorPosition.touchingSliceAt;
  41553. // direct line to the slice
  41554. return [
  41555. ['M', labelPosition.x, labelPosition.y],
  41556. ['L', touchingSliceAt.x, touchingSliceAt.y]
  41557. ];
  41558. },
  41559. crookedLine: function (labelPosition, connectorPosition, options) {
  41560. var touchingSliceAt = connectorPosition.touchingSliceAt,
  41561. series = this.series,
  41562. pieCenterX = series.center[0],
  41563. plotWidth = series.chart.plotWidth,
  41564. plotLeft = series.chart.plotLeft,
  41565. alignment = labelPosition.alignment,
  41566. radius = this.shapeArgs.r,
  41567. crookDistance = relativeLength(// % to fraction
  41568. options.crookDistance, 1),
  41569. crookX = alignment === 'left' ?
  41570. pieCenterX + radius + (plotWidth + plotLeft -
  41571. pieCenterX - radius) * (1 - crookDistance) :
  41572. plotLeft + (pieCenterX - radius) * crookDistance,
  41573. segmentWithCrook = [
  41574. 'L',
  41575. crookX,
  41576. labelPosition.y
  41577. ],
  41578. useCrook = true;
  41579. // crookedLine formula doesn't make sense if the path overlaps
  41580. // the label - use straight line instead in that case
  41581. if (alignment === 'left' ?
  41582. (crookX > labelPosition.x || crookX < touchingSliceAt.x) :
  41583. (crookX < labelPosition.x || crookX > touchingSliceAt.x)) {
  41584. useCrook = false;
  41585. }
  41586. // assemble the path
  41587. var path = [
  41588. ['M',
  41589. labelPosition.x,
  41590. labelPosition.y]
  41591. ];
  41592. if (useCrook) {
  41593. path.push(segmentWithCrook);
  41594. }
  41595. path.push(['L', touchingSliceAt.x, touchingSliceAt.y]);
  41596. return path;
  41597. }
  41598. },
  41599. /**
  41600. * Extendable method for getting the path of the connector between the
  41601. * data label and the pie slice.
  41602. */
  41603. getConnectorPath: function () {
  41604. var labelPosition = this.labelPosition,
  41605. options = this.series.options.dataLabels,
  41606. connectorShape = options.connectorShape,
  41607. predefinedShapes = this.connectorShapes;
  41608. // find out whether to use the predefined shape
  41609. if (predefinedShapes[connectorShape]) {
  41610. connectorShape = predefinedShapes[connectorShape];
  41611. }
  41612. return connectorShape.call(this, {
  41613. // pass simplified label position object for user's convenience
  41614. x: labelPosition.final.x,
  41615. y: labelPosition.final.y,
  41616. alignment: labelPosition.alignment
  41617. }, labelPosition.connectorPosition, options);
  41618. }
  41619. }
  41620. /* eslint-enable valid-jsdoc */
  41621. );
  41622. /**
  41623. * A `pie` series. If the [type](#series.pie.type) option is not specified,
  41624. * it is inherited from [chart.type](#chart.type).
  41625. *
  41626. * @extends series,plotOptions.pie
  41627. * @excluding cropThreshold, dataParser, dataURL, stack, xAxis, yAxis,
  41628. * dataSorting, step, boostThreshold, boostBlending
  41629. * @product highcharts
  41630. * @apioption series.pie
  41631. */
  41632. /**
  41633. * An array of data points for the series. For the `pie` series type,
  41634. * points can be given in the following ways:
  41635. *
  41636. * 1. An array of numerical values. In this case, the numerical values will be
  41637. * interpreted as `y` options. Example:
  41638. * ```js
  41639. * data: [0, 5, 3, 5]
  41640. * ```
  41641. *
  41642. * 2. An array of objects with named values. The following snippet shows only a
  41643. * few settings, see the complete options set below. If the total number of
  41644. * data points exceeds the series'
  41645. * [turboThreshold](#series.pie.turboThreshold),
  41646. * this option is not available.
  41647. * ```js
  41648. * data: [{
  41649. * y: 1,
  41650. * name: "Point2",
  41651. * color: "#00FF00"
  41652. * }, {
  41653. * y: 7,
  41654. * name: "Point1",
  41655. * color: "#FF00FF"
  41656. * }]
  41657. * ```
  41658. *
  41659. * @sample {highcharts} highcharts/chart/reflow-true/
  41660. * Numerical values
  41661. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41662. * Arrays of numeric x and y
  41663. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41664. * Arrays of datetime x and y
  41665. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41666. * Arrays of point.name and y
  41667. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41668. * Config objects
  41669. *
  41670. * @type {Array<number|Array<string,(number|null)>|null|*>}
  41671. * @extends series.line.data
  41672. * @excluding marker, x
  41673. * @product highcharts
  41674. * @apioption series.pie.data
  41675. */
  41676. /**
  41677. * @type {Highcharts.SeriesPieDataLabelsOptionsObject}
  41678. * @product highcharts
  41679. * @apioption series.pie.data.dataLabels
  41680. */
  41681. /**
  41682. * The sequential index of the data point in the legend.
  41683. *
  41684. * @type {number}
  41685. * @product highcharts
  41686. * @apioption series.pie.data.legendIndex
  41687. */
  41688. /**
  41689. * Whether to display a slice offset from the center.
  41690. *
  41691. * @sample {highcharts} highcharts/point/sliced/
  41692. * One sliced point
  41693. *
  41694. * @type {boolean}
  41695. * @product highcharts
  41696. * @apioption series.pie.data.sliced
  41697. */
  41698. /**
  41699. * @excluding legendItemClick
  41700. * @product highcharts
  41701. * @apioption series.pie.events
  41702. */
  41703. ''; // placeholder for transpiled doclets above
  41704. });
  41705. _registerModule(_modules, 'Core/Series/DataLabels.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  41706. /* *
  41707. *
  41708. * (c) 2010-2020 Torstein Honsi
  41709. *
  41710. * License: www.highcharts.com/license
  41711. *
  41712. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41713. *
  41714. * */
  41715. var noop = H.noop,
  41716. seriesTypes = H.seriesTypes;
  41717. var arrayMax = U.arrayMax,
  41718. clamp = U.clamp,
  41719. defined = U.defined,
  41720. extend = U.extend,
  41721. fireEvent = U.fireEvent,
  41722. format = U.format,
  41723. getDeferredAnimation = U.getDeferredAnimation,
  41724. isArray = U.isArray,
  41725. merge = U.merge,
  41726. objectEach = U.objectEach,
  41727. pick = U.pick,
  41728. relativeLength = U.relativeLength,
  41729. splat = U.splat,
  41730. stableSort = U.stableSort;
  41731. /**
  41732. * Callback JavaScript function to format the data label as a string. Note that
  41733. * if a `format` is defined, the format takes precedence and the formatter is
  41734. * ignored.
  41735. *
  41736. * @callback Highcharts.DataLabelsFormatterCallbackFunction
  41737. *
  41738. * @param {Highcharts.PointLabelObject} this
  41739. * Data label context to format
  41740. *
  41741. * @param {Highcharts.DataLabelsOptions} options
  41742. * [API options](/highcharts/plotOptions.series.dataLabels) of the data label
  41743. *
  41744. * @return {number|string|null|undefined}
  41745. * Formatted data label text
  41746. */
  41747. /**
  41748. * Values for handling data labels that flow outside the plot area.
  41749. *
  41750. * @typedef {"allow"|"justify"} Highcharts.DataLabelsOverflowValue
  41751. */
  41752. var Series = H.Series;
  41753. /* eslint-disable valid-jsdoc */
  41754. /**
  41755. * General distribution algorithm for distributing labels of differing size
  41756. * along a confined length in two dimensions. The algorithm takes an array of
  41757. * objects containing a size, a target and a rank. It will place the labels as
  41758. * close as possible to their targets, skipping the lowest ranked labels if
  41759. * necessary.
  41760. *
  41761. * @private
  41762. * @function Highcharts.distribute
  41763. * @param {Highcharts.DataLabelsBoxArray} boxes
  41764. * @param {number} len
  41765. * @param {number} [maxDistance]
  41766. * @return {void}
  41767. */
  41768. H.distribute = function (boxes, len, maxDistance) {
  41769. var i,
  41770. overlapping = true,
  41771. origBoxes = boxes, // Original array will be altered with added .pos
  41772. restBoxes = [], // The outranked overshoot
  41773. box,
  41774. target,
  41775. total = 0,
  41776. reducedLen = origBoxes.reducedLen || len;
  41777. /**
  41778. * @private
  41779. */
  41780. function sortByTarget(a, b) {
  41781. return a.target - b.target;
  41782. }
  41783. // If the total size exceeds the len, remove those boxes with the lowest
  41784. // rank
  41785. i = boxes.length;
  41786. while (i--) {
  41787. total += boxes[i].size;
  41788. }
  41789. // Sort by rank, then slice away overshoot
  41790. if (total > reducedLen) {
  41791. stableSort(boxes, function (a, b) {
  41792. return (b.rank || 0) - (a.rank || 0);
  41793. });
  41794. i = 0;
  41795. total = 0;
  41796. while (total <= reducedLen) {
  41797. total += boxes[i].size;
  41798. i++;
  41799. }
  41800. restBoxes = boxes.splice(i - 1, boxes.length);
  41801. }
  41802. // Order by target
  41803. stableSort(boxes, sortByTarget);
  41804. // So far we have been mutating the original array. Now
  41805. // create a copy with target arrays
  41806. boxes = boxes.map(function (box) {
  41807. return {
  41808. size: box.size,
  41809. targets: [box.target],
  41810. align: pick(box.align, 0.5)
  41811. };
  41812. });
  41813. while (overlapping) {
  41814. // Initial positions: target centered in box
  41815. i = boxes.length;
  41816. while (i--) {
  41817. box = boxes[i];
  41818. // Composite box, average of targets
  41819. target = (Math.min.apply(0, box.targets) +
  41820. Math.max.apply(0, box.targets)) / 2;
  41821. box.pos = clamp(target - box.size * box.align, 0, len - box.size);
  41822. }
  41823. // Detect overlap and join boxes
  41824. i = boxes.length;
  41825. overlapping = false;
  41826. while (i--) {
  41827. // Overlap
  41828. if (i > 0 &&
  41829. boxes[i - 1].pos + boxes[i - 1].size >
  41830. boxes[i].pos) {
  41831. // Add this size to the previous box
  41832. boxes[i - 1].size += boxes[i].size;
  41833. boxes[i - 1].targets = boxes[i - 1]
  41834. .targets
  41835. .concat(boxes[i].targets);
  41836. boxes[i - 1].align = 0.5;
  41837. // Overlapping right, push left
  41838. if (boxes[i - 1].pos + boxes[i - 1].size > len) {
  41839. boxes[i - 1].pos = len - boxes[i - 1].size;
  41840. }
  41841. boxes.splice(i, 1); // Remove this item
  41842. overlapping = true;
  41843. }
  41844. }
  41845. }
  41846. // Add the rest (hidden boxes)
  41847. origBoxes.push.apply(origBoxes, restBoxes);
  41848. // Now the composite boxes are placed, we need to put the original boxes
  41849. // within them
  41850. i = 0;
  41851. boxes.some(function (box) {
  41852. var posInCompositeBox = 0;
  41853. if (box.targets.some(function () {
  41854. origBoxes[i].pos = box.pos + posInCompositeBox;
  41855. // If the distance between the position and the target exceeds
  41856. // maxDistance, abort the loop and decrease the length in increments
  41857. // of 10% to recursively reduce the number of visible boxes by
  41858. // rank. Once all boxes are within the maxDistance, we're good.
  41859. if (typeof maxDistance !== 'undefined' &&
  41860. Math.abs(origBoxes[i].pos - origBoxes[i].target) > maxDistance) {
  41861. // Reset the positions that are already set
  41862. origBoxes.slice(0, i + 1).forEach(function (box) {
  41863. delete box.pos;
  41864. });
  41865. // Try with a smaller length
  41866. origBoxes.reducedLen =
  41867. (origBoxes.reducedLen || len) - (len * 0.1);
  41868. // Recurse
  41869. if (origBoxes.reducedLen > len * 0.1) {
  41870. H.distribute(origBoxes, len, maxDistance);
  41871. }
  41872. // Exceeded maxDistance => abort
  41873. return true;
  41874. }
  41875. posInCompositeBox += origBoxes[i].size;
  41876. i++;
  41877. })) {
  41878. // Exceeded maxDistance => abort
  41879. return true;
  41880. }
  41881. });
  41882. // Add the rest (hidden) boxes and sort by target
  41883. stableSort(origBoxes, sortByTarget);
  41884. };
  41885. /**
  41886. * Draw the data labels
  41887. *
  41888. * @private
  41889. * @function Highcharts.Series#drawDataLabels
  41890. * @return {void}
  41891. * @fires Highcharts.Series#event:afterDrawDataLabels
  41892. */
  41893. Series.prototype.drawDataLabels = function () {
  41894. var series = this,
  41895. chart = series.chart,
  41896. seriesOptions = series.options,
  41897. seriesDlOptions = seriesOptions.dataLabels,
  41898. points = series.points,
  41899. pointOptions,
  41900. hasRendered = series.hasRendered || 0,
  41901. dataLabelsGroup,
  41902. dataLabelAnim = seriesDlOptions.animation,
  41903. animationConfig = seriesDlOptions.defer ?
  41904. getDeferredAnimation(chart,
  41905. dataLabelAnim,
  41906. series) :
  41907. { defer: 0,
  41908. duration: 0 },
  41909. renderer = chart.renderer;
  41910. /**
  41911. * Handle the dataLabels.filter option.
  41912. * @private
  41913. */
  41914. function applyFilter(point, options) {
  41915. var filter = options.filter,
  41916. op,
  41917. prop,
  41918. val;
  41919. if (filter) {
  41920. op = filter.operator;
  41921. prop = point[filter.property];
  41922. val = filter.value;
  41923. if ((op === '>' && prop > val) ||
  41924. (op === '<' && prop < val) ||
  41925. (op === '>=' && prop >= val) ||
  41926. (op === '<=' && prop <= val) ||
  41927. (op === '==' && prop == val) || // eslint-disable-line eqeqeq
  41928. (op === '===' && prop === val)) {
  41929. return true;
  41930. }
  41931. return false;
  41932. }
  41933. return true;
  41934. }
  41935. /**
  41936. * Merge two objects that can be arrays. If one of them is an array, the
  41937. * other is merged into each element. If both are arrays, each element is
  41938. * merged by index. If neither are arrays, we use normal merge.
  41939. * @private
  41940. */
  41941. function mergeArrays(one, two) {
  41942. var res = [],
  41943. i;
  41944. if (isArray(one) && !isArray(two)) {
  41945. res = one.map(function (el) {
  41946. return merge(el, two);
  41947. });
  41948. }
  41949. else if (isArray(two) && !isArray(one)) {
  41950. res = two.map(function (el) {
  41951. return merge(one, el);
  41952. });
  41953. }
  41954. else if (!isArray(one) && !isArray(two)) {
  41955. res = merge(one, two);
  41956. }
  41957. else {
  41958. i = Math.max(one.length, two.length);
  41959. while (i--) {
  41960. res[i] = merge(one[i], two[i]);
  41961. }
  41962. }
  41963. return res;
  41964. }
  41965. // Merge in plotOptions.dataLabels for series
  41966. seriesDlOptions = mergeArrays(mergeArrays(chart.options.plotOptions &&
  41967. chart.options.plotOptions.series &&
  41968. chart.options.plotOptions.series.dataLabels, chart.options.plotOptions &&
  41969. chart.options.plotOptions[series.type] &&
  41970. chart.options.plotOptions[series.type].dataLabels), seriesDlOptions);
  41971. fireEvent(this, 'drawDataLabels');
  41972. if (isArray(seriesDlOptions) ||
  41973. seriesDlOptions.enabled ||
  41974. series._hasPointLabels) {
  41975. // Create a separate group for the data labels to avoid rotation
  41976. dataLabelsGroup = series.plotGroup('dataLabelsGroup', 'data-labels', !hasRendered ? 'hidden' : 'inherit', // #5133, #10220
  41977. seriesDlOptions.zIndex || 6);
  41978. dataLabelsGroup.attr({ opacity: +hasRendered }); // #3300
  41979. if (!hasRendered) {
  41980. var group = series.dataLabelsGroup;
  41981. if (group) {
  41982. if (series.visible) { // #2597, #3023, #3024
  41983. dataLabelsGroup.show(true);
  41984. }
  41985. group[seriesOptions.animation ? 'animate' : 'attr']({ opacity: 1 }, animationConfig);
  41986. }
  41987. }
  41988. // Make the labels for each point
  41989. points.forEach(function (point) {
  41990. // Merge in series options for the point.
  41991. // @note dataLabelAttribs (like pointAttribs) would eradicate
  41992. // the need for dlOptions, and simplify the section below.
  41993. pointOptions = splat(mergeArrays(seriesDlOptions, point.dlOptions || // dlOptions is used in treemaps
  41994. (point.options && point.options.dataLabels)));
  41995. // Handle each individual data label for this point
  41996. pointOptions.forEach(function (labelOptions, i) {
  41997. // Options for one datalabel
  41998. var labelEnabled = (labelOptions.enabled &&
  41999. // #2282, #4641, #7112, #10049
  42000. (!point.isNull || point.dataLabelOnNull) &&
  42001. applyFilter(point,
  42002. labelOptions)),
  42003. labelConfig,
  42004. formatString,
  42005. labelText,
  42006. style,
  42007. rotation,
  42008. attr,
  42009. dataLabel = point.dataLabels ? point.dataLabels[i] :
  42010. point.dataLabel,
  42011. connector = point.connectors ? point.connectors[i] :
  42012. point.connector,
  42013. labelDistance = pick(labelOptions.distance,
  42014. point.labelDistance),
  42015. isNew = !dataLabel;
  42016. if (labelEnabled) {
  42017. // Create individual options structure that can be extended
  42018. // without affecting others
  42019. labelConfig = point.getLabelConfig();
  42020. formatString = pick(labelOptions[point.formatPrefix + 'Format'], labelOptions.format);
  42021. labelText = defined(formatString) ?
  42022. format(formatString, labelConfig, chart) :
  42023. (labelOptions[point.formatPrefix + 'Formatter'] ||
  42024. labelOptions.formatter).call(labelConfig, labelOptions);
  42025. style = labelOptions.style;
  42026. rotation = labelOptions.rotation;
  42027. if (!chart.styledMode) {
  42028. // Determine the color
  42029. style.color = pick(labelOptions.color, style.color, series.color, '#000000');
  42030. // Get automated contrast color
  42031. if (style.color === 'contrast') {
  42032. point.contrastColor = renderer.getContrast((point.color || series.color));
  42033. style.color = (!defined(labelDistance) &&
  42034. labelOptions.inside) ||
  42035. labelDistance < 0 ||
  42036. !!seriesOptions.stacking ?
  42037. point.contrastColor :
  42038. '#000000';
  42039. }
  42040. else {
  42041. delete point.contrastColor;
  42042. }
  42043. if (seriesOptions.cursor) {
  42044. style.cursor = seriesOptions.cursor;
  42045. }
  42046. }
  42047. attr = {
  42048. r: labelOptions.borderRadius || 0,
  42049. rotation: rotation,
  42050. padding: labelOptions.padding,
  42051. zIndex: 1
  42052. };
  42053. if (!chart.styledMode) {
  42054. attr.fill = labelOptions.backgroundColor;
  42055. attr.stroke = labelOptions.borderColor;
  42056. attr['stroke-width'] = labelOptions.borderWidth;
  42057. }
  42058. // Remove unused attributes (#947)
  42059. objectEach(attr, function (val, name) {
  42060. if (typeof val === 'undefined') {
  42061. delete attr[name];
  42062. }
  42063. });
  42064. }
  42065. // If the point is outside the plot area, destroy it. #678, #820
  42066. if (dataLabel && (!labelEnabled || !defined(labelText))) {
  42067. point.dataLabel =
  42068. point.dataLabel && point.dataLabel.destroy();
  42069. if (point.dataLabels) {
  42070. // Remove point.dataLabels if this was the last one
  42071. if (point.dataLabels.length === 1) {
  42072. delete point.dataLabels;
  42073. }
  42074. else {
  42075. delete point.dataLabels[i];
  42076. }
  42077. }
  42078. if (!i) {
  42079. delete point.dataLabel;
  42080. }
  42081. if (connector) {
  42082. point.connector = point.connector.destroy();
  42083. if (point.connectors) {
  42084. // Remove point.connectors if this was the last one
  42085. if (point.connectors.length === 1) {
  42086. delete point.connectors;
  42087. }
  42088. else {
  42089. delete point.connectors[i];
  42090. }
  42091. }
  42092. }
  42093. // Individual labels are disabled if the are explicitly disabled
  42094. // in the point options, or if they fall outside the plot area.
  42095. }
  42096. else if (labelEnabled && defined(labelText)) {
  42097. if (!dataLabel) {
  42098. // Create new label element
  42099. point.dataLabels = point.dataLabels || [];
  42100. dataLabel = point.dataLabels[i] = rotation ?
  42101. // Labels don't rotate, use text element
  42102. renderer.text(labelText, 0, -9999, labelOptions.useHTML)
  42103. .addClass('highcharts-data-label') :
  42104. // We can use label
  42105. renderer.label(labelText, 0, -9999, labelOptions.shape, null, null, labelOptions.useHTML, null, 'data-label');
  42106. // Store for backwards compatibility
  42107. if (!i) {
  42108. point.dataLabel = dataLabel;
  42109. }
  42110. dataLabel.addClass(' highcharts-data-label-color-' + point.colorIndex +
  42111. ' ' + (labelOptions.className || '') +
  42112. ( // #3398
  42113. labelOptions.useHTML ?
  42114. ' highcharts-tracker' :
  42115. ''));
  42116. }
  42117. else {
  42118. // Use old element and just update text
  42119. attr.text = labelText;
  42120. }
  42121. // Store data label options for later access
  42122. dataLabel.options = labelOptions;
  42123. dataLabel.attr(attr);
  42124. if (!chart.styledMode) {
  42125. // Styles must be applied before add in order to read
  42126. // text bounding box
  42127. dataLabel.css(style).shadow(labelOptions.shadow);
  42128. }
  42129. if (!dataLabel.added) {
  42130. dataLabel.add(dataLabelsGroup);
  42131. }
  42132. if (labelOptions.textPath && !labelOptions.useHTML) {
  42133. dataLabel.setTextPath((point.getDataLabelPath &&
  42134. point.getDataLabelPath(dataLabel)) || point.graphic, labelOptions.textPath);
  42135. if (point.dataLabelPath &&
  42136. !labelOptions.textPath.enabled) {
  42137. // clean the DOM
  42138. point.dataLabelPath = point.dataLabelPath.destroy();
  42139. }
  42140. }
  42141. // Now the data label is created and placed at 0,0, so we
  42142. // need to align it
  42143. series.alignDataLabel(point, dataLabel, labelOptions, null, isNew);
  42144. }
  42145. });
  42146. });
  42147. }
  42148. fireEvent(this, 'afterDrawDataLabels');
  42149. };
  42150. /**
  42151. * Align each individual data label.
  42152. *
  42153. * @private
  42154. * @function Highcharts.Series#alignDataLabel
  42155. * @param {Highcharts.Point} point
  42156. * @param {Highcharts.SVGElement} dataLabel
  42157. * @param {Highcharts.DataLabelsOptions} options
  42158. * @param {Highcharts.BBoxObject} alignTo
  42159. * @param {boolean} [isNew]
  42160. * @return {void}
  42161. */
  42162. Series.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  42163. var series = this,
  42164. chart = this.chart,
  42165. inverted = this.isCartesian && chart.inverted,
  42166. enabledDataSorting = this.enabledDataSorting,
  42167. plotX = pick(point.dlBox && point.dlBox.centerX,
  42168. point.plotX, -9999),
  42169. plotY = pick(point.plotY, -9999),
  42170. bBox = dataLabel.getBBox(),
  42171. baseline,
  42172. rotation = options.rotation,
  42173. normRotation,
  42174. negRotation,
  42175. align = options.align,
  42176. rotCorr, // rotation correction
  42177. isInsidePlot = chart.isInsidePlot(plotX,
  42178. Math.round(plotY),
  42179. inverted),
  42180. // Math.round for rounding errors (#2683), alignTo to allow column
  42181. // labels (#2700)
  42182. alignAttr, // the final position;
  42183. justify = pick(options.overflow, (enabledDataSorting ? 'none' : 'justify')) === 'justify', visible = this.visible &&
  42184. point.visible !== false &&
  42185. (point.series.forceDL ||
  42186. (enabledDataSorting && !justify) ||
  42187. isInsidePlot ||
  42188. (
  42189. // If the data label is inside the align box, it is enough
  42190. // that parts of the align box is inside the plot area
  42191. // (#12370)
  42192. options.inside && alignTo && chart.isInsidePlot(plotX, inverted ?
  42193. alignTo.x + 1 :
  42194. alignTo.y + alignTo.height - 1, inverted))), setStartPos = function (alignOptions) {
  42195. if (enabledDataSorting && series.xAxis && !justify) {
  42196. series.setDataLabelStartPos(point, dataLabel, isNew, isInsidePlot, alignOptions);
  42197. }
  42198. };
  42199. if (visible) {
  42200. baseline = chart.renderer.fontMetrics(chart.styledMode ? void 0 : options.style.fontSize, dataLabel).b;
  42201. // The alignment box is a singular point
  42202. alignTo = extend({
  42203. x: inverted ? this.yAxis.len - plotY : plotX,
  42204. y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
  42205. width: 0,
  42206. height: 0
  42207. }, alignTo);
  42208. // Add the text size for alignment calculation
  42209. extend(options, {
  42210. width: bBox.width,
  42211. height: bBox.height
  42212. });
  42213. // Allow a hook for changing alignment in the last moment, then do the
  42214. // alignment
  42215. if (rotation) {
  42216. justify = false; // Not supported for rotated text
  42217. rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
  42218. alignAttr = {
  42219. x: (alignTo.x +
  42220. (options.x || 0) +
  42221. alignTo.width / 2 +
  42222. rotCorr.x),
  42223. y: (alignTo.y +
  42224. (options.y || 0) +
  42225. { top: 0, middle: 0.5, bottom: 1 }[options.verticalAlign] *
  42226. alignTo.height)
  42227. };
  42228. setStartPos(alignAttr); // data sorting
  42229. dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
  42230. .attr({
  42231. align: align
  42232. });
  42233. // Compensate for the rotated label sticking out on the sides
  42234. normRotation = (rotation + 720) % 360;
  42235. negRotation = normRotation > 180 && normRotation < 360;
  42236. if (align === 'left') {
  42237. alignAttr.y -= negRotation ? bBox.height : 0;
  42238. }
  42239. else if (align === 'center') {
  42240. alignAttr.x -= bBox.width / 2;
  42241. alignAttr.y -= bBox.height / 2;
  42242. }
  42243. else if (align === 'right') {
  42244. alignAttr.x -= bBox.width;
  42245. alignAttr.y -= negRotation ? 0 : bBox.height;
  42246. }
  42247. dataLabel.placed = true;
  42248. dataLabel.alignAttr = alignAttr;
  42249. }
  42250. else {
  42251. setStartPos(alignTo); // data sorting
  42252. dataLabel.align(options, null, alignTo);
  42253. alignAttr = dataLabel.alignAttr;
  42254. }
  42255. // Handle justify or crop
  42256. if (justify && alignTo.height >= 0) { // #8830
  42257. this.justifyDataLabel(dataLabel, options, alignAttr, bBox, alignTo, isNew);
  42258. // Now check that the data label is within the plot area
  42259. }
  42260. else if (pick(options.crop, true)) {
  42261. visible =
  42262. chart.isInsidePlot(alignAttr.x, alignAttr.y) &&
  42263. chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height);
  42264. }
  42265. // When we're using a shape, make it possible with a connector or an
  42266. // arrow pointing to thie point
  42267. if (options.shape && !rotation) {
  42268. dataLabel[isNew ? 'attr' : 'animate']({
  42269. anchorX: inverted ?
  42270. chart.plotWidth - point.plotY :
  42271. point.plotX,
  42272. anchorY: inverted ?
  42273. chart.plotHeight - point.plotX :
  42274. point.plotY
  42275. });
  42276. }
  42277. }
  42278. // To use alignAttr property in hideOverlappingLabels
  42279. if (isNew && enabledDataSorting) {
  42280. dataLabel.placed = false;
  42281. }
  42282. // Show or hide based on the final aligned position
  42283. if (!visible && (!enabledDataSorting || justify)) {
  42284. dataLabel.hide(true);
  42285. dataLabel.placed = false; // don't animate back in
  42286. }
  42287. };
  42288. /**
  42289. * Set starting position for data label sorting animation.
  42290. *
  42291. * @private
  42292. * @function Highcharts.Series#setDataLabelStartPos
  42293. * @param {Highcharts.SVGElement} dataLabel
  42294. * @param {Highcharts.ColumnPoint} point
  42295. * @param {boolean | undefined} [isNew]
  42296. * @param {boolean} [isInside]
  42297. * @param {Highcharts.AlignObject} [alignOptions]
  42298. *
  42299. * @return {void}
  42300. */
  42301. Series.prototype.setDataLabelStartPos = function (point, dataLabel, isNew, isInside, alignOptions) {
  42302. var chart = this.chart,
  42303. inverted = chart.inverted,
  42304. xAxis = this.xAxis,
  42305. reversed = xAxis.reversed,
  42306. labelCenter = inverted ? dataLabel.height / 2 : dataLabel.width / 2,
  42307. pointWidth = point.pointWidth,
  42308. halfWidth = pointWidth ? pointWidth / 2 : 0,
  42309. startXPos,
  42310. startYPos;
  42311. startXPos = inverted ?
  42312. alignOptions.x :
  42313. (reversed ?
  42314. -labelCenter - halfWidth :
  42315. xAxis.width - labelCenter + halfWidth);
  42316. startYPos = inverted ?
  42317. (reversed ?
  42318. this.yAxis.height - labelCenter + halfWidth :
  42319. -labelCenter - halfWidth) : alignOptions.y;
  42320. dataLabel.startXPos = startXPos;
  42321. dataLabel.startYPos = startYPos;
  42322. // We need to handle visibility in case of sorting point outside plot area
  42323. if (!isInside) {
  42324. dataLabel
  42325. .attr({ opacity: 1 })
  42326. .animate({ opacity: 0 }, void 0, dataLabel.hide);
  42327. }
  42328. else if (dataLabel.visibility === 'hidden') {
  42329. dataLabel.show();
  42330. dataLabel
  42331. .attr({ opacity: 0 })
  42332. .animate({ opacity: 1 });
  42333. }
  42334. // Save start position on first render, but do not change position
  42335. if (!chart.hasRendered) {
  42336. return;
  42337. }
  42338. // Set start position
  42339. if (isNew) {
  42340. dataLabel.attr({ x: dataLabel.startXPos, y: dataLabel.startYPos });
  42341. }
  42342. dataLabel.placed = true;
  42343. };
  42344. /**
  42345. * If data labels fall partly outside the plot area, align them back in, in a
  42346. * way that doesn't hide the point.
  42347. *
  42348. * @private
  42349. * @function Highcharts.Series#justifyDataLabel
  42350. * @param {Highcharts.SVGElement} dataLabel
  42351. * @param {Highcharts.DataLabelsOptions} options
  42352. * @param {Highcharts.SVGAttributes} alignAttr
  42353. * @param {Highcharts.BBoxObject} bBox
  42354. * @param {Highcharts.BBoxObject} [alignTo]
  42355. * @param {boolean} [isNew]
  42356. * @return {boolean|undefined}
  42357. */
  42358. Series.prototype.justifyDataLabel = function (dataLabel, options, alignAttr, bBox, alignTo, isNew) {
  42359. var chart = this.chart,
  42360. align = options.align,
  42361. verticalAlign = options.verticalAlign,
  42362. off,
  42363. justified,
  42364. padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
  42365. var _a = options.x,
  42366. x = _a === void 0 ? 0 : _a,
  42367. _b = options.y,
  42368. y = _b === void 0 ? 0 : _b;
  42369. // Off left
  42370. off = alignAttr.x + padding;
  42371. if (off < 0) {
  42372. if (align === 'right' && x >= 0) {
  42373. options.align = 'left';
  42374. options.inside = true;
  42375. }
  42376. else {
  42377. x -= off;
  42378. }
  42379. justified = true;
  42380. }
  42381. // Off right
  42382. off = alignAttr.x + bBox.width - padding;
  42383. if (off > chart.plotWidth) {
  42384. if (align === 'left' && x <= 0) {
  42385. options.align = 'right';
  42386. options.inside = true;
  42387. }
  42388. else {
  42389. x += chart.plotWidth - off;
  42390. }
  42391. justified = true;
  42392. }
  42393. // Off top
  42394. off = alignAttr.y + padding;
  42395. if (off < 0) {
  42396. if (verticalAlign === 'bottom' && y >= 0) {
  42397. options.verticalAlign = 'top';
  42398. options.inside = true;
  42399. }
  42400. else {
  42401. y -= off;
  42402. }
  42403. justified = true;
  42404. }
  42405. // Off bottom
  42406. off = alignAttr.y + bBox.height - padding;
  42407. if (off > chart.plotHeight) {
  42408. if (verticalAlign === 'top' && y <= 0) {
  42409. options.verticalAlign = 'bottom';
  42410. options.inside = true;
  42411. }
  42412. else {
  42413. y += chart.plotHeight - off;
  42414. }
  42415. justified = true;
  42416. }
  42417. if (justified) {
  42418. options.x = x;
  42419. options.y = y;
  42420. dataLabel.placed = !isNew;
  42421. dataLabel.align(options, void 0, alignTo);
  42422. }
  42423. return justified;
  42424. };
  42425. if (seriesTypes.pie) {
  42426. seriesTypes.pie.prototype.dataLabelPositioners = {
  42427. // Based on the value computed in Highcharts' distribute algorithm.
  42428. radialDistributionY: function (point) {
  42429. return point.top + point.distributeBox.pos;
  42430. },
  42431. // get the x - use the natural x position for labels near the
  42432. // top and bottom, to prevent the top and botton slice
  42433. // connectors from touching each other on either side
  42434. // Based on the value computed in Highcharts' distribute algorithm.
  42435. radialDistributionX: function (series, point, y, naturalY) {
  42436. return series.getX(y < point.top + 2 || y > point.bottom - 2 ?
  42437. naturalY :
  42438. y, point.half, point);
  42439. },
  42440. // dataLabels.distance determines the x position of the label
  42441. justify: function (point, radius, seriesCenter) {
  42442. return seriesCenter[0] + (point.half ? -1 : 1) *
  42443. (radius + point.labelDistance);
  42444. },
  42445. // Left edges of the left-half labels touch the left edge of the plot
  42446. // area. Right edges of the right-half labels touch the right edge of
  42447. // the plot area.
  42448. alignToPlotEdges: function (dataLabel, half, plotWidth, plotLeft) {
  42449. var dataLabelWidth = dataLabel.getBBox().width;
  42450. return half ? dataLabelWidth + plotLeft :
  42451. plotWidth - dataLabelWidth - plotLeft;
  42452. },
  42453. // Connectors of each side end in the same x position. Labels are
  42454. // aligned to them. Left edge of the widest left-half label touches the
  42455. // left edge of the plot area. Right edge of the widest right-half label
  42456. // touches the right edge of the plot area.
  42457. alignToConnectors: function (points, half, plotWidth, plotLeft) {
  42458. var maxDataLabelWidth = 0,
  42459. dataLabelWidth;
  42460. // find widest data label
  42461. points.forEach(function (point) {
  42462. dataLabelWidth = point.dataLabel.getBBox().width;
  42463. if (dataLabelWidth > maxDataLabelWidth) {
  42464. maxDataLabelWidth = dataLabelWidth;
  42465. }
  42466. });
  42467. return half ? maxDataLabelWidth + plotLeft :
  42468. plotWidth - maxDataLabelWidth - plotLeft;
  42469. }
  42470. };
  42471. /**
  42472. * Override the base drawDataLabels method by pie specific functionality
  42473. *
  42474. * @private
  42475. * @function Highcharts.seriesTypes.pie#drawDataLabels
  42476. * @return {void}
  42477. */
  42478. seriesTypes.pie.prototype.drawDataLabels = function () {
  42479. var series = this,
  42480. data = series.data,
  42481. point,
  42482. chart = series.chart,
  42483. options = series.options.dataLabels || {},
  42484. connectorPadding = options.connectorPadding,
  42485. connectorWidth,
  42486. plotWidth = chart.plotWidth,
  42487. plotHeight = chart.plotHeight,
  42488. plotLeft = chart.plotLeft,
  42489. maxWidth = Math.round(chart.chartWidth / 3),
  42490. connector,
  42491. seriesCenter = series.center,
  42492. radius = seriesCenter[2] / 2,
  42493. centerY = seriesCenter[1],
  42494. dataLabel,
  42495. dataLabelWidth,
  42496. // labelPos,
  42497. labelPosition,
  42498. labelHeight,
  42499. // divide the points into right and left halves for anti collision
  42500. halves = [
  42501. [],
  42502. [] // left
  42503. ],
  42504. x,
  42505. y,
  42506. visibility,
  42507. j,
  42508. overflow = [0, 0, 0, 0], // top, right, bottom, left
  42509. dataLabelPositioners = series.dataLabelPositioners,
  42510. pointDataLabelsOptions;
  42511. // get out if not enabled
  42512. if (!series.visible ||
  42513. (!options.enabled &&
  42514. !series._hasPointLabels)) {
  42515. return;
  42516. }
  42517. // Reset all labels that have been shortened
  42518. data.forEach(function (point) {
  42519. if (point.dataLabel && point.visible && point.dataLabel.shortened) {
  42520. point.dataLabel
  42521. .attr({
  42522. width: 'auto'
  42523. }).css({
  42524. width: 'auto',
  42525. textOverflow: 'clip'
  42526. });
  42527. point.dataLabel.shortened = false;
  42528. }
  42529. });
  42530. // run parent method
  42531. Series.prototype.drawDataLabels.apply(series);
  42532. data.forEach(function (point) {
  42533. if (point.dataLabel) {
  42534. if (point.visible) { // #407, #2510
  42535. // Arrange points for detection collision
  42536. halves[point.half].push(point);
  42537. // Reset positions (#4905)
  42538. point.dataLabel._pos = null;
  42539. // Avoid long labels squeezing the pie size too far down
  42540. if (!defined(options.style.width) &&
  42541. !defined(point.options.dataLabels &&
  42542. point.options.dataLabels.style &&
  42543. point.options.dataLabels.style.width)) {
  42544. if (point.dataLabel.getBBox().width > maxWidth) {
  42545. point.dataLabel.css({
  42546. // Use a fraction of the maxWidth to avoid
  42547. // wrapping close to the end of the string.
  42548. width: Math.round(maxWidth * 0.7) + 'px'
  42549. });
  42550. point.dataLabel.shortened = true;
  42551. }
  42552. }
  42553. }
  42554. else {
  42555. point.dataLabel = point.dataLabel.destroy();
  42556. // Workaround to make pies destroy multiple datalabels
  42557. // correctly. This logic needs rewriting to support multiple
  42558. // datalabels fully.
  42559. if (point.dataLabels && point.dataLabels.length === 1) {
  42560. delete point.dataLabels;
  42561. }
  42562. }
  42563. }
  42564. });
  42565. /* Loop over the points in each half, starting from the top and bottom
  42566. * of the pie to detect overlapping labels.
  42567. */
  42568. halves.forEach(function (points, i) {
  42569. var top,
  42570. bottom,
  42571. length = points.length,
  42572. positions = [],
  42573. naturalY,
  42574. sideOverflow,
  42575. size,
  42576. distributionLength;
  42577. if (!length) {
  42578. return;
  42579. }
  42580. // Sort by angle
  42581. series.sortByAngle(points, i - 0.5);
  42582. // Only do anti-collision when we have dataLabels outside the pie
  42583. // and have connectors. (#856)
  42584. if (series.maxLabelDistance > 0) {
  42585. top = Math.max(0, centerY - radius - series.maxLabelDistance);
  42586. bottom = Math.min(centerY + radius + series.maxLabelDistance, chart.plotHeight);
  42587. points.forEach(function (point) {
  42588. // check if specific points' label is outside the pie
  42589. if (point.labelDistance > 0 && point.dataLabel) {
  42590. // point.top depends on point.labelDistance value
  42591. // Used for calculation of y value in getX method
  42592. point.top = Math.max(0, centerY - radius - point.labelDistance);
  42593. point.bottom = Math.min(centerY + radius + point.labelDistance, chart.plotHeight);
  42594. size = point.dataLabel.getBBox().height || 21;
  42595. // point.positionsIndex is needed for getting index of
  42596. // parameter related to specific point inside positions
  42597. // array - not every point is in positions array.
  42598. point.distributeBox = {
  42599. target: point.labelPosition.natural.y -
  42600. point.top + size / 2,
  42601. size: size,
  42602. rank: point.y
  42603. };
  42604. positions.push(point.distributeBox);
  42605. }
  42606. });
  42607. distributionLength = bottom + size - top;
  42608. H.distribute(positions, distributionLength, distributionLength / 5);
  42609. }
  42610. // Now the used slots are sorted, fill them up sequentially
  42611. for (j = 0; j < length; j++) {
  42612. point = points[j];
  42613. // labelPos = point.labelPos;
  42614. labelPosition = point.labelPosition;
  42615. dataLabel = point.dataLabel;
  42616. visibility = point.visible === false ? 'hidden' : 'inherit';
  42617. naturalY = labelPosition.natural.y;
  42618. y = naturalY;
  42619. if (positions && defined(point.distributeBox)) {
  42620. if (typeof point.distributeBox.pos === 'undefined') {
  42621. visibility = 'hidden';
  42622. }
  42623. else {
  42624. labelHeight = point.distributeBox.size;
  42625. // Find label's y position
  42626. y = dataLabelPositioners
  42627. .radialDistributionY(point);
  42628. }
  42629. }
  42630. // It is needed to delete point.positionIndex for
  42631. // dynamically added points etc.
  42632. delete point.positionIndex; // @todo unused
  42633. // Find label's x position
  42634. // justify is undocumented in the API - preserve support for it
  42635. if (options.justify) {
  42636. x = dataLabelPositioners.justify(point, radius, seriesCenter);
  42637. }
  42638. else {
  42639. switch (options.alignTo) {
  42640. case 'connectors':
  42641. x = dataLabelPositioners.alignToConnectors(points, i, plotWidth, plotLeft);
  42642. break;
  42643. case 'plotEdges':
  42644. x = dataLabelPositioners.alignToPlotEdges(dataLabel, i, plotWidth, plotLeft);
  42645. break;
  42646. default:
  42647. x = dataLabelPositioners.radialDistributionX(series, point, y, naturalY);
  42648. }
  42649. }
  42650. // Record the placement and visibility
  42651. dataLabel._attr = {
  42652. visibility: visibility,
  42653. align: labelPosition.alignment
  42654. };
  42655. pointDataLabelsOptions = point.options.dataLabels || {};
  42656. dataLabel._pos = {
  42657. x: (x +
  42658. pick(pointDataLabelsOptions.x, options.x) + // (#12985)
  42659. ({
  42660. left: connectorPadding,
  42661. right: -connectorPadding
  42662. }[labelPosition.alignment] || 0)),
  42663. // 10 is for the baseline (label vs text)
  42664. y: (y +
  42665. pick(pointDataLabelsOptions.y, options.y) - // (#12985)
  42666. 10)
  42667. };
  42668. // labelPos.x = x;
  42669. // labelPos.y = y;
  42670. labelPosition.final.x = x;
  42671. labelPosition.final.y = y;
  42672. // Detect overflowing data labels
  42673. if (pick(options.crop, true)) {
  42674. dataLabelWidth = dataLabel.getBBox().width;
  42675. sideOverflow = null;
  42676. // Overflow left
  42677. if (x - dataLabelWidth < connectorPadding &&
  42678. i === 1 // left half
  42679. ) {
  42680. sideOverflow = Math.round(dataLabelWidth - x + connectorPadding);
  42681. overflow[3] = Math.max(sideOverflow, overflow[3]);
  42682. // Overflow right
  42683. }
  42684. else if (x + dataLabelWidth > plotWidth - connectorPadding &&
  42685. i === 0 // right half
  42686. ) {
  42687. sideOverflow = Math.round(x + dataLabelWidth - plotWidth + connectorPadding);
  42688. overflow[1] = Math.max(sideOverflow, overflow[1]);
  42689. }
  42690. // Overflow top
  42691. if (y - labelHeight / 2 < 0) {
  42692. overflow[0] = Math.max(Math.round(-y + labelHeight / 2), overflow[0]);
  42693. // Overflow left
  42694. }
  42695. else if (y + labelHeight / 2 > plotHeight) {
  42696. overflow[2] = Math.max(Math.round(y + labelHeight / 2 - plotHeight), overflow[2]);
  42697. }
  42698. dataLabel.sideOverflow = sideOverflow;
  42699. }
  42700. } // for each point
  42701. }); // for each half
  42702. // Do not apply the final placement and draw the connectors until we
  42703. // have verified that labels are not spilling over.
  42704. if (arrayMax(overflow) === 0 ||
  42705. this.verifyDataLabelOverflow(overflow)) {
  42706. // Place the labels in the final position
  42707. this.placeDataLabels();
  42708. this.points.forEach(function (point) {
  42709. // #8864: every connector can have individual options
  42710. pointDataLabelsOptions =
  42711. merge(options, point.options.dataLabels);
  42712. connectorWidth =
  42713. pick(pointDataLabelsOptions.connectorWidth, 1);
  42714. // Draw the connector
  42715. if (connectorWidth) {
  42716. var isNew;
  42717. connector = point.connector;
  42718. dataLabel = point.dataLabel;
  42719. if (dataLabel &&
  42720. dataLabel._pos &&
  42721. point.visible &&
  42722. point.labelDistance > 0) {
  42723. visibility = dataLabel._attr.visibility;
  42724. isNew = !connector;
  42725. if (isNew) {
  42726. point.connector = connector = chart.renderer
  42727. .path()
  42728. .addClass('highcharts-data-label-connector ' +
  42729. ' highcharts-color-' + point.colorIndex +
  42730. (point.className ?
  42731. ' ' + point.className :
  42732. ''))
  42733. .add(series.dataLabelsGroup);
  42734. if (!chart.styledMode) {
  42735. connector.attr({
  42736. 'stroke-width': connectorWidth,
  42737. 'stroke': (pointDataLabelsOptions.connectorColor ||
  42738. point.color ||
  42739. '#666666')
  42740. });
  42741. }
  42742. }
  42743. connector[isNew ? 'attr' : 'animate']({
  42744. d: point.getConnectorPath()
  42745. });
  42746. connector.attr('visibility', visibility);
  42747. }
  42748. else if (connector) {
  42749. point.connector = connector.destroy();
  42750. }
  42751. }
  42752. });
  42753. }
  42754. };
  42755. /**
  42756. * Extendable method for getting the path of the connector between the data
  42757. * label and the pie slice.
  42758. *
  42759. * @private
  42760. * @function Highcharts.seriesTypes.pie#connectorPath
  42761. *
  42762. * @param {*} labelPos
  42763. *
  42764. * @return {Highcharts.SVGPathArray}
  42765. */
  42766. // TODO: depracated - remove it
  42767. /*
  42768. seriesTypes.pie.prototype.connectorPath = function (labelPos) {
  42769. var x = labelPos.x,
  42770. y = labelPos.y;
  42771. return pick(this.options.dataLabels.softConnector, true) ? [
  42772. 'M',
  42773. // end of the string at the label
  42774. x + (labelPos[6] === 'left' ? 5 : -5), y,
  42775. 'C',
  42776. x, y, // first break, next to the label
  42777. 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
  42778. labelPos[2], labelPos[3], // second break
  42779. 'L',
  42780. labelPos[4], labelPos[5] // base
  42781. ] : [
  42782. 'M',
  42783. // end of the string at the label
  42784. x + (labelPos[6] === 'left' ? 5 : -5), y,
  42785. 'L',
  42786. labelPos[2], labelPos[3], // second break
  42787. 'L',
  42788. labelPos[4], labelPos[5] // base
  42789. ];
  42790. };
  42791. */
  42792. /**
  42793. * Perform the final placement of the data labels after we have verified
  42794. * that they fall within the plot area.
  42795. *
  42796. * @private
  42797. * @function Highcharts.seriesTypes.pie#placeDataLabels
  42798. * @return {void}
  42799. */
  42800. seriesTypes.pie.prototype.placeDataLabels = function () {
  42801. this.points.forEach(function (point) {
  42802. var dataLabel = point.dataLabel,
  42803. _pos;
  42804. if (dataLabel && point.visible) {
  42805. _pos = dataLabel._pos;
  42806. if (_pos) {
  42807. // Shorten data labels with ellipsis if they still overflow
  42808. // after the pie has reached minSize (#223).
  42809. if (dataLabel.sideOverflow) {
  42810. dataLabel._attr.width =
  42811. Math.max(dataLabel.getBBox().width -
  42812. dataLabel.sideOverflow, 0);
  42813. dataLabel.css({
  42814. width: dataLabel._attr.width + 'px',
  42815. textOverflow: ((this.options.dataLabels.style || {})
  42816. .textOverflow ||
  42817. 'ellipsis')
  42818. });
  42819. dataLabel.shortened = true;
  42820. }
  42821. dataLabel.attr(dataLabel._attr);
  42822. dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
  42823. dataLabel.moved = true;
  42824. }
  42825. else if (dataLabel) {
  42826. dataLabel.attr({ y: -9999 });
  42827. }
  42828. }
  42829. // Clear for update
  42830. delete point.distributeBox;
  42831. }, this);
  42832. };
  42833. seriesTypes.pie.prototype.alignDataLabel = noop;
  42834. /**
  42835. * Verify whether the data labels are allowed to draw, or we should run more
  42836. * translation and data label positioning to keep them inside the plot area.
  42837. * Returns true when data labels are ready to draw.
  42838. *
  42839. * @private
  42840. * @function Highcharts.seriesTypes.pie#verifyDataLabelOverflow
  42841. * @param {Array<number>} overflow
  42842. * @return {boolean}
  42843. */
  42844. seriesTypes.pie.prototype.verifyDataLabelOverflow = function (overflow) {
  42845. var center = this.center,
  42846. options = this.options,
  42847. centerOption = options.center,
  42848. minSize = options.minSize || 80,
  42849. newSize = minSize,
  42850. // If a size is set, return true and don't try to shrink the pie
  42851. // to fit the labels.
  42852. ret = options.size !== null;
  42853. if (!ret) {
  42854. // Handle horizontal size and center
  42855. if (centerOption[0] !== null) { // Fixed center
  42856. newSize = Math.max(center[2] -
  42857. Math.max(overflow[1], overflow[3]), minSize);
  42858. }
  42859. else { // Auto center
  42860. newSize = Math.max(
  42861. // horizontal overflow
  42862. center[2] - overflow[1] - overflow[3], minSize);
  42863. // horizontal center
  42864. center[0] += (overflow[3] - overflow[1]) / 2;
  42865. }
  42866. // Handle vertical size and center
  42867. if (centerOption[1] !== null) { // Fixed center
  42868. newSize = clamp(newSize, minSize, center[2] - Math.max(overflow[0], overflow[2]));
  42869. }
  42870. else { // Auto center
  42871. newSize = clamp(newSize, minSize,
  42872. // vertical overflow
  42873. center[2] - overflow[0] - overflow[2]);
  42874. // vertical center
  42875. center[1] += (overflow[0] - overflow[2]) / 2;
  42876. }
  42877. // If the size must be decreased, we need to run translate and
  42878. // drawDataLabels again
  42879. if (newSize < center[2]) {
  42880. center[2] = newSize;
  42881. center[3] = Math.min(// #3632
  42882. relativeLength(options.innerSize || 0, newSize), newSize);
  42883. this.translate(center);
  42884. if (this.drawDataLabels) {
  42885. this.drawDataLabels();
  42886. }
  42887. // Else, return true to indicate that the pie and its labels is
  42888. // within the plot area
  42889. }
  42890. else {
  42891. ret = true;
  42892. }
  42893. }
  42894. return ret;
  42895. };
  42896. }
  42897. if (seriesTypes.column) {
  42898. /**
  42899. * Override the basic data label alignment by adjusting for the position of
  42900. * the column.
  42901. *
  42902. * @private
  42903. * @function Highcharts.seriesTypes.column#alignDataLabel
  42904. * @param {Highcharts.Point} point
  42905. * @param {Highcharts.SVGElement} dataLabel
  42906. * @param {Highcharts.DataLabelsOptions} options
  42907. * @param {Highcharts.BBoxObject} alignTo
  42908. * @param {boolean} [isNew]
  42909. * @return {void}
  42910. */
  42911. seriesTypes.column.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  42912. var inverted = this.chart.inverted,
  42913. series = point.series,
  42914. // data label box for alignment
  42915. dlBox = point.dlBox || point.shapeArgs,
  42916. below = pick(point.below, // range series
  42917. point.plotY >
  42918. pick(this.translatedThreshold,
  42919. series.yAxis.len)),
  42920. // draw it inside the box?
  42921. inside = pick(options.inside, !!this.options.stacking),
  42922. overshoot;
  42923. // Align to the column itself, or the top of it
  42924. if (dlBox) { // Area range uses this method but not alignTo
  42925. alignTo = merge(dlBox);
  42926. if (alignTo.y < 0) {
  42927. alignTo.height += alignTo.y;
  42928. alignTo.y = 0;
  42929. }
  42930. // If parts of the box overshoots outside the plot area, modify the
  42931. // box to center the label inside
  42932. overshoot = alignTo.y + alignTo.height - series.yAxis.len;
  42933. if (overshoot > 0 && overshoot < alignTo.height) {
  42934. alignTo.height -= overshoot;
  42935. }
  42936. if (inverted) {
  42937. alignTo = {
  42938. x: series.yAxis.len - alignTo.y - alignTo.height,
  42939. y: series.xAxis.len - alignTo.x - alignTo.width,
  42940. width: alignTo.height,
  42941. height: alignTo.width
  42942. };
  42943. }
  42944. // Compute the alignment box
  42945. if (!inside) {
  42946. if (inverted) {
  42947. alignTo.x += below ? 0 : alignTo.width;
  42948. alignTo.width = 0;
  42949. }
  42950. else {
  42951. alignTo.y += below ? alignTo.height : 0;
  42952. alignTo.height = 0;
  42953. }
  42954. }
  42955. }
  42956. // When alignment is undefined (typically columns and bars), display the
  42957. // individual point below or above the point depending on the threshold
  42958. options.align = pick(options.align, !inverted || inside ? 'center' : below ? 'right' : 'left');
  42959. options.verticalAlign = pick(options.verticalAlign, inverted || inside ? 'middle' : below ? 'top' : 'bottom');
  42960. // Call the parent method
  42961. Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
  42962. // If label was justified and we have contrast, set it:
  42963. if (options.inside && point.contrastColor) {
  42964. dataLabel.css({
  42965. color: point.contrastColor
  42966. });
  42967. }
  42968. };
  42969. }
  42970. });
  42971. _registerModule(_modules, 'Extensions/OverlappingDataLabels.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  42972. /* *
  42973. *
  42974. * Highcharts module to hide overlapping data labels.
  42975. * This module is included in Highcharts.
  42976. *
  42977. * (c) 2009-2020 Torstein Honsi
  42978. *
  42979. * License: www.highcharts.com/license
  42980. *
  42981. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42982. *
  42983. * */
  42984. var addEvent = U.addEvent,
  42985. fireEvent = U.fireEvent,
  42986. isArray = U.isArray,
  42987. isNumber = U.isNumber,
  42988. objectEach = U.objectEach,
  42989. pick = U.pick;
  42990. /* eslint-disable no-invalid-this */
  42991. // Collect potensial overlapping data labels. Stack labels probably don't need
  42992. // to be considered because they are usually accompanied by data labels that lie
  42993. // inside the columns.
  42994. addEvent(Chart, 'render', function collectAndHide() {
  42995. var labels = [];
  42996. // Consider external label collectors
  42997. (this.labelCollectors || []).forEach(function (collector) {
  42998. labels = labels.concat(collector());
  42999. });
  43000. (this.yAxis || []).forEach(function (yAxis) {
  43001. if (yAxis.stacking &&
  43002. yAxis.options.stackLabels &&
  43003. !yAxis.options.stackLabels.allowOverlap) {
  43004. objectEach(yAxis.stacking.stacks, function (stack) {
  43005. objectEach(stack, function (stackItem) {
  43006. labels.push(stackItem.label);
  43007. });
  43008. });
  43009. }
  43010. });
  43011. (this.series || []).forEach(function (series) {
  43012. var dlOptions = series.options.dataLabels;
  43013. if (series.visible &&
  43014. !(dlOptions.enabled === false && !series._hasPointLabels)) { // #3866
  43015. (series.nodes || series.points).forEach(function (point) {
  43016. if (point.visible) {
  43017. var dataLabels = (isArray(point.dataLabels) ?
  43018. point.dataLabels :
  43019. (point.dataLabel ? [point.dataLabel] : []));
  43020. dataLabels.forEach(function (label) {
  43021. var options = label.options;
  43022. label.labelrank = pick(options.labelrank, point.labelrank, point.shapeArgs && point.shapeArgs.height); // #4118
  43023. if (!options.allowOverlap) {
  43024. labels.push(label);
  43025. }
  43026. });
  43027. }
  43028. });
  43029. }
  43030. });
  43031. this.hideOverlappingLabels(labels);
  43032. });
  43033. /**
  43034. * Hide overlapping labels. Labels are moved and faded in and out on zoom to
  43035. * provide a smooth visual imression.
  43036. *
  43037. * @private
  43038. * @function Highcharts.Chart#hideOverlappingLabels
  43039. * @param {Array<Highcharts.SVGElement>} labels
  43040. * Rendered data labels
  43041. * @requires modules/overlapping-datalabels
  43042. */
  43043. Chart.prototype.hideOverlappingLabels = function (labels) {
  43044. var chart = this,
  43045. len = labels.length,
  43046. ren = chart.renderer,
  43047. label,
  43048. i,
  43049. j,
  43050. label1,
  43051. label2,
  43052. box1,
  43053. box2,
  43054. isLabelAffected = false,
  43055. isIntersectRect = function (box1,
  43056. box2) {
  43057. return !(box2.x >= box1.x + box1.width ||
  43058. box2.x + box2.width <= box1.x ||
  43059. box2.y >= box1.y + box1.height ||
  43060. box2.y + box2.height <= box1.y);
  43061. },
  43062. // Get the box with its position inside the chart, as opposed to getBBox
  43063. // that only reports the position relative to the parent.
  43064. getAbsoluteBox = function (label) {
  43065. var pos,
  43066. parent,
  43067. bBox,
  43068. // Substract the padding if no background or border (#4333)
  43069. padding = label.box ? 0 : (label.padding || 0),
  43070. lineHeightCorrection = 0,
  43071. xOffset = 0,
  43072. boxWidth,
  43073. alignValue;
  43074. if (label &&
  43075. (!label.alignAttr || label.placed)) {
  43076. pos = label.alignAttr || {
  43077. x: label.attr('x'),
  43078. y: label.attr('y')
  43079. };
  43080. parent = label.parentGroup;
  43081. // Get width and height if pure text nodes (stack labels)
  43082. if (!label.width) {
  43083. bBox = label.getBBox();
  43084. label.width = bBox.width;
  43085. label.height = bBox.height;
  43086. // Labels positions are computed from top left corner, so
  43087. // we need to substract the text height from text nodes too.
  43088. lineHeightCorrection = ren
  43089. .fontMetrics(null, label.element).h;
  43090. }
  43091. boxWidth = label.width - 2 * padding;
  43092. alignValue = {
  43093. left: '0',
  43094. center: '0.5',
  43095. right: '1'
  43096. }[label.alignValue];
  43097. if (alignValue) {
  43098. xOffset = +alignValue * boxWidth;
  43099. }
  43100. else if (isNumber(label.x) && Math.round(label.x) !== label.translateX) {
  43101. xOffset = label.x - label.translateX;
  43102. }
  43103. return {
  43104. x: pos.x + (parent.translateX || 0) + padding -
  43105. (xOffset || 0),
  43106. y: pos.y + (parent.translateY || 0) + padding -
  43107. lineHeightCorrection,
  43108. width: label.width - 2 * padding,
  43109. height: label.height - 2 * padding
  43110. };
  43111. }
  43112. };
  43113. for (i = 0; i < len; i++) {
  43114. label = labels[i];
  43115. if (label) {
  43116. // Mark with initial opacity
  43117. label.oldOpacity = label.opacity;
  43118. label.newOpacity = 1;
  43119. label.absoluteBox = getAbsoluteBox(label);
  43120. }
  43121. }
  43122. // Prevent a situation in a gradually rising slope, that each label will
  43123. // hide the previous one because the previous one always has lower rank.
  43124. labels.sort(function (a, b) {
  43125. return (b.labelrank || 0) - (a.labelrank || 0);
  43126. });
  43127. // Detect overlapping labels
  43128. for (i = 0; i < len; i++) {
  43129. label1 = labels[i];
  43130. box1 = label1 && label1.absoluteBox;
  43131. for (j = i + 1; j < len; ++j) {
  43132. label2 = labels[j];
  43133. box2 = label2 && label2.absoluteBox;
  43134. if (box1 &&
  43135. box2 &&
  43136. label1 !== label2 && // #6465, polar chart with connectEnds
  43137. label1.newOpacity !== 0 &&
  43138. label2.newOpacity !== 0) {
  43139. if (isIntersectRect(box1, box2)) {
  43140. (label1.labelrank < label2.labelrank ? label1 : label2)
  43141. .newOpacity = 0;
  43142. }
  43143. }
  43144. }
  43145. }
  43146. // Hide or show
  43147. labels.forEach(function (label) {
  43148. var complete,
  43149. newOpacity;
  43150. if (label) {
  43151. newOpacity = label.newOpacity;
  43152. if (label.oldOpacity !== newOpacity) {
  43153. // Make sure the label is completely hidden to avoid catching
  43154. // clicks (#4362)
  43155. if (label.alignAttr && label.placed) { // data labels
  43156. label[newOpacity ? 'removeClass' : 'addClass']('highcharts-data-label-hidden');
  43157. complete = function () {
  43158. if (!chart.styledMode) {
  43159. label.css({ pointerEvents: newOpacity ? 'auto' : 'none' });
  43160. }
  43161. label.visibility = newOpacity ? 'inherit' : 'hidden';
  43162. };
  43163. isLabelAffected = true;
  43164. // Animate or set the opacity
  43165. label.alignAttr.opacity = newOpacity;
  43166. label[label.isOld ? 'animate' : 'attr'](label.alignAttr, null, complete);
  43167. fireEvent(chart, 'afterHideOverlappingLabel');
  43168. }
  43169. else { // other labels, tick labels
  43170. label.attr({
  43171. opacity: newOpacity
  43172. });
  43173. }
  43174. }
  43175. label.isOld = true;
  43176. }
  43177. });
  43178. if (isLabelAffected) {
  43179. fireEvent(chart, 'afterHideAllOverlappingLabels');
  43180. }
  43181. };
  43182. });
  43183. _registerModule(_modules, 'Core/Interaction.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (Chart, H, Legend, O, Point, U) {
  43184. /* *
  43185. *
  43186. * (c) 2010-2020 Torstein Honsi
  43187. *
  43188. * License: www.highcharts.com/license
  43189. *
  43190. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43191. *
  43192. * */
  43193. var defaultOptions = O.defaultOptions;
  43194. var addEvent = U.addEvent,
  43195. createElement = U.createElement,
  43196. css = U.css,
  43197. defined = U.defined,
  43198. extend = U.extend,
  43199. fireEvent = U.fireEvent,
  43200. isArray = U.isArray,
  43201. isFunction = U.isFunction,
  43202. isNumber = U.isNumber,
  43203. isObject = U.isObject,
  43204. merge = U.merge,
  43205. objectEach = U.objectEach,
  43206. pick = U.pick;
  43207. /**
  43208. * @interface Highcharts.PointEventsOptionsObject
  43209. */ /**
  43210. * Fires when the point is selected either programmatically or following a click
  43211. * on the point. One parameter, `event`, is passed to the function. Returning
  43212. * `false` cancels the operation.
  43213. * @name Highcharts.PointEventsOptionsObject#select
  43214. * @type {Highcharts.PointSelectCallbackFunction|undefined}
  43215. */ /**
  43216. * Fires when the point is unselected either programmatically or following a
  43217. * click on the point. One parameter, `event`, is passed to the function.
  43218. * Returning `false` cancels the operation.
  43219. * @name Highcharts.PointEventsOptionsObject#unselect
  43220. * @type {Highcharts.PointUnselectCallbackFunction|undefined}
  43221. */
  43222. /**
  43223. * Information about the select/unselect event.
  43224. *
  43225. * @interface Highcharts.PointInteractionEventObject
  43226. * @extends global.Event
  43227. */ /**
  43228. * @name Highcharts.PointInteractionEventObject#accumulate
  43229. * @type {boolean}
  43230. */
  43231. /**
  43232. * Gets fired when the point is selected either programmatically or following a
  43233. * click on the point.
  43234. *
  43235. * @callback Highcharts.PointSelectCallbackFunction
  43236. *
  43237. * @param {Highcharts.Point} this
  43238. * Point where the event occured.
  43239. *
  43240. * @param {Highcharts.PointInteractionEventObject} event
  43241. * Event that occured.
  43242. */
  43243. /**
  43244. * Fires when the point is unselected either programmatically or following a
  43245. * click on the point.
  43246. *
  43247. * @callback Highcharts.PointUnselectCallbackFunction
  43248. *
  43249. * @param {Highcharts.Point} this
  43250. * Point where the event occured.
  43251. *
  43252. * @param {Highcharts.PointInteractionEventObject} event
  43253. * Event that occured.
  43254. */
  43255. var hasTouch = H.hasTouch,
  43256. Series = H.Series,
  43257. seriesTypes = H.seriesTypes,
  43258. svg = H.svg,
  43259. TrackerMixin;
  43260. /* eslint-disable valid-jsdoc */
  43261. /**
  43262. * TrackerMixin for points and graphs.
  43263. *
  43264. * @private
  43265. * @mixin Highcharts.TrackerMixin
  43266. */
  43267. TrackerMixin = H.TrackerMixin = {
  43268. /**
  43269. * Draw the tracker for a point.
  43270. *
  43271. * @private
  43272. * @function Highcharts.TrackerMixin.drawTrackerPoint
  43273. * @param {Highcharts.Series} this
  43274. * @fires Highcharts.Series#event:afterDrawTracker
  43275. */
  43276. drawTrackerPoint: function () {
  43277. var series = this,
  43278. chart = series.chart,
  43279. pointer = chart.pointer,
  43280. onMouseOver = function (e) {
  43281. var point = pointer.getPointFromEvent(e);
  43282. // undefined on graph in scatterchart
  43283. if (typeof point !== 'undefined') {
  43284. pointer.isDirectTouch = true;
  43285. point.onMouseOver(e);
  43286. }
  43287. }, dataLabels;
  43288. // Add reference to the point
  43289. series.points.forEach(function (point) {
  43290. dataLabels = (isArray(point.dataLabels) ?
  43291. point.dataLabels :
  43292. (point.dataLabel ? [point.dataLabel] : []));
  43293. if (point.graphic) {
  43294. point.graphic.element.point = point;
  43295. }
  43296. dataLabels.forEach(function (dataLabel) {
  43297. if (dataLabel.div) {
  43298. dataLabel.div.point = point;
  43299. }
  43300. else {
  43301. dataLabel.element.point = point;
  43302. }
  43303. });
  43304. });
  43305. // Add the event listeners, we need to do this only once
  43306. if (!series._hasTracking) {
  43307. series.trackerGroups.forEach(function (key) {
  43308. if (series[key]) {
  43309. // we don't always have dataLabelsGroup
  43310. series[key]
  43311. .addClass('highcharts-tracker')
  43312. .on('mouseover', onMouseOver)
  43313. .on('mouseout', function (e) {
  43314. pointer.onTrackerMouseOut(e);
  43315. });
  43316. if (hasTouch) {
  43317. series[key].on('touchstart', onMouseOver);
  43318. }
  43319. if (!chart.styledMode && series.options.cursor) {
  43320. series[key]
  43321. .css(css)
  43322. .css({ cursor: series.options.cursor });
  43323. }
  43324. }
  43325. });
  43326. series._hasTracking = true;
  43327. }
  43328. fireEvent(this, 'afterDrawTracker');
  43329. },
  43330. /**
  43331. * Draw the tracker object that sits above all data labels and markers to
  43332. * track mouse events on the graph or points. For the line type charts
  43333. * the tracker uses the same graphPath, but with a greater stroke width
  43334. * for better control.
  43335. *
  43336. * @private
  43337. * @function Highcharts.TrackerMixin.drawTrackerGraph
  43338. * @param {Highcharts.Series} this
  43339. * @fires Highcharts.Series#event:afterDrawTracker
  43340. */
  43341. drawTrackerGraph: function () {
  43342. var series = this,
  43343. options = series.options,
  43344. trackByArea = options.trackByArea,
  43345. trackerPath = [].concat(trackByArea ?
  43346. series.areaPath :
  43347. series.graphPath),
  43348. // trackerPathLength = trackerPath.length,
  43349. chart = series.chart,
  43350. pointer = chart.pointer,
  43351. renderer = chart.renderer,
  43352. snap = chart.options.tooltip.snap,
  43353. tracker = series.tracker,
  43354. i,
  43355. onMouseOver = function (e) {
  43356. if (chart.hoverSeries !== series) {
  43357. series.onMouseOver();
  43358. }
  43359. },
  43360. /*
  43361. * Empirical lowest possible opacities for TRACKER_FILL for an
  43362. * element to stay invisible but clickable
  43363. * IE6: 0.002
  43364. * IE7: 0.002
  43365. * IE8: 0.002
  43366. * IE9: 0.00000000001 (unlimited)
  43367. * IE10: 0.0001 (exporting only)
  43368. * FF: 0.00000000001 (unlimited)
  43369. * Chrome: 0.000001
  43370. * Safari: 0.000001
  43371. * Opera: 0.00000000001 (unlimited)
  43372. */
  43373. TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
  43374. // Draw the tracker
  43375. if (tracker) {
  43376. tracker.attr({ d: trackerPath });
  43377. }
  43378. else if (series.graph) { // create
  43379. series.tracker = renderer.path(trackerPath)
  43380. .attr({
  43381. visibility: series.visible ? 'visible' : 'hidden',
  43382. zIndex: 2
  43383. })
  43384. .addClass(trackByArea ?
  43385. 'highcharts-tracker-area' :
  43386. 'highcharts-tracker-line')
  43387. .add(series.group);
  43388. if (!chart.styledMode) {
  43389. series.tracker.attr({
  43390. 'stroke-linecap': 'round',
  43391. 'stroke-linejoin': 'round',
  43392. stroke: TRACKER_FILL,
  43393. fill: trackByArea ? TRACKER_FILL : 'none',
  43394. 'stroke-width': series.graph.strokeWidth() +
  43395. (trackByArea ? 0 : 2 * snap)
  43396. });
  43397. }
  43398. // The tracker is added to the series group, which is clipped, but
  43399. // is covered by the marker group. So the marker group also needs to
  43400. // capture events.
  43401. [series.tracker, series.markerGroup].forEach(function (tracker) {
  43402. tracker.addClass('highcharts-tracker')
  43403. .on('mouseover', onMouseOver)
  43404. .on('mouseout', function (e) {
  43405. pointer.onTrackerMouseOut(e);
  43406. });
  43407. if (options.cursor && !chart.styledMode) {
  43408. tracker.css({ cursor: options.cursor });
  43409. }
  43410. if (hasTouch) {
  43411. tracker.on('touchstart', onMouseOver);
  43412. }
  43413. });
  43414. }
  43415. fireEvent(this, 'afterDrawTracker');
  43416. }
  43417. };
  43418. /* End TrackerMixin */
  43419. // Add tracking event listener to the series group, so the point graphics
  43420. // themselves act as trackers
  43421. if (seriesTypes.column) {
  43422. /**
  43423. * @private
  43424. * @borrows Highcharts.TrackerMixin.drawTrackerPoint as Highcharts.seriesTypes.column#drawTracker
  43425. */
  43426. seriesTypes.column.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
  43427. }
  43428. if (seriesTypes.pie) {
  43429. /**
  43430. * @private
  43431. * @borrows Highcharts.TrackerMixin.drawTrackerPoint as Highcharts.seriesTypes.pie#drawTracker
  43432. */
  43433. seriesTypes.pie.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
  43434. }
  43435. if (seriesTypes.scatter) {
  43436. /**
  43437. * @private
  43438. * @borrows Highcharts.TrackerMixin.drawTrackerPoint as Highcharts.seriesTypes.scatter#drawTracker
  43439. */
  43440. seriesTypes.scatter.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
  43441. }
  43442. // Extend Legend for item events.
  43443. extend(Legend.prototype, {
  43444. /**
  43445. * @private
  43446. * @function Highcharts.Legend#setItemEvents
  43447. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  43448. * @param {Highcharts.SVGElement} legendItem
  43449. * @param {boolean} [useHTML=false]
  43450. * @fires Highcharts.Point#event:legendItemClick
  43451. * @fires Highcharts.Series#event:legendItemClick
  43452. */
  43453. setItemEvents: function (item, legendItem, useHTML) {
  43454. var legend = this,
  43455. boxWrapper = legend.chart.renderer.boxWrapper,
  43456. isPoint = item instanceof Point,
  43457. activeClass = 'highcharts-legend-' +
  43458. (isPoint ? 'point' : 'series') + '-active',
  43459. styledMode = legend.chart.styledMode,
  43460. // When `useHTML`, the symbol is rendered in other group, so
  43461. // we need to apply events listeners to both places
  43462. legendItems = useHTML ?
  43463. [legendItem,
  43464. item.legendSymbol] :
  43465. [item.legendGroup];
  43466. // Set the events on the item group, or in case of useHTML, the item
  43467. // itself (#1249)
  43468. legendItems.forEach(function (element) {
  43469. if (element) {
  43470. element
  43471. .on('mouseover', function () {
  43472. if (item.visible) {
  43473. legend.allItems.forEach(function (inactiveItem) {
  43474. if (item !== inactiveItem) {
  43475. inactiveItem.setState('inactive', !isPoint);
  43476. }
  43477. });
  43478. }
  43479. item.setState('hover');
  43480. // A CSS class to dim or hide other than the hovered
  43481. // series.
  43482. // Works only if hovered series is visible (#10071).
  43483. if (item.visible) {
  43484. boxWrapper.addClass(activeClass);
  43485. }
  43486. if (!styledMode) {
  43487. legendItem.css(legend.options.itemHoverStyle);
  43488. }
  43489. })
  43490. .on('mouseout', function () {
  43491. if (!legend.chart.styledMode) {
  43492. legendItem.css(merge(item.visible ?
  43493. legend.itemStyle :
  43494. legend.itemHiddenStyle));
  43495. }
  43496. legend.allItems.forEach(function (inactiveItem) {
  43497. if (item !== inactiveItem) {
  43498. inactiveItem.setState('', !isPoint);
  43499. }
  43500. });
  43501. // A CSS class to dim or hide other than the hovered
  43502. // series.
  43503. boxWrapper.removeClass(activeClass);
  43504. item.setState();
  43505. })
  43506. .on('click', function (event) {
  43507. var strLegendItemClick = 'legendItemClick',
  43508. fnLegendItemClick = function () {
  43509. if (item.setVisible) {
  43510. item.setVisible();
  43511. }
  43512. // Reset inactive state
  43513. legend.allItems.forEach(function (inactiveItem) {
  43514. if (item !== inactiveItem) {
  43515. inactiveItem.setState(item.visible ? 'inactive' : '', !isPoint);
  43516. }
  43517. });
  43518. };
  43519. // A CSS class to dim or hide other than the hovered
  43520. // series. Event handling in iOS causes the activeClass
  43521. // to be added prior to click in some cases (#7418).
  43522. boxWrapper.removeClass(activeClass);
  43523. // Pass over the click/touch event. #4.
  43524. event = {
  43525. browserEvent: event
  43526. };
  43527. // click the name or symbol
  43528. if (item.firePointEvent) { // point
  43529. item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
  43530. }
  43531. else {
  43532. fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
  43533. }
  43534. });
  43535. }
  43536. });
  43537. },
  43538. /**
  43539. * @private
  43540. * @function Highcharts.Legend#createCheckboxForItem
  43541. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  43542. * @fires Highcharts.Series#event:checkboxClick
  43543. */
  43544. createCheckboxForItem: function (item) {
  43545. var legend = this;
  43546. item.checkbox = createElement('input', {
  43547. type: 'checkbox',
  43548. className: 'highcharts-legend-checkbox',
  43549. checked: item.selected,
  43550. defaultChecked: item.selected // required by IE7
  43551. }, legend.options.itemCheckboxStyle, legend.chart.container);
  43552. addEvent(item.checkbox, 'click', function (event) {
  43553. var target = event.target;
  43554. fireEvent(item.series || item, 'checkboxClick', {
  43555. checked: target.checked,
  43556. item: item
  43557. }, function () {
  43558. item.select();
  43559. });
  43560. });
  43561. }
  43562. });
  43563. // Extend the Chart object with interaction
  43564. extend(Chart.prototype, /** @lends Chart.prototype */ {
  43565. /**
  43566. * Display the zoom button, so users can reset zoom to the default view
  43567. * settings.
  43568. *
  43569. * @function Highcharts.Chart#showResetZoom
  43570. *
  43571. * @fires Highcharts.Chart#event:afterShowResetZoom
  43572. * @fires Highcharts.Chart#event:beforeShowResetZoom
  43573. */
  43574. showResetZoom: function () {
  43575. var chart = this,
  43576. lang = defaultOptions.lang,
  43577. btnOptions = chart.options.chart.resetZoomButton,
  43578. theme = btnOptions.theme,
  43579. states = theme.states,
  43580. alignTo = (btnOptions.relativeTo === 'chart' ||
  43581. btnOptions.relativeTo === 'spaceBox' ?
  43582. null :
  43583. 'plotBox');
  43584. /**
  43585. * @private
  43586. */
  43587. function zoomOut() {
  43588. chart.zoomOut();
  43589. }
  43590. fireEvent(this, 'beforeShowResetZoom', null, function () {
  43591. chart.resetZoomButton = chart.renderer
  43592. .button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
  43593. .attr({
  43594. align: btnOptions.position.align,
  43595. title: lang.resetZoomTitle
  43596. })
  43597. .addClass('highcharts-reset-zoom')
  43598. .add()
  43599. .align(btnOptions.position, false, alignTo);
  43600. });
  43601. fireEvent(this, 'afterShowResetZoom');
  43602. },
  43603. /**
  43604. * Zoom the chart out after a user has zoomed in. See also
  43605. * [Axis.setExtremes](/class-reference/Highcharts.Axis#setExtremes).
  43606. *
  43607. * @function Highcharts.Chart#zoomOut
  43608. *
  43609. * @fires Highcharts.Chart#event:selection
  43610. */
  43611. zoomOut: function () {
  43612. fireEvent(this, 'selection', { resetSelection: true }, this.zoom);
  43613. },
  43614. /**
  43615. * Zoom into a given portion of the chart given by axis coordinates.
  43616. *
  43617. * @private
  43618. * @function Highcharts.Chart#zoom
  43619. * @param {Highcharts.SelectEventObject} event
  43620. */
  43621. zoom: function (event) {
  43622. var chart = this,
  43623. hasZoomed,
  43624. pointer = chart.pointer,
  43625. displayButton = false,
  43626. mouseDownPos = chart.inverted ? pointer.mouseDownX : pointer.mouseDownY,
  43627. resetZoomButton;
  43628. // If zoom is called with no arguments, reset the axes
  43629. if (!event || event.resetSelection) {
  43630. chart.axes.forEach(function (axis) {
  43631. hasZoomed = axis.zoom();
  43632. });
  43633. pointer.initiated = false; // #6804
  43634. }
  43635. else { // else, zoom in on all axes
  43636. event.xAxis.concat(event.yAxis).forEach(function (axisData) {
  43637. var axis = axisData.axis,
  43638. axisStartPos = chart.inverted ? axis.left : axis.top,
  43639. axisEndPos = chart.inverted ?
  43640. axisStartPos + axis.width : axisStartPos + axis.height,
  43641. isXAxis = axis.isXAxis,
  43642. isWithinPane = false;
  43643. // Check if zoomed area is within the pane (#1289).
  43644. // In case of multiple panes only one pane should be zoomed.
  43645. if ((!isXAxis &&
  43646. mouseDownPos >= axisStartPos &&
  43647. mouseDownPos <= axisEndPos) ||
  43648. isXAxis ||
  43649. !defined(mouseDownPos)) {
  43650. isWithinPane = true;
  43651. }
  43652. // don't zoom more than minRange
  43653. if (pointer[isXAxis ? 'zoomX' : 'zoomY'] && isWithinPane) {
  43654. hasZoomed = axis.zoom(axisData.min, axisData.max);
  43655. if (axis.displayBtn) {
  43656. displayButton = true;
  43657. }
  43658. }
  43659. });
  43660. }
  43661. // Show or hide the Reset zoom button
  43662. resetZoomButton = chart.resetZoomButton;
  43663. if (displayButton && !resetZoomButton) {
  43664. chart.showResetZoom();
  43665. }
  43666. else if (!displayButton && isObject(resetZoomButton)) {
  43667. chart.resetZoomButton = resetZoomButton.destroy();
  43668. }
  43669. // Redraw
  43670. if (hasZoomed) {
  43671. chart.redraw(pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100));
  43672. }
  43673. },
  43674. /**
  43675. * Pan the chart by dragging the mouse across the pane. This function is
  43676. * called on mouse move, and the distance to pan is computed from chartX
  43677. * compared to the first chartX position in the dragging operation.
  43678. *
  43679. * @private
  43680. * @function Highcharts.Chart#pan
  43681. * @param {Highcharts.PointerEventObject} e
  43682. * @param {string} panning
  43683. */
  43684. pan: function (e, panning) {
  43685. var chart = this,
  43686. hoverPoints = chart.hoverPoints,
  43687. panningOptions,
  43688. chartOptions = chart.options.chart,
  43689. hasMapNavigation = chart.options.mapNavigation &&
  43690. chart.options.mapNavigation.enabled,
  43691. doRedraw,
  43692. type;
  43693. if (typeof panning === 'object') {
  43694. panningOptions = panning;
  43695. }
  43696. else {
  43697. panningOptions = {
  43698. enabled: panning,
  43699. type: 'x'
  43700. };
  43701. }
  43702. if (chartOptions && chartOptions.panning) {
  43703. chartOptions.panning = panningOptions;
  43704. }
  43705. type = panningOptions.type;
  43706. fireEvent(this, 'pan', { originalEvent: e }, function () {
  43707. // remove active points for shared tooltip
  43708. if (hoverPoints) {
  43709. hoverPoints.forEach(function (point) {
  43710. point.setState();
  43711. });
  43712. }
  43713. // panning axis mapping
  43714. var xy = [1]; // x
  43715. if (type === 'xy') {
  43716. xy = [1, 0];
  43717. }
  43718. else if (type === 'y') {
  43719. xy = [0];
  43720. }
  43721. xy.forEach(function (isX) {
  43722. 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) ||
  43723. (!axis.reversed && chart.inverted) ?
  43724. -1 :
  43725. 1, extremes = axis.getExtremes(), panMin = axis.toValue(startPos - mousePos, true) +
  43726. halfPointRange * pointRangeDirection, panMax = axis.toValue(startPos + axis.len - mousePos, true) -
  43727. halfPointRange * pointRangeDirection, flipped = panMax < panMin, newMin = flipped ? panMax : panMin, newMax = flipped ? panMin : panMax, hasVerticalPanning = axis.hasVerticalPanning(), paddedMin, paddedMax, spill, panningState = axis.panningState;
  43728. // General calculations of panning state.
  43729. // This is related to using vertical panning. (#11315).
  43730. axis.series.forEach(function (series) {
  43731. if (hasVerticalPanning &&
  43732. !isX && (!panningState || panningState.isDirty)) {
  43733. var processedData = series.getProcessedData(true),
  43734. dataExtremes = series.getExtremes(processedData.yData,
  43735. true);
  43736. if (!panningState) {
  43737. panningState = {
  43738. startMin: Number.MAX_VALUE,
  43739. startMax: -Number.MAX_VALUE
  43740. };
  43741. }
  43742. if (isNumber(dataExtremes.dataMin) &&
  43743. isNumber(dataExtremes.dataMax)) {
  43744. panningState.startMin = Math.min(dataExtremes.dataMin, panningState.startMin);
  43745. panningState.startMax = Math.max(dataExtremes.dataMax, panningState.startMax);
  43746. }
  43747. }
  43748. });
  43749. paddedMin = Math.min(H.pick(panningState === null || panningState === void 0 ? void 0 : panningState.startMin, extremes.dataMin), halfPointRange ?
  43750. extremes.min :
  43751. axis.toValue(axis.toPixels(extremes.min) -
  43752. axis.minPixelPadding));
  43753. paddedMax = Math.max(H.pick(panningState === null || panningState === void 0 ? void 0 : panningState.startMax, extremes.dataMax), halfPointRange ?
  43754. extremes.max :
  43755. axis.toValue(axis.toPixels(extremes.max) +
  43756. axis.minPixelPadding));
  43757. axis.panningState = panningState;
  43758. // It is not necessary to calculate extremes on ordinal axis,
  43759. // because they are already calculated, so we don't want to
  43760. // override them.
  43761. if (!axis.isOrdinal) {
  43762. // If the new range spills over, either to the min or max,
  43763. // adjust the new range.
  43764. spill = paddedMin - newMin;
  43765. if (spill > 0) {
  43766. newMax += spill;
  43767. newMin = paddedMin;
  43768. }
  43769. spill = newMax - paddedMax;
  43770. if (spill > 0) {
  43771. newMax = paddedMax;
  43772. newMin -= spill;
  43773. }
  43774. // Set new extremes if they are actually new
  43775. if (axis.series.length &&
  43776. newMin !== extremes.min &&
  43777. newMax !== extremes.max &&
  43778. newMin >= paddedMin &&
  43779. newMax <= paddedMax) {
  43780. axis.setExtremes(newMin, newMax, false, false, { trigger: 'pan' });
  43781. if (!chart.resetZoomButton &&
  43782. !hasMapNavigation &&
  43783. // Show reset zoom button only when both newMin and
  43784. // newMax values are between padded axis range.
  43785. newMin !== paddedMin &&
  43786. newMax !== paddedMax &&
  43787. type.match('y')) {
  43788. chart.showResetZoom();
  43789. axis.displayBtn = false;
  43790. }
  43791. doRedraw = true;
  43792. }
  43793. // set new reference for next run:
  43794. chart[mouseDown] = mousePos;
  43795. }
  43796. });
  43797. if (doRedraw) {
  43798. chart.redraw(false);
  43799. }
  43800. css(chart.container, { cursor: 'move' });
  43801. });
  43802. }
  43803. });
  43804. // Extend the Point object with interaction
  43805. extend(Point.prototype, /** @lends Highcharts.Point.prototype */ {
  43806. /**
  43807. * Toggle the selection status of a point.
  43808. *
  43809. * @see Highcharts.Chart#getSelectedPoints
  43810. *
  43811. * @sample highcharts/members/point-select/
  43812. * Select a point from a button
  43813. * @sample highcharts/chart/events-selection-points/
  43814. * Select a range of points through a drag selection
  43815. * @sample maps/series/data-id/
  43816. * Select a point in Highmaps
  43817. *
  43818. * @function Highcharts.Point#select
  43819. *
  43820. * @param {boolean} [selected]
  43821. * When `true`, the point is selected. When `false`, the point is
  43822. * unselected. When `null` or `undefined`, the selection state is toggled.
  43823. *
  43824. * @param {boolean} [accumulate=false]
  43825. * When `true`, the selection is added to other selected points.
  43826. * When `false`, other selected points are deselected. Internally in
  43827. * Highcharts, when
  43828. * [allowPointSelect](https://api.highcharts.com/highcharts/plotOptions.series.allowPointSelect)
  43829. * is `true`, selected points are accumulated on Control, Shift or Cmd
  43830. * clicking the point.
  43831. *
  43832. * @fires Highcharts.Point#event:select
  43833. * @fires Highcharts.Point#event:unselect
  43834. */
  43835. select: function (selected, accumulate) {
  43836. var point = this,
  43837. series = point.series,
  43838. chart = series.chart;
  43839. selected = pick(selected, !point.selected);
  43840. this.selectedStaging = selected;
  43841. // fire the event with the default handler
  43842. point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () {
  43843. /**
  43844. * Whether the point is selected or not.
  43845. *
  43846. * @see Point#select
  43847. * @see Chart#getSelectedPoints
  43848. *
  43849. * @name Highcharts.Point#selected
  43850. * @type {boolean}
  43851. */
  43852. point.selected = point.options.selected = selected;
  43853. series.options.data[series.data.indexOf(point)] =
  43854. point.options;
  43855. point.setState(selected && 'select');
  43856. // unselect all other points unless Ctrl or Cmd + click
  43857. if (!accumulate) {
  43858. chart.getSelectedPoints().forEach(function (loopPoint) {
  43859. var loopSeries = loopPoint.series;
  43860. if (loopPoint.selected && loopPoint !== point) {
  43861. loopPoint.selected = loopPoint.options.selected =
  43862. false;
  43863. loopSeries.options.data[loopSeries.data.indexOf(loopPoint)] = loopPoint.options;
  43864. // Programatically selecting a point should restore
  43865. // normal state, but when click happened on other
  43866. // point, set inactive state to match other points
  43867. loopPoint.setState(chart.hoverPoints &&
  43868. loopSeries.options.inactiveOtherPoints ?
  43869. 'inactive' : '');
  43870. loopPoint.firePointEvent('unselect');
  43871. }
  43872. });
  43873. }
  43874. });
  43875. delete this.selectedStaging;
  43876. },
  43877. /**
  43878. * Runs on mouse over the point. Called internally from mouse and touch
  43879. * events.
  43880. *
  43881. * @function Highcharts.Point#onMouseOver
  43882. *
  43883. * @param {Highcharts.PointerEventObject} [e]
  43884. * The event arguments.
  43885. */
  43886. onMouseOver: function (e) {
  43887. var point = this,
  43888. series = point.series,
  43889. chart = series.chart,
  43890. pointer = chart.pointer;
  43891. e = e ?
  43892. pointer.normalize(e) :
  43893. // In cases where onMouseOver is called directly without an event
  43894. pointer.getChartCoordinatesFromPoint(point, chart.inverted);
  43895. pointer.runPointActions(e, point);
  43896. },
  43897. /**
  43898. * Runs on mouse out from the point. Called internally from mouse and touch
  43899. * events.
  43900. *
  43901. * @function Highcharts.Point#onMouseOut
  43902. * @fires Highcharts.Point#event:mouseOut
  43903. */
  43904. onMouseOut: function () {
  43905. var point = this,
  43906. chart = point.series.chart;
  43907. point.firePointEvent('mouseOut');
  43908. if (!point.series.options.inactiveOtherPoints) {
  43909. (chart.hoverPoints || []).forEach(function (p) {
  43910. p.setState();
  43911. });
  43912. }
  43913. chart.hoverPoints = chart.hoverPoint = null;
  43914. },
  43915. /**
  43916. * Import events from the series' and point's options. Only do it on
  43917. * demand, to save processing time on hovering.
  43918. *
  43919. * @private
  43920. * @function Highcharts.Point#importEvents
  43921. */
  43922. importEvents: function () {
  43923. if (!this.hasImportedEvents) {
  43924. var point = this,
  43925. options = merge(point.series.options.point,
  43926. point.options),
  43927. events = options.events;
  43928. point.events = events;
  43929. objectEach(events, function (event, eventType) {
  43930. if (isFunction(event)) {
  43931. addEvent(point, eventType, event);
  43932. }
  43933. });
  43934. this.hasImportedEvents = true;
  43935. }
  43936. },
  43937. /**
  43938. * Set the point's state.
  43939. *
  43940. * @function Highcharts.Point#setState
  43941. *
  43942. * @param {Highcharts.PointStateValue|""} [state]
  43943. * The new state, can be one of `'hover'`, `'select'`, `'inactive'`,
  43944. * or `''` (an empty string), `'normal'` or `undefined` to set to
  43945. * normal state.
  43946. * @param {boolean} [move]
  43947. * State for animation.
  43948. *
  43949. * @fires Highcharts.Point#event:afterSetState
  43950. */
  43951. setState: function (state, move) {
  43952. var point = this,
  43953. series = point.series,
  43954. previousState = point.state,
  43955. stateOptions = (series.options.states[state || 'normal'] ||
  43956. {}),
  43957. markerOptions = (defaultOptions.plotOptions[series.type].marker &&
  43958. series.options.marker),
  43959. normalDisabled = (markerOptions && markerOptions.enabled === false),
  43960. markerStateOptions = ((markerOptions &&
  43961. markerOptions.states &&
  43962. markerOptions.states[state || 'normal']) || {}),
  43963. stateDisabled = markerStateOptions.enabled === false,
  43964. stateMarkerGraphic = series.stateMarkerGraphic,
  43965. pointMarker = point.marker || {},
  43966. chart = series.chart,
  43967. halo = series.halo,
  43968. haloOptions,
  43969. markerAttribs,
  43970. pointAttribs,
  43971. pointAttribsAnimation,
  43972. hasMarkers = (markerOptions && series.markerAttribs),
  43973. newSymbol;
  43974. state = state || ''; // empty string
  43975. if (
  43976. // already has this state
  43977. (state === point.state && !move) ||
  43978. // selected points don't respond to hover
  43979. (point.selected && state !== 'select') ||
  43980. // series' state options is disabled
  43981. (stateOptions.enabled === false) ||
  43982. // general point marker's state options is disabled
  43983. (state && (stateDisabled ||
  43984. (normalDisabled &&
  43985. markerStateOptions.enabled === false))) ||
  43986. // individual point marker's state options is disabled
  43987. (state &&
  43988. pointMarker.states &&
  43989. pointMarker.states[state] &&
  43990. pointMarker.states[state].enabled === false) // #1610
  43991. ) {
  43992. return;
  43993. }
  43994. point.state = state;
  43995. if (hasMarkers) {
  43996. markerAttribs = series.markerAttribs(point, state);
  43997. }
  43998. // Apply hover styles to the existing point
  43999. if (point.graphic) {
  44000. if (previousState) {
  44001. point.graphic.removeClass('highcharts-point-' + previousState);
  44002. }
  44003. if (state) {
  44004. point.graphic.addClass('highcharts-point-' + state);
  44005. }
  44006. if (!chart.styledMode) {
  44007. pointAttribs = series.pointAttribs(point, state);
  44008. pointAttribsAnimation = pick(chart.options.chart.animation, stateOptions.animation);
  44009. // Some inactive points (e.g. slices in pie) should apply
  44010. // oppacity also for it's labels
  44011. if (series.options.inactiveOtherPoints && pointAttribs.opacity) {
  44012. (point.dataLabels || []).forEach(function (label) {
  44013. if (label) {
  44014. label.animate({
  44015. opacity: pointAttribs.opacity
  44016. }, pointAttribsAnimation);
  44017. }
  44018. });
  44019. if (point.connector) {
  44020. point.connector.animate({
  44021. opacity: pointAttribs.opacity
  44022. }, pointAttribsAnimation);
  44023. }
  44024. }
  44025. point.graphic.animate(pointAttribs, pointAttribsAnimation);
  44026. }
  44027. if (markerAttribs) {
  44028. point.graphic.animate(markerAttribs, pick(
  44029. // Turn off globally:
  44030. chart.options.chart.animation, markerStateOptions.animation, markerOptions.animation));
  44031. }
  44032. // Zooming in from a range with no markers to a range with markers
  44033. if (stateMarkerGraphic) {
  44034. stateMarkerGraphic.hide();
  44035. }
  44036. }
  44037. else {
  44038. // if a graphic is not applied to each point in the normal state,
  44039. // create a shared graphic for the hover state
  44040. if (state && markerStateOptions) {
  44041. newSymbol = pointMarker.symbol || series.symbol;
  44042. // If the point has another symbol than the previous one, throw
  44043. // away the state marker graphic and force a new one (#1459)
  44044. if (stateMarkerGraphic &&
  44045. stateMarkerGraphic.currentSymbol !== newSymbol) {
  44046. stateMarkerGraphic = stateMarkerGraphic.destroy();
  44047. }
  44048. // Add a new state marker graphic
  44049. if (markerAttribs) {
  44050. if (!stateMarkerGraphic) {
  44051. if (newSymbol) {
  44052. series.stateMarkerGraphic = stateMarkerGraphic =
  44053. chart.renderer
  44054. .symbol(newSymbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height)
  44055. .add(series.markerGroup);
  44056. stateMarkerGraphic.currentSymbol = newSymbol;
  44057. }
  44058. // Move the existing graphic
  44059. }
  44060. else {
  44061. stateMarkerGraphic[move ? 'animate' : 'attr']({
  44062. x: markerAttribs.x,
  44063. y: markerAttribs.y
  44064. });
  44065. }
  44066. }
  44067. if (!chart.styledMode && stateMarkerGraphic) {
  44068. stateMarkerGraphic.attr(series.pointAttribs(point, state));
  44069. }
  44070. }
  44071. if (stateMarkerGraphic) {
  44072. stateMarkerGraphic[state && point.isInside ? 'show' : 'hide'](); // #2450
  44073. stateMarkerGraphic.element.point = point; // #4310
  44074. }
  44075. }
  44076. // Show me your halo
  44077. haloOptions = stateOptions.halo;
  44078. var markerGraphic = (point.graphic || stateMarkerGraphic);
  44079. var markerVisibility = (markerGraphic && markerGraphic.visibility || 'inherit');
  44080. if (haloOptions &&
  44081. haloOptions.size &&
  44082. markerGraphic &&
  44083. markerVisibility !== 'hidden' &&
  44084. !point.isCluster) {
  44085. if (!halo) {
  44086. series.halo = halo = chart.renderer.path()
  44087. // #5818, #5903, #6705
  44088. .add(markerGraphic.parentGroup);
  44089. }
  44090. halo.show()[move ? 'animate' : 'attr']({
  44091. d: point.haloPath(haloOptions.size)
  44092. });
  44093. halo.attr({
  44094. 'class': 'highcharts-halo highcharts-color-' +
  44095. pick(point.colorIndex, series.colorIndex) +
  44096. (point.className ? ' ' + point.className : ''),
  44097. 'visibility': markerVisibility,
  44098. 'zIndex': -1 // #4929, #8276
  44099. });
  44100. halo.point = point; // #6055
  44101. if (!chart.styledMode) {
  44102. halo.attr(extend({
  44103. 'fill': point.color || series.color,
  44104. 'fill-opacity': haloOptions.opacity
  44105. }, haloOptions.attributes));
  44106. }
  44107. }
  44108. else if (halo && halo.point && halo.point.haloPath) {
  44109. // Animate back to 0 on the current halo point (#6055)
  44110. halo.animate({ d: halo.point.haloPath(0) }, null,
  44111. // Hide after unhovering. The `complete` callback runs in the
  44112. // halo's context (#7681).
  44113. halo.hide);
  44114. }
  44115. fireEvent(point, 'afterSetState');
  44116. },
  44117. /**
  44118. * Get the path definition for the halo, which is usually a shadow-like
  44119. * circle around the currently hovered point.
  44120. *
  44121. * @function Highcharts.Point#haloPath
  44122. *
  44123. * @param {number} size
  44124. * The radius of the circular halo.
  44125. *
  44126. * @return {Highcharts.SVGPathArray}
  44127. * The path definition.
  44128. */
  44129. haloPath: function (size) {
  44130. var series = this.series,
  44131. chart = series.chart;
  44132. return chart.renderer.symbols.circle(Math.floor(this.plotX) - size, this.plotY - size, size * 2, size * 2);
  44133. }
  44134. });
  44135. // Extend the Series object with interaction
  44136. extend(Series.prototype, /** @lends Highcharts.Series.prototype */ {
  44137. /**
  44138. * Runs on mouse over the series graphical items.
  44139. *
  44140. * @function Highcharts.Series#onMouseOver
  44141. * @fires Highcharts.Series#event:mouseOver
  44142. */
  44143. onMouseOver: function () {
  44144. var series = this,
  44145. chart = series.chart,
  44146. hoverSeries = chart.hoverSeries,
  44147. pointer = chart.pointer;
  44148. pointer.setHoverChartIndex();
  44149. // set normal state to previous series
  44150. if (hoverSeries && hoverSeries !== series) {
  44151. hoverSeries.onMouseOut();
  44152. }
  44153. // trigger the event, but to save processing time,
  44154. // only if defined
  44155. if (series.options.events.mouseOver) {
  44156. fireEvent(series, 'mouseOver');
  44157. }
  44158. // hover this
  44159. series.setState('hover');
  44160. /**
  44161. * Contains the original hovered series.
  44162. *
  44163. * @name Highcharts.Chart#hoverSeries
  44164. * @type {Highcharts.Series|null}
  44165. */
  44166. chart.hoverSeries = series;
  44167. },
  44168. /**
  44169. * Runs on mouse out of the series graphical items.
  44170. *
  44171. * @function Highcharts.Series#onMouseOut
  44172. *
  44173. * @fires Highcharts.Series#event:mouseOut
  44174. */
  44175. onMouseOut: function () {
  44176. // trigger the event only if listeners exist
  44177. var series = this,
  44178. options = series.options,
  44179. chart = series.chart,
  44180. tooltip = chart.tooltip,
  44181. hoverPoint = chart.hoverPoint;
  44182. // #182, set to null before the mouseOut event fires
  44183. chart.hoverSeries = null;
  44184. // trigger mouse out on the point, which must be in this series
  44185. if (hoverPoint) {
  44186. hoverPoint.onMouseOut();
  44187. }
  44188. // fire the mouse out event
  44189. if (series && options.events.mouseOut) {
  44190. fireEvent(series, 'mouseOut');
  44191. }
  44192. // hide the tooltip
  44193. if (tooltip &&
  44194. !series.stickyTracking &&
  44195. (!tooltip.shared || series.noSharedTooltip)) {
  44196. tooltip.hide();
  44197. }
  44198. // Reset all inactive states
  44199. chart.series.forEach(function (s) {
  44200. s.setState('', true);
  44201. });
  44202. },
  44203. /**
  44204. * Set the state of the series. Called internally on mouse interaction
  44205. * operations, but it can also be called directly to visually
  44206. * highlight a series.
  44207. *
  44208. * @function Highcharts.Series#setState
  44209. *
  44210. * @param {Highcharts.SeriesStateValue|""} [state]
  44211. * The new state, can be either `'hover'`, `'inactive'`, `'select'`,
  44212. * or `''` (an empty string), `'normal'` or `undefined` to set to
  44213. * normal state.
  44214. * @param {boolean} [inherit]
  44215. * Determines if state should be inherited by points too.
  44216. */
  44217. setState: function (state, inherit) {
  44218. var series = this,
  44219. options = series.options,
  44220. graph = series.graph,
  44221. inactiveOtherPoints = options.inactiveOtherPoints,
  44222. stateOptions = options.states,
  44223. lineWidth = options.lineWidth,
  44224. opacity = options.opacity,
  44225. // By default a quick animation to hover/inactive,
  44226. // slower to un-hover
  44227. stateAnimation = pick((stateOptions[state || 'normal'] &&
  44228. stateOptions[state || 'normal'].animation),
  44229. series.chart.options.chart.animation),
  44230. attribs,
  44231. i = 0;
  44232. state = state || '';
  44233. if (series.state !== state) {
  44234. // Toggle class names
  44235. [
  44236. series.group,
  44237. series.markerGroup,
  44238. series.dataLabelsGroup
  44239. ].forEach(function (group) {
  44240. if (group) {
  44241. // Old state
  44242. if (series.state) {
  44243. group.removeClass('highcharts-series-' + series.state);
  44244. }
  44245. // New state
  44246. if (state) {
  44247. group.addClass('highcharts-series-' + state);
  44248. }
  44249. }
  44250. });
  44251. series.state = state;
  44252. if (!series.chart.styledMode) {
  44253. if (stateOptions[state] &&
  44254. stateOptions[state].enabled === false) {
  44255. return;
  44256. }
  44257. if (state) {
  44258. lineWidth = (stateOptions[state].lineWidth ||
  44259. lineWidth + (stateOptions[state].lineWidthPlus || 0)); // #4035
  44260. opacity = pick(stateOptions[state].opacity, opacity);
  44261. }
  44262. if (graph && !graph.dashstyle) {
  44263. attribs = {
  44264. 'stroke-width': lineWidth
  44265. };
  44266. // Animate the graph stroke-width.
  44267. graph.animate(attribs, stateAnimation);
  44268. while (series['zone-graph-' + i]) {
  44269. series['zone-graph-' + i].attr(attribs);
  44270. i = i + 1;
  44271. }
  44272. }
  44273. // For some types (pie, networkgraph, sankey) opacity is
  44274. // resolved on a point level
  44275. if (!inactiveOtherPoints) {
  44276. [
  44277. series.group,
  44278. series.markerGroup,
  44279. series.dataLabelsGroup,
  44280. series.labelBySeries
  44281. ].forEach(function (group) {
  44282. if (group) {
  44283. group.animate({
  44284. opacity: opacity
  44285. }, stateAnimation);
  44286. }
  44287. });
  44288. }
  44289. }
  44290. }
  44291. // Don't loop over points on a series that doesn't apply inactive state
  44292. // to siblings markers (e.g. line, column)
  44293. if (inherit && inactiveOtherPoints && series.points) {
  44294. series.setAllPointsToState(state);
  44295. }
  44296. },
  44297. /**
  44298. * Set the state for all points in the series.
  44299. *
  44300. * @function Highcharts.Series#setAllPointsToState
  44301. *
  44302. * @private
  44303. *
  44304. * @param {string} [state]
  44305. * Can be either `hover` or undefined to set to normal state.
  44306. */
  44307. setAllPointsToState: function (state) {
  44308. this.points.forEach(function (point) {
  44309. if (point.setState) {
  44310. point.setState(state);
  44311. }
  44312. });
  44313. },
  44314. /**
  44315. * Show or hide the series.
  44316. *
  44317. * @function Highcharts.Series#setVisible
  44318. *
  44319. * @param {boolean} [visible]
  44320. * True to show the series, false to hide. If undefined, the visibility is
  44321. * toggled.
  44322. *
  44323. * @param {boolean} [redraw=true]
  44324. * Whether to redraw the chart after the series is altered. If doing more
  44325. * operations on the chart, it is a good idea to set redraw to false and
  44326. * call {@link Chart#redraw|chart.redraw()} after.
  44327. *
  44328. * @fires Highcharts.Series#event:hide
  44329. * @fires Highcharts.Series#event:show
  44330. */
  44331. setVisible: function (vis, redraw) {
  44332. var series = this,
  44333. chart = series.chart,
  44334. legendItem = series.legendItem,
  44335. showOrHide,
  44336. ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
  44337. oldVisibility = series.visible;
  44338. // if called without an argument, toggle visibility
  44339. series.visible =
  44340. vis =
  44341. series.options.visible =
  44342. series.userOptions.visible =
  44343. typeof vis === 'undefined' ? !oldVisibility : vis; // #5618
  44344. showOrHide = vis ? 'show' : 'hide';
  44345. // show or hide elements
  44346. [
  44347. 'group',
  44348. 'dataLabelsGroup',
  44349. 'markerGroup',
  44350. 'tracker',
  44351. 'tt'
  44352. ].forEach(function (key) {
  44353. if (series[key]) {
  44354. series[key][showOrHide]();
  44355. }
  44356. });
  44357. // hide tooltip (#1361)
  44358. if (chart.hoverSeries === series ||
  44359. (chart.hoverPoint && chart.hoverPoint.series) === series) {
  44360. series.onMouseOut();
  44361. }
  44362. if (legendItem) {
  44363. chart.legend.colorizeItem(series, vis);
  44364. }
  44365. // rescale or adapt to resized chart
  44366. series.isDirty = true;
  44367. // in a stack, all other series are affected
  44368. if (series.options.stacking) {
  44369. chart.series.forEach(function (otherSeries) {
  44370. if (otherSeries.options.stacking && otherSeries.visible) {
  44371. otherSeries.isDirty = true;
  44372. }
  44373. });
  44374. }
  44375. // show or hide linked series
  44376. series.linkedSeries.forEach(function (otherSeries) {
  44377. otherSeries.setVisible(vis, false);
  44378. });
  44379. if (ignoreHiddenSeries) {
  44380. chart.isDirtyBox = true;
  44381. }
  44382. fireEvent(series, showOrHide);
  44383. if (redraw !== false) {
  44384. chart.redraw();
  44385. }
  44386. },
  44387. /**
  44388. * Show the series if hidden.
  44389. *
  44390. * @sample highcharts/members/series-hide/
  44391. * Toggle visibility from a button
  44392. *
  44393. * @function Highcharts.Series#show
  44394. * @fires Highcharts.Series#event:show
  44395. */
  44396. show: function () {
  44397. this.setVisible(true);
  44398. },
  44399. /**
  44400. * Hide the series if visible. If the
  44401. * [chart.ignoreHiddenSeries](https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries)
  44402. * option is true, the chart is redrawn without this series.
  44403. *
  44404. * @sample highcharts/members/series-hide/
  44405. * Toggle visibility from a button
  44406. *
  44407. * @function Highcharts.Series#hide
  44408. * @fires Highcharts.Series#event:hide
  44409. */
  44410. hide: function () {
  44411. this.setVisible(false);
  44412. },
  44413. /**
  44414. * Select or unselect the series. This means its
  44415. * {@link Highcharts.Series.selected|selected}
  44416. * property is set, the checkbox in the legend is toggled and when selected,
  44417. * the series is returned by the {@link Highcharts.Chart#getSelectedSeries}
  44418. * function.
  44419. *
  44420. * @sample highcharts/members/series-select/
  44421. * Select a series from a button
  44422. *
  44423. * @function Highcharts.Series#select
  44424. *
  44425. * @param {boolean} [selected]
  44426. * True to select the series, false to unselect. If undefined, the selection
  44427. * state is toggled.
  44428. *
  44429. * @fires Highcharts.Series#event:select
  44430. * @fires Highcharts.Series#event:unselect
  44431. */
  44432. select: function (selected) {
  44433. var series = this;
  44434. series.selected =
  44435. selected =
  44436. this.options.selected = (typeof selected === 'undefined' ?
  44437. !series.selected :
  44438. selected);
  44439. if (series.checkbox) {
  44440. series.checkbox.checked = selected;
  44441. }
  44442. fireEvent(series, selected ? 'select' : 'unselect');
  44443. },
  44444. /**
  44445. * @private
  44446. * @borrows Highcharts.TrackerMixin.drawTrackerGraph as Highcharts.Series#drawTracker
  44447. */
  44448. drawTracker: TrackerMixin.drawTrackerGraph
  44449. });
  44450. });
  44451. _registerModule(_modules, 'Core/Responsive.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  44452. /* *
  44453. *
  44454. * (c) 2010-2020 Torstein Honsi
  44455. *
  44456. * License: www.highcharts.com/license
  44457. *
  44458. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  44459. *
  44460. * */
  44461. var find = U.find,
  44462. isArray = U.isArray,
  44463. isObject = U.isObject,
  44464. merge = U.merge,
  44465. objectEach = U.objectEach,
  44466. pick = U.pick,
  44467. splat = U.splat,
  44468. uniqueKey = U.uniqueKey;
  44469. /**
  44470. * A callback function to gain complete control on when the responsive rule
  44471. * applies.
  44472. *
  44473. * @callback Highcharts.ResponsiveCallbackFunction
  44474. *
  44475. * @param {Highcharts.Chart} this
  44476. * Chart context.
  44477. *
  44478. * @return {boolean}
  44479. * Return `true` if it applies.
  44480. */
  44481. /**
  44482. * Allows setting a set of rules to apply for different screen or chart
  44483. * sizes. Each rule specifies additional chart options.
  44484. *
  44485. * @sample {highstock} stock/demo/responsive/
  44486. * Stock chart
  44487. * @sample highcharts/responsive/axis/
  44488. * Axis
  44489. * @sample highcharts/responsive/legend/
  44490. * Legend
  44491. * @sample highcharts/responsive/classname/
  44492. * Class name
  44493. *
  44494. * @since 5.0.0
  44495. * @apioption responsive
  44496. */
  44497. /**
  44498. * A set of rules for responsive settings. The rules are executed from
  44499. * the top down.
  44500. *
  44501. * @sample {highcharts} highcharts/responsive/axis/
  44502. * Axis changes
  44503. * @sample {highstock} highcharts/responsive/axis/
  44504. * Axis changes
  44505. * @sample {highmaps} highcharts/responsive/axis/
  44506. * Axis changes
  44507. *
  44508. * @type {Array<*>}
  44509. * @since 5.0.0
  44510. * @apioption responsive.rules
  44511. */
  44512. /**
  44513. * A full set of chart options to apply as overrides to the general
  44514. * chart options. The chart options are applied when the given rule
  44515. * is active.
  44516. *
  44517. * A special case is configuration objects that take arrays, for example
  44518. * [xAxis](#xAxis), [yAxis](#yAxis) or [series](#series). For these
  44519. * collections, an `id` option is used to map the new option set to
  44520. * an existing object. If an existing object of the same id is not found,
  44521. * the item of the same indexupdated. So for example, setting `chartOptions`
  44522. * with two series items without an `id`, will cause the existing chart's
  44523. * two series to be updated with respective options.
  44524. *
  44525. * @sample {highstock} stock/demo/responsive/
  44526. * Stock chart
  44527. * @sample highcharts/responsive/axis/
  44528. * Axis
  44529. * @sample highcharts/responsive/legend/
  44530. * Legend
  44531. * @sample highcharts/responsive/classname/
  44532. * Class name
  44533. *
  44534. * @type {Highcharts.Options}
  44535. * @since 5.0.0
  44536. * @apioption responsive.rules.chartOptions
  44537. */
  44538. /**
  44539. * Under which conditions the rule applies.
  44540. *
  44541. * @since 5.0.0
  44542. * @apioption responsive.rules.condition
  44543. */
  44544. /**
  44545. * A callback function to gain complete control on when the responsive
  44546. * rule applies. Return `true` if it applies. This opens for checking
  44547. * against other metrics than the chart size, for example the document
  44548. * size or other elements.
  44549. *
  44550. * @type {Highcharts.ResponsiveCallbackFunction}
  44551. * @since 5.0.0
  44552. * @context Highcharts.Chart
  44553. * @apioption responsive.rules.condition.callback
  44554. */
  44555. /**
  44556. * The responsive rule applies if the chart height is less than this.
  44557. *
  44558. * @type {number}
  44559. * @since 5.0.0
  44560. * @apioption responsive.rules.condition.maxHeight
  44561. */
  44562. /**
  44563. * The responsive rule applies if the chart width is less than this.
  44564. *
  44565. * @sample highcharts/responsive/axis/
  44566. * Max width is 500
  44567. *
  44568. * @type {number}
  44569. * @since 5.0.0
  44570. * @apioption responsive.rules.condition.maxWidth
  44571. */
  44572. /**
  44573. * The responsive rule applies if the chart height is greater than this.
  44574. *
  44575. * @type {number}
  44576. * @default 0
  44577. * @since 5.0.0
  44578. * @apioption responsive.rules.condition.minHeight
  44579. */
  44580. /**
  44581. * The responsive rule applies if the chart width is greater than this.
  44582. *
  44583. * @type {number}
  44584. * @default 0
  44585. * @since 5.0.0
  44586. * @apioption responsive.rules.condition.minWidth
  44587. */
  44588. /* eslint-disable no-invalid-this, valid-jsdoc */
  44589. /**
  44590. * Update the chart based on the current chart/document size and options for
  44591. * responsiveness.
  44592. *
  44593. * @private
  44594. * @function Highcharts.Chart#setResponsive
  44595. * @param {boolean} [redraw=true]
  44596. * @param {boolean} [reset=false]
  44597. * Reset by un-applying all rules. Chart.update resets all rules before applying
  44598. * updated options.
  44599. */
  44600. Chart.prototype.setResponsive = function (redraw, reset) {
  44601. var options = this.options.responsive,
  44602. ruleIds = [],
  44603. currentResponsive = this.currentResponsive,
  44604. currentRuleIds,
  44605. undoOptions;
  44606. if (!reset && options && options.rules) {
  44607. options.rules.forEach(function (rule) {
  44608. if (typeof rule._id === 'undefined') {
  44609. rule._id = uniqueKey();
  44610. }
  44611. this.matchResponsiveRule(rule, ruleIds /* , redraw */);
  44612. }, this);
  44613. }
  44614. // Merge matching rules
  44615. var mergedOptions = merge.apply(0,
  44616. ruleIds.map(function (ruleId) {
  44617. return find(options.rules,
  44618. function (rule) {
  44619. return rule._id === ruleId;
  44620. }).chartOptions;
  44621. }));
  44622. mergedOptions.isResponsiveOptions = true;
  44623. // Stringified key for the rules that currently apply.
  44624. ruleIds = (ruleIds.toString() || void 0);
  44625. currentRuleIds = currentResponsive && currentResponsive.ruleIds;
  44626. // Changes in what rules apply
  44627. if (ruleIds !== currentRuleIds) {
  44628. // Undo previous rules. Before we apply a new set of rules, we need to
  44629. // roll back completely to base options (#6291).
  44630. if (currentResponsive) {
  44631. this.update(currentResponsive.undoOptions, redraw, true);
  44632. }
  44633. if (ruleIds) {
  44634. // Get undo-options for matching rules
  44635. undoOptions = this.currentOptions(mergedOptions);
  44636. undoOptions.isResponsiveOptions = true;
  44637. this.currentResponsive = {
  44638. ruleIds: ruleIds,
  44639. mergedOptions: mergedOptions,
  44640. undoOptions: undoOptions
  44641. };
  44642. this.update(mergedOptions, redraw, true);
  44643. }
  44644. else {
  44645. this.currentResponsive = void 0;
  44646. }
  44647. }
  44648. };
  44649. /**
  44650. * Handle a single responsiveness rule.
  44651. *
  44652. * @private
  44653. * @function Highcharts.Chart#matchResponsiveRule
  44654. * @param {Highcharts.ResponsiveRulesOptions} rule
  44655. * @param {Array<string>} matches
  44656. */
  44657. Chart.prototype.matchResponsiveRule = function (rule, matches) {
  44658. var condition = rule.condition,
  44659. fn = condition.callback || function () {
  44660. return (this.chartWidth <= pick(condition.maxWidth,
  44661. Number.MAX_VALUE) &&
  44662. this.chartHeight <=
  44663. pick(condition.maxHeight,
  44664. Number.MAX_VALUE) &&
  44665. this.chartWidth >= pick(condition.minWidth, 0) &&
  44666. this.chartHeight >= pick(condition.minHeight, 0));
  44667. };
  44668. if (fn.call(this)) {
  44669. matches.push(rule._id);
  44670. }
  44671. };
  44672. /**
  44673. * Get the current values for a given set of options. Used before we update
  44674. * the chart with a new responsiveness rule.
  44675. *
  44676. * @todo Restore axis options (by id?). The matching of items in collections
  44677. * bears resemblance to the oneToOne matching in Chart.update. Probably we can
  44678. * refactor out that matching and reuse it in both functions.
  44679. *
  44680. * @private
  44681. * @function Highcharts.Chart#currentOptions
  44682. * @param {Highcharts.Options} options
  44683. * @return {Highcharts.Options}
  44684. */
  44685. Chart.prototype.currentOptions = function (options) {
  44686. var chart = this,
  44687. ret = {};
  44688. /**
  44689. * Recurse over a set of options and its current values,
  44690. * and store the current values in the ret object.
  44691. */
  44692. function getCurrent(options, curr, ret, depth) {
  44693. var i;
  44694. objectEach(options, function (val, key) {
  44695. if (!depth &&
  44696. chart.collectionsWithUpdate.indexOf(key) > -1) {
  44697. val = splat(val);
  44698. ret[key] = [];
  44699. // Iterate over collections like series, xAxis or yAxis and map
  44700. // the items by index.
  44701. for (i = 0; i < Math.max(val.length, curr[key].length); i++) {
  44702. // Item exists in current data (#6347)
  44703. if (curr[key][i]) {
  44704. // If the item is missing from the new data, we need to
  44705. // save the whole config structure. Like when
  44706. // responsively updating from a dual axis layout to a
  44707. // single axis and back (#13544).
  44708. if (val[i] === void 0) {
  44709. ret[key][i] = curr[key][i];
  44710. // Otherwise, proceed
  44711. }
  44712. else {
  44713. ret[key][i] = {};
  44714. getCurrent(val[i], curr[key][i], ret[key][i], depth + 1);
  44715. }
  44716. }
  44717. }
  44718. }
  44719. else if (isObject(val)) {
  44720. ret[key] = isArray(val) ? [] : {};
  44721. getCurrent(val, curr[key] || {}, ret[key], depth + 1);
  44722. }
  44723. else if (typeof curr[key] === 'undefined') { // #10286
  44724. ret[key] = null;
  44725. }
  44726. else {
  44727. ret[key] = curr[key];
  44728. }
  44729. });
  44730. }
  44731. getCurrent(options, this.options, ret, 0);
  44732. return ret;
  44733. };
  44734. });
  44735. _registerModule(_modules, 'masters/highcharts.src.js', [_modules['Core/Globals.js']], function (Highcharts) {
  44736. return Highcharts;
  44737. });
  44738. _modules['masters/highcharts.src.js']._modules = _modules;
  44739. return _modules['masters/highcharts.src.js'];
  44740. }));