highcharts.src.js 1.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149
  1. /**
  2. * @license Highcharts JS v8.1.2 (2020-06-16)
  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, 'parts/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.1.2',
  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. * An array containing the current chart objects in the page. A chart's
  86. * position in the array is preserved throughout the page's lifetime. When
  87. * a chart is destroyed, the array item becomes `undefined`.
  88. *
  89. * @name Highcharts.charts
  90. * @type {Array<Highcharts.Chart|undefined>}
  91. */
  92. charts: [],
  93. /**
  94. * A hook for defining additional date format specifiers. New
  95. * specifiers are defined as key-value pairs by using the
  96. * specifier as key, and a function which takes the timestamp as
  97. * value. This function returns the formatted portion of the
  98. * date.
  99. *
  100. * @sample highcharts/global/dateformats/
  101. * Adding support for week number
  102. *
  103. * @name Highcharts.dateFormats
  104. * @type {Highcharts.Dictionary<Highcharts.TimeFormatCallbackFunction>}
  105. */
  106. dateFormats: {}
  107. };
  108. return H;
  109. });
  110. _registerModule(_modules, 'parts/Utilities.js', [_modules['parts/Globals.js']], function (H) {
  111. /* *
  112. *
  113. * (c) 2010-2020 Torstein Honsi
  114. *
  115. * License: www.highcharts.com/license
  116. *
  117. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  118. *
  119. * */
  120. /**
  121. * An animation configuration. Animation configurations can also be defined as
  122. * booleans, where `false` turns off animation and `true` defaults to a duration
  123. * of 500ms.
  124. *
  125. * @interface Highcharts.AnimationOptionsObject
  126. */ /**
  127. * A callback function to exectute when the animation finishes.
  128. * @name Highcharts.AnimationOptionsObject#complete
  129. * @type {Function|undefined}
  130. */ /**
  131. * The animation duration in milliseconds.
  132. * @name Highcharts.AnimationOptionsObject#duration
  133. * @type {number|undefined}
  134. */ /**
  135. * The name of an easing function as defined on the `Math` object.
  136. * @name Highcharts.AnimationOptionsObject#easing
  137. * @type {string|Function|undefined}
  138. */ /**
  139. * A callback function to execute on each step of each attribute or CSS property
  140. * that's being animated. The first argument contains information about the
  141. * animation and progress.
  142. * @name Highcharts.AnimationOptionsObject#step
  143. * @type {Function|undefined}
  144. */
  145. /**
  146. * Creates a frame for the animated SVG element.
  147. *
  148. * @callback Highcharts.AnimationStepCallbackFunction
  149. *
  150. * @param {Highcharts.SVGElement} this
  151. * The SVG element to animate.
  152. *
  153. * @return {void}
  154. */
  155. /**
  156. * Interface description for a class.
  157. *
  158. * @interface Highcharts.Class<T>
  159. * @extends Function
  160. */ /**
  161. * Class costructor.
  162. * @function Highcharts.Class<T>#new
  163. * @param {...Array<*>} args
  164. * Constructor arguments.
  165. * @return {T}
  166. * Class instance.
  167. */
  168. /**
  169. * A style object with camel case property names to define visual appearance of
  170. * a SVG element or HTML element. The properties can be whatever styles are
  171. * supported on the given SVG or HTML element.
  172. *
  173. * @example
  174. * {
  175. * fontFamily: 'monospace',
  176. * fontSize: '1.2em'
  177. * }
  178. *
  179. * @interface Highcharts.CSSObject
  180. */ /**
  181. * @name Highcharts.CSSObject#[key:string]
  182. * @type {boolean|number|string|undefined}
  183. */ /**
  184. * Background style for the element.
  185. * @name Highcharts.CSSObject#background
  186. * @type {string|undefined}
  187. */ /**
  188. * Background color of the element.
  189. * @name Highcharts.CSSObject#backgroundColor
  190. * @type {Highcharts.ColorString|undefined}
  191. */ /**
  192. * Border style for the element.
  193. * @name Highcharts.CSSObject#border
  194. * @type {string|undefined}
  195. */ /**
  196. * Radius of the element border.
  197. * @name Highcharts.CSSObject#borderRadius
  198. * @type {number|undefined}
  199. */ /**
  200. * Color used in the element. The 'contrast' option is a Highcharts custom
  201. * property that results in black or white, depending on the background of the
  202. * element.
  203. * @name Highcharts.CSSObject#color
  204. * @type {'contrast'|Highcharts.ColorString|undefined}
  205. */ /**
  206. * Style of the mouse cursor when resting over the element.
  207. * @name Highcharts.CSSObject#cursor
  208. * @type {Highcharts.CursorValue|undefined}
  209. */ /**
  210. * Font family of the element text. Multiple values have to be in decreasing
  211. * preference order and separated by comma.
  212. * @name Highcharts.CSSObject#fontFamily
  213. * @type {string|undefined}
  214. */ /**
  215. * Font size of the element text.
  216. * @name Highcharts.CSSObject#fontSize
  217. * @type {string|undefined}
  218. */ /**
  219. * Font weight of the element text.
  220. * @name Highcharts.CSSObject#fontWeight
  221. * @type {string|undefined}
  222. */ /**
  223. * Height of the element.
  224. * @name Highcharts.CSSObject#height
  225. * @type {number|undefined}
  226. */ /**
  227. * Width of the element border.
  228. * @name Highcharts.CSSObject#lineWidth
  229. * @type {number|undefined}
  230. */ /**
  231. * Opacity of the element.
  232. * @name Highcharts.CSSObject#opacity
  233. * @type {number|undefined}
  234. */ /**
  235. * Space around the element content.
  236. * @name Highcharts.CSSObject#padding
  237. * @type {string|undefined}
  238. */ /**
  239. * Behaviour of the element when the mouse cursor rests over it.
  240. * @name Highcharts.CSSObject#pointerEvents
  241. * @type {string|undefined}
  242. */ /**
  243. * Positioning of the element.
  244. * @name Highcharts.CSSObject#position
  245. * @type {string|undefined}
  246. */ /**
  247. * Alignment of the element text.
  248. * @name Highcharts.CSSObject#textAlign
  249. * @type {string|undefined}
  250. */ /**
  251. * Additional decoration of the element text.
  252. * @name Highcharts.CSSObject#textDecoration
  253. * @type {string|undefined}
  254. */ /**
  255. * Outline style of the element text.
  256. * @name Highcharts.CSSObject#textOutline
  257. * @type {string|undefined}
  258. */ /**
  259. * Line break style of the element text. Highcharts SVG elements support
  260. * `ellipsis` when a `width` is set.
  261. * @name Highcharts.CSSObject#textOverflow
  262. * @type {string|undefined}
  263. */ /**
  264. * Top spacing of the element relative to the parent element.
  265. * @name Highcharts.CSSObject#top
  266. * @type {string|undefined}
  267. */ /**
  268. * Animated transition of selected element properties.
  269. * @name Highcharts.CSSObject#transition
  270. * @type {string|undefined}
  271. */ /**
  272. * Line break style of the element text.
  273. * @name Highcharts.CSSObject#whiteSpace
  274. * @type {string|undefined}
  275. */ /**
  276. * Width of the element.
  277. * @name Highcharts.CSSObject#width
  278. * @type {number|undefined}
  279. */
  280. /**
  281. * All possible cursor styles.
  282. *
  283. * @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
  284. */
  285. /**
  286. * All possible dash styles.
  287. *
  288. * @typedef {'Dash'|'DashDot'|'Dot'|'LongDash'|'LongDashDot'|'LongDashDotDot'|'ShortDash'|'ShortDashDot'|'ShortDashDotDot'|'ShortDot'|'Solid'} Highcharts.DashStyleValue
  289. */
  290. /**
  291. * Generic dictionary in TypeScript notation.
  292. * Use the native `Record<string, any>` instead.
  293. *
  294. * @deprecated
  295. * @interface Highcharts.Dictionary<T>
  296. */ /**
  297. * @name Highcharts.Dictionary<T>#[key:string]
  298. * @type {T}
  299. */
  300. /**
  301. * The function callback to execute when the event is fired. The `this` context
  302. * contains the instance, that fired the event.
  303. *
  304. * @callback Highcharts.EventCallbackFunction<T>
  305. *
  306. * @param {T} this
  307. *
  308. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  309. * Event arguments.
  310. *
  311. * @return {boolean|void}
  312. */
  313. /**
  314. * The event options for adding function callback.
  315. *
  316. * @interface Highcharts.EventOptionsObject
  317. */ /**
  318. * The order the event handler should be called. This opens for having one
  319. * handler be called before another, independent of in which order they were
  320. * added.
  321. * @name Highcharts.EventOptionsObject#order
  322. * @type {number}
  323. */
  324. /**
  325. * Formats data as a string. Usually the data is accessible throught the `this`
  326. * keyword.
  327. *
  328. * @callback Highcharts.FormatterCallbackFunction<T>
  329. *
  330. * @param {T} this
  331. * Context to format
  332. *
  333. * @return {string}
  334. * Formatted text
  335. */
  336. /**
  337. * An object of key-value pairs for HTML attributes.
  338. *
  339. * @typedef {Highcharts.Dictionary<boolean|number|string|Function>} Highcharts.HTMLAttributes
  340. */
  341. /**
  342. * An HTML DOM element. The type is a reference to the regular HTMLElement in
  343. * the global scope.
  344. *
  345. * @typedef {global.HTMLElement} Highcharts.HTMLDOMElement
  346. *
  347. * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
  348. */
  349. /**
  350. * The iterator callback.
  351. *
  352. * @callback Highcharts.ObjectEachCallbackFunction<T>
  353. *
  354. * @param {T} this
  355. * The context.
  356. *
  357. * @param {*} value
  358. * The property value.
  359. *
  360. * @param {string} key
  361. * The property key.
  362. *
  363. * @param {*} obj
  364. * The object that objectEach is being applied to.
  365. */
  366. /**
  367. * An object containing `left` and `top` properties for the position in the
  368. * page.
  369. *
  370. * @interface Highcharts.OffsetObject
  371. */ /**
  372. * Left distance to the page border.
  373. * @name Highcharts.OffsetObject#left
  374. * @type {number}
  375. */ /**
  376. * Top distance to the page border.
  377. * @name Highcharts.OffsetObject#top
  378. * @type {number}
  379. */
  380. /**
  381. * Describes a range.
  382. *
  383. * @interface Highcharts.RangeObject
  384. */ /**
  385. * Maximum number of the range.
  386. * @name Highcharts.RangeObject#max
  387. * @type {number}
  388. */ /**
  389. * Minimum number of the range.
  390. * @name Highcharts.RangeObject#min
  391. * @type {number}
  392. */
  393. /**
  394. * If a number is given, it defines the pixel length. If a percentage string is
  395. * given, like for example `'50%'`, the setting defines a length relative to a
  396. * base size, for example the size of a container.
  397. *
  398. * @typedef {number|string} Highcharts.RelativeSize
  399. */
  400. /**
  401. * Proceed function to call original (wrapped) function.
  402. *
  403. * @callback Highcharts.WrapProceedFunction
  404. *
  405. * @param {*} [arg1]
  406. * Optional argument. Without any arguments defaults to first argument of
  407. * the wrapping function.
  408. *
  409. * @param {*} [arg2]
  410. * Optional argument. Without any arguments defaults to second argument
  411. * of the wrapping function.
  412. *
  413. * @param {*} [arg3]
  414. * Optional argument. Without any arguments defaults to third argument of
  415. * the wrapping function.
  416. *
  417. * @return {*}
  418. * Return value of the original function.
  419. */
  420. /**
  421. * The Highcharts object is the placeholder for all other members, and various
  422. * utility functions. The most important member of the namespace would be the
  423. * chart constructor.
  424. *
  425. * @example
  426. * var chart = Highcharts.chart('container', { ... });
  427. *
  428. * @namespace Highcharts
  429. */
  430. H.timers = [];
  431. var charts = H.charts, doc = H.doc, win = H.win;
  432. /**
  433. * Provide error messages for debugging, with links to online explanation. This
  434. * function can be overridden to provide custom error handling.
  435. *
  436. * @sample highcharts/chart/highcharts-error/
  437. * Custom error handler
  438. *
  439. * @function Highcharts.error
  440. *
  441. * @param {number|string} code
  442. * The error code. See
  443. * [errors.xml](https://github.com/highcharts/highcharts/blob/master/errors/errors.xml)
  444. * for available codes. If it is a string, the error message is printed
  445. * directly in the console.
  446. *
  447. * @param {boolean} [stop=false]
  448. * Whether to throw an error or just log a warning in the console.
  449. *
  450. * @param {Highcharts.Chart} [chart]
  451. * Reference to the chart that causes the error. Used in 'debugger'
  452. * module to display errors directly on the chart.
  453. * Important note: This argument is undefined for errors that lack
  454. * access to the Chart instance.
  455. *
  456. * @param {Highcharts.Dictionary<string>} [params]
  457. * Additional parameters for the generated message.
  458. *
  459. * @return {void}
  460. */
  461. function error(code, stop, chart, params) {
  462. var severity = stop ? 'Highcharts error' : 'Highcharts warning';
  463. if (code === 32) {
  464. code = severity + ": Deprecated member";
  465. }
  466. var isCode = isNumber(code), message = isCode ?
  467. severity + " #" + code + ": www.highcharts.com/errors/" + code + "/" :
  468. code.toString(), defaultHandler = function () {
  469. if (stop) {
  470. throw new Error(message);
  471. }
  472. // else ...
  473. if (win.console &&
  474. error.messages.indexOf(message) === -1 // prevent console flooting
  475. ) {
  476. console.log(message); // eslint-disable-line no-console
  477. }
  478. };
  479. if (typeof params !== 'undefined') {
  480. var additionalMessages_1 = '';
  481. if (isCode) {
  482. message += '?';
  483. }
  484. objectEach(params, function (value, key) {
  485. additionalMessages_1 += "\n - " + key + ": " + value;
  486. if (isCode) {
  487. message += encodeURI(key) + '=' + encodeURI(value);
  488. }
  489. });
  490. message += additionalMessages_1;
  491. }
  492. if (chart) {
  493. fireEvent(chart, 'displayError', { code: code, message: message, params: params }, defaultHandler);
  494. }
  495. else {
  496. defaultHandler();
  497. }
  498. error.messages.push(message);
  499. }
  500. (function (error) {
  501. error.messages = [];
  502. })(error || (error = {}));
  503. H.error = error;
  504. /* eslint-disable no-invalid-this, valid-jsdoc */
  505. /**
  506. * An animator object used internally. One instance applies to one property
  507. * (attribute or style prop) on one element. Animation is always initiated
  508. * through {@link SVGElement#animate}.
  509. *
  510. * @example
  511. * var rect = renderer.rect(0, 0, 10, 10).add();
  512. * rect.animate({ width: 100 });
  513. *
  514. * @private
  515. * @class
  516. * @name Highcharts.Fx
  517. */
  518. var Fx = /** @class */ (function () {
  519. /* *
  520. *
  521. * Constructors
  522. *
  523. * */
  524. /**
  525. *
  526. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} elem
  527. * The element to animate.
  528. *
  529. * @param {Highcharts.AnimationOptionsObject} options
  530. * Animation options.
  531. *
  532. * @param {string} prop
  533. * The single attribute or CSS property to animate.
  534. */
  535. function Fx(elem, options, prop) {
  536. this.options = options;
  537. this.elem = elem;
  538. this.prop = prop;
  539. }
  540. /* *
  541. *
  542. * Functions
  543. *
  544. * */
  545. /**
  546. * Set the current step of a path definition on SVGElement.
  547. *
  548. * @function Highcharts.Fx#dSetter
  549. *
  550. * @return {void}
  551. */
  552. Fx.prototype.dSetter = function () {
  553. var paths = this.paths, start = paths && paths[0], end = paths && paths[1], path = [], now = this.now || 0;
  554. // Land on the final path without adjustment points appended in the ends
  555. if (now === 1 || !start || !end) {
  556. path = this.toD || [];
  557. }
  558. else if (start.length === end.length && now < 1) {
  559. for (var i = 0; i < end.length; i++) {
  560. // Tween between the start segment and the end segment. Start
  561. // with a copy of the end segment and tween the appropriate
  562. // numerics
  563. var startSeg = start[i];
  564. var endSeg = end[i];
  565. var tweenSeg = [];
  566. for (var j = 0; j < endSeg.length; j++) {
  567. var startItem = startSeg[j];
  568. var endItem = endSeg[j];
  569. // Tween numbers
  570. if (typeof startItem === 'number' &&
  571. typeof endItem === 'number' &&
  572. // Arc boolean flags
  573. !(endSeg[0] === 'A' && (j === 4 || j === 5))) {
  574. tweenSeg[j] = startItem + now * (endItem - startItem);
  575. // Strings, take directly from the end segment
  576. }
  577. else {
  578. tweenSeg[j] = endItem;
  579. }
  580. }
  581. path.push(tweenSeg);
  582. }
  583. // If animation is finished or length not matching, land on right value
  584. }
  585. else {
  586. path = end;
  587. }
  588. this.elem.attr('d', path, void 0, true);
  589. };
  590. /**
  591. * Update the element with the current animation step.
  592. *
  593. * @function Highcharts.Fx#update
  594. *
  595. * @return {void}
  596. */
  597. Fx.prototype.update = function () {
  598. var elem = this.elem, prop = this.prop, // if destroyed, it is null
  599. now = this.now, step = this.options.step;
  600. // Animation setter defined from outside
  601. if (this[prop + 'Setter']) {
  602. this[prop + 'Setter']();
  603. // Other animations on SVGElement
  604. }
  605. else if (elem.attr) {
  606. if (elem.element) {
  607. elem.attr(prop, now, null, true);
  608. }
  609. // HTML styles, raw HTML content like container size
  610. }
  611. else {
  612. elem.style[prop] = now + this.unit;
  613. }
  614. if (step) {
  615. step.call(elem, now, this);
  616. }
  617. };
  618. /**
  619. * Run an animation.
  620. *
  621. * @function Highcharts.Fx#run
  622. *
  623. * @param {number} from
  624. * The current value, value to start from.
  625. *
  626. * @param {number} to
  627. * The end value, value to land on.
  628. *
  629. * @param {string} unit
  630. * The property unit, for example `px`.
  631. *
  632. * @return {void}
  633. */
  634. Fx.prototype.run = function (from, to, unit) {
  635. var self = this, options = self.options, timer = function (gotoEnd) {
  636. return timer.stopped ? false : self.step(gotoEnd);
  637. }, requestAnimationFrame = win.requestAnimationFrame ||
  638. function (step) {
  639. setTimeout(step, 13);
  640. }, step = function () {
  641. for (var i = 0; i < H.timers.length; i++) {
  642. if (!H.timers[i]()) {
  643. H.timers.splice(i--, 1);
  644. }
  645. }
  646. if (H.timers.length) {
  647. requestAnimationFrame(step);
  648. }
  649. };
  650. if (from === to && !this.elem['forceAnimate:' + this.prop]) {
  651. delete options.curAnim[this.prop];
  652. if (options.complete && Object.keys(options.curAnim).length === 0) {
  653. options.complete.call(this.elem);
  654. }
  655. }
  656. else { // #7166
  657. this.startTime = +new Date();
  658. this.start = from;
  659. this.end = to;
  660. this.unit = unit;
  661. this.now = this.start;
  662. this.pos = 0;
  663. timer.elem = this.elem;
  664. timer.prop = this.prop;
  665. if (timer() && H.timers.push(timer) === 1) {
  666. requestAnimationFrame(step);
  667. }
  668. }
  669. };
  670. /**
  671. * Run a single step in the animation.
  672. *
  673. * @function Highcharts.Fx#step
  674. *
  675. * @param {boolean} [gotoEnd]
  676. * Whether to go to the endpoint of the animation after abort.
  677. *
  678. * @return {boolean}
  679. * Returns `true` if animation continues.
  680. */
  681. Fx.prototype.step = function (gotoEnd) {
  682. var t = +new Date(), ret, done, options = this.options, elem = this.elem, complete = options.complete, duration = options.duration, curAnim = options.curAnim;
  683. if (elem.attr && !elem.element) { // #2616, element is destroyed
  684. ret = false;
  685. }
  686. else if (gotoEnd || t >= duration + this.startTime) {
  687. this.now = this.end;
  688. this.pos = 1;
  689. this.update();
  690. curAnim[this.prop] = true;
  691. done = true;
  692. objectEach(curAnim, function (val) {
  693. if (val !== true) {
  694. done = false;
  695. }
  696. });
  697. if (done && complete) {
  698. complete.call(elem);
  699. }
  700. ret = false;
  701. }
  702. else {
  703. this.pos = options.easing((t - this.startTime) / duration);
  704. this.now = this.start + ((this.end - this.start) * this.pos);
  705. this.update();
  706. ret = true;
  707. }
  708. return ret;
  709. };
  710. /**
  711. * Prepare start and end values so that the path can be animated one to one.
  712. *
  713. * @function Highcharts.Fx#initPath
  714. *
  715. * @param {Highcharts.SVGElement} elem
  716. * The SVGElement item.
  717. *
  718. * @param {Highcharts.SVGPathArray|undefined} fromD
  719. * Starting path definition.
  720. *
  721. * @param {Highcharts.SVGPathArray} toD
  722. * Ending path definition.
  723. *
  724. * @return {Array<Highcharts.SVGPathArray,Highcharts.SVGPathArray>}
  725. * An array containing start and end paths in array form so that
  726. * they can be animated in parallel.
  727. */
  728. Fx.prototype.initPath = function (elem, fromD, toD) {
  729. var shift, startX = elem.startX, endX = elem.endX, fullLength, i, start = fromD && fromD.slice(), // copy
  730. end = toD.slice(), // copy
  731. isArea = elem.isArea, positionFactor = isArea ? 2 : 1, reverse;
  732. if (!start) {
  733. return [end, end];
  734. }
  735. /**
  736. * If shifting points, prepend a dummy point to the end path.
  737. * @private
  738. * @param {Highcharts.SVGPathArray} arr - array
  739. * @param {Highcharts.SVGPathArray} other - array
  740. * @return {void}
  741. */
  742. function prepend(arr, other) {
  743. while (arr.length < fullLength) {
  744. // Move to, line to or curve to?
  745. var moveSegment = arr[0], otherSegment = other[fullLength - arr.length];
  746. if (otherSegment && moveSegment[0] === 'M') {
  747. if (otherSegment[0] === 'C') {
  748. arr[0] = [
  749. 'C',
  750. moveSegment[1],
  751. moveSegment[2],
  752. moveSegment[1],
  753. moveSegment[2],
  754. moveSegment[1],
  755. moveSegment[2]
  756. ];
  757. }
  758. else {
  759. arr[0] = ['L', moveSegment[1], moveSegment[2]];
  760. }
  761. }
  762. // Prepend a copy of the first point
  763. arr.unshift(moveSegment);
  764. // For areas, the bottom path goes back again to the left, so we
  765. // need to append a copy of the last point.
  766. if (isArea) {
  767. arr.push(arr[arr.length - 1]);
  768. }
  769. }
  770. }
  771. /**
  772. * Copy and append last point until the length matches the end length.
  773. * @private
  774. * @param {Highcharts.SVGPathArray} arr - array
  775. * @param {Highcharts.SVGPathArray} other - array
  776. * @return {void}
  777. */
  778. function append(arr, other) {
  779. while (arr.length < fullLength) {
  780. // Pull out the slice that is going to be appended or inserted.
  781. // In a line graph, the positionFactor is 1, and the last point
  782. // is sliced out. In an area graph, the positionFactor is 2,
  783. // causing the middle two points to be sliced out, since an area
  784. // path starts at left, follows the upper path then turns and
  785. // follows the bottom back.
  786. var segmentToAdd = arr[arr.length / positionFactor - 1].slice();
  787. // Disable the first control point of curve segments
  788. if (segmentToAdd[0] === 'C') {
  789. segmentToAdd[1] = segmentToAdd[5];
  790. segmentToAdd[2] = segmentToAdd[6];
  791. }
  792. if (!isArea) {
  793. arr.push(segmentToAdd);
  794. }
  795. else {
  796. var lowerSegmentToAdd = arr[arr.length / positionFactor].slice();
  797. arr.splice(arr.length / 2, 0, segmentToAdd, lowerSegmentToAdd);
  798. }
  799. }
  800. }
  801. // For sideways animation, find out how much we need to shift to get the
  802. // start path Xs to match the end path Xs.
  803. if (startX && endX) {
  804. for (i = 0; i < startX.length; i++) {
  805. // Moving left, new points coming in on right
  806. if (startX[i] === endX[0]) {
  807. shift = i;
  808. break;
  809. // Moving right
  810. }
  811. else if (startX[0] ===
  812. endX[endX.length - startX.length + i]) {
  813. shift = i;
  814. reverse = true;
  815. break;
  816. // Fixed from the right side, "scaling" left
  817. }
  818. else if (startX[startX.length - 1] ===
  819. endX[endX.length - startX.length + i]) {
  820. shift = startX.length - i;
  821. break;
  822. }
  823. }
  824. if (typeof shift === 'undefined') {
  825. start = [];
  826. }
  827. }
  828. if (start.length && isNumber(shift)) {
  829. // The common target length for the start and end array, where both
  830. // arrays are padded in opposite ends
  831. fullLength = end.length + shift * positionFactor;
  832. if (!reverse) {
  833. prepend(end, start);
  834. append(start, end);
  835. }
  836. else {
  837. prepend(start, end);
  838. append(end, start);
  839. }
  840. }
  841. return [start, end];
  842. };
  843. /**
  844. * Handle animation of the color attributes directly.
  845. *
  846. * @function Highcharts.Fx#fillSetter
  847. *
  848. * @return {void}
  849. */
  850. Fx.prototype.fillSetter = function () {
  851. Fx.prototype.strokeSetter.apply(this, arguments);
  852. };
  853. /**
  854. * Handle animation of the color attributes directly.
  855. *
  856. * @function Highcharts.Fx#strokeSetter
  857. *
  858. * @return {void}
  859. */
  860. Fx.prototype.strokeSetter = function () {
  861. this.elem.attr(this.prop, H.color(this.start).tweenTo(H.color(this.end), this.pos), null, true);
  862. };
  863. return Fx;
  864. }());
  865. H.Fx = Fx;
  866. /* eslint-disable valid-jsdoc */
  867. /**
  868. * Utility function to deep merge two or more objects and return a third object.
  869. * If the first argument is true, the contents of the second object is copied
  870. * into the first object. The merge function can also be used with a single
  871. * object argument to create a deep copy of an object.
  872. *
  873. * @function Highcharts.merge<T>
  874. *
  875. * @param {boolean} extend
  876. * Whether to extend the left-side object (a) or return a whole new
  877. * object.
  878. *
  879. * @param {T|undefined} a
  880. * The first object to extend. When only this is given, the function
  881. * returns a deep copy.
  882. *
  883. * @param {...Array<object|undefined>} [n]
  884. * An object to merge into the previous one.
  885. *
  886. * @return {T}
  887. * The merged object. If the first argument is true, the return is the
  888. * same as the second argument.
  889. */ /**
  890. * Utility function to deep merge two or more objects and return a third object.
  891. * The merge function can also be used with a single object argument to create a
  892. * deep copy of an object.
  893. *
  894. * @function Highcharts.merge<T>
  895. *
  896. * @param {T|undefined} a
  897. * The first object to extend. When only this is given, the function
  898. * returns a deep copy.
  899. *
  900. * @param {...Array<object|undefined>} [n]
  901. * An object to merge into the previous one.
  902. *
  903. * @return {T}
  904. * The merged object. If the first argument is true, the return is the
  905. * same as the second argument.
  906. */
  907. function merge() {
  908. /* eslint-enable valid-jsdoc */
  909. var i, args = arguments, len, ret = {}, doCopy = function (copy, original) {
  910. // An object is replacing a primitive
  911. if (typeof copy !== 'object') {
  912. copy = {};
  913. }
  914. objectEach(original, function (value, key) {
  915. // Copy the contents of objects, but not arrays or DOM nodes
  916. if (isObject(value, true) &&
  917. !isClass(value) &&
  918. !isDOMElement(value)) {
  919. copy[key] = doCopy(copy[key] || {}, value);
  920. // Primitives and arrays are copied over directly
  921. }
  922. else {
  923. copy[key] = original[key];
  924. }
  925. });
  926. return copy;
  927. };
  928. // If first argument is true, copy into the existing object. Used in
  929. // setOptions.
  930. if (args[0] === true) {
  931. ret = args[1];
  932. args = Array.prototype.slice.call(args, 2);
  933. }
  934. // For each argument, extend the return
  935. len = args.length;
  936. for (i = 0; i < len; i++) {
  937. ret = doCopy(ret, args[i]);
  938. }
  939. return ret;
  940. }
  941. H.merge = merge;
  942. /**
  943. * Constrain a value to within a lower and upper threshold.
  944. *
  945. * @private
  946. * @param {number} value The initial value
  947. * @param {number} min The lower threshold
  948. * @param {number} max The upper threshold
  949. * @return {number} Returns a number value within min and max.
  950. */
  951. function clamp(value, min, max) {
  952. return value > min ? value < max ? value : max : min;
  953. }
  954. /**
  955. * Shortcut for parseInt
  956. *
  957. * @private
  958. * @function Highcharts.pInt
  959. *
  960. * @param {*} s
  961. * any
  962. *
  963. * @param {number} [mag]
  964. * Magnitude
  965. *
  966. * @return {number}
  967. * number
  968. */
  969. var pInt = H.pInt = function pInt(s, mag) {
  970. return parseInt(s, mag || 10);
  971. };
  972. /**
  973. * Utility function to check for string type.
  974. *
  975. * @function Highcharts.isString
  976. *
  977. * @param {*} s
  978. * The item to check.
  979. *
  980. * @return {boolean}
  981. * True if the argument is a string.
  982. */
  983. var isString = H.isString = function isString(s) {
  984. return typeof s === 'string';
  985. };
  986. /**
  987. * Utility function to check if an item is an array.
  988. *
  989. * @function Highcharts.isArray
  990. *
  991. * @param {*} obj
  992. * The item to check.
  993. *
  994. * @return {boolean}
  995. * True if the argument is an array.
  996. */
  997. var isArray = H.isArray = function isArray(obj) {
  998. var str = Object.prototype.toString.call(obj);
  999. return str === '[object Array]' || str === '[object Array Iterator]';
  1000. };
  1001. /**
  1002. * Utility function to check if an item is of type object.
  1003. *
  1004. * @function Highcharts.isObject
  1005. *
  1006. * @param {*} obj
  1007. * The item to check.
  1008. *
  1009. * @param {boolean} [strict=false]
  1010. * Also checks that the object is not an array.
  1011. *
  1012. * @return {boolean}
  1013. * True if the argument is an object.
  1014. */
  1015. function isObject(obj, strict) {
  1016. return (!!obj &&
  1017. typeof obj === 'object' &&
  1018. (!strict || !isArray(obj))); // eslint-disable-line @typescript-eslint/no-explicit-any
  1019. }
  1020. H.isObject = isObject;
  1021. /**
  1022. * Utility function to check if an Object is a HTML Element.
  1023. *
  1024. * @function Highcharts.isDOMElement
  1025. *
  1026. * @param {*} obj
  1027. * The item to check.
  1028. *
  1029. * @return {boolean}
  1030. * True if the argument is a HTML Element.
  1031. */
  1032. var isDOMElement = H.isDOMElement = function isDOMElement(obj) {
  1033. return isObject(obj) && typeof obj.nodeType === 'number';
  1034. };
  1035. /**
  1036. * Utility function to check if an Object is a class.
  1037. *
  1038. * @function Highcharts.isClass
  1039. *
  1040. * @param {object|undefined} obj
  1041. * The item to check.
  1042. *
  1043. * @return {boolean}
  1044. * True if the argument is a class.
  1045. */
  1046. var isClass = H.isClass = function isClass(obj) {
  1047. var c = obj && obj.constructor;
  1048. return !!(isObject(obj, true) &&
  1049. !isDOMElement(obj) &&
  1050. (c && c.name && c.name !== 'Object'));
  1051. };
  1052. /**
  1053. * Utility function to check if an item is a number and it is finite (not NaN,
  1054. * Infinity or -Infinity).
  1055. *
  1056. * @function Highcharts.isNumber
  1057. *
  1058. * @param {*} n
  1059. * The item to check.
  1060. *
  1061. * @return {boolean}
  1062. * True if the item is a finite number
  1063. */
  1064. var isNumber = H.isNumber = function isNumber(n) {
  1065. return typeof n === 'number' && !isNaN(n) && n < Infinity && n > -Infinity;
  1066. };
  1067. /**
  1068. * Remove the last occurence of an item from an array.
  1069. *
  1070. * @function Highcharts.erase
  1071. *
  1072. * @param {Array<*>} arr
  1073. * The array.
  1074. *
  1075. * @param {*} item
  1076. * The item to remove.
  1077. *
  1078. * @return {void}
  1079. */
  1080. var erase = H.erase = function erase(arr, item) {
  1081. var i = arr.length;
  1082. while (i--) {
  1083. if (arr[i] === item) {
  1084. arr.splice(i, 1);
  1085. break;
  1086. }
  1087. }
  1088. };
  1089. /**
  1090. * Check if an object is null or undefined.
  1091. *
  1092. * @function Highcharts.defined
  1093. *
  1094. * @param {*} obj
  1095. * The object to check.
  1096. *
  1097. * @return {boolean}
  1098. * False if the object is null or undefined, otherwise true.
  1099. */
  1100. var defined = H.defined = function defined(obj) {
  1101. return typeof obj !== 'undefined' && obj !== null;
  1102. };
  1103. /**
  1104. * Set or get an attribute or an object of attributes. To use as a setter, pass
  1105. * a key and a value, or let the second argument be a collection of keys and
  1106. * values. To use as a getter, pass only a string as the second argument.
  1107. *
  1108. * @function Highcharts.attr
  1109. *
  1110. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} elem
  1111. * The DOM element to receive the attribute(s).
  1112. *
  1113. * @param {string|Highcharts.HTMLAttributes|Highcharts.SVGAttributes} [prop]
  1114. * The property or an object of key-value pairs.
  1115. *
  1116. * @param {number|string} [value]
  1117. * The value if a single property is set.
  1118. *
  1119. * @return {string|null|undefined}
  1120. * When used as a getter, return the value.
  1121. */
  1122. function attr(elem, prop, value) {
  1123. var ret;
  1124. // if the prop is a string
  1125. if (isString(prop)) {
  1126. // set the value
  1127. if (defined(value)) {
  1128. elem.setAttribute(prop, value);
  1129. // get the value
  1130. }
  1131. else if (elem && elem.getAttribute) {
  1132. ret = elem.getAttribute(prop);
  1133. // IE7 and below cannot get class through getAttribute (#7850)
  1134. if (!ret && prop === 'class') {
  1135. ret = elem.getAttribute(prop + 'Name');
  1136. }
  1137. }
  1138. // else if prop is defined, it is a hash of key/value pairs
  1139. }
  1140. else {
  1141. objectEach(prop, function (val, key) {
  1142. elem.setAttribute(key, val);
  1143. });
  1144. }
  1145. return ret;
  1146. }
  1147. H.attr = attr;
  1148. /**
  1149. * Check if an element is an array, and if not, make it into an array.
  1150. *
  1151. * @function Highcharts.splat
  1152. *
  1153. * @param {*} obj
  1154. * The object to splat.
  1155. *
  1156. * @return {Array}
  1157. * The produced or original array.
  1158. */
  1159. var splat = H.splat = function splat(obj) {
  1160. return isArray(obj) ? obj : [obj];
  1161. };
  1162. /**
  1163. * Set a timeout if the delay is given, otherwise perform the function
  1164. * synchronously.
  1165. *
  1166. * @function Highcharts.syncTimeout
  1167. *
  1168. * @param {Function} fn
  1169. * The function callback.
  1170. *
  1171. * @param {number} delay
  1172. * Delay in milliseconds.
  1173. *
  1174. * @param {*} [context]
  1175. * An optional context to send to the function callback.
  1176. *
  1177. * @return {number}
  1178. * An identifier for the timeout that can later be cleared with
  1179. * Highcharts.clearTimeout. Returns -1 if there is no timeout.
  1180. */
  1181. var syncTimeout = H.syncTimeout = function syncTimeout(fn, delay, context) {
  1182. if (delay > 0) {
  1183. return setTimeout(fn, delay, context);
  1184. }
  1185. fn.call(0, context);
  1186. return -1;
  1187. };
  1188. /**
  1189. * Internal clear timeout. The function checks that the `id` was not removed
  1190. * (e.g. by `chart.destroy()`). For the details see
  1191. * [issue #7901](https://github.com/highcharts/highcharts/issues/7901).
  1192. *
  1193. * @function Highcharts.clearTimeout
  1194. *
  1195. * @param {number} id
  1196. * Id of a timeout.
  1197. *
  1198. * @return {void}
  1199. */
  1200. var internalClearTimeout = H.clearTimeout = function (id) {
  1201. if (defined(id)) {
  1202. clearTimeout(id);
  1203. }
  1204. };
  1205. /* eslint-disable valid-jsdoc */
  1206. /**
  1207. * Utility function to extend an object with the members of another.
  1208. *
  1209. * @function Highcharts.extend<T>
  1210. *
  1211. * @param {T|undefined} a
  1212. * The object to be extended.
  1213. *
  1214. * @param {object} b
  1215. * The object to add to the first one.
  1216. *
  1217. * @return {T}
  1218. * Object a, the original object.
  1219. */
  1220. var extend = H.extend = function extend(a, b) {
  1221. /* eslint-enable valid-jsdoc */
  1222. var n;
  1223. if (!a) {
  1224. a = {};
  1225. }
  1226. for (n in b) { // eslint-disable-line guard-for-in
  1227. a[n] = b[n];
  1228. }
  1229. return a;
  1230. };
  1231. /* eslint-disable valid-jsdoc */
  1232. /**
  1233. * Return the first value that is not null or undefined.
  1234. *
  1235. * @function Highcharts.pick<T>
  1236. *
  1237. * @param {...Array<T|null|undefined>} items
  1238. * Variable number of arguments to inspect.
  1239. *
  1240. * @return {T}
  1241. * The value of the first argument that is not null or undefined.
  1242. */
  1243. function pick() {
  1244. var args = arguments;
  1245. var length = args.length;
  1246. for (var i = 0; i < length; i++) {
  1247. var arg = args[i];
  1248. if (typeof arg !== 'undefined' && arg !== null) {
  1249. return arg;
  1250. }
  1251. }
  1252. }
  1253. H.pick = pick;
  1254. /**
  1255. * Set CSS on a given element.
  1256. *
  1257. * @function Highcharts.css
  1258. *
  1259. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
  1260. * An HTML DOM element.
  1261. *
  1262. * @param {Highcharts.CSSObject} styles
  1263. * Style object with camel case property names.
  1264. *
  1265. * @return {void}
  1266. */
  1267. var css = H.css = function css(el, styles) {
  1268. if (H.isMS && !H.svg) { // #2686
  1269. if (styles && typeof styles.opacity !== 'undefined') {
  1270. styles.filter =
  1271. 'alpha(opacity=' + (styles.opacity * 100) + ')';
  1272. }
  1273. }
  1274. extend(el.style, styles);
  1275. };
  1276. /**
  1277. * Utility function to create an HTML element with attributes and styles.
  1278. *
  1279. * @function Highcharts.createElement
  1280. *
  1281. * @param {string} tag
  1282. * The HTML tag.
  1283. *
  1284. * @param {Highcharts.HTMLAttributes} [attribs]
  1285. * Attributes as an object of key-value pairs.
  1286. *
  1287. * @param {Highcharts.CSSObject} [styles]
  1288. * Styles as an object of key-value pairs.
  1289. *
  1290. * @param {Highcharts.HTMLDOMElement} [parent]
  1291. * The parent HTML object.
  1292. *
  1293. * @param {boolean} [nopad=false]
  1294. * If true, remove all padding, border and margin.
  1295. *
  1296. * @return {Highcharts.HTMLDOMElement}
  1297. * The created DOM element.
  1298. */
  1299. var createElement = H.createElement = function createElement(tag, attribs, styles, parent, nopad) {
  1300. var el = doc.createElement(tag);
  1301. if (attribs) {
  1302. extend(el, attribs);
  1303. }
  1304. if (nopad) {
  1305. css(el, { padding: '0', border: 'none', margin: '0' });
  1306. }
  1307. if (styles) {
  1308. css(el, styles);
  1309. }
  1310. if (parent) {
  1311. parent.appendChild(el);
  1312. }
  1313. return el;
  1314. };
  1315. // eslint-disable-next-line valid-jsdoc
  1316. /**
  1317. * Extend a prototyped class by new members.
  1318. *
  1319. * @function Highcharts.extendClass<T>
  1320. *
  1321. * @param {Highcharts.Class<T>} parent
  1322. * The parent prototype to inherit.
  1323. *
  1324. * @param {Highcharts.Dictionary<*>} members
  1325. * A collection of prototype members to add or override compared to the
  1326. * parent prototype.
  1327. *
  1328. * @return {Highcharts.Class<T>}
  1329. * A new prototype.
  1330. */
  1331. var extendClass = H.extendClass = function extendClass(parent, members) {
  1332. var obj = (function () { });
  1333. obj.prototype = new parent(); // eslint-disable-line new-cap
  1334. extend(obj.prototype, members);
  1335. return obj;
  1336. };
  1337. /**
  1338. * Left-pad a string to a given length by adding a character repetetively.
  1339. *
  1340. * @function Highcharts.pad
  1341. *
  1342. * @param {number} number
  1343. * The input string or number.
  1344. *
  1345. * @param {number} [length]
  1346. * The desired string length.
  1347. *
  1348. * @param {string} [padder=0]
  1349. * The character to pad with.
  1350. *
  1351. * @return {string}
  1352. * The padded string.
  1353. */
  1354. var pad = H.pad = function pad(number, length, padder) {
  1355. return new Array((length || 2) +
  1356. 1 -
  1357. String(number)
  1358. .replace('-', '')
  1359. .length).join(padder || '0') + number;
  1360. };
  1361. /**
  1362. * Return a length based on either the integer value, or a percentage of a base.
  1363. *
  1364. * @function Highcharts.relativeLength
  1365. *
  1366. * @param {Highcharts.RelativeSize} value
  1367. * A percentage string or a number.
  1368. *
  1369. * @param {number} base
  1370. * The full length that represents 100%.
  1371. *
  1372. * @param {number} [offset=0]
  1373. * A pixel offset to apply for percentage values. Used internally in
  1374. * axis positioning.
  1375. *
  1376. * @return {number}
  1377. * The computed length.
  1378. */
  1379. var relativeLength = H.relativeLength = function relativeLength(value, base, offset) {
  1380. return (/%$/).test(value) ?
  1381. (base * parseFloat(value) / 100) + (offset || 0) :
  1382. parseFloat(value);
  1383. };
  1384. /**
  1385. * Wrap a method with extended functionality, preserving the original function.
  1386. *
  1387. * @function Highcharts.wrap
  1388. *
  1389. * @param {*} obj
  1390. * The context object that the method belongs to. In real cases, this is
  1391. * often a prototype.
  1392. *
  1393. * @param {string} method
  1394. * The name of the method to extend.
  1395. *
  1396. * @param {Highcharts.WrapProceedFunction} func
  1397. * A wrapper function callback. This function is called with the same
  1398. * arguments as the original function, except that the original function
  1399. * is unshifted and passed as the first argument.
  1400. */
  1401. var wrap = H.wrap = function wrap(obj, method, func) {
  1402. var proceed = obj[method];
  1403. obj[method] = function () {
  1404. var args = Array.prototype.slice.call(arguments), outerArgs = arguments, ctx = this, ret;
  1405. ctx.proceed = function () {
  1406. proceed.apply(ctx, arguments.length ? arguments : outerArgs);
  1407. };
  1408. args.unshift(proceed);
  1409. ret = func.apply(this, args);
  1410. ctx.proceed = null;
  1411. return ret;
  1412. };
  1413. };
  1414. /**
  1415. * Format a string according to a subset of the rules of Python's String.format
  1416. * method.
  1417. *
  1418. * @example
  1419. * var s = Highcharts.format(
  1420. * 'The {color} fox was {len:.2f} feet long',
  1421. * { color: 'red', len: Math.PI }
  1422. * );
  1423. * // => The red fox was 3.14 feet long
  1424. *
  1425. * @function Highcharts.format
  1426. *
  1427. * @param {string} str
  1428. * The string to format.
  1429. *
  1430. * @param {Record<string, *>} ctx
  1431. * The context, a collection of key-value pairs where each key is
  1432. * replaced by its value.
  1433. *
  1434. * @param {Highcharts.Chart} [chart]
  1435. * A `Chart` instance used to get numberFormatter and time.
  1436. *
  1437. * @return {string}
  1438. * The formatted string.
  1439. */
  1440. var format = H.format = function (str, ctx, chart) {
  1441. var splitter = '{', isInside = false, segment, valueAndFormat, ret = [], val, index;
  1442. var floatRegex = /f$/;
  1443. var decRegex = /\.([0-9])/;
  1444. var lang = H.defaultOptions.lang;
  1445. var time = chart && chart.time || H.time;
  1446. var numberFormatter = chart && chart.numberFormatter || numberFormat;
  1447. while (str) {
  1448. index = str.indexOf(splitter);
  1449. if (index === -1) {
  1450. break;
  1451. }
  1452. segment = str.slice(0, index);
  1453. if (isInside) { // we're on the closing bracket looking back
  1454. valueAndFormat = segment.split(':');
  1455. val = getNestedProperty(valueAndFormat.shift() || '', ctx);
  1456. // Format the replacement
  1457. if (valueAndFormat.length && typeof val === 'number') {
  1458. segment = valueAndFormat.join(':');
  1459. if (floatRegex.test(segment)) { // float
  1460. var decimals = parseInt((segment.match(decRegex) || ['', '-1'])[1], 10);
  1461. if (val !== null) {
  1462. val = numberFormatter(val, decimals, lang.decimalPoint, segment.indexOf(',') > -1 ? lang.thousandsSep : '');
  1463. }
  1464. }
  1465. else {
  1466. val = time.dateFormat(segment, val);
  1467. }
  1468. }
  1469. // Push the result and advance the cursor
  1470. ret.push(val);
  1471. }
  1472. else {
  1473. ret.push(segment);
  1474. }
  1475. str = str.slice(index + 1); // the rest
  1476. isInside = !isInside; // toggle
  1477. splitter = isInside ? '}' : '{'; // now look for next matching bracket
  1478. }
  1479. ret.push(str);
  1480. return ret.join('');
  1481. };
  1482. /**
  1483. * Get the magnitude of a number.
  1484. *
  1485. * @function Highcharts.getMagnitude
  1486. *
  1487. * @param {number} num
  1488. * The number.
  1489. *
  1490. * @return {number}
  1491. * The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2 etc.
  1492. */
  1493. var getMagnitude = H.getMagnitude = function (num) {
  1494. return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
  1495. };
  1496. /**
  1497. * Take an interval and normalize it to multiples of round numbers.
  1498. *
  1499. * @deprecated
  1500. * @function Highcharts.normalizeTickInterval
  1501. *
  1502. * @param {number} interval
  1503. * The raw, un-rounded interval.
  1504. *
  1505. * @param {Array<*>} [multiples]
  1506. * Allowed multiples.
  1507. *
  1508. * @param {number} [magnitude]
  1509. * The magnitude of the number.
  1510. *
  1511. * @param {boolean} [allowDecimals]
  1512. * Whether to allow decimals.
  1513. *
  1514. * @param {boolean} [hasTickAmount]
  1515. * If it has tickAmount, avoid landing on tick intervals lower than
  1516. * original.
  1517. *
  1518. * @return {number}
  1519. * The normalized interval.
  1520. *
  1521. * @todo
  1522. * Move this function to the Axis prototype. It is here only for historical
  1523. * reasons.
  1524. */
  1525. var normalizeTickInterval = H.normalizeTickInterval = function (interval, multiples, magnitude, allowDecimals, hasTickAmount) {
  1526. var normalized, i, retInterval = interval;
  1527. // round to a tenfold of 1, 2, 2.5 or 5
  1528. magnitude = pick(magnitude, 1);
  1529. normalized = interval / magnitude;
  1530. // multiples for a linear scale
  1531. if (!multiples) {
  1532. multiples = hasTickAmount ?
  1533. // Finer grained ticks when the tick amount is hard set, including
  1534. // when alignTicks is true on multiple axes (#4580).
  1535. [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
  1536. // Else, let ticks fall on rounder numbers
  1537. [1, 2, 2.5, 5, 10];
  1538. // the allowDecimals option
  1539. if (allowDecimals === false) {
  1540. if (magnitude === 1) {
  1541. multiples = multiples.filter(function (num) {
  1542. return num % 1 === 0;
  1543. });
  1544. }
  1545. else if (magnitude <= 0.1) {
  1546. multiples = [1 / magnitude];
  1547. }
  1548. }
  1549. }
  1550. // normalize the interval to the nearest multiple
  1551. for (i = 0; i < multiples.length; i++) {
  1552. retInterval = multiples[i];
  1553. // only allow tick amounts smaller than natural
  1554. if ((hasTickAmount &&
  1555. retInterval * magnitude >= interval) ||
  1556. (!hasTickAmount &&
  1557. (normalized <=
  1558. (multiples[i] +
  1559. (multiples[i + 1] || multiples[i])) / 2))) {
  1560. break;
  1561. }
  1562. }
  1563. // Multiply back to the correct magnitude. Correct floats to appropriate
  1564. // precision (#6085).
  1565. retInterval = correctFloat(retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10));
  1566. return retInterval;
  1567. };
  1568. /**
  1569. * Sort an object array and keep the order of equal items. The ECMAScript
  1570. * standard does not specify the behaviour when items are equal.
  1571. *
  1572. * @function Highcharts.stableSort
  1573. *
  1574. * @param {Array<*>} arr
  1575. * The array to sort.
  1576. *
  1577. * @param {Function} sortFunction
  1578. * The function to sort it with, like with regular Array.prototype.sort.
  1579. *
  1580. * @return {void}
  1581. */
  1582. var stableSort = H.stableSort = function stableSort(arr, sortFunction) {
  1583. // @todo It seems like Chrome since v70 sorts in a stable way internally,
  1584. // plus all other browsers do it, so over time we may be able to remove this
  1585. // function
  1586. var length = arr.length, sortValue, i;
  1587. // Add index to each item
  1588. for (i = 0; i < length; i++) {
  1589. arr[i].safeI = i; // stable sort index
  1590. }
  1591. arr.sort(function (a, b) {
  1592. sortValue = sortFunction(a, b);
  1593. return sortValue === 0 ? a.safeI - b.safeI : sortValue;
  1594. });
  1595. // Remove index from items
  1596. for (i = 0; i < length; i++) {
  1597. delete arr[i].safeI; // stable sort index
  1598. }
  1599. };
  1600. /**
  1601. * Non-recursive method to find the lowest member of an array. `Math.min` raises
  1602. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1603. * than 150.000 points. This method is slightly slower, but safe.
  1604. *
  1605. * @function Highcharts.arrayMin
  1606. *
  1607. * @param {Array<*>} data
  1608. * An array of numbers.
  1609. *
  1610. * @return {number}
  1611. * The lowest number.
  1612. */
  1613. var arrayMin = H.arrayMin = function arrayMin(data) {
  1614. var i = data.length, min = data[0];
  1615. while (i--) {
  1616. if (data[i] < min) {
  1617. min = data[i];
  1618. }
  1619. }
  1620. return min;
  1621. };
  1622. /**
  1623. * Non-recursive method to find the lowest member of an array. `Math.max` raises
  1624. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1625. * than 150.000 points. This method is slightly slower, but safe.
  1626. *
  1627. * @function Highcharts.arrayMax
  1628. *
  1629. * @param {Array<*>} data
  1630. * An array of numbers.
  1631. *
  1632. * @return {number}
  1633. * The highest number.
  1634. */
  1635. var arrayMax = H.arrayMax = function arrayMax(data) {
  1636. var i = data.length, max = data[0];
  1637. while (i--) {
  1638. if (data[i] > max) {
  1639. max = data[i];
  1640. }
  1641. }
  1642. return max;
  1643. };
  1644. /**
  1645. * Utility method that destroys any SVGElement instances that are properties on
  1646. * the given object. It loops all properties and invokes destroy if there is a
  1647. * destroy method. The property is then delete.
  1648. *
  1649. * @function Highcharts.destroyObjectProperties
  1650. *
  1651. * @param {*} obj
  1652. * The object to destroy properties on.
  1653. *
  1654. * @param {*} [except]
  1655. * Exception, do not destroy this property, only delete it.
  1656. *
  1657. * @return {void}
  1658. */
  1659. var destroyObjectProperties = H.destroyObjectProperties =
  1660. function destroyObjectProperties(obj, except) {
  1661. objectEach(obj, function (val, n) {
  1662. // If the object is non-null and destroy is defined
  1663. if (val && val !== except && val.destroy) {
  1664. // Invoke the destroy
  1665. val.destroy();
  1666. }
  1667. // Delete the property from the object.
  1668. delete obj[n];
  1669. });
  1670. };
  1671. /**
  1672. * Discard a HTML element by moving it to the bin and delete.
  1673. *
  1674. * @function Highcharts.discardElement
  1675. *
  1676. * @param {Highcharts.HTMLDOMElement} element
  1677. * The HTML node to discard.
  1678. *
  1679. * @return {void}
  1680. */
  1681. var discardElement = H.discardElement = function discardElement(element) {
  1682. var garbageBin = H.garbageBin;
  1683. // create a garbage bin element, not part of the DOM
  1684. if (!garbageBin) {
  1685. garbageBin = createElement('div');
  1686. }
  1687. // move the node and empty bin
  1688. if (element) {
  1689. garbageBin.appendChild(element);
  1690. }
  1691. garbageBin.innerHTML = '';
  1692. };
  1693. /**
  1694. * Fix JS round off float errors.
  1695. *
  1696. * @function Highcharts.correctFloat
  1697. *
  1698. * @param {number} num
  1699. * A float number to fix.
  1700. *
  1701. * @param {number} [prec=14]
  1702. * The precision.
  1703. *
  1704. * @return {number}
  1705. * The corrected float number.
  1706. */
  1707. var correctFloat = H.correctFloat = function correctFloat(num, prec) {
  1708. return parseFloat(num.toPrecision(prec || 14));
  1709. };
  1710. /**
  1711. * Set the global animation to either a given value, or fall back to the given
  1712. * chart's animation option.
  1713. *
  1714. * @function Highcharts.setAnimation
  1715. *
  1716. * @param {boolean|Highcharts.AnimationOptionsObject|undefined} animation
  1717. * The animation object.
  1718. *
  1719. * @param {Highcharts.Chart} chart
  1720. * The chart instance.
  1721. *
  1722. * @return {void}
  1723. *
  1724. * @todo
  1725. * This function always relates to a chart, and sets a property on the renderer,
  1726. * so it should be moved to the SVGRenderer.
  1727. */
  1728. var setAnimation = H.setAnimation = function setAnimation(animation, chart) {
  1729. chart.renderer.globalAnimation = pick(animation, chart.options.chart.animation, true);
  1730. };
  1731. /**
  1732. * Get the animation in object form, where a disabled animation is always
  1733. * returned as `{ duration: 0 }`.
  1734. *
  1735. * @function Highcharts.animObject
  1736. *
  1737. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=0]
  1738. * An animation setting. Can be an object with duration, complete and
  1739. * easing properties, or a boolean to enable or disable.
  1740. *
  1741. * @return {Highcharts.AnimationOptionsObject}
  1742. * An object with at least a duration property.
  1743. */
  1744. var animObject = H.animObject = function animObject(animation) {
  1745. return isObject(animation) ?
  1746. merge(animation) :
  1747. { duration: animation ? 500 : 0 };
  1748. };
  1749. /**
  1750. * The time unit lookup
  1751. *
  1752. * @ignore
  1753. */
  1754. var timeUnits = H.timeUnits = {
  1755. millisecond: 1,
  1756. second: 1000,
  1757. minute: 60000,
  1758. hour: 3600000,
  1759. day: 24 * 3600000,
  1760. week: 7 * 24 * 3600000,
  1761. month: 28 * 24 * 3600000,
  1762. year: 364 * 24 * 3600000
  1763. };
  1764. /**
  1765. * Format a number and return a string based on input settings.
  1766. *
  1767. * @sample highcharts/members/highcharts-numberformat/
  1768. * Custom number format
  1769. *
  1770. * @function Highcharts.numberFormat
  1771. *
  1772. * @param {number} number
  1773. * The input number to format.
  1774. *
  1775. * @param {number} decimals
  1776. * The amount of decimals. A value of -1 preserves the amount in the
  1777. * input number.
  1778. *
  1779. * @param {string} [decimalPoint]
  1780. * The decimal point, defaults to the one given in the lang options, or
  1781. * a dot.
  1782. *
  1783. * @param {string} [thousandsSep]
  1784. * The thousands separator, defaults to the one given in the lang
  1785. * options, or a space character.
  1786. *
  1787. * @return {string}
  1788. * The formatted number.
  1789. */
  1790. var numberFormat = H.numberFormat = function numberFormat(number, decimals, decimalPoint, thousandsSep) {
  1791. number = +number || 0;
  1792. decimals = +decimals;
  1793. var lang = H.defaultOptions.lang, origDec = (number.toString().split('.')[1] || '').split('e')[0].length, strinteger, thousands, ret, roundedNumber, exponent = number.toString().split('e'), fractionDigits;
  1794. if (decimals === -1) {
  1795. // Preserve decimals. Not huge numbers (#3793).
  1796. decimals = Math.min(origDec, 20);
  1797. }
  1798. else if (!isNumber(decimals)) {
  1799. decimals = 2;
  1800. }
  1801. else if (decimals && exponent[1] && exponent[1] < 0) {
  1802. // Expose decimals from exponential notation (#7042)
  1803. fractionDigits = decimals + +exponent[1];
  1804. if (fractionDigits >= 0) {
  1805. // remove too small part of the number while keeping the notation
  1806. exponent[0] = (+exponent[0]).toExponential(fractionDigits)
  1807. .split('e')[0];
  1808. decimals = fractionDigits;
  1809. }
  1810. else {
  1811. // fractionDigits < 0
  1812. exponent[0] = exponent[0].split('.')[0] || 0;
  1813. if (decimals < 20) {
  1814. // use number instead of exponential notation (#7405)
  1815. number = (exponent[0] * Math.pow(10, exponent[1]))
  1816. .toFixed(decimals);
  1817. }
  1818. else {
  1819. // or zero
  1820. number = 0;
  1821. }
  1822. exponent[1] = 0;
  1823. }
  1824. }
  1825. // Add another decimal to avoid rounding errors of float numbers. (#4573)
  1826. // Then use toFixed to handle rounding.
  1827. roundedNumber = (Math.abs(exponent[1] ? exponent[0] : number) +
  1828. Math.pow(10, -Math.max(decimals, origDec) - 1)).toFixed(decimals);
  1829. // A string containing the positive integer component of the number
  1830. strinteger = String(pInt(roundedNumber));
  1831. // Leftover after grouping into thousands. Can be 0, 1 or 2.
  1832. thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
  1833. // Language
  1834. decimalPoint = pick(decimalPoint, lang.decimalPoint);
  1835. thousandsSep = pick(thousandsSep, lang.thousandsSep);
  1836. // Start building the return
  1837. ret = number < 0 ? '-' : '';
  1838. // Add the leftover after grouping into thousands. For example, in the
  1839. // number 42 000 000, this line adds 42.
  1840. ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
  1841. // Add the remaining thousands groups, joined by the thousands separator
  1842. ret += strinteger
  1843. .substr(thousands)
  1844. .replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
  1845. // Add the decimal point and the decimal component
  1846. if (decimals) {
  1847. // Get the decimal component
  1848. ret += decimalPoint + roundedNumber.slice(-decimals);
  1849. }
  1850. if (exponent[1] && +ret !== 0) {
  1851. ret += 'e' + exponent[1];
  1852. }
  1853. return ret;
  1854. };
  1855. /**
  1856. * Easing definition
  1857. *
  1858. * @private
  1859. * @function Math.easeInOutSine
  1860. *
  1861. * @param {number} pos
  1862. * Current position, ranging from 0 to 1.
  1863. *
  1864. * @return {number}
  1865. * Ease result
  1866. */
  1867. Math.easeInOutSine = function (pos) {
  1868. return -0.5 * (Math.cos(Math.PI * pos) - 1);
  1869. };
  1870. /**
  1871. * Returns the value of a property path on a given object.
  1872. *
  1873. * @private
  1874. * @function getNestedProperty
  1875. *
  1876. * @param {string} path
  1877. * Path to the property, for example `custom.myValue`.
  1878. *
  1879. * @param {unknown} obj
  1880. * Instance containing the property on the specific path.
  1881. *
  1882. * @return {unknown}
  1883. * The unknown property value.
  1884. */
  1885. function getNestedProperty(path, obj) {
  1886. if (!path) {
  1887. return obj;
  1888. }
  1889. var pathElements = path.split('.').reverse();
  1890. var subProperty = obj;
  1891. if (pathElements.length === 1) {
  1892. return subProperty[path];
  1893. }
  1894. var pathElement = pathElements.pop();
  1895. while (typeof pathElement !== 'undefined' &&
  1896. typeof subProperty !== 'undefined' &&
  1897. subProperty !== null) {
  1898. subProperty = subProperty[pathElement];
  1899. pathElement = pathElements.pop();
  1900. }
  1901. return subProperty;
  1902. }
  1903. /**
  1904. * Get the computed CSS value for given element and property, only for numerical
  1905. * properties. For width and height, the dimension of the inner box (excluding
  1906. * padding) is returned. Used for fitting the chart within the container.
  1907. *
  1908. * @function Highcharts.getStyle
  1909. *
  1910. * @param {Highcharts.HTMLDOMElement} el
  1911. * An HTML element.
  1912. *
  1913. * @param {string} prop
  1914. * The property name.
  1915. *
  1916. * @param {boolean} [toInt=true]
  1917. * Parse to integer.
  1918. *
  1919. * @return {number|string}
  1920. * The numeric value.
  1921. */
  1922. var getStyle = H.getStyle = function (el, prop, toInt) {
  1923. var style;
  1924. // For width and height, return the actual inner pixel size (#4913)
  1925. if (prop === 'width') {
  1926. var offsetWidth = Math.min(el.offsetWidth, el.scrollWidth);
  1927. // In flex boxes, we need to use getBoundingClientRect and floor it,
  1928. // because scrollWidth doesn't support subpixel precision (#6427) ...
  1929. var boundingClientRectWidth = el.getBoundingClientRect &&
  1930. el.getBoundingClientRect().width;
  1931. // ...unless if the containing div or its parents are transform-scaled
  1932. // down, in which case the boundingClientRect can't be used as it is
  1933. // also scaled down (#9871, #10498).
  1934. if (boundingClientRectWidth < offsetWidth &&
  1935. boundingClientRectWidth >= offsetWidth - 1) {
  1936. offsetWidth = Math.floor(boundingClientRectWidth);
  1937. }
  1938. return Math.max(0, // #8377
  1939. (offsetWidth -
  1940. H.getStyle(el, 'padding-left') -
  1941. H.getStyle(el, 'padding-right')));
  1942. }
  1943. if (prop === 'height') {
  1944. return Math.max(0, // #8377
  1945. Math.min(el.offsetHeight, el.scrollHeight) -
  1946. H.getStyle(el, 'padding-top') -
  1947. H.getStyle(el, 'padding-bottom'));
  1948. }
  1949. if (!win.getComputedStyle) {
  1950. // SVG not supported, forgot to load oldie.js?
  1951. error(27, true);
  1952. }
  1953. // Otherwise, get the computed style
  1954. style = win.getComputedStyle(el, undefined); // eslint-disable-line no-undefined
  1955. if (style) {
  1956. style = style.getPropertyValue(prop);
  1957. if (pick(toInt, prop !== 'opacity')) {
  1958. style = pInt(style);
  1959. }
  1960. }
  1961. return style;
  1962. };
  1963. /**
  1964. * Search for an item in an array.
  1965. *
  1966. * @function Highcharts.inArray
  1967. *
  1968. * @deprecated
  1969. *
  1970. * @param {*} item
  1971. * The item to search for.
  1972. *
  1973. * @param {Array<*>} arr
  1974. * The array or node collection to search in.
  1975. *
  1976. * @param {number} [fromIndex=0]
  1977. * The index to start searching from.
  1978. *
  1979. * @return {number}
  1980. * The index within the array, or -1 if not found.
  1981. */
  1982. var inArray = H.inArray = function (item, arr, fromIndex) {
  1983. error(32, false, void 0, { 'Highcharts.inArray': 'use Array.indexOf' });
  1984. return arr.indexOf(item, fromIndex);
  1985. };
  1986. /* eslint-disable valid-jsdoc */
  1987. /**
  1988. * Return the value of the first element in the array that satisfies the
  1989. * provided testing function.
  1990. *
  1991. * @function Highcharts.find<T>
  1992. *
  1993. * @param {Array<T>} arr
  1994. * The array to test.
  1995. *
  1996. * @param {Function} callback
  1997. * The callback function. The function receives the item as the first
  1998. * argument. Return `true` if this item satisfies the condition.
  1999. *
  2000. * @return {T|undefined}
  2001. * The value of the element.
  2002. */
  2003. var find = H.find = Array.prototype.find ?
  2004. /* eslint-enable valid-jsdoc */
  2005. function (arr, callback) {
  2006. return arr.find(callback);
  2007. } :
  2008. // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
  2009. function (arr, callback) {
  2010. var i, length = arr.length;
  2011. for (i = 0; i < length; i++) {
  2012. if (callback(arr[i], i)) { // eslint-disable-line callback-return
  2013. return arr[i];
  2014. }
  2015. }
  2016. };
  2017. /**
  2018. * Returns an array of a given object's own properties.
  2019. *
  2020. * @function Highcharts.keys
  2021. * @deprecated
  2022. *
  2023. * @param {*} obj
  2024. * The object of which the properties are to be returned.
  2025. *
  2026. * @return {Array<string>}
  2027. * An array of strings that represents all the properties.
  2028. */
  2029. H.keys = function (obj) {
  2030. error(32, false, void 0, { 'Highcharts.keys': 'use Object.keys' });
  2031. return Object.keys(obj);
  2032. };
  2033. /**
  2034. * Get the element's offset position, corrected for `overflow: auto`.
  2035. *
  2036. * @function Highcharts.offset
  2037. *
  2038. * @param {global.Element} el
  2039. * The DOM element.
  2040. *
  2041. * @return {Highcharts.OffsetObject}
  2042. * An object containing `left` and `top` properties for the position in
  2043. * the page.
  2044. */
  2045. var offset = H.offset = function offset(el) {
  2046. var docElem = doc.documentElement, box = (el.parentElement || el.parentNode) ?
  2047. el.getBoundingClientRect() :
  2048. { top: 0, left: 0 };
  2049. return {
  2050. top: box.top + (win.pageYOffset || docElem.scrollTop) -
  2051. (docElem.clientTop || 0),
  2052. left: box.left + (win.pageXOffset || docElem.scrollLeft) -
  2053. (docElem.clientLeft || 0)
  2054. };
  2055. };
  2056. /**
  2057. * Stop running animation.
  2058. *
  2059. * @function Highcharts.stop
  2060. *
  2061. * @param {Highcharts.SVGElement} el
  2062. * The SVGElement to stop animation on.
  2063. *
  2064. * @param {string} [prop]
  2065. * The property to stop animating. If given, the stop method will stop a
  2066. * single property from animating, while others continue.
  2067. *
  2068. * @return {void}
  2069. *
  2070. * @todo
  2071. * A possible extension to this would be to stop a single property, when
  2072. * we want to continue animating others. Then assign the prop to the timer
  2073. * in the Fx.run method, and check for the prop here. This would be an
  2074. * improvement in all cases where we stop the animation from .attr. Instead of
  2075. * stopping everything, we can just stop the actual attributes we're setting.
  2076. */
  2077. var stop = H.stop = function (el, prop) {
  2078. var i = H.timers.length;
  2079. // Remove timers related to this element (#4519)
  2080. while (i--) {
  2081. if (H.timers[i].elem === el && (!prop || prop === H.timers[i].prop)) {
  2082. H.timers[i].stopped = true; // #4667
  2083. }
  2084. }
  2085. };
  2086. /* eslint-disable valid-jsdoc */
  2087. /**
  2088. * Iterate over object key pairs in an object.
  2089. *
  2090. * @function Highcharts.objectEach<T>
  2091. *
  2092. * @param {*} obj
  2093. * The object to iterate over.
  2094. *
  2095. * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
  2096. * The iterator callback. It passes three arguments:
  2097. * * value - The property value.
  2098. * * key - The property key.
  2099. * * obj - The object that objectEach is being applied to.
  2100. *
  2101. * @param {T} [ctx]
  2102. * The context.
  2103. *
  2104. * @return {void}
  2105. */
  2106. var objectEach = H.objectEach = function objectEach(obj, fn, ctx) {
  2107. /* eslint-enable valid-jsdoc */
  2108. for (var key in obj) {
  2109. if (Object.hasOwnProperty.call(obj, key)) {
  2110. fn.call(ctx || obj[key], obj[key], key, obj);
  2111. }
  2112. }
  2113. };
  2114. /**
  2115. * Iterate over an array.
  2116. *
  2117. * @deprecated
  2118. * @function Highcharts.each
  2119. *
  2120. * @param {Array<*>} arr
  2121. * The array to iterate over.
  2122. *
  2123. * @param {Function} fn
  2124. * The iterator callback. It passes three arguments:
  2125. * - `item`: The array item.
  2126. * - `index`: The item's index in the array.
  2127. * - `arr`: The array that each is being applied to.
  2128. *
  2129. * @param {*} [ctx]
  2130. * The context.
  2131. *
  2132. * @return {void}
  2133. */
  2134. /**
  2135. * Filter an array by a callback.
  2136. *
  2137. * @deprecated
  2138. * @function Highcharts.grep
  2139. *
  2140. * @param {Array<*>} arr
  2141. * The array to filter.
  2142. *
  2143. * @param {Function} callback
  2144. * The callback function. The function receives the item as the first
  2145. * argument. Return `true` if the item is to be preserved.
  2146. *
  2147. * @return {Array<*>}
  2148. * A new, filtered array.
  2149. */
  2150. /**
  2151. * Map an array by a callback.
  2152. *
  2153. * @deprecated
  2154. * @function Highcharts.map
  2155. *
  2156. * @param {Array<*>} arr
  2157. * The array to map.
  2158. *
  2159. * @param {Function} fn
  2160. * The callback function. Return the new value for the new array.
  2161. *
  2162. * @return {Array<*>}
  2163. * A new array item with modified items.
  2164. */
  2165. /**
  2166. * Reduce an array to a single value.
  2167. *
  2168. * @deprecated
  2169. * @function Highcharts.reduce
  2170. *
  2171. * @param {Array<*>} arr
  2172. * The array to reduce.
  2173. *
  2174. * @param {Function} fn
  2175. * The callback function. Return the reduced value. Receives 4
  2176. * arguments: Accumulated/reduced value, current value, current array
  2177. * index, and the array.
  2178. *
  2179. * @param {*} initialValue
  2180. * The initial value of the accumulator.
  2181. *
  2182. * @return {*}
  2183. * The reduced value.
  2184. */
  2185. /**
  2186. * Test whether at least one element in the array passes the test implemented by
  2187. * the provided function.
  2188. *
  2189. * @deprecated
  2190. * @function Highcharts.some
  2191. *
  2192. * @param {Array<*>} arr
  2193. * The array to test
  2194. *
  2195. * @param {Function} fn
  2196. * The function to run on each item. Return truty to pass the test.
  2197. * Receives arguments `currentValue`, `index` and `array`.
  2198. *
  2199. * @param {*} ctx
  2200. * The context.
  2201. *
  2202. * @return {boolean}
  2203. */
  2204. objectEach({
  2205. map: 'map',
  2206. each: 'forEach',
  2207. grep: 'filter',
  2208. reduce: 'reduce',
  2209. some: 'some'
  2210. }, function (val, key) {
  2211. H[key] = function (arr) {
  2212. var _a;
  2213. error(32, false, void 0, (_a = {}, _a["Highcharts." + key] = "use Array." + val, _a));
  2214. return Array.prototype[val].apply(arr, [].slice.call(arguments, 1));
  2215. };
  2216. });
  2217. /* eslint-disable valid-jsdoc */
  2218. /**
  2219. * Add an event listener.
  2220. *
  2221. * @function Highcharts.addEvent<T>
  2222. *
  2223. * @param {Highcharts.Class<T>|T} el
  2224. * The element or object to add a listener to. It can be a
  2225. * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
  2226. *
  2227. * @param {string} type
  2228. * The event type.
  2229. *
  2230. * @param {Highcharts.EventCallbackFunction<T>|Function} fn
  2231. * The function callback to execute when the event is fired.
  2232. *
  2233. * @param {Highcharts.EventOptionsObject} [options]
  2234. * Options for adding the event.
  2235. *
  2236. * @return {Function}
  2237. * A callback function to remove the added event.
  2238. */
  2239. var addEvent = H.addEvent = function (el, type, fn, options) {
  2240. if (options === void 0) { options = {}; }
  2241. /* eslint-enable valid-jsdoc */
  2242. var events, addEventListener = (el.addEventListener || H.addEventListenerPolyfill);
  2243. // If we're setting events directly on the constructor, use a separate
  2244. // collection, `protoEvents` to distinguish it from the item events in
  2245. // `hcEvents`.
  2246. if (typeof el === 'function' && el.prototype) {
  2247. events = el.prototype.protoEvents = el.prototype.protoEvents || {};
  2248. }
  2249. else {
  2250. events = el.hcEvents = el.hcEvents || {};
  2251. }
  2252. // Allow click events added to points, otherwise they will be prevented by
  2253. // the TouchPointer.pinch function after a pinch zoom operation (#7091).
  2254. if (H.Point &&
  2255. el instanceof H.Point &&
  2256. el.series &&
  2257. el.series.chart) {
  2258. el.series.chart.runTrackerClick = true;
  2259. }
  2260. // Handle DOM events
  2261. if (addEventListener) {
  2262. addEventListener.call(el, type, fn, false);
  2263. }
  2264. if (!events[type]) {
  2265. events[type] = [];
  2266. }
  2267. var eventObject = {
  2268. fn: fn,
  2269. order: typeof options.order === 'number' ? options.order : Infinity
  2270. };
  2271. events[type].push(eventObject);
  2272. // Order the calls
  2273. events[type].sort(function (a, b) {
  2274. return a.order - b.order;
  2275. });
  2276. // Return a function that can be called to remove this event.
  2277. return function () {
  2278. removeEvent(el, type, fn);
  2279. };
  2280. };
  2281. /* eslint-disable valid-jsdoc */
  2282. /**
  2283. * Remove an event that was added with {@link Highcharts#addEvent}.
  2284. *
  2285. * @function Highcharts.removeEvent<T>
  2286. *
  2287. * @param {Highcharts.Class<T>|T} el
  2288. * The element to remove events on.
  2289. *
  2290. * @param {string} [type]
  2291. * The type of events to remove. If undefined, all events are removed
  2292. * from the element.
  2293. *
  2294. * @param {Highcharts.EventCallbackFunction<T>} [fn]
  2295. * The specific callback to remove. If undefined, all events that match
  2296. * the element and optionally the type are removed.
  2297. *
  2298. * @return {void}
  2299. */
  2300. var removeEvent = H.removeEvent = function removeEvent(el, type, fn) {
  2301. /* eslint-enable valid-jsdoc */
  2302. var events;
  2303. /**
  2304. * @private
  2305. * @param {string} type - event type
  2306. * @param {Highcharts.EventCallbackFunction<T>} fn - callback
  2307. * @return {void}
  2308. */
  2309. function removeOneEvent(type, fn) {
  2310. var removeEventListener = (el.removeEventListener || H.removeEventListenerPolyfill);
  2311. if (removeEventListener) {
  2312. removeEventListener.call(el, type, fn, false);
  2313. }
  2314. }
  2315. /**
  2316. * @private
  2317. * @param {any} eventCollection - collection
  2318. * @return {void}
  2319. */
  2320. function removeAllEvents(eventCollection) {
  2321. var types, len;
  2322. if (!el.nodeName) {
  2323. return; // break on non-DOM events
  2324. }
  2325. if (type) {
  2326. types = {};
  2327. types[type] = true;
  2328. }
  2329. else {
  2330. types = eventCollection;
  2331. }
  2332. objectEach(types, function (_val, n) {
  2333. if (eventCollection[n]) {
  2334. len = eventCollection[n].length;
  2335. while (len--) {
  2336. removeOneEvent(n, eventCollection[n][len].fn);
  2337. }
  2338. }
  2339. });
  2340. }
  2341. ['protoEvents', 'hcEvents'].forEach(function (coll, i) {
  2342. var eventElem = i ? el : el.prototype;
  2343. var eventCollection = eventElem && eventElem[coll];
  2344. if (eventCollection) {
  2345. if (type) {
  2346. events = (eventCollection[type] || []);
  2347. if (fn) {
  2348. eventCollection[type] = events.filter(function (obj) {
  2349. return fn !== obj.fn;
  2350. });
  2351. removeOneEvent(type, fn);
  2352. }
  2353. else {
  2354. removeAllEvents(eventCollection);
  2355. eventCollection[type] = [];
  2356. }
  2357. }
  2358. else {
  2359. removeAllEvents(eventCollection);
  2360. eventElem[coll] = {};
  2361. }
  2362. }
  2363. });
  2364. };
  2365. /* eslint-disable valid-jsdoc */
  2366. /**
  2367. * Fire an event that was registered with {@link Highcharts#addEvent}.
  2368. *
  2369. * @function Highcharts.fireEvent<T>
  2370. *
  2371. * @param {T} el
  2372. * The object to fire the event on. It can be a {@link HTMLDOMElement},
  2373. * an {@link SVGElement} or any other object.
  2374. *
  2375. * @param {string} type
  2376. * The type of event.
  2377. *
  2378. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  2379. * Custom event arguments that are passed on as an argument to the event
  2380. * handler.
  2381. *
  2382. * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
  2383. * The default function to execute if the other listeners haven't
  2384. * returned false.
  2385. *
  2386. * @return {void}
  2387. */
  2388. var fireEvent = H.fireEvent = function (el, type, eventArguments, defaultFunction) {
  2389. /* eslint-enable valid-jsdoc */
  2390. var e, i;
  2391. eventArguments = eventArguments || {};
  2392. if (doc.createEvent &&
  2393. (el.dispatchEvent || el.fireEvent)) {
  2394. e = doc.createEvent('Events');
  2395. e.initEvent(type, true, true);
  2396. extend(e, eventArguments);
  2397. if (el.dispatchEvent) {
  2398. el.dispatchEvent(e);
  2399. }
  2400. else {
  2401. el.fireEvent(type, e);
  2402. }
  2403. }
  2404. else {
  2405. if (!eventArguments.target) {
  2406. // We're running a custom event
  2407. extend(eventArguments, {
  2408. // Attach a simple preventDefault function to skip
  2409. // default handler if called. The built-in
  2410. // defaultPrevented property is not overwritable (#5112)
  2411. preventDefault: function () {
  2412. eventArguments.defaultPrevented = true;
  2413. },
  2414. // Setting target to native events fails with clicking
  2415. // the zoom-out button in Chrome.
  2416. target: el,
  2417. // If the type is not set, we're running a custom event
  2418. // (#2297). If it is set, we're running a browser event,
  2419. // and setting it will cause en error in IE8 (#2465).
  2420. type: type
  2421. });
  2422. }
  2423. var fireInOrder = function (protoEvents, hcEvents) {
  2424. if (protoEvents === void 0) { protoEvents = []; }
  2425. if (hcEvents === void 0) { hcEvents = []; }
  2426. var iA = 0;
  2427. var iB = 0;
  2428. var length = protoEvents.length + hcEvents.length;
  2429. for (i = 0; i < length; i++) {
  2430. var obj = (!protoEvents[iA] ?
  2431. hcEvents[iB++] :
  2432. !hcEvents[iB] ?
  2433. protoEvents[iA++] :
  2434. protoEvents[iA].order <= hcEvents[iB].order ?
  2435. protoEvents[iA++] :
  2436. hcEvents[iB++]);
  2437. // If the event handler return false, prevent the default
  2438. // handler from executing
  2439. if (obj.fn.call(el, eventArguments) === false) {
  2440. eventArguments.preventDefault();
  2441. }
  2442. }
  2443. };
  2444. fireInOrder(el.protoEvents && el.protoEvents[type], el.hcEvents && el.hcEvents[type]);
  2445. }
  2446. // Run the default if not prevented
  2447. if (defaultFunction && !eventArguments.defaultPrevented) {
  2448. defaultFunction.call(el, eventArguments);
  2449. }
  2450. };
  2451. /**
  2452. * The global animate method, which uses Fx to create individual animators.
  2453. *
  2454. * @function Highcharts.animate
  2455. *
  2456. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} el
  2457. * The element to animate.
  2458. *
  2459. * @param {Highcharts.CSSObject|Highcharts.SVGAttributes} params
  2460. * An object containing key-value pairs of the properties to animate.
  2461. * Supports numeric as pixel-based CSS properties for HTML objects and
  2462. * attributes for SVGElements.
  2463. *
  2464. * @param {Highcharts.AnimationOptionsObject} [opt]
  2465. * Animation options.
  2466. *
  2467. * @return {void}
  2468. */
  2469. var animate = H.animate = function (el, params, opt) {
  2470. var start, unit = '', end, fx, args;
  2471. if (!isObject(opt)) { // Number or undefined/null
  2472. args = arguments;
  2473. opt = {
  2474. duration: args[2],
  2475. easing: args[3],
  2476. complete: args[4]
  2477. };
  2478. }
  2479. if (!isNumber(opt.duration)) {
  2480. opt.duration = 400;
  2481. }
  2482. opt.easing = typeof opt.easing === 'function' ?
  2483. opt.easing :
  2484. (Math[opt.easing] || Math.easeInOutSine);
  2485. opt.curAnim = merge(params);
  2486. objectEach(params, function (val, prop) {
  2487. // Stop current running animation of this property
  2488. stop(el, prop);
  2489. fx = new Fx(el, opt, prop);
  2490. end = null;
  2491. if (prop === 'd' && isArray(params.d)) {
  2492. fx.paths = fx.initPath(el, el.pathArray, params.d);
  2493. fx.toD = params.d;
  2494. start = 0;
  2495. end = 1;
  2496. }
  2497. else if (el.attr) {
  2498. start = el.attr(prop);
  2499. }
  2500. else {
  2501. start = parseFloat(getStyle(el, prop)) || 0;
  2502. if (prop !== 'opacity') {
  2503. unit = 'px';
  2504. }
  2505. }
  2506. if (!end) {
  2507. end = val;
  2508. }
  2509. if (end && end.match && end.match('px')) {
  2510. end = end.replace(/px/g, ''); // #4351
  2511. }
  2512. fx.run(start, end, unit);
  2513. });
  2514. };
  2515. /**
  2516. * Factory to create new series prototypes.
  2517. *
  2518. * @function Highcharts.seriesType
  2519. *
  2520. * @param {string} type
  2521. * The series type name.
  2522. *
  2523. * @param {string} parent
  2524. * The parent series type name. Use `line` to inherit from the basic
  2525. * {@link Series} object.
  2526. *
  2527. * @param {Highcharts.SeriesOptionsType|Highcharts.Dictionary<*>} options
  2528. * The additional default options that are merged with the parent's
  2529. * options.
  2530. *
  2531. * @param {Highcharts.Dictionary<*>} [props]
  2532. * The properties (functions and primitives) to set on the new
  2533. * prototype.
  2534. *
  2535. * @param {Highcharts.Dictionary<*>} [pointProps]
  2536. * Members for a series-specific extension of the {@link Point}
  2537. * prototype if needed.
  2538. *
  2539. * @return {Highcharts.Series}
  2540. * The newly created prototype as extended from {@link Series} or its
  2541. * derivatives.
  2542. */
  2543. // docs: add to API + extending Highcharts
  2544. var seriesType = H.seriesType = function (type, parent, options, props, pointProps) {
  2545. var defaultOptions = getOptions(), seriesTypes = H.seriesTypes;
  2546. // Merge the options
  2547. defaultOptions.plotOptions[type] = merge(defaultOptions.plotOptions[parent], options);
  2548. // Create the class
  2549. seriesTypes[type] = extendClass(seriesTypes[parent] || function () { }, props);
  2550. seriesTypes[type].prototype.type = type;
  2551. // Create the point class if needed
  2552. if (pointProps) {
  2553. seriesTypes[type].prototype.pointClass =
  2554. extendClass(H.Point, pointProps);
  2555. }
  2556. return seriesTypes[type];
  2557. };
  2558. var serialMode;
  2559. /**
  2560. * Get a unique key for using in internal element id's and pointers. The key is
  2561. * composed of a random hash specific to this Highcharts instance, and a
  2562. * counter.
  2563. *
  2564. * @example
  2565. * var id = uniqueKey(); // => 'highcharts-x45f6hp-0'
  2566. *
  2567. * @function Highcharts.uniqueKey
  2568. *
  2569. * @return {string}
  2570. * A unique key.
  2571. */
  2572. var uniqueKey = H.uniqueKey = (function () {
  2573. var hash = Math.random().toString(36).substring(2, 9) + '-';
  2574. var id = 0;
  2575. return function () {
  2576. return 'highcharts-' + (serialMode ? '' : hash) + id++;
  2577. };
  2578. }());
  2579. /**
  2580. * Activates a serial mode for element IDs provided by
  2581. * {@link Highcharts.uniqueKey}. This mode can be used in automated tests, where
  2582. * a simple comparison of two rendered SVG graphics is needed.
  2583. *
  2584. * **Note:** This is only for testing purposes and will break functionality in
  2585. * webpages with multiple charts.
  2586. *
  2587. * @example
  2588. * if (
  2589. * process &&
  2590. * process.env.NODE_ENV === 'development'
  2591. * ) {
  2592. * Highcharts.useSerialIds(true);
  2593. * }
  2594. *
  2595. * @function Highcharts.useSerialIds
  2596. *
  2597. * @param {boolean} [mode]
  2598. * Changes the state of serial mode.
  2599. *
  2600. * @return {boolean|undefined}
  2601. * State of the serial mode.
  2602. */
  2603. var useSerialIds = H.useSerialIds = function (mode) {
  2604. return (serialMode = pick(mode, serialMode));
  2605. };
  2606. var isFunction = H.isFunction = function (obj) {
  2607. return typeof obj === 'function';
  2608. };
  2609. /**
  2610. * Get the updated default options. Until 3.0.7, merely exposing defaultOptions
  2611. * for outside modules wasn't enough because the setOptions method created a new
  2612. * object.
  2613. *
  2614. * @function Highcharts.getOptions
  2615. *
  2616. * @return {Highcharts.Options}
  2617. */
  2618. var getOptions = H.getOptions = function () {
  2619. return H.defaultOptions;
  2620. };
  2621. /**
  2622. * Merge the default options with custom options and return the new options
  2623. * structure. Commonly used for defining reusable templates.
  2624. *
  2625. * @sample highcharts/global/useutc-false Setting a global option
  2626. * @sample highcharts/members/setoptions Applying a global theme
  2627. *
  2628. * @function Highcharts.setOptions
  2629. *
  2630. * @param {Highcharts.Options} options
  2631. * The new custom chart options.
  2632. *
  2633. * @return {Highcharts.Options}
  2634. * Updated options.
  2635. */
  2636. var setOptions = H.setOptions = function (options) {
  2637. // Copy in the default options
  2638. H.defaultOptions = merge(true, H.defaultOptions, options);
  2639. // Update the time object
  2640. if (options.time || options.global) {
  2641. H.time.update(merge(H.defaultOptions.global, H.defaultOptions.time, options.global, options.time));
  2642. }
  2643. return H.defaultOptions;
  2644. };
  2645. // Register Highcharts as a plugin in jQuery
  2646. if (win.jQuery) {
  2647. /**
  2648. * Highcharts-extended JQuery.
  2649. *
  2650. * @external JQuery
  2651. */
  2652. /**
  2653. * Helper function to return the chart of the current JQuery selector
  2654. * element.
  2655. *
  2656. * @function external:JQuery#highcharts
  2657. *
  2658. * @return {Highcharts.Chart}
  2659. * The chart that is linked to the JQuery selector element.
  2660. */ /**
  2661. * Factory function to create a chart in the current JQuery selector
  2662. * element.
  2663. *
  2664. * @function external:JQuery#highcharts
  2665. *
  2666. * @param {'Chart'|'Map'|'StockChart'|string} [className]
  2667. * Name of the factory class in the Highcharts namespace.
  2668. *
  2669. * @param {Highcharts.Options} [options]
  2670. * The chart options structure.
  2671. *
  2672. * @param {Highcharts.ChartCallbackFunction} [callback]
  2673. * Function to run when the chart has loaded and and all external
  2674. * images are loaded. Defining a
  2675. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  2676. * handler is equivalent.
  2677. *
  2678. * @return {JQuery}
  2679. * The current JQuery selector.
  2680. */
  2681. win.jQuery.fn.highcharts = function () {
  2682. var args = [].slice.call(arguments);
  2683. if (this[0]) { // this[0] is the renderTo div
  2684. // Create the chart
  2685. if (args[0]) {
  2686. new H[ // eslint-disable-line computed-property-spacing, no-new
  2687. // Constructor defaults to Chart
  2688. isString(args[0]) ? args.shift() : 'Chart'](this[0], args[0], args[1]);
  2689. return this;
  2690. }
  2691. // When called without parameters or with the return argument,
  2692. // return an existing chart
  2693. return charts[attr(this[0], 'data-highcharts-chart')];
  2694. }
  2695. };
  2696. }
  2697. // TODO use named exports when supported.
  2698. var utilitiesModule = {
  2699. Fx: H.Fx,
  2700. addEvent: addEvent,
  2701. animate: animate,
  2702. animObject: animObject,
  2703. arrayMax: arrayMax,
  2704. arrayMin: arrayMin,
  2705. attr: attr,
  2706. clamp: clamp,
  2707. clearTimeout: internalClearTimeout,
  2708. correctFloat: correctFloat,
  2709. createElement: createElement,
  2710. css: css,
  2711. defined: defined,
  2712. destroyObjectProperties: destroyObjectProperties,
  2713. discardElement: discardElement,
  2714. erase: erase,
  2715. error: error,
  2716. extend: extend,
  2717. extendClass: extendClass,
  2718. find: find,
  2719. fireEvent: fireEvent,
  2720. format: format,
  2721. getMagnitude: getMagnitude,
  2722. getNestedProperty: getNestedProperty,
  2723. getOptions: getOptions,
  2724. getStyle: getStyle,
  2725. inArray: inArray,
  2726. isArray: isArray,
  2727. isClass: isClass,
  2728. isDOMElement: isDOMElement,
  2729. isFunction: isFunction,
  2730. isNumber: isNumber,
  2731. isObject: isObject,
  2732. isString: isString,
  2733. merge: merge,
  2734. normalizeTickInterval: normalizeTickInterval,
  2735. numberFormat: numberFormat,
  2736. objectEach: objectEach,
  2737. offset: offset,
  2738. pad: pad,
  2739. pick: pick,
  2740. pInt: pInt,
  2741. relativeLength: relativeLength,
  2742. removeEvent: removeEvent,
  2743. seriesType: seriesType,
  2744. setAnimation: setAnimation,
  2745. setOptions: setOptions,
  2746. splat: splat,
  2747. stableSort: stableSort,
  2748. stop: stop,
  2749. syncTimeout: syncTimeout,
  2750. timeUnits: timeUnits,
  2751. uniqueKey: uniqueKey,
  2752. useSerialIds: useSerialIds,
  2753. wrap: wrap
  2754. };
  2755. return utilitiesModule;
  2756. });
  2757. _registerModule(_modules, 'parts/Color.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  2758. /* *
  2759. *
  2760. * (c) 2010-2020 Torstein Honsi
  2761. *
  2762. * License: www.highcharts.com/license
  2763. *
  2764. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2765. *
  2766. * */
  2767. /**
  2768. * A valid color to be parsed and handled by Highcharts. Highcharts internally
  2769. * supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
  2770. * rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
  2771. * browsers and displayed correctly, but Highcharts is not able to process them
  2772. * and apply concepts like opacity and brightening.
  2773. *
  2774. * @typedef {string} Highcharts.ColorString
  2775. */
  2776. /**
  2777. * A valid color type than can be parsed and handled by Highcharts. It can be a
  2778. * color string, a gradient object, or a pattern object.
  2779. *
  2780. * @typedef {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} Highcharts.ColorType
  2781. */
  2782. /**
  2783. * Gradient options instead of a solid color.
  2784. *
  2785. * @example
  2786. * // Linear gradient used as a color option
  2787. * color: {
  2788. * linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
  2789. * stops: [
  2790. * [0, '#003399'], // start
  2791. * [0.5, '#ffffff'], // middle
  2792. * [1, '#3366AA'] // end
  2793. * ]
  2794. * }
  2795. *
  2796. * @interface Highcharts.GradientColorObject
  2797. */ /**
  2798. * Holds an object that defines the start position and the end position relative
  2799. * to the shape.
  2800. * @name Highcharts.GradientColorObject#linearGradient
  2801. * @type {Highcharts.LinearGradientColorObject|undefined}
  2802. */ /**
  2803. * Holds an object that defines the center position and the radius.
  2804. * @name Highcharts.GradientColorObject#radialGradient
  2805. * @type {Highcharts.RadialGradientColorObject|undefined}
  2806. */ /**
  2807. * The first item in each tuple is the position in the gradient, where 0 is the
  2808. * start of the gradient and 1 is the end of the gradient. Multiple stops can be
  2809. * applied. The second item is the color for each stop. This color can also be
  2810. * given in the rgba format.
  2811. * @name Highcharts.GradientColorObject#stops
  2812. * @type {Array<Highcharts.GradientColorStopObject>}
  2813. */
  2814. /**
  2815. * Color stop tuple.
  2816. *
  2817. * @see Highcharts.GradientColorObject
  2818. *
  2819. * @interface Highcharts.GradientColorStopObject
  2820. */ /**
  2821. * @name Highcharts.GradientColorStopObject#0
  2822. * @type {number}
  2823. */ /**
  2824. * @name Highcharts.GradientColorStopObject#1
  2825. * @type {Highcharts.ColorString}
  2826. */ /**
  2827. * @name Highcharts.GradoentColorStopObject#color
  2828. * @type {Highcharts.Color|undefined}
  2829. */
  2830. /**
  2831. * Defines the start position and the end position for a gradient relative
  2832. * to the shape. Start position (x1, y1) and end position (x2, y2) are relative
  2833. * to the shape, where 0 means top/left and 1 is bottom/right.
  2834. *
  2835. * @interface Highcharts.LinearGradientColorObject
  2836. */ /**
  2837. * Start horizontal position of the gradient. Float ranges 0-1.
  2838. * @name Highcharts.LinearGradientColorObject#x1
  2839. * @type {number}
  2840. */ /**
  2841. * End horizontal position of the gradient. Float ranges 0-1.
  2842. * @name Highcharts.LinearGradientColorObject#x2
  2843. * @type {number}
  2844. */ /**
  2845. * Start vertical position of the gradient. Float ranges 0-1.
  2846. * @name Highcharts.LinearGradientColorObject#y1
  2847. * @type {number}
  2848. */ /**
  2849. * End vertical position of the gradient. Float ranges 0-1.
  2850. * @name Highcharts.LinearGradientColorObject#y2
  2851. * @type {number}
  2852. */
  2853. /**
  2854. * Defines the center position and the radius for a gradient.
  2855. *
  2856. * @interface Highcharts.RadialGradientColorObject
  2857. */ /**
  2858. * Center horizontal position relative to the shape. Float ranges 0-1.
  2859. * @name Highcharts.RadialGradientColorObject#cx
  2860. * @type {number}
  2861. */ /**
  2862. * Center vertical position relative to the shape. Float ranges 0-1.
  2863. * @name Highcharts.RadialGradientColorObject#cy
  2864. * @type {number}
  2865. */ /**
  2866. * Radius relative to the shape. Float ranges 0-1.
  2867. * @name Highcharts.RadialGradientColorObject#r
  2868. * @type {number}
  2869. */
  2870. var isNumber = U.isNumber, merge = U.merge, pInt = U.pInt;
  2871. /* eslint-disable no-invalid-this, valid-jsdoc */
  2872. /**
  2873. * Handle color operations. Some object methods are chainable.
  2874. *
  2875. * @class
  2876. * @name Highcharts.Color
  2877. *
  2878. * @param {Highcharts.ColorType} input
  2879. * The input color in either rbga or hex format
  2880. */
  2881. var Color = /** @class */ (function () {
  2882. /* *
  2883. *
  2884. * Constructors
  2885. *
  2886. * */
  2887. function Color(input) {
  2888. // Collection of parsers. This can be extended from the outside by pushing
  2889. // parsers to Highcharts.Color.prototype.parsers.
  2890. this.parsers = [{
  2891. // RGBA color
  2892. // eslint-disable-next-line max-len
  2893. 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*\)/,
  2894. parse: function (result) {
  2895. return [
  2896. pInt(result[1]),
  2897. pInt(result[2]),
  2898. pInt(result[3]),
  2899. parseFloat(result[4], 10)
  2900. ];
  2901. }
  2902. }, {
  2903. // RGB color
  2904. regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
  2905. parse: function (result) {
  2906. return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
  2907. }
  2908. }];
  2909. this.rgba = [];
  2910. // Backwards compatibility, allow instanciation without new (#13053)
  2911. if (!(this instanceof Color)) {
  2912. return new Color(input);
  2913. }
  2914. this.init(input);
  2915. }
  2916. /* *
  2917. *
  2918. * Static Functions
  2919. *
  2920. * */
  2921. /**
  2922. * Creates a color instance out of a color string or object.
  2923. *
  2924. * @function Highcharts.Color.parse
  2925. *
  2926. * @param {Highcharts.ColorType} input
  2927. * The input color in either rbga or hex format.
  2928. *
  2929. * @return {Highcharts.Color}
  2930. * Color instance.
  2931. */
  2932. Color.parse = function (input) {
  2933. return new Color(input);
  2934. };
  2935. /* *
  2936. *
  2937. * Functions
  2938. *
  2939. * */
  2940. /**
  2941. * Parse the input color to rgba array
  2942. *
  2943. * @private
  2944. * @function Highcharts.Color#init
  2945. *
  2946. * @param {Highcharts.ColorType} input
  2947. * The input color in either rbga or hex format
  2948. *
  2949. * @return {void}
  2950. */
  2951. Color.prototype.init = function (input) {
  2952. var result, rgba, i, parser, len;
  2953. this.input = input = Color.names[input && input.toLowerCase ?
  2954. input.toLowerCase() :
  2955. ''] || input;
  2956. // Gradients
  2957. if (input && input.stops) {
  2958. this.stops = input.stops.map(function (stop) {
  2959. return new Color(stop[1]);
  2960. });
  2961. // Solid colors
  2962. }
  2963. else {
  2964. // Bitmasking as input[0] is not working for legacy IE.
  2965. if (input &&
  2966. input.charAt &&
  2967. input.charAt() === '#') {
  2968. len = input.length;
  2969. input = parseInt(input.substr(1), 16);
  2970. // Handle long-form, e.g. #AABBCC
  2971. if (len === 7) {
  2972. rgba = [
  2973. (input & 0xFF0000) >> 16,
  2974. (input & 0xFF00) >> 8,
  2975. (input & 0xFF),
  2976. 1
  2977. ];
  2978. // Handle short-form, e.g. #ABC
  2979. // In short form, the value is assumed to be the same
  2980. // for both nibbles for each component. e.g. #ABC = #AABBCC
  2981. }
  2982. else if (len === 4) {
  2983. rgba = [
  2984. (((input & 0xF00) >> 4) |
  2985. (input & 0xF00) >> 8),
  2986. (((input & 0xF0) >> 4) |
  2987. (input & 0xF0)),
  2988. ((input & 0xF) << 4) | (input & 0xF),
  2989. 1
  2990. ];
  2991. }
  2992. }
  2993. // Otherwise, check regex parsers
  2994. if (!rgba) {
  2995. i = this.parsers.length;
  2996. while (i-- && !rgba) {
  2997. parser = this.parsers[i];
  2998. result = parser.regex.exec(input);
  2999. if (result) {
  3000. rgba = parser.parse(result);
  3001. }
  3002. }
  3003. }
  3004. }
  3005. this.rgba = rgba || [];
  3006. };
  3007. /**
  3008. * Return the color or gradient stops in the specified format
  3009. *
  3010. * @function Highcharts.Color#get
  3011. *
  3012. * @param {string} [format]
  3013. * Possible values are 'a', 'rgb', 'rgba' (default).
  3014. *
  3015. * @return {Highcharts.ColorType}
  3016. * This color as a string or gradient stops.
  3017. */
  3018. Color.prototype.get = function (format) {
  3019. var input = this.input, rgba = this.rgba, ret;
  3020. if (typeof this.stops !== 'undefined') {
  3021. ret = merge(input);
  3022. ret.stops = [].concat(ret.stops);
  3023. this.stops.forEach(function (stop, i) {
  3024. ret.stops[i] = [
  3025. ret.stops[i][0],
  3026. stop.get(format)
  3027. ];
  3028. });
  3029. // it's NaN if gradient colors on a column chart
  3030. }
  3031. else if (rgba && isNumber(rgba[0])) {
  3032. if (format === 'rgb' || (!format && rgba[3] === 1)) {
  3033. ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
  3034. }
  3035. else if (format === 'a') {
  3036. ret = rgba[3];
  3037. }
  3038. else {
  3039. ret = 'rgba(' + rgba.join(',') + ')';
  3040. }
  3041. }
  3042. else {
  3043. ret = input;
  3044. }
  3045. return ret;
  3046. };
  3047. /**
  3048. * Brighten the color instance.
  3049. *
  3050. * @function Highcharts.Color#brighten
  3051. *
  3052. * @param {number} alpha
  3053. * The alpha value.
  3054. *
  3055. * @return {Highcharts.Color}
  3056. * This color with modifications.
  3057. */
  3058. Color.prototype.brighten = function (alpha) {
  3059. var i, rgba = this.rgba;
  3060. if (this.stops) {
  3061. this.stops.forEach(function (stop) {
  3062. stop.brighten(alpha);
  3063. });
  3064. }
  3065. else if (isNumber(alpha) && alpha !== 0) {
  3066. for (i = 0; i < 3; i++) {
  3067. rgba[i] += pInt(alpha * 255);
  3068. if (rgba[i] < 0) {
  3069. rgba[i] = 0;
  3070. }
  3071. if (rgba[i] > 255) {
  3072. rgba[i] = 255;
  3073. }
  3074. }
  3075. }
  3076. return this;
  3077. };
  3078. /**
  3079. * Set the color's opacity to a given alpha value.
  3080. *
  3081. * @function Highcharts.Color#setOpacity
  3082. *
  3083. * @param {number} alpha
  3084. * Opacity between 0 and 1.
  3085. *
  3086. * @return {Highcharts.Color}
  3087. * Color with modifications.
  3088. */
  3089. Color.prototype.setOpacity = function (alpha) {
  3090. this.rgba[3] = alpha;
  3091. return this;
  3092. };
  3093. /**
  3094. * Return an intermediate color between two colors.
  3095. *
  3096. * @function Highcharts.Color#tweenTo
  3097. *
  3098. * @param {Highcharts.Color} to
  3099. * The color object to tween to.
  3100. *
  3101. * @param {number} pos
  3102. * The intermediate position, where 0 is the from color (current
  3103. * color item), and 1 is the `to` color.
  3104. *
  3105. * @return {Highcharts.ColorString}
  3106. * The intermediate color in rgba notation.
  3107. */
  3108. Color.prototype.tweenTo = function (to, pos) {
  3109. // Check for has alpha, because rgba colors perform worse due to lack of
  3110. // support in WebKit.
  3111. var fromRgba = this.rgba, toRgba = to.rgba, hasAlpha, ret;
  3112. // Unsupported color, return to-color (#3920, #7034)
  3113. if (!toRgba.length || !fromRgba || !fromRgba.length) {
  3114. ret = to.input || 'none';
  3115. // Interpolate
  3116. }
  3117. else {
  3118. hasAlpha = (toRgba[3] !== 1 || fromRgba[3] !== 1);
  3119. ret = (hasAlpha ? 'rgba(' : 'rgb(') +
  3120. Math.round(toRgba[0] + (fromRgba[0] - toRgba[0]) * (1 - pos)) +
  3121. ',' +
  3122. Math.round(toRgba[1] + (fromRgba[1] - toRgba[1]) * (1 - pos)) +
  3123. ',' +
  3124. Math.round(toRgba[2] + (fromRgba[2] - toRgba[2]) * (1 - pos)) +
  3125. (hasAlpha ?
  3126. (',' +
  3127. (toRgba[3] + (fromRgba[3] - toRgba[3]) * (1 - pos))) :
  3128. '') +
  3129. ')';
  3130. }
  3131. return ret;
  3132. };
  3133. /* *
  3134. *
  3135. * Static Properties
  3136. *
  3137. * */
  3138. // Collection of named colors. Can be extended from the outside by adding
  3139. // colors to Highcharts.Color.names.
  3140. Color.names = {
  3141. white: '#ffffff',
  3142. black: '#000000'
  3143. };
  3144. return Color;
  3145. }());
  3146. H.Color = Color;
  3147. /**
  3148. * Creates a color instance out of a color string.
  3149. *
  3150. * @function Highcharts.color
  3151. *
  3152. * @param {Highcharts.ColorType} input
  3153. * The input color in either rbga or hex format
  3154. *
  3155. * @return {Highcharts.Color}
  3156. * Color instance
  3157. */
  3158. H.color = Color.parse;
  3159. return H.Color;
  3160. });
  3161. _registerModule(_modules, 'parts/SVGElement.js', [_modules['parts/Color.js'], _modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (Color, H, U) {
  3162. /* *
  3163. *
  3164. * (c) 2010-2020 Torstein Honsi
  3165. *
  3166. * License: www.highcharts.com/license
  3167. *
  3168. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3169. *
  3170. * */
  3171. var deg2rad = H.deg2rad, doc = H.doc, hasTouch = H.hasTouch, isFirefox = H.isFirefox, noop = H.noop, svg = H.svg, SVG_NS = H.SVG_NS, win = H.win;
  3172. var animate = U.animate, animObject = U.animObject, attr = U.attr, createElement = U.createElement, css = U.css, defined = U.defined, erase = U.erase, extend = U.extend, fireEvent = U.fireEvent, inArray = U.inArray, isArray = U.isArray, isFunction = U.isFunction, isNumber = U.isNumber, isString = U.isString, merge = U.merge, objectEach = U.objectEach, pick = U.pick, pInt = U.pInt, stop = U.stop, uniqueKey = U.uniqueKey;
  3173. /**
  3174. * The horizontal alignment of an element.
  3175. *
  3176. * @typedef {"center"|"left"|"right"} Highcharts.AlignValue
  3177. */
  3178. /**
  3179. * Options to align the element relative to the chart or another box.
  3180. *
  3181. * @interface Highcharts.AlignObject
  3182. */ /**
  3183. * Horizontal alignment. Can be one of `left`, `center` and `right`.
  3184. *
  3185. * @name Highcharts.AlignObject#align
  3186. * @type {Highcharts.AlignValue|undefined}
  3187. *
  3188. * @default left
  3189. */ /**
  3190. * Vertical alignment. Can be one of `top`, `middle` and `bottom`.
  3191. *
  3192. * @name Highcharts.AlignObject#verticalAlign
  3193. * @type {Highcharts.VerticalAlignValue|undefined}
  3194. *
  3195. * @default top
  3196. */ /**
  3197. * Horizontal pixel offset from alignment.
  3198. *
  3199. * @name Highcharts.AlignObject#x
  3200. * @type {number|undefined}
  3201. *
  3202. * @default 0
  3203. */ /**
  3204. * Vertical pixel offset from alignment.
  3205. *
  3206. * @name Highcharts.AlignObject#y
  3207. * @type {number|undefined}
  3208. *
  3209. * @default 0
  3210. */ /**
  3211. * Use the `transform` attribute with translateX and translateY custom
  3212. * attributes to align this elements rather than `x` and `y` attributes.
  3213. *
  3214. * @name Highcharts.AlignObject#alignByTranslate
  3215. * @type {boolean|undefined}
  3216. *
  3217. * @default false
  3218. */
  3219. /**
  3220. * Bounding box of an element.
  3221. *
  3222. * @interface Highcharts.BBoxObject
  3223. * @extends Highcharts.PositionObject
  3224. */ /**
  3225. * Height of the bounding box.
  3226. *
  3227. * @name Highcharts.BBoxObject#height
  3228. * @type {number}
  3229. */ /**
  3230. * Width of the bounding box.
  3231. *
  3232. * @name Highcharts.BBoxObject#width
  3233. * @type {number}
  3234. */ /**
  3235. * Horizontal position of the bounding box.
  3236. *
  3237. * @name Highcharts.BBoxObject#x
  3238. * @type {number}
  3239. */ /**
  3240. * Vertical position of the bounding box.
  3241. *
  3242. * @name Highcharts.BBoxObject#y
  3243. * @type {number}
  3244. */
  3245. /**
  3246. * An object of key-value pairs for SVG attributes. Attributes in Highcharts
  3247. * elements for the most parts correspond to SVG, but some are specific to
  3248. * Highcharts, like `zIndex`, `rotation`, `rotationOriginX`,
  3249. * `rotationOriginY`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
  3250. * attributes containing a hyphen are _not_ camel-cased, they should be
  3251. * quoted to preserve the hyphen.
  3252. *
  3253. * @example
  3254. * {
  3255. * 'stroke': '#ff0000', // basic
  3256. * 'stroke-width': 2, // hyphenated
  3257. * 'rotation': 45 // custom
  3258. * 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
  3259. * }
  3260. *
  3261. * @interface Highcharts.SVGAttributes
  3262. */ /**
  3263. * @name Highcharts.SVGAttributes#[key:string]
  3264. * @type {*}
  3265. */ /**
  3266. * @name Highcharts.SVGAttributes#d
  3267. * @type {string|Highcharts.SVGPathArray|undefined}
  3268. */ /**
  3269. * @name Highcharts.SVGAttributes#fill
  3270. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  3271. */ /**
  3272. * @name Highcharts.SVGAttributes#inverted
  3273. * @type {boolean|undefined}
  3274. */ /**
  3275. * @name Highcharts.SVGAttributes#matrix
  3276. * @type {Array<number>|undefined}
  3277. */ /**
  3278. * @name Highcharts.SVGAttributes#rotation
  3279. * @type {number|undefined}
  3280. */ /**
  3281. * @name Highcharts.SVGAttributes#rotationOriginX
  3282. * @type {number|undefined}
  3283. */ /**
  3284. * @name Highcharts.SVGAttributes#rotationOriginY
  3285. * @type {number|undefined}
  3286. */ /**
  3287. * @name Highcharts.SVGAttributes#scaleX
  3288. * @type {number|undefined}
  3289. */ /**
  3290. * @name Highcharts.SVGAttributes#scaleY
  3291. * @type {number|undefined}
  3292. */ /**
  3293. * @name Highcharts.SVGAttributes#stroke
  3294. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  3295. */ /**
  3296. * @name Highcharts.SVGAttributes#style
  3297. * @type {string|Highcharts.CSSObject|undefined}
  3298. */ /**
  3299. * @name Highcharts.SVGAttributes#translateX
  3300. * @type {number|undefined}
  3301. */ /**
  3302. * @name Highcharts.SVGAttributes#translateY
  3303. * @type {number|undefined}
  3304. */ /**
  3305. * @name Highcharts.SVGAttributes#zIndex
  3306. * @type {number|undefined}
  3307. */
  3308. /**
  3309. * An SVG DOM element. The type is a reference to the regular SVGElement in the
  3310. * global scope.
  3311. *
  3312. * @typedef {globals.GlobalSVGElement} Highcharts.SVGDOMElement
  3313. *
  3314. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  3315. */
  3316. /**
  3317. * The vertical alignment of an element.
  3318. *
  3319. * @typedef {"bottom"|"middle"|"top"} Highcharts.VerticalAlignValue
  3320. */
  3321. ''; // detach doclets above
  3322. /* eslint-disable no-invalid-this, valid-jsdoc */
  3323. /**
  3324. * The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
  3325. * rendering layer of Highcharts. Combined with the
  3326. * {@link Highcharts.SVGRenderer}
  3327. * object, these prototypes allow freeform annotation in the charts or even in
  3328. * HTML pages without instanciating a chart. The SVGElement can also wrap HTML
  3329. * labels, when `text` or `label` elements are created with the `useHTML`
  3330. * parameter.
  3331. *
  3332. * The SVGElement instances are created through factory functions on the
  3333. * {@link Highcharts.SVGRenderer}
  3334. * object, like
  3335. * {@link Highcharts.SVGRenderer#rect|rect},
  3336. * {@link Highcharts.SVGRenderer#path|path},
  3337. * {@link Highcharts.SVGRenderer#text|text},
  3338. * {@link Highcharts.SVGRenderer#label|label},
  3339. * {@link Highcharts.SVGRenderer#g|g}
  3340. * and more.
  3341. *
  3342. * @class
  3343. * @name Highcharts.SVGElement
  3344. */
  3345. var SVGElement = /** @class */ (function () {
  3346. function SVGElement() {
  3347. /* *
  3348. *
  3349. * Properties
  3350. *
  3351. * */
  3352. this.element = void 0;
  3353. this.height = void 0;
  3354. this.opacity = 1; // Default base for animation
  3355. this.renderer = void 0;
  3356. this.SVG_NS = SVG_NS;
  3357. // Custom attributes used for symbols, these should be filtered out when
  3358. // setting SVGElement attributes (#9375).
  3359. this.symbolCustomAttribs = [
  3360. 'x',
  3361. 'y',
  3362. 'width',
  3363. 'height',
  3364. 'r',
  3365. 'start',
  3366. 'end',
  3367. 'innerR',
  3368. 'anchorX',
  3369. 'anchorY',
  3370. 'rounded'
  3371. ];
  3372. this.width = void 0;
  3373. }
  3374. /* *
  3375. *
  3376. * Functions
  3377. *
  3378. * */
  3379. /**
  3380. * Get the current value of an attribute or pseudo attribute,
  3381. * used mainly for animation. Called internally from
  3382. * the {@link Highcharts.SVGRenderer#attr} function.
  3383. *
  3384. * @private
  3385. * @function Highcharts.SVGElement#_defaultGetter
  3386. *
  3387. * @param {string} key
  3388. * Property key.
  3389. *
  3390. * @return {number|string}
  3391. * Property value.
  3392. */
  3393. SVGElement.prototype._defaultGetter = function (key) {
  3394. var ret = pick(this[key + 'Value'], // align getter
  3395. this[key], this.element ? this.element.getAttribute(key) : null, 0);
  3396. if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
  3397. ret = parseFloat(ret);
  3398. }
  3399. return ret;
  3400. };
  3401. /**
  3402. * @private
  3403. * @function Highcharts.SVGElement#_defaultSetter
  3404. *
  3405. * @param {string} value
  3406. *
  3407. * @param {string} key
  3408. *
  3409. * @param {Highcharts.SVGDOMElement} element
  3410. *
  3411. * @return {void}
  3412. */
  3413. SVGElement.prototype._defaultSetter = function (value, key, element) {
  3414. element.setAttribute(key, value);
  3415. };
  3416. /**
  3417. * Add the element to the DOM. All elements must be added this way.
  3418. *
  3419. * @sample highcharts/members/renderer-g
  3420. * Elements added to a group
  3421. *
  3422. * @function Highcharts.SVGElement#add
  3423. *
  3424. * @param {Highcharts.SVGElement} [parent]
  3425. * The parent item to add it to. If undefined, the element is added
  3426. * to the {@link Highcharts.SVGRenderer.box}.
  3427. *
  3428. * @return {Highcharts.SVGElement}
  3429. * Returns the SVGElement for chaining.
  3430. */
  3431. SVGElement.prototype.add = function (parent) {
  3432. var renderer = this.renderer, element = this.element, inserted;
  3433. if (parent) {
  3434. this.parentGroup = parent;
  3435. }
  3436. // Mark as inverted
  3437. this.parentInverted = parent && parent.inverted;
  3438. // Build formatted text
  3439. if (typeof this.textStr !== 'undefined' &&
  3440. this.element.nodeName === 'text' // Not for SVGLabel instances
  3441. ) {
  3442. renderer.buildText(this);
  3443. }
  3444. // Mark as added
  3445. this.added = true;
  3446. // If we're adding to renderer root, or other elements in the group
  3447. // have a z index, we need to handle it
  3448. if (!parent || parent.handleZ || this.zIndex) {
  3449. inserted = this.zIndexSetter();
  3450. }
  3451. // If zIndex is not handled, append at the end
  3452. if (!inserted) {
  3453. (parent ?
  3454. parent.element :
  3455. renderer.box).appendChild(element);
  3456. }
  3457. // fire an event for internal hooks
  3458. if (this.onAdd) {
  3459. this.onAdd();
  3460. }
  3461. return this;
  3462. };
  3463. /**
  3464. * Add a class name to an element.
  3465. *
  3466. * @function Highcharts.SVGElement#addClass
  3467. *
  3468. * @param {string} className
  3469. * The new class name to add.
  3470. *
  3471. * @param {boolean} [replace=false]
  3472. * When true, the existing class name(s) will be overwritten with the new
  3473. * one. When false, the new one is added.
  3474. *
  3475. * @return {Highcharts.SVGElement}
  3476. * Return the SVG element for chainability.
  3477. */
  3478. SVGElement.prototype.addClass = function (className, replace) {
  3479. var currentClassName = replace ? '' : (this.attr('class') || '');
  3480. // Trim the string and remove duplicates
  3481. className = (className || '')
  3482. .split(/ /g)
  3483. .reduce(function (newClassName, name) {
  3484. if (currentClassName.indexOf(name) === -1) {
  3485. newClassName.push(name);
  3486. }
  3487. return newClassName;
  3488. }, (currentClassName ?
  3489. [currentClassName] :
  3490. []))
  3491. .join(' ');
  3492. if (className !== currentClassName) {
  3493. this.attr('class', className);
  3494. }
  3495. return this;
  3496. };
  3497. /**
  3498. * This method is executed in the end of `attr()`, after setting all
  3499. * attributes in the hash. In can be used to efficiently consolidate
  3500. * multiple attributes in one SVG property -- e.g., translate, rotate and
  3501. * scale are merged in one "transform" attribute in the SVG node.
  3502. *
  3503. * @private
  3504. * @function Highcharts.SVGElement#afterSetters
  3505. */
  3506. SVGElement.prototype.afterSetters = function () {
  3507. // Update transform. Do this outside the loop to prevent redundant
  3508. // updating for batch setting of attributes.
  3509. if (this.doTransform) {
  3510. this.updateTransform();
  3511. this.doTransform = false;
  3512. }
  3513. };
  3514. /**
  3515. * Align the element relative to the chart or another box.
  3516. *
  3517. * @function Highcharts.SVGElement#align
  3518. *
  3519. * @param {Highcharts.AlignObject} [alignOptions]
  3520. * The alignment options. The function can be called without this
  3521. * parameter in order to re-align an element after the box has been
  3522. * updated.
  3523. *
  3524. * @param {boolean} [alignByTranslate]
  3525. * Align element by translation.
  3526. *
  3527. * @param {string|Highcharts.BBoxObject} [box]
  3528. * The box to align to, needs a width and height. When the box is a
  3529. * string, it refers to an object in the Renderer. For example, when
  3530. * box is `spacingBox`, it refers to `Renderer.spacingBox` which
  3531. * holds `width`, `height`, `x` and `y` properties.
  3532. *
  3533. * @return {Highcharts.SVGElement} Returns the SVGElement for chaining.
  3534. */
  3535. SVGElement.prototype.align = function (alignOptions, alignByTranslate, box) {
  3536. var align, vAlign, x, y, attribs = {}, alignTo, renderer = this.renderer, alignedObjects = renderer.alignedObjects, alignFactor, vAlignFactor;
  3537. // First call on instanciate
  3538. if (alignOptions) {
  3539. this.alignOptions = alignOptions;
  3540. this.alignByTranslate = alignByTranslate;
  3541. if (!box || isString(box)) {
  3542. this.alignTo = alignTo = box || 'renderer';
  3543. // prevent duplicates, like legendGroup after resize
  3544. erase(alignedObjects, this);
  3545. alignedObjects.push(this);
  3546. box = void 0; // reassign it below
  3547. }
  3548. // When called on resize, no arguments are supplied
  3549. }
  3550. else {
  3551. alignOptions = this.alignOptions;
  3552. alignByTranslate = this.alignByTranslate;
  3553. alignTo = this.alignTo;
  3554. }
  3555. box = pick(box, renderer[alignTo], renderer);
  3556. // Assign variables
  3557. align = alignOptions.align;
  3558. vAlign = alignOptions.verticalAlign;
  3559. // default: left align
  3560. x = (box.x || 0) + (alignOptions.x || 0);
  3561. // default: top align
  3562. y = (box.y || 0) + (alignOptions.y || 0);
  3563. // Align
  3564. if (align === 'right') {
  3565. alignFactor = 1;
  3566. }
  3567. else if (align === 'center') {
  3568. alignFactor = 2;
  3569. }
  3570. if (alignFactor) {
  3571. x += (box.width - (alignOptions.width || 0)) /
  3572. alignFactor;
  3573. }
  3574. attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
  3575. // Vertical align
  3576. if (vAlign === 'bottom') {
  3577. vAlignFactor = 1;
  3578. }
  3579. else if (vAlign === 'middle') {
  3580. vAlignFactor = 2;
  3581. }
  3582. if (vAlignFactor) {
  3583. y += (box.height - (alignOptions.height || 0)) /
  3584. vAlignFactor;
  3585. }
  3586. attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
  3587. // Animate only if already placed
  3588. this[this.placed ? 'animate' : 'attr'](attribs);
  3589. this.placed = true;
  3590. this.alignAttr = attribs;
  3591. return this;
  3592. };
  3593. /**
  3594. * @private
  3595. * @function Highcharts.SVGElement#alignSetter
  3596. * @param {"left"|"center"|"right"} value
  3597. */
  3598. SVGElement.prototype.alignSetter = function (value) {
  3599. var convert = {
  3600. left: 'start',
  3601. center: 'middle',
  3602. right: 'end'
  3603. };
  3604. if (convert[value]) {
  3605. this.alignValue = value;
  3606. this.element.setAttribute('text-anchor', convert[value]);
  3607. }
  3608. };
  3609. /**
  3610. * Animate to given attributes or CSS properties.
  3611. *
  3612. * @sample highcharts/members/element-on/
  3613. * Setting some attributes by animation
  3614. *
  3615. * @function Highcharts.SVGElement#animate
  3616. *
  3617. * @param {Highcharts.SVGAttributes} params
  3618. * SVG attributes or CSS to animate.
  3619. *
  3620. * @param {boolean|Highcharts.AnimationOptionsObject} [options]
  3621. * Animation options.
  3622. *
  3623. * @param {Function} [complete]
  3624. * Function to perform at the end of animation.
  3625. *
  3626. * @return {Highcharts.SVGElement}
  3627. * Returns the SVGElement for chaining.
  3628. */
  3629. SVGElement.prototype.animate = function (params, options, complete) {
  3630. var animOptions = animObject(pick(options, this.renderer.globalAnimation, true));
  3631. // When the page is hidden save resources in the background by not
  3632. // running animation at all (#9749).
  3633. if (pick(doc.hidden, doc.msHidden, doc.webkitHidden, false)) {
  3634. animOptions.duration = 0;
  3635. }
  3636. if (animOptions.duration !== 0) {
  3637. // allows using a callback with the global animation without
  3638. // overwriting it
  3639. if (complete) {
  3640. animOptions.complete = complete;
  3641. }
  3642. animate(this, params, animOptions);
  3643. }
  3644. else {
  3645. this.attr(params, void 0, complete);
  3646. // Call the end step synchronously
  3647. objectEach(params, function (val, prop) {
  3648. if (animOptions.step) {
  3649. animOptions.step.call(this, val, { prop: prop, pos: 1 });
  3650. }
  3651. }, this);
  3652. }
  3653. return this;
  3654. };
  3655. /**
  3656. * Apply a text outline through a custom CSS property, by copying the text
  3657. * element and apply stroke to the copy. Used internally. Contrast checks at
  3658. * [example](https://jsfiddle.net/highcharts/43soe9m1/2/).
  3659. *
  3660. * @example
  3661. * // Specific color
  3662. * text.css({
  3663. * textOutline: '1px black'
  3664. * });
  3665. * // Automatic contrast
  3666. * text.css({
  3667. * color: '#000000', // black text
  3668. * textOutline: '1px contrast' // => white outline
  3669. * });
  3670. *
  3671. * @private
  3672. * @function Highcharts.SVGElement#applyTextOutline
  3673. *
  3674. * @param {string} textOutline
  3675. * A custom CSS `text-outline` setting, defined by `width color`.
  3676. */
  3677. SVGElement.prototype.applyTextOutline = function (textOutline) {
  3678. var elem = this.element, tspans, hasContrast = textOutline.indexOf('contrast') !== -1, styles = {}, color, strokeWidth, firstRealChild;
  3679. // When the text shadow is set to contrast, use dark stroke for light
  3680. // text and vice versa.
  3681. if (hasContrast) {
  3682. styles.textOutline = textOutline = textOutline.replace(/contrast/g, this.renderer.getContrast(elem.style.fill));
  3683. }
  3684. // Extract the stroke width and color
  3685. textOutline = textOutline.split(' ');
  3686. color = textOutline[textOutline.length - 1];
  3687. strokeWidth = textOutline[0];
  3688. if (strokeWidth && strokeWidth !== 'none' && H.svg) {
  3689. this.fakeTS = true; // Fake text shadow
  3690. tspans = [].slice.call(elem.getElementsByTagName('tspan'));
  3691. // In order to get the right y position of the clone,
  3692. // copy over the y setter
  3693. this.ySetter = this.xSetter;
  3694. // Since the stroke is applied on center of the actual outline, we
  3695. // need to double it to get the correct stroke-width outside the
  3696. // glyphs.
  3697. strokeWidth = strokeWidth.replace(/(^[\d\.]+)(.*?)$/g, function (match, digit, unit) {
  3698. return (2 * digit) + unit;
  3699. });
  3700. // Remove shadows from previous runs.
  3701. this.removeTextOutline(tspans);
  3702. // Check if the element contains RTL characters.
  3703. // Comparing against Hebrew and Arabic characters,
  3704. // excluding Arabic digits. Source:
  3705. // https://www.unicode.org/Public/UNIDATA/extracted/DerivedBidiClass.txt
  3706. var isRTL_1 = elem.textContent ?
  3707. /^[\u0591-\u065F\u066A-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]/
  3708. .test(elem.textContent) : false;
  3709. // For each of the tspans, create a stroked copy behind it.
  3710. firstRealChild = elem.firstChild;
  3711. tspans.forEach(function (tspan, y) {
  3712. var clone;
  3713. // Let the first line start at the correct X position
  3714. if (y === 0) {
  3715. tspan.setAttribute('x', elem.getAttribute('x'));
  3716. y = elem.getAttribute('y');
  3717. tspan.setAttribute('y', y || 0);
  3718. if (y === null) {
  3719. elem.setAttribute('y', 0);
  3720. }
  3721. }
  3722. // Create the clone and apply outline properties.
  3723. // For RTL elements apply outline properties for orginal element
  3724. // to prevent outline from overlapping the text.
  3725. // For RTL in Firefox keep the orginal order (#10162).
  3726. clone = tspan.cloneNode(true);
  3727. attr((isRTL_1 && !isFirefox) ? tspan : clone, {
  3728. 'class': 'highcharts-text-outline',
  3729. fill: color,
  3730. stroke: color,
  3731. 'stroke-width': strokeWidth,
  3732. 'stroke-linejoin': 'round'
  3733. });
  3734. elem.insertBefore(clone, firstRealChild);
  3735. });
  3736. // Create a whitespace between tspan and clone,
  3737. // to fix the display of Arabic characters in Firefox.
  3738. if (isRTL_1 && isFirefox && tspans[0]) {
  3739. var whitespace = tspans[0].cloneNode(true);
  3740. whitespace.textContent = ' ';
  3741. elem.insertBefore(whitespace, firstRealChild);
  3742. }
  3743. }
  3744. };
  3745. /**
  3746. * @function Highcharts.SVGElement#attr
  3747. * @param {string} key
  3748. * @return {number|string}
  3749. */ /**
  3750. * Apply native and custom attributes to the SVG elements.
  3751. *
  3752. * In order to set the rotation center for rotation, set x and y to 0 and
  3753. * use `translateX` and `translateY` attributes to position the element
  3754. * instead.
  3755. *
  3756. * Attributes frequently used in Highcharts are `fill`, `stroke`,
  3757. * `stroke-width`.
  3758. *
  3759. * @sample highcharts/members/renderer-rect/
  3760. * Setting some attributes
  3761. *
  3762. * @example
  3763. * // Set multiple attributes
  3764. * element.attr({
  3765. * stroke: 'red',
  3766. * fill: 'blue',
  3767. * x: 10,
  3768. * y: 10
  3769. * });
  3770. *
  3771. * // Set a single attribute
  3772. * element.attr('stroke', 'red');
  3773. *
  3774. * // Get an attribute
  3775. * element.attr('stroke'); // => 'red'
  3776. *
  3777. * @function Highcharts.SVGElement#attr
  3778. *
  3779. * @param {string|Highcharts.SVGAttributes} [hash]
  3780. * The native and custom SVG attributes.
  3781. *
  3782. * @param {number|string|Highcharts.SVGPathArray} [val]
  3783. * If the type of the first argument is `string`, the second can be a
  3784. * value, which will serve as a single attribute setter. If the first
  3785. * argument is a string and the second is undefined, the function
  3786. * serves as a getter and the current value of the property is
  3787. * returned.
  3788. *
  3789. * @param {Function} [complete]
  3790. * A callback function to execute after setting the attributes. This
  3791. * makes the function compliant and interchangeable with the
  3792. * {@link SVGElement#animate} function.
  3793. *
  3794. * @param {boolean} [continueAnimation=true]
  3795. * Used internally when `.attr` is called as part of an animation
  3796. * step. Otherwise, calling `.attr` for an attribute will stop
  3797. * animation for that attribute.
  3798. *
  3799. * @return {Highcharts.SVGElement}
  3800. * If used as a setter, it returns the current
  3801. * {@link Highcharts.SVGElement} so the calls can be chained. If
  3802. * used as a getter, the current value of the attribute is returned.
  3803. */
  3804. SVGElement.prototype.attr = function (hash, val, complete, continueAnimation) {
  3805. var key, element = this.element, hasSetSymbolSize, ret = this, skipAttr, setter, symbolCustomAttribs = this.symbolCustomAttribs;
  3806. // single key-value pair
  3807. if (typeof hash === 'string' && typeof val !== 'undefined') {
  3808. key = hash;
  3809. hash = {};
  3810. hash[key] = val;
  3811. }
  3812. // used as a getter: first argument is a string, second is undefined
  3813. if (typeof hash === 'string') {
  3814. ret = (this[hash + 'Getter'] ||
  3815. this._defaultGetter).call(this, hash, element);
  3816. // setter
  3817. }
  3818. else {
  3819. objectEach(hash, function eachAttribute(val, key) {
  3820. skipAttr = false;
  3821. // Unless .attr is from the animator update, stop current
  3822. // running animation of this property
  3823. if (!continueAnimation) {
  3824. stop(this, key);
  3825. }
  3826. // Special handling of symbol attributes
  3827. if (this.symbolName &&
  3828. symbolCustomAttribs.indexOf(key) !== -1) {
  3829. if (!hasSetSymbolSize) {
  3830. this.symbolAttr(hash);
  3831. hasSetSymbolSize = true;
  3832. }
  3833. skipAttr = true;
  3834. }
  3835. if (this.rotation && (key === 'x' || key === 'y')) {
  3836. this.doTransform = true;
  3837. }
  3838. if (!skipAttr) {
  3839. setter = (this[key + 'Setter'] ||
  3840. this._defaultSetter);
  3841. setter.call(this, val, key, element);
  3842. // Let the shadow follow the main element
  3843. if (!this.styledMode &&
  3844. this.shadows &&
  3845. /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
  3846. this.updateShadows(key, val, setter);
  3847. }
  3848. }
  3849. }, this);
  3850. this.afterSetters();
  3851. }
  3852. // In accordance with animate, run a complete callback
  3853. if (complete) {
  3854. complete.call(this);
  3855. }
  3856. return ret;
  3857. };
  3858. /**
  3859. * Apply a clipping rectangle to this element.
  3860. *
  3861. * @function Highcharts.SVGElement#clip
  3862. *
  3863. * @param {Highcharts.ClipRectElement} [clipRect]
  3864. * The clipping rectangle. If skipped, the current clip is removed.
  3865. *
  3866. * @return {Highcharts.SVGElement}
  3867. * Returns the SVG element to allow chaining.
  3868. */
  3869. SVGElement.prototype.clip = function (clipRect) {
  3870. return this.attr('clip-path', clipRect ?
  3871. 'url(' + this.renderer.url + '#' + clipRect.id + ')' :
  3872. 'none');
  3873. };
  3874. /**
  3875. * Calculate the coordinates needed for drawing a rectangle crisply and
  3876. * return the calculated attributes.
  3877. *
  3878. * @function Highcharts.SVGElement#crisp
  3879. *
  3880. * @param {Highcharts.RectangleObject} rect
  3881. * Rectangle to crisp.
  3882. *
  3883. * @param {number} [strokeWidth]
  3884. * The stroke width to consider when computing crisp positioning. It can
  3885. * also be set directly on the rect parameter.
  3886. *
  3887. * @return {Highcharts.RectangleObject}
  3888. * The modified rectangle arguments.
  3889. */
  3890. SVGElement.prototype.crisp = function (rect, strokeWidth) {
  3891. var wrapper = this, normalizer;
  3892. strokeWidth = strokeWidth || rect.strokeWidth || 0;
  3893. // Math.round because strokeWidth can sometimes have roundoff errors
  3894. normalizer = Math.round(strokeWidth) % 2 / 2;
  3895. // normalize for crisp edges
  3896. rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
  3897. rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
  3898. rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
  3899. rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
  3900. if (defined(rect.strokeWidth)) {
  3901. rect.strokeWidth = strokeWidth;
  3902. }
  3903. return rect;
  3904. };
  3905. /**
  3906. * Build and apply an SVG gradient out of a common JavaScript configuration
  3907. * object. This function is called from the attribute setters. An event
  3908. * hook is added for supporting other complex color types.
  3909. *
  3910. * @private
  3911. * @function Highcharts.SVGElement#complexColor
  3912. *
  3913. * @param {Highcharts.GradientColorObject|Highcharts.PatternObject} colorOptions
  3914. * The gradient or pattern options structure.
  3915. *
  3916. * @param {string} prop
  3917. * The property to apply, can either be `fill` or `stroke`.
  3918. *
  3919. * @param {Highcharts.SVGDOMElement} elem
  3920. * SVG element to apply the gradient on.
  3921. */
  3922. SVGElement.prototype.complexColor = function (colorOptions, prop, elem) {
  3923. var renderer = this.renderer, colorObject, gradName, gradAttr, radAttr, gradients, stops, stopColor, stopOpacity, radialReference, id, key = [], value;
  3924. fireEvent(this.renderer, 'complexColor', {
  3925. args: arguments
  3926. }, function () {
  3927. // Apply linear or radial gradients
  3928. if (colorOptions.radialGradient) {
  3929. gradName = 'radialGradient';
  3930. }
  3931. else if (colorOptions.linearGradient) {
  3932. gradName = 'linearGradient';
  3933. }
  3934. if (gradName) {
  3935. gradAttr = colorOptions[gradName];
  3936. gradients = renderer.gradients;
  3937. stops = colorOptions.stops;
  3938. radialReference = elem.radialReference;
  3939. // Keep < 2.2 kompatibility
  3940. if (isArray(gradAttr)) {
  3941. colorOptions[gradName] = gradAttr = {
  3942. x1: gradAttr[0],
  3943. y1: gradAttr[1],
  3944. x2: gradAttr[2],
  3945. y2: gradAttr[3],
  3946. gradientUnits: 'userSpaceOnUse'
  3947. };
  3948. }
  3949. // Correct the radial gradient for the radial reference system
  3950. if (gradName === 'radialGradient' &&
  3951. radialReference &&
  3952. !defined(gradAttr.gradientUnits)) {
  3953. // Save the radial attributes for updating
  3954. radAttr = gradAttr;
  3955. gradAttr = merge(gradAttr, renderer.getRadialAttr(radialReference, radAttr), { gradientUnits: 'userSpaceOnUse' });
  3956. }
  3957. // Build the unique key to detect whether we need to create a
  3958. // new element (#1282)
  3959. objectEach(gradAttr, function (val, n) {
  3960. if (n !== 'id') {
  3961. key.push(n, val);
  3962. }
  3963. });
  3964. objectEach(stops, function (val) {
  3965. key.push(val);
  3966. });
  3967. key = key.join(',');
  3968. // Check if a gradient object with the same config object is
  3969. // created within this renderer
  3970. if (gradients[key]) {
  3971. id = gradients[key].attr('id');
  3972. }
  3973. else {
  3974. // Set the id and create the element
  3975. gradAttr.id = id = uniqueKey();
  3976. var gradientObject_1 = gradients[key] =
  3977. renderer.createElement(gradName)
  3978. .attr(gradAttr)
  3979. .add(renderer.defs);
  3980. gradientObject_1.radAttr = radAttr;
  3981. // The gradient needs to keep a list of stops to be able to
  3982. // destroy them
  3983. gradientObject_1.stops = [];
  3984. stops.forEach(function (stop) {
  3985. var stopObject;
  3986. if (stop[1].indexOf('rgba') === 0) {
  3987. colorObject = Color.parse(stop[1]);
  3988. stopColor = colorObject.get('rgb');
  3989. stopOpacity = colorObject.get('a');
  3990. }
  3991. else {
  3992. stopColor = stop[1];
  3993. stopOpacity = 1;
  3994. }
  3995. stopObject = renderer.createElement('stop').attr({
  3996. offset: stop[0],
  3997. 'stop-color': stopColor,
  3998. 'stop-opacity': stopOpacity
  3999. }).add(gradientObject_1);
  4000. // Add the stop element to the gradient
  4001. gradientObject_1.stops.push(stopObject);
  4002. });
  4003. }
  4004. // Set the reference to the gradient object
  4005. value = 'url(' + renderer.url + '#' + id + ')';
  4006. elem.setAttribute(prop, value);
  4007. elem.gradient = key;
  4008. // Allow the color to be concatenated into tooltips formatters
  4009. // etc. (#2995)
  4010. colorOptions.toString = function () {
  4011. return value;
  4012. };
  4013. }
  4014. });
  4015. };
  4016. /**
  4017. * Set styles for the element. In addition to CSS styles supported by
  4018. * native SVG and HTML elements, there are also some custom made for
  4019. * Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
  4020. * elements.
  4021. *
  4022. * @sample highcharts/members/renderer-text-on-chart/
  4023. * Styled text
  4024. *
  4025. * @function Highcharts.SVGElement#css
  4026. *
  4027. * @param {Highcharts.CSSObject} styles
  4028. * The new CSS styles.
  4029. *
  4030. * @return {Highcharts.SVGElement}
  4031. * Return the SVG element for chaining.
  4032. */
  4033. SVGElement.prototype.css = function (styles) {
  4034. var oldStyles = this.styles, newStyles = {}, elem = this.element, textWidth, serializedCss = '', hyphenate, hasNew = !oldStyles,
  4035. // These CSS properties are interpreted internally by the SVG
  4036. // renderer, but are not supported by SVG and should not be added to
  4037. // the DOM. In styled mode, no CSS should find its way to the DOM
  4038. // whatsoever (#6173, #6474).
  4039. svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
  4040. // convert legacy
  4041. if (styles && styles.color) {
  4042. styles.fill = styles.color;
  4043. }
  4044. // Filter out existing styles to increase performance (#2640)
  4045. if (oldStyles) {
  4046. objectEach(styles, function (style, n) {
  4047. if (oldStyles && oldStyles[n] !== style) {
  4048. newStyles[n] = style;
  4049. hasNew = true;
  4050. }
  4051. });
  4052. }
  4053. if (hasNew) {
  4054. // Merge the new styles with the old ones
  4055. if (oldStyles) {
  4056. styles = extend(oldStyles, newStyles);
  4057. }
  4058. // Get the text width from style
  4059. if (styles) {
  4060. // Previously set, unset it (#8234)
  4061. if (styles.width === null || styles.width === 'auto') {
  4062. delete this.textWidth;
  4063. // Apply new
  4064. }
  4065. else if (elem.nodeName.toLowerCase() === 'text' &&
  4066. styles.width) {
  4067. textWidth = this.textWidth = pInt(styles.width);
  4068. }
  4069. }
  4070. // store object
  4071. this.styles = styles;
  4072. if (textWidth && (!svg && this.renderer.forExport)) {
  4073. delete styles.width;
  4074. }
  4075. // Serialize and set style attribute
  4076. if (elem.namespaceURI === this.SVG_NS) { // #7633
  4077. hyphenate = function (a, b) {
  4078. return '-' + b.toLowerCase();
  4079. };
  4080. objectEach(styles, function (style, n) {
  4081. if (svgPseudoProps.indexOf(n) === -1) {
  4082. serializedCss +=
  4083. n.replace(/([A-Z])/g, hyphenate) + ':' +
  4084. style + ';';
  4085. }
  4086. });
  4087. if (serializedCss) {
  4088. attr(elem, 'style', serializedCss); // #1881
  4089. }
  4090. }
  4091. else {
  4092. css(elem, styles);
  4093. }
  4094. if (this.added) {
  4095. // Rebuild text after added. Cache mechanisms in the buildText
  4096. // will prevent building if there are no significant changes.
  4097. if (this.element.nodeName === 'text') {
  4098. this.renderer.buildText(this);
  4099. }
  4100. // Apply text outline after added
  4101. if (styles && styles.textOutline) {
  4102. this.applyTextOutline(styles.textOutline);
  4103. }
  4104. }
  4105. }
  4106. return this;
  4107. };
  4108. /**
  4109. * @private
  4110. * @function Highcharts.SVGElement#dashstyleSetter
  4111. * @param {string} value
  4112. */
  4113. SVGElement.prototype.dashstyleSetter = function (value) {
  4114. var i, strokeWidth = this['stroke-width'];
  4115. // If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new
  4116. // strokeWidth function, we should be able to use that instead.
  4117. if (strokeWidth === 'inherit') {
  4118. strokeWidth = 1;
  4119. }
  4120. value = value && value.toLowerCase();
  4121. if (value) {
  4122. var v = value
  4123. .replace('shortdashdotdot', '3,1,1,1,1,1,')
  4124. .replace('shortdashdot', '3,1,1,1')
  4125. .replace('shortdot', '1,1,')
  4126. .replace('shortdash', '3,1,')
  4127. .replace('longdash', '8,3,')
  4128. .replace(/dot/g, '1,3,')
  4129. .replace('dash', '4,3,')
  4130. .replace(/,$/, '')
  4131. .split(','); // ending comma
  4132. i = v.length;
  4133. while (i--) {
  4134. v[i] = '' + (pInt(v[i]) * pick(strokeWidth, NaN));
  4135. }
  4136. value = v.join(',').replace(/NaN/g, 'none'); // #3226
  4137. this.element.setAttribute('stroke-dasharray', value);
  4138. }
  4139. };
  4140. /**
  4141. * Destroy the element and element wrapper and clear up the DOM and event
  4142. * hooks.
  4143. *
  4144. * @function Highcharts.SVGElement#destroy
  4145. */
  4146. SVGElement.prototype.destroy = function () {
  4147. var wrapper = this, element = wrapper.element || {}, renderer = wrapper.renderer, parentToClean = (renderer.isSVG &&
  4148. element.nodeName === 'SPAN' &&
  4149. wrapper.parentGroup ||
  4150. void 0), grandParent, ownerSVGElement = element.ownerSVGElement, i;
  4151. // remove events
  4152. element.onclick = element.onmouseout = element.onmouseover =
  4153. element.onmousemove = element.point = null;
  4154. stop(wrapper); // stop running animations
  4155. if (wrapper.clipPath && ownerSVGElement) {
  4156. var clipPath_1 = wrapper.clipPath;
  4157. // Look for existing references to this clipPath and remove them
  4158. // before destroying the element (#6196).
  4159. // The upper case version is for Edge
  4160. [].forEach.call(ownerSVGElement.querySelectorAll('[clip-path],[CLIP-PATH]'), function (el) {
  4161. var clipPathAttr = el.getAttribute('clip-path');
  4162. if (clipPathAttr.indexOf(clipPath_1.element.id) > -1) {
  4163. el.removeAttribute('clip-path');
  4164. }
  4165. });
  4166. wrapper.clipPath = clipPath_1.destroy();
  4167. }
  4168. // Destroy stops in case this is a gradient object @todo old code?
  4169. if (wrapper.stops) {
  4170. for (i = 0; i < wrapper.stops.length; i++) {
  4171. wrapper.stops[i].destroy();
  4172. }
  4173. wrapper.stops.length = 0;
  4174. wrapper.stops = void 0;
  4175. }
  4176. // remove element
  4177. wrapper.safeRemoveChild(element);
  4178. if (!renderer.styledMode) {
  4179. wrapper.destroyShadows();
  4180. }
  4181. // In case of useHTML, clean up empty containers emulating SVG groups
  4182. // (#1960, #2393, #2697).
  4183. while (parentToClean &&
  4184. parentToClean.div &&
  4185. parentToClean.div.childNodes.length === 0) {
  4186. grandParent = parentToClean.parentGroup;
  4187. wrapper.safeRemoveChild(parentToClean.div);
  4188. delete parentToClean.div;
  4189. parentToClean = grandParent;
  4190. }
  4191. // remove from alignObjects
  4192. if (wrapper.alignTo) {
  4193. erase(renderer.alignedObjects, wrapper);
  4194. }
  4195. objectEach(wrapper, function (val, key) {
  4196. // Destroy child elements of a group
  4197. if (wrapper[key] &&
  4198. wrapper[key].parentGroup === wrapper &&
  4199. wrapper[key].destroy) {
  4200. wrapper[key].destroy();
  4201. }
  4202. // Delete all properties
  4203. delete wrapper[key];
  4204. });
  4205. return;
  4206. };
  4207. /**
  4208. * Destroy shadows on the element.
  4209. *
  4210. * @private
  4211. * @function Highcharts.SVGElement#destroyShadows
  4212. *
  4213. * @return {void}
  4214. */
  4215. SVGElement.prototype.destroyShadows = function () {
  4216. (this.shadows || []).forEach(function (shadow) {
  4217. this.safeRemoveChild(shadow);
  4218. }, this);
  4219. this.shadows = void 0;
  4220. };
  4221. /**
  4222. * @private
  4223. */
  4224. SVGElement.prototype.destroyTextPath = function (elem, path) {
  4225. var textElement = elem.getElementsByTagName('text')[0];
  4226. var tspans;
  4227. if (textElement) {
  4228. // Remove textPath attributes
  4229. textElement.removeAttribute('dx');
  4230. textElement.removeAttribute('dy');
  4231. // Remove ID's:
  4232. path.element.setAttribute('id', '');
  4233. // Check if textElement includes textPath,
  4234. if (this.textPathWrapper &&
  4235. textElement.getElementsByTagName('textPath').length) {
  4236. // Move nodes to <text>
  4237. tspans = this.textPathWrapper.element.childNodes;
  4238. // Now move all <tspan>'s to the <textPath> node
  4239. while (tspans.length) {
  4240. textElement.appendChild(tspans[0]);
  4241. }
  4242. // Remove <textPath> from the DOM
  4243. textElement.removeChild(this.textPathWrapper.element);
  4244. }
  4245. }
  4246. else if (elem.getAttribute('dx') || elem.getAttribute('dy')) {
  4247. // Remove textPath attributes from elem
  4248. // to get correct text-outline position
  4249. elem.removeAttribute('dx');
  4250. elem.removeAttribute('dy');
  4251. }
  4252. if (this.textPathWrapper) {
  4253. // Set textPathWrapper to undefined and destroy it
  4254. this.textPathWrapper = this.textPathWrapper.destroy();
  4255. }
  4256. };
  4257. /**
  4258. * @private
  4259. * @function Highcharts.SVGElement#dSettter
  4260. * @param {number|string|Highcharts.SVGPathArray} value
  4261. * @param {string} key
  4262. * @param {Highcharts.SVGDOMElement} element
  4263. */
  4264. SVGElement.prototype.dSetter = function (value, key, element) {
  4265. if (isArray(value)) {
  4266. // Backwards compatibility, convert one-dimensional array into an
  4267. // array of segments
  4268. if (typeof value[0] === 'string') {
  4269. value = this.renderer.pathToSegments(value);
  4270. }
  4271. this.pathArray = value;
  4272. value = value.reduce(function (acc, seg, i) {
  4273. if (!seg || !seg.join) {
  4274. return (seg || '').toString();
  4275. }
  4276. return (i ? acc + ' ' : '') + seg.join(' ');
  4277. }, '');
  4278. }
  4279. if (/(NaN| {2}|^$)/.test(value)) {
  4280. value = 'M 0 0';
  4281. }
  4282. // Check for cache before resetting. Resetting causes disturbance in the
  4283. // DOM, causing flickering in some cases in Edge/IE (#6747). Also
  4284. // possible performance gain.
  4285. if (this[key] !== value) {
  4286. element.setAttribute(key, value);
  4287. this[key] = value;
  4288. }
  4289. };
  4290. /**
  4291. * Fade out an element by animating its opacity down to 0, and hide it on
  4292. * complete. Used internally for the tooltip.
  4293. *
  4294. * @function Highcharts.SVGElement#fadeOut
  4295. *
  4296. * @param {number} [duration=150]
  4297. * The fade duration in milliseconds.
  4298. */
  4299. SVGElement.prototype.fadeOut = function (duration) {
  4300. var elemWrapper = this;
  4301. elemWrapper.animate({
  4302. opacity: 0
  4303. }, {
  4304. duration: pick(duration, 150),
  4305. complete: function () {
  4306. // #3088, assuming we're only using this for tooltips
  4307. elemWrapper.attr({ y: -9999 }).hide();
  4308. }
  4309. });
  4310. };
  4311. /**
  4312. * @private
  4313. * @function Highcharts.SVGElement#fillSetter
  4314. * @param {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} value
  4315. * @param {string} key
  4316. * @param {Highcharts.SVGDOMElement} element
  4317. */
  4318. SVGElement.prototype.fillSetter = function (value, key, element) {
  4319. if (typeof value === 'string') {
  4320. element.setAttribute(key, value);
  4321. }
  4322. else if (value) {
  4323. this.complexColor(value, key, element);
  4324. }
  4325. };
  4326. /**
  4327. * Get the bounding box (width, height, x and y) for the element. Generally
  4328. * used to get rendered text size. Since this is called a lot in charts,
  4329. * the results are cached based on text properties, in order to save DOM
  4330. * traffic. The returned bounding box includes the rotation, so for example
  4331. * a single text line of rotation 90 will report a greater height, and a
  4332. * width corresponding to the line-height.
  4333. *
  4334. * @sample highcharts/members/renderer-on-chart/
  4335. * Draw a rectangle based on a text's bounding box
  4336. *
  4337. * @function Highcharts.SVGElement#getBBox
  4338. *
  4339. * @param {boolean} [reload]
  4340. * Skip the cache and get the updated DOM bouding box.
  4341. *
  4342. * @param {number} [rot]
  4343. * Override the element's rotation. This is internally used on axis
  4344. * labels with a value of 0 to find out what the bounding box would
  4345. * be have been if it were not rotated.
  4346. *
  4347. * @return {Highcharts.BBoxObject}
  4348. * The bounding box with `x`, `y`, `width` and `height` properties.
  4349. */
  4350. SVGElement.prototype.getBBox = function (reload, rot) {
  4351. var wrapper = this, bBox, // = wrapper.bBox,
  4352. renderer = wrapper.renderer, width, height, element = wrapper.element, styles = wrapper.styles, fontSize, textStr = wrapper.textStr, toggleTextShadowShim, cache = renderer.cache, cacheKeys = renderer.cacheKeys, isSVG = element.namespaceURI === wrapper.SVG_NS, cacheKey;
  4353. var rotation = pick(rot, wrapper.rotation, 0);
  4354. fontSize = renderer.styledMode ? (element &&
  4355. SVGElement.prototype.getStyle.call(element, 'font-size')) : (styles && styles.fontSize);
  4356. // Avoid undefined and null (#7316)
  4357. if (defined(textStr)) {
  4358. cacheKey = textStr.toString();
  4359. // Since numbers are monospaced, and numerical labels appear a lot
  4360. // in a chart, we assume that a label of n characters has the same
  4361. // bounding box as others of the same length. Unless there is inner
  4362. // HTML in the label. In that case, leave the numbers as is (#5899).
  4363. if (cacheKey.indexOf('<') === -1) {
  4364. cacheKey = cacheKey.replace(/[0-9]/g, '0');
  4365. }
  4366. // Properties that affect bounding box
  4367. cacheKey += [
  4368. '',
  4369. rotation,
  4370. fontSize,
  4371. wrapper.textWidth,
  4372. styles && styles.textOverflow,
  4373. styles && styles.fontWeight // #12163
  4374. ].join(',');
  4375. }
  4376. if (cacheKey && !reload) {
  4377. bBox = cache[cacheKey];
  4378. }
  4379. // No cache found
  4380. if (!bBox) {
  4381. // SVG elements
  4382. if (isSVG || renderer.forExport) {
  4383. try { // Fails in Firefox if the container has display: none.
  4384. // When the text shadow shim is used, we need to hide the
  4385. // fake shadows to get the correct bounding box (#3872)
  4386. toggleTextShadowShim = this.fakeTS && function (display) {
  4387. [].forEach.call(element.querySelectorAll('.highcharts-text-outline'), function (tspan) {
  4388. tspan.style.display = display;
  4389. });
  4390. };
  4391. // Workaround for #3842, Firefox reporting wrong bounding
  4392. // box for shadows
  4393. if (isFunction(toggleTextShadowShim)) {
  4394. toggleTextShadowShim('none');
  4395. }
  4396. bBox = element.getBBox ?
  4397. // SVG: use extend because IE9 is not allowed to change
  4398. // width and height in case of rotation (below)
  4399. extend({}, element.getBBox()) : {
  4400. // Legacy IE in export mode
  4401. width: element.offsetWidth,
  4402. height: element.offsetHeight
  4403. };
  4404. // #3842
  4405. if (isFunction(toggleTextShadowShim)) {
  4406. toggleTextShadowShim('');
  4407. }
  4408. }
  4409. catch (e) {
  4410. '';
  4411. }
  4412. // If the bBox is not set, the try-catch block above failed. The
  4413. // other condition is for Opera that returns a width of
  4414. // -Infinity on hidden elements.
  4415. if (!bBox || bBox.width < 0) {
  4416. bBox = { width: 0, height: 0 };
  4417. }
  4418. // VML Renderer or useHTML within SVG
  4419. }
  4420. else {
  4421. bBox = wrapper.htmlGetBBox();
  4422. }
  4423. // True SVG elements as well as HTML elements in modern browsers
  4424. // using the .useHTML option need to compensated for rotation
  4425. if (renderer.isSVG) {
  4426. width = bBox.width;
  4427. height = bBox.height;
  4428. // Workaround for wrong bounding box in IE, Edge and Chrome on
  4429. // Windows. With Highcharts' default font, IE and Edge report
  4430. // a box height of 16.899 and Chrome rounds it to 17. If this
  4431. // stands uncorrected, it results in more padding added below
  4432. // the text than above when adding a label border or background.
  4433. // Also vertical positioning is affected.
  4434. // https://jsfiddle.net/highcharts/em37nvuj/
  4435. // (#1101, #1505, #1669, #2568, #6213).
  4436. if (isSVG) {
  4437. bBox.height = height = ({
  4438. '11px,17': 14,
  4439. '13px,20': 16
  4440. }[styles &&
  4441. styles.fontSize + ',' + Math.round(height)] ||
  4442. height);
  4443. }
  4444. // Adjust for rotated text
  4445. if (rotation) {
  4446. var rad = rotation * deg2rad;
  4447. bBox.width = Math.abs(height * Math.sin(rad)) +
  4448. Math.abs(width * Math.cos(rad));
  4449. bBox.height = Math.abs(height * Math.cos(rad)) +
  4450. Math.abs(width * Math.sin(rad));
  4451. }
  4452. }
  4453. // Cache it. When loading a chart in a hidden iframe in Firefox and
  4454. // IE/Edge, the bounding box height is 0, so don't cache it (#5620).
  4455. if (cacheKey && bBox.height > 0) {
  4456. // Rotate (#4681)
  4457. while (cacheKeys.length > 250) {
  4458. delete cache[cacheKeys.shift()];
  4459. }
  4460. if (!cache[cacheKey]) {
  4461. cacheKeys.push(cacheKey);
  4462. }
  4463. cache[cacheKey] = bBox;
  4464. }
  4465. }
  4466. return bBox;
  4467. };
  4468. /**
  4469. * Get the computed style. Only in styled mode.
  4470. *
  4471. * @example
  4472. * chart.series[0].points[0].graphic.getStyle('stroke-width'); // => '1px'
  4473. *
  4474. * @function Highcharts.SVGElement#getStyle
  4475. *
  4476. * @param {string} prop
  4477. * The property name to check for.
  4478. *
  4479. * @return {string}
  4480. * The current computed value.
  4481. */
  4482. SVGElement.prototype.getStyle = function (prop) {
  4483. return win
  4484. .getComputedStyle(this.element || this, '')
  4485. .getPropertyValue(prop);
  4486. };
  4487. /**
  4488. * Check if an element has the given class name.
  4489. *
  4490. * @function Highcharts.SVGElement#hasClass
  4491. *
  4492. * @param {string} className
  4493. * The class name to check for.
  4494. *
  4495. * @return {boolean}
  4496. * Whether the class name is found.
  4497. */
  4498. SVGElement.prototype.hasClass = function (className) {
  4499. return ('' + this.attr('class'))
  4500. .split(' ')
  4501. .indexOf(className) !== -1;
  4502. };
  4503. /**
  4504. * Hide the element, similar to setting the `visibility` attribute to
  4505. * `hidden`.
  4506. *
  4507. * @function Highcharts.SVGElement#hide
  4508. *
  4509. * @param {boolean} [hideByTranslation=false]
  4510. * The flag to determine if element should be hidden by moving out
  4511. * of the viewport. Used for example for dataLabels.
  4512. *
  4513. * @return {Highcharts.SVGElement}
  4514. * Returns the SVGElement for chaining.
  4515. */
  4516. SVGElement.prototype.hide = function (hideByTranslation) {
  4517. if (hideByTranslation) {
  4518. this.attr({ y: -9999 });
  4519. }
  4520. else {
  4521. this.attr({ visibility: 'hidden' });
  4522. }
  4523. return this;
  4524. };
  4525. /**
  4526. * @private
  4527. */
  4528. SVGElement.prototype.htmlGetBBox = function () {
  4529. return { height: 0, width: 0, x: 0, y: 0 };
  4530. };
  4531. /**
  4532. * Initialize the SVG element. This function only exists to make the
  4533. * initialization process overridable. It should not be called directly.
  4534. *
  4535. * @function Highcharts.SVGElement#init
  4536. *
  4537. * @param {Highcharts.SVGRenderer} renderer
  4538. * The SVGRenderer instance to initialize to.
  4539. *
  4540. * @param {string} nodeName
  4541. * The SVG node name.
  4542. */
  4543. SVGElement.prototype.init = function (renderer, nodeName) {
  4544. /**
  4545. * The primary DOM node. Each `SVGElement` instance wraps a main DOM
  4546. * node, but may also represent more nodes.
  4547. *
  4548. * @name Highcharts.SVGElement#element
  4549. * @type {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement}
  4550. */
  4551. this.element = nodeName === 'span' ?
  4552. createElement(nodeName) :
  4553. doc.createElementNS(this.SVG_NS, nodeName);
  4554. /**
  4555. * The renderer that the SVGElement belongs to.
  4556. *
  4557. * @name Highcharts.SVGElement#renderer
  4558. * @type {Highcharts.SVGRenderer}
  4559. */
  4560. this.renderer = renderer;
  4561. fireEvent(this, 'afterInit');
  4562. };
  4563. /**
  4564. * Invert a group, rotate and flip. This is used internally on inverted
  4565. * charts, where the points and graphs are drawn as if not inverted, then
  4566. * the series group elements are inverted.
  4567. *
  4568. * @function Highcharts.SVGElement#invert
  4569. *
  4570. * @param {boolean} inverted
  4571. * Whether to invert or not. An inverted shape can be un-inverted by
  4572. * setting it to false.
  4573. *
  4574. * @return {Highcharts.SVGElement}
  4575. * Return the SVGElement for chaining.
  4576. */
  4577. SVGElement.prototype.invert = function (inverted) {
  4578. var wrapper = this;
  4579. wrapper.inverted = inverted;
  4580. wrapper.updateTransform();
  4581. return wrapper;
  4582. };
  4583. /**
  4584. * Add an event listener. This is a simple setter that replaces all other
  4585. * events of the same type, opposed to the {@link Highcharts#addEvent}
  4586. * function.
  4587. *
  4588. * @sample highcharts/members/element-on/
  4589. * A clickable rectangle
  4590. *
  4591. * @function Highcharts.SVGElement#on
  4592. *
  4593. * @param {string} eventType
  4594. * The event type. If the type is `click`, Highcharts will internally
  4595. * translate it to a `touchstart` event on touch devices, to prevent the
  4596. * browser from waiting for a click event from firing.
  4597. *
  4598. * @param {Function} handler
  4599. * The handler callback.
  4600. *
  4601. * @return {Highcharts.SVGElement}
  4602. * The SVGElement for chaining.
  4603. */
  4604. SVGElement.prototype.on = function (eventType, handler) {
  4605. var svgElement = this, element = svgElement.element, touchStartPos, touchEventFired;
  4606. // touch
  4607. if (hasTouch && eventType === 'click') {
  4608. element.ontouchstart = function (e) {
  4609. // save touch position for later calculation
  4610. touchStartPos = {
  4611. clientX: e.touches[0].clientX,
  4612. clientY: e.touches[0].clientY
  4613. };
  4614. };
  4615. // Instead of ontouchstart, event handlers should be called
  4616. // on touchend - similar to how current mouseup events are called
  4617. element.ontouchend = function (e) {
  4618. // hasMoved is a boolean variable containing logic if page
  4619. // was scrolled, so if touch position changed more than
  4620. // ~4px (value borrowed from general touch handler)
  4621. var hasMoved = touchStartPos.clientX ? Math.sqrt(Math.pow(touchStartPos.clientX - e.changedTouches[0].clientX, 2) +
  4622. Math.pow(touchStartPos.clientY - e.changedTouches[0].clientY, 2)) >= 4 : false;
  4623. if (!hasMoved) { // only call handlers if page was not scrolled
  4624. handler.call(element, e);
  4625. }
  4626. touchEventFired = true;
  4627. // prevent other events from being fired. #9682
  4628. e.preventDefault();
  4629. };
  4630. element.onclick = function (e) {
  4631. // Do not call onclick handler if touch event was fired already.
  4632. if (!touchEventFired) {
  4633. handler.call(element, e);
  4634. }
  4635. };
  4636. }
  4637. else {
  4638. // simplest possible event model for internal use
  4639. element['on' + eventType] = handler;
  4640. }
  4641. return this;
  4642. };
  4643. /**
  4644. * @private
  4645. * @function Highcharts.SVGElement#opacitySetter
  4646. * @param {string} value
  4647. * @param {string} key
  4648. * @param {Highcharts.SVGDOMElement} element
  4649. */
  4650. SVGElement.prototype.opacitySetter = function (value, key, element) {
  4651. this[key] = value;
  4652. element.setAttribute(key, value);
  4653. };
  4654. /**
  4655. * Remove a class name from the element.
  4656. *
  4657. * @function Highcharts.SVGElement#removeClass
  4658. *
  4659. * @param {string|RegExp} className
  4660. * The class name to remove.
  4661. *
  4662. * @return {Highcharts.SVGElement} Returns the SVG element for chainability.
  4663. */
  4664. SVGElement.prototype.removeClass = function (className) {
  4665. return this.attr('class', ('' + this.attr('class'))
  4666. .replace(isString(className) ?
  4667. new RegExp("(^| )" + className + "( |$)") : // #12064, #13590
  4668. className, ' ')
  4669. .replace(/ +/g, ' ')
  4670. .trim());
  4671. };
  4672. /**
  4673. * @private
  4674. * @param {Array<Highcharts.SVGDOMElement>} tspans
  4675. * Text spans.
  4676. */
  4677. SVGElement.prototype.removeTextOutline = function (tspans) {
  4678. // Iterate from the end to
  4679. // support removing items inside the cycle (#6472).
  4680. var i = tspans.length, tspan;
  4681. while (i--) {
  4682. tspan = tspans[i];
  4683. if (tspan.getAttribute('class') === 'highcharts-text-outline') {
  4684. // Remove then erase
  4685. erase(tspans, this.element.removeChild(tspan));
  4686. }
  4687. }
  4688. };
  4689. /**
  4690. * Removes an element from the DOM.
  4691. *
  4692. * @private
  4693. * @function Highcharts.SVGElement#safeRemoveChild
  4694. *
  4695. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  4696. * The DOM node to remove.
  4697. */
  4698. SVGElement.prototype.safeRemoveChild = function (element) {
  4699. var parentNode = element.parentNode;
  4700. if (parentNode) {
  4701. parentNode.removeChild(element);
  4702. }
  4703. };
  4704. /**
  4705. * Set the coordinates needed to draw a consistent radial gradient across
  4706. * a shape regardless of positioning inside the chart. Used on pie slices
  4707. * to make all the slices have the same radial reference point.
  4708. *
  4709. * @function Highcharts.SVGElement#setRadialReference
  4710. *
  4711. * @param {Array<number>} coordinates
  4712. * The center reference. The format is `[centerX, centerY, diameter]` in
  4713. * pixels.
  4714. *
  4715. * @return {Highcharts.SVGElement}
  4716. * Returns the SVGElement for chaining.
  4717. */
  4718. SVGElement.prototype.setRadialReference = function (coordinates) {
  4719. var existingGradient = (this.element.gradient &&
  4720. this.renderer.gradients[this.element.gradient]);
  4721. this.element.radialReference = coordinates;
  4722. // On redrawing objects with an existing gradient, the gradient needs
  4723. // to be repositioned (#3801)
  4724. if (existingGradient && existingGradient.radAttr) {
  4725. existingGradient.animate(this.renderer.getRadialAttr(coordinates, existingGradient.radAttr));
  4726. }
  4727. return this;
  4728. };
  4729. /**
  4730. * @private
  4731. * @function Highcharts.SVGElement#setTextPath
  4732. * @param {Highcharts.SVGElement} path
  4733. * Path to follow.
  4734. * @param {Highcharts.DataLabelsTextPathOptionsObject} textPathOptions
  4735. * Options.
  4736. * @return {Highcharts.SVGElement}
  4737. * Returns the SVGElement for chaining.
  4738. */
  4739. SVGElement.prototype.setTextPath = function (path, textPathOptions) {
  4740. var elem = this.element, attribsMap = {
  4741. textAnchor: 'text-anchor'
  4742. }, attrs, adder = false, textPathElement, textPathId, textPathWrapper = this.textPathWrapper, tspans, firstTime = !textPathWrapper;
  4743. // Defaults
  4744. textPathOptions = merge(true, {
  4745. enabled: true,
  4746. attributes: {
  4747. dy: -5,
  4748. startOffset: '50%',
  4749. textAnchor: 'middle'
  4750. }
  4751. }, textPathOptions);
  4752. attrs = textPathOptions.attributes;
  4753. if (path && textPathOptions && textPathOptions.enabled) {
  4754. // In case of fixed width for a text, string is rebuilt
  4755. // (e.g. ellipsis is applied), so we need to rebuild textPath too
  4756. if (textPathWrapper &&
  4757. textPathWrapper.element.parentNode === null) {
  4758. // When buildText functionality was triggered again
  4759. // and deletes textPathWrapper parentNode
  4760. firstTime = true;
  4761. textPathWrapper = textPathWrapper.destroy();
  4762. }
  4763. else if (textPathWrapper) {
  4764. // Case after drillup when spans were added into
  4765. // the DOM outside the textPathWrapper parentGroup
  4766. this.removeTextOutline.call(textPathWrapper.parentGroup, [].slice.call(elem.getElementsByTagName('tspan')));
  4767. }
  4768. // label() has padding, text() doesn't
  4769. if (this.options && this.options.padding) {
  4770. attrs.dx = -this.options.padding;
  4771. }
  4772. if (!textPathWrapper) {
  4773. // Create <textPath>, defer the DOM adder
  4774. this.textPathWrapper = textPathWrapper =
  4775. this.renderer.createElement('textPath');
  4776. adder = true;
  4777. }
  4778. textPathElement = textPathWrapper.element;
  4779. // Set ID for the path
  4780. textPathId = path.element.getAttribute('id');
  4781. if (!textPathId) {
  4782. path.element.setAttribute('id', textPathId = uniqueKey());
  4783. }
  4784. // Change DOM structure, by placing <textPath> tag in <text>
  4785. if (firstTime) {
  4786. tspans = elem.getElementsByTagName('tspan');
  4787. // Now move all <tspan>'s to the <textPath> node
  4788. while (tspans.length) {
  4789. // Remove "y" from tspans, as Firefox translates them
  4790. tspans[0].setAttribute('y', 0);
  4791. // Remove "x" from tspans
  4792. if (isNumber(attrs.dx)) {
  4793. tspans[0].setAttribute('x', -attrs.dx);
  4794. }
  4795. textPathElement.appendChild(tspans[0]);
  4796. }
  4797. }
  4798. // Add <textPath> to the DOM
  4799. if (adder &&
  4800. textPathWrapper) {
  4801. textPathWrapper.add({
  4802. // label() is placed in a group, text() is standalone
  4803. element: this.text ? this.text.element : elem
  4804. });
  4805. }
  4806. // Set basic options:
  4807. // Use `setAttributeNS` because Safari needs this..
  4808. textPathElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.renderer.url + '#' + textPathId);
  4809. // Presentation attributes:
  4810. // dx/dy options must by set on <text> (parent),
  4811. // the rest should be set on <textPath>
  4812. if (defined(attrs.dy)) {
  4813. textPathElement.parentNode
  4814. .setAttribute('dy', attrs.dy);
  4815. delete attrs.dy;
  4816. }
  4817. if (defined(attrs.dx)) {
  4818. textPathElement.parentNode
  4819. .setAttribute('dx', attrs.dx);
  4820. delete attrs.dx;
  4821. }
  4822. // Additional attributes
  4823. objectEach(attrs, function (val, key) {
  4824. textPathElement.setAttribute(attribsMap[key] || key, val);
  4825. });
  4826. // Remove translation, text that follows path does not need that
  4827. elem.removeAttribute('transform');
  4828. // Remove shadows and text outlines
  4829. this.removeTextOutline.call(textPathWrapper, [].slice.call(elem.getElementsByTagName('tspan')));
  4830. // Remove background and border for label(), see #10545
  4831. // Alternatively, we can disable setting background rects in
  4832. // series.drawDataLabels()
  4833. if (this.text && !this.renderer.styledMode) {
  4834. this.attr({
  4835. fill: 'none',
  4836. 'stroke-width': 0
  4837. });
  4838. }
  4839. // Disable some functions
  4840. this.updateTransform = noop;
  4841. this.applyTextOutline = noop;
  4842. }
  4843. else if (textPathWrapper) {
  4844. // Reset to prototype
  4845. delete this.updateTransform;
  4846. delete this.applyTextOutline;
  4847. // Restore DOM structure:
  4848. this.destroyTextPath(elem, path);
  4849. // Bring attributes back
  4850. this.updateTransform();
  4851. // Set textOutline back for text()
  4852. if (this.options && this.options.rotation) {
  4853. this.applyTextOutline(this.options.style.textOutline);
  4854. }
  4855. }
  4856. return this;
  4857. };
  4858. /**
  4859. * Add a shadow to the element. Must be called after the element is added to
  4860. * the DOM. In styled mode, this method is not used, instead use `defs` and
  4861. * filters.
  4862. *
  4863. * @example
  4864. * renderer.rect(10, 100, 100, 100)
  4865. * .attr({ fill: 'red' })
  4866. * .shadow(true);
  4867. *
  4868. * @function Highcharts.SVGElement#shadow
  4869. *
  4870. * @param {boolean|Highcharts.ShadowOptionsObject} [shadowOptions]
  4871. * The shadow options. If `true`, the default options are applied. If
  4872. * `false`, the current shadow will be removed.
  4873. *
  4874. * @param {Highcharts.SVGElement} [group]
  4875. * The SVG group element where the shadows will be applied. The
  4876. * default is to add it to the same parent as the current element.
  4877. * Internally, this is ised for pie slices, where all the shadows are
  4878. * added to an element behind all the slices.
  4879. *
  4880. * @param {boolean} [cutOff]
  4881. * Used internally for column shadows.
  4882. *
  4883. * @return {Highcharts.SVGElement}
  4884. * Returns the SVGElement for chaining.
  4885. */
  4886. SVGElement.prototype.shadow = function (shadowOptions, group, cutOff) {
  4887. var shadows = [], i, shadow, element = this.element, strokeWidth, shadowElementOpacity, update = false, oldShadowOptions = this.oldShadowOptions,
  4888. // compensate for inverted plot area
  4889. transform;
  4890. var defaultShadowOptions = {
  4891. color: '#000000',
  4892. offsetX: 1,
  4893. offsetY: 1,
  4894. opacity: 0.15,
  4895. width: 3
  4896. };
  4897. var options;
  4898. if (shadowOptions === true) {
  4899. options = defaultShadowOptions;
  4900. }
  4901. else if (typeof shadowOptions === 'object') {
  4902. options = extend(defaultShadowOptions, shadowOptions);
  4903. }
  4904. // Update shadow when options change (#12091).
  4905. if (options) {
  4906. // Go over each key to look for change
  4907. if (options && oldShadowOptions) {
  4908. objectEach(options, function (value, key) {
  4909. if (value !== oldShadowOptions[key]) {
  4910. update = true;
  4911. }
  4912. });
  4913. }
  4914. if (update) {
  4915. this.destroyShadows();
  4916. }
  4917. this.oldShadowOptions = options;
  4918. }
  4919. if (!options) {
  4920. this.destroyShadows();
  4921. }
  4922. else if (!this.shadows) {
  4923. shadowElementOpacity = options.opacity / options.width;
  4924. transform = this.parentInverted ?
  4925. 'translate(-1,-1)' :
  4926. "translate(" + options.offsetX + ", " + options.offsetY + ")";
  4927. for (i = 1; i <= options.width; i++) {
  4928. shadow = element.cloneNode(false);
  4929. strokeWidth = (options.width * 2) + 1 - (2 * i);
  4930. attr(shadow, {
  4931. stroke: (shadowOptions.color ||
  4932. '#000000'),
  4933. 'stroke-opacity': shadowElementOpacity * i,
  4934. 'stroke-width': strokeWidth,
  4935. transform: transform,
  4936. fill: 'none'
  4937. });
  4938. shadow.setAttribute('class', (shadow.getAttribute('class') || '') + ' highcharts-shadow');
  4939. if (cutOff) {
  4940. attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
  4941. shadow.cutHeight = strokeWidth;
  4942. }
  4943. if (group) {
  4944. group.element.appendChild(shadow);
  4945. }
  4946. else if (element.parentNode) {
  4947. element.parentNode.insertBefore(shadow, element);
  4948. }
  4949. shadows.push(shadow);
  4950. }
  4951. this.shadows = shadows;
  4952. }
  4953. return this;
  4954. };
  4955. /**
  4956. * Show the element after it has been hidden.
  4957. *
  4958. * @function Highcharts.SVGElement#show
  4959. *
  4960. * @param {boolean} [inherit=false]
  4961. * Set the visibility attribute to `inherit` rather than `visible`.
  4962. * The difference is that an element with `visibility="visible"`
  4963. * will be visible even if the parent is hidden.
  4964. *
  4965. * @return {Highcharts.SVGElement}
  4966. * Returns the SVGElement for chaining.
  4967. */
  4968. SVGElement.prototype.show = function (inherit) {
  4969. return this.attr({ visibility: inherit ? 'inherit' : 'visible' });
  4970. };
  4971. /**
  4972. * WebKit and Batik have problems with a stroke-width of zero, so in this
  4973. * case we remove the stroke attribute altogether. #1270, #1369, #3065,
  4974. * #3072.
  4975. *
  4976. * @private
  4977. * @function Highcharts.SVGElement#strokeSetter
  4978. * @param {number|string} value
  4979. * @param {string} key
  4980. * @param {Highcharts.SVGDOMElement} element
  4981. */
  4982. SVGElement.prototype.strokeSetter = function (value, key, element) {
  4983. this[key] = value;
  4984. // Only apply the stroke attribute if the stroke width is defined and
  4985. // larger than 0
  4986. if (this.stroke && this['stroke-width']) {
  4987. // Use prototype as instance may be overridden
  4988. SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element);
  4989. element.setAttribute('stroke-width', this['stroke-width']);
  4990. this.hasStroke = true;
  4991. }
  4992. else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
  4993. element.removeAttribute('stroke');
  4994. this.hasStroke = false;
  4995. }
  4996. else if (this.renderer.styledMode && this['stroke-width']) {
  4997. element.setAttribute('stroke-width', this['stroke-width']);
  4998. this.hasStroke = true;
  4999. }
  5000. };
  5001. /**
  5002. * Get the computed stroke width in pixel values. This is used extensively
  5003. * when drawing shapes to ensure the shapes are rendered crisp and
  5004. * positioned correctly relative to each other. Using
  5005. * `shape-rendering: crispEdges` leaves us less control over positioning,
  5006. * for example when we want to stack columns next to each other, or position
  5007. * things pixel-perfectly within the plot box.
  5008. *
  5009. * The common pattern when placing a shape is:
  5010. * - Create the SVGElement and add it to the DOM. In styled mode, it will
  5011. * now receive a stroke width from the style sheet. In classic mode we
  5012. * will add the `stroke-width` attribute.
  5013. * - Read the computed `elem.strokeWidth()`.
  5014. * - Place it based on the stroke width.
  5015. *
  5016. * @function Highcharts.SVGElement#strokeWidth
  5017. *
  5018. * @return {number}
  5019. * The stroke width in pixels. Even if the given stroke widtch (in CSS or by
  5020. * attributes) is based on `em` or other units, the pixel size is returned.
  5021. */
  5022. SVGElement.prototype.strokeWidth = function () {
  5023. // In non-styled mode, read the stroke width as set by .attr
  5024. if (!this.renderer.styledMode) {
  5025. return this['stroke-width'] || 0;
  5026. }
  5027. // In styled mode, read computed stroke width
  5028. var val = this.getStyle('stroke-width'), ret = 0, dummy;
  5029. // Read pixel values directly
  5030. if (val.indexOf('px') === val.length - 2) {
  5031. ret = pInt(val);
  5032. // Other values like em, pt etc need to be measured
  5033. }
  5034. else if (val !== '') {
  5035. dummy = doc.createElementNS(SVG_NS, 'rect');
  5036. attr(dummy, {
  5037. width: val,
  5038. 'stroke-width': 0
  5039. });
  5040. this.element.parentNode.appendChild(dummy);
  5041. ret = dummy.getBBox().width;
  5042. dummy.parentNode.removeChild(dummy);
  5043. }
  5044. return ret;
  5045. };
  5046. /**
  5047. * If one of the symbol size affecting parameters are changed,
  5048. * check all the others only once for each call to an element's
  5049. * .attr() method
  5050. *
  5051. * @private
  5052. * @function Highcharts.SVGElement#symbolAttr
  5053. *
  5054. * @param {Highcharts.SVGAttributes} hash
  5055. * The attributes to set.
  5056. */
  5057. SVGElement.prototype.symbolAttr = function (hash) {
  5058. var wrapper = this;
  5059. [
  5060. 'x',
  5061. 'y',
  5062. 'r',
  5063. 'start',
  5064. 'end',
  5065. 'width',
  5066. 'height',
  5067. 'innerR',
  5068. 'anchorX',
  5069. 'anchorY',
  5070. 'clockwise'
  5071. ].forEach(function (key) {
  5072. wrapper[key] = pick(hash[key], wrapper[key]);
  5073. });
  5074. wrapper.attr({
  5075. d: wrapper.renderer.symbols[wrapper.symbolName](wrapper.x, wrapper.y, wrapper.width, wrapper.height, wrapper)
  5076. });
  5077. };
  5078. /**
  5079. * @private
  5080. * @function Highcharts.SVGElement#textSetter
  5081. * @param {string} value
  5082. */
  5083. SVGElement.prototype.textSetter = function (value) {
  5084. if (value !== this.textStr) {
  5085. // Delete size caches when the text changes
  5086. // delete this.bBox; // old code in series-label
  5087. delete this.textPxLength;
  5088. this.textStr = value;
  5089. if (this.added) {
  5090. this.renderer.buildText(this);
  5091. }
  5092. }
  5093. };
  5094. /**
  5095. * @private
  5096. * @function Highcharts.SVGElement#titleSetter
  5097. * @param {string} value
  5098. */
  5099. SVGElement.prototype.titleSetter = function (value) {
  5100. var titleNode = this.element.getElementsByTagName('title')[0];
  5101. if (!titleNode) {
  5102. titleNode = doc.createElementNS(this.SVG_NS, 'title');
  5103. this.element.appendChild(titleNode);
  5104. }
  5105. // Remove text content if it exists
  5106. if (titleNode.firstChild) {
  5107. titleNode.removeChild(titleNode.firstChild);
  5108. }
  5109. titleNode.appendChild(doc.createTextNode(
  5110. // #3276, #3895
  5111. String(pick(value, ''))
  5112. .replace(/<[^>]*>/g, '')
  5113. .replace(/&lt;/g, '<')
  5114. .replace(/&gt;/g, '>')));
  5115. };
  5116. /**
  5117. * Bring the element to the front. Alternatively, a new zIndex can be set.
  5118. *
  5119. * @sample highcharts/members/element-tofront/
  5120. * Click an element to bring it to front
  5121. *
  5122. * @function Highcharts.SVGElement#toFront
  5123. *
  5124. * @return {Highcharts.SVGElement}
  5125. * Returns the SVGElement for chaining.
  5126. */
  5127. SVGElement.prototype.toFront = function () {
  5128. var element = this.element;
  5129. element.parentNode.appendChild(element);
  5130. return this;
  5131. };
  5132. /**
  5133. * Move an object and its children by x and y values.
  5134. *
  5135. * @function Highcharts.SVGElement#translate
  5136. *
  5137. * @param {number} x
  5138. * The x value.
  5139. *
  5140. * @param {number} y
  5141. * The y value.
  5142. *
  5143. * @return {Highcharts.SVGElement}
  5144. */
  5145. SVGElement.prototype.translate = function (x, y) {
  5146. return this.attr({
  5147. translateX: x,
  5148. translateY: y
  5149. });
  5150. };
  5151. /**
  5152. * Update the shadow elements with new attributes.
  5153. *
  5154. * @private
  5155. * @function Highcharts.SVGElement#updateShadows
  5156. *
  5157. * @param {string} key
  5158. * The attribute name.
  5159. *
  5160. * @param {number} value
  5161. * The value of the attribute.
  5162. *
  5163. * @param {Function} setter
  5164. * The setter function, inherited from the parent wrapper.
  5165. */
  5166. SVGElement.prototype.updateShadows = function (key, value, setter) {
  5167. var shadows = this.shadows;
  5168. if (shadows) {
  5169. var i = shadows.length;
  5170. while (i--) {
  5171. setter.call(shadows[i], key === 'height' ?
  5172. Math.max(value - (shadows[i].cutHeight || 0), 0) :
  5173. key === 'd' ? this.d : value, key, shadows[i]);
  5174. }
  5175. }
  5176. };
  5177. /**
  5178. * Update the transform attribute based on internal properties. Deals with
  5179. * the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
  5180. * attributes and updates the SVG `transform` attribute.
  5181. *
  5182. * @private
  5183. * @function Highcharts.SVGElement#updateTransform
  5184. */
  5185. SVGElement.prototype.updateTransform = function () {
  5186. var wrapper = this, translateX = wrapper.translateX || 0, translateY = wrapper.translateY || 0, scaleX = wrapper.scaleX, scaleY = wrapper.scaleY, inverted = wrapper.inverted, rotation = wrapper.rotation, matrix = wrapper.matrix, element = wrapper.element, transform;
  5187. // Flipping affects translate as adjustment for flipping around the
  5188. // group's axis
  5189. if (inverted) {
  5190. translateX += wrapper.width;
  5191. translateY += wrapper.height;
  5192. }
  5193. // Apply translate. Nearly all transformed elements have translation,
  5194. // so instead of checking for translate = 0, do it always (#1767,
  5195. // #1846).
  5196. transform = ['translate(' + translateX + ',' + translateY + ')'];
  5197. // apply matrix
  5198. if (defined(matrix)) {
  5199. transform.push('matrix(' + matrix.join(',') + ')');
  5200. }
  5201. // apply rotation
  5202. if (inverted) {
  5203. transform.push('rotate(90) scale(-1,1)');
  5204. }
  5205. else if (rotation) { // text rotation
  5206. transform.push('rotate(' + rotation + ' ' +
  5207. pick(this.rotationOriginX, element.getAttribute('x'), 0) +
  5208. ' ' +
  5209. pick(this.rotationOriginY, element.getAttribute('y') || 0) + ')');
  5210. }
  5211. // apply scale
  5212. if (defined(scaleX) || defined(scaleY)) {
  5213. transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
  5214. }
  5215. if (transform.length) {
  5216. element.setAttribute('transform', transform.join(' '));
  5217. }
  5218. };
  5219. /**
  5220. * @private
  5221. * @function Highcharts.SVGElement#visibilitySetter
  5222. *
  5223. * @param {string} value
  5224. *
  5225. * @param {string} key
  5226. *
  5227. * @param {Highcharts.SVGDOMElement} element
  5228. *
  5229. * @return {void}
  5230. */
  5231. SVGElement.prototype.visibilitySetter = function (value, key, element) {
  5232. // IE9-11 doesn't handle visibilty:inherit well, so we remove the
  5233. // attribute instead (#2881, #3909)
  5234. if (value === 'inherit') {
  5235. element.removeAttribute(key);
  5236. }
  5237. else if (this[key] !== value) { // #6747
  5238. element.setAttribute(key, value);
  5239. }
  5240. this[key] = value;
  5241. };
  5242. /**
  5243. * @private
  5244. * @function Highcharts.SVGElement#xGetter
  5245. *
  5246. * @param {string} key
  5247. *
  5248. * @return {number|string|null}
  5249. */
  5250. SVGElement.prototype.xGetter = function (key) {
  5251. if (this.element.nodeName === 'circle') {
  5252. if (key === 'x') {
  5253. key = 'cx';
  5254. }
  5255. else if (key === 'y') {
  5256. key = 'cy';
  5257. }
  5258. }
  5259. return this._defaultGetter(key);
  5260. };
  5261. /**
  5262. * @private
  5263. * @function Highcharts.SVGElement#zIndexSetter
  5264. * @param {number} [value]
  5265. * @param {string} [key]
  5266. * @return {boolean}
  5267. */
  5268. SVGElement.prototype.zIndexSetter = function (value, key) {
  5269. var renderer = this.renderer, parentGroup = this.parentGroup, parentWrapper = parentGroup || renderer, parentNode = parentWrapper.element || renderer.box, childNodes, otherElement, otherZIndex, element = this.element, inserted = false, undefinedOtherZIndex, svgParent = parentNode === renderer.box, run = this.added, i;
  5270. if (defined(value)) {
  5271. // So we can read it for other elements in the group
  5272. element.setAttribute('data-z-index', value);
  5273. value = +value;
  5274. if (this[key] === value) {
  5275. // Only update when needed (#3865)
  5276. run = false;
  5277. }
  5278. }
  5279. else if (defined(this[key])) {
  5280. element.removeAttribute('data-z-index');
  5281. }
  5282. this[key] = value;
  5283. // Insert according to this and other elements' zIndex. Before .add() is
  5284. // called, nothing is done. Then on add, or by later calls to
  5285. // zIndexSetter, the node is placed on the right place in the DOM.
  5286. if (run) {
  5287. value = this.zIndex;
  5288. if (value && parentGroup) {
  5289. parentGroup.handleZ = true;
  5290. }
  5291. childNodes = parentNode.childNodes;
  5292. for (i = childNodes.length - 1; i >= 0 && !inserted; i--) {
  5293. otherElement = childNodes[i];
  5294. otherZIndex = otherElement.getAttribute('data-z-index');
  5295. undefinedOtherZIndex = !defined(otherZIndex);
  5296. if (otherElement !== element) {
  5297. if (
  5298. // Negative zIndex versus no zIndex:
  5299. // On all levels except the highest. If the parent is
  5300. // <svg>, then we don't want to put items before <desc>
  5301. // or <defs>
  5302. value < 0 &&
  5303. undefinedOtherZIndex &&
  5304. !svgParent &&
  5305. !i) {
  5306. parentNode.insertBefore(element, childNodes[i]);
  5307. inserted = true;
  5308. }
  5309. else if (
  5310. // Insert after the first element with a lower zIndex
  5311. pInt(otherZIndex) <= value ||
  5312. // If negative zIndex, add this before first undefined
  5313. // zIndex element
  5314. (undefinedOtherZIndex &&
  5315. (!defined(value) || value >= 0))) {
  5316. parentNode.insertBefore(element, childNodes[i + 1] || null // null for oldIE export
  5317. );
  5318. inserted = true;
  5319. }
  5320. }
  5321. }
  5322. if (!inserted) {
  5323. parentNode.insertBefore(element, childNodes[svgParent ? 3 : 0] || null // null for oldIE
  5324. );
  5325. inserted = true;
  5326. }
  5327. }
  5328. return inserted;
  5329. };
  5330. return SVGElement;
  5331. }());
  5332. // Some shared setters and getters
  5333. SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter;
  5334. SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
  5335. SVGElement.prototype.matrixSetter =
  5336. SVGElement.prototype.rotationOriginXSetter =
  5337. SVGElement.prototype.rotationOriginYSetter =
  5338. SVGElement.prototype.rotationSetter =
  5339. SVGElement.prototype.scaleXSetter =
  5340. SVGElement.prototype.scaleYSetter =
  5341. SVGElement.prototype.translateXSetter =
  5342. SVGElement.prototype.translateYSetter =
  5343. SVGElement.prototype.verticalAlignSetter = function (value, key) {
  5344. this[key] = value;
  5345. this.doTransform = true;
  5346. };
  5347. H.SVGElement = SVGElement;
  5348. return H.SVGElement;
  5349. });
  5350. _registerModule(_modules, 'parts/SVGLabel.js', [_modules['parts/SVGElement.js'], _modules['parts/Utilities.js']], function (SVGElement, U) {
  5351. /* *
  5352. *
  5353. * (c) 2010-2020 Torstein Honsi
  5354. *
  5355. * License: www.highcharts.com/license
  5356. *
  5357. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5358. *
  5359. * */
  5360. var __extends = (this && this.__extends) || (function () {
  5361. var extendStatics = function (d, b) {
  5362. extendStatics = Object.setPrototypeOf ||
  5363. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5364. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5365. return extendStatics(d, b);
  5366. };
  5367. return function (d, b) {
  5368. extendStatics(d, b);
  5369. function __() { this.constructor = d; }
  5370. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5371. };
  5372. })();
  5373. var defined = U.defined, extend = U.extend, isNumber = U.isNumber, merge = U.merge, removeEvent = U.removeEvent;
  5374. /**
  5375. * SVG label to render text.
  5376. * @private
  5377. * @class
  5378. * @name Highcharts.SVGLabel
  5379. * @augments Highcharts.SVGElement
  5380. */
  5381. var SVGLabel = /** @class */ (function (_super) {
  5382. __extends(SVGLabel, _super);
  5383. /* *
  5384. *
  5385. * Constructors
  5386. *
  5387. * */
  5388. function SVGLabel(renderer, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  5389. var _this = _super.call(this) || this;
  5390. _this.init(renderer, 'g');
  5391. _this.textStr = str;
  5392. _this.x = x;
  5393. _this.y = y;
  5394. _this.anchorX = anchorX;
  5395. _this.anchorY = anchorY;
  5396. _this.baseline = baseline;
  5397. _this.className = className;
  5398. if (className !== 'button') {
  5399. _this.addClass('highcharts-label');
  5400. }
  5401. if (className) {
  5402. _this.addClass('highcharts-' + className);
  5403. }
  5404. _this.text = renderer.text('', 0, 0, useHTML)
  5405. .attr({
  5406. zIndex: 1
  5407. });
  5408. // Validate the shape argument
  5409. var hasBGImage;
  5410. if (typeof shape === 'string') {
  5411. hasBGImage = /^url\((.*?)\)$/.test(shape);
  5412. if (_this.renderer.symbols[shape] || hasBGImage) {
  5413. _this.symbolKey = shape;
  5414. }
  5415. }
  5416. _this.bBox = SVGLabel.emptyBBox;
  5417. _this.padding = 3;
  5418. _this.paddingLeft = 0;
  5419. _this.baselineOffset = 0;
  5420. _this.needsBox = renderer.styledMode || hasBGImage;
  5421. _this.deferredAttr = {};
  5422. _this.alignFactor = 0;
  5423. return _this;
  5424. }
  5425. /* *
  5426. *
  5427. * Functions
  5428. *
  5429. * */
  5430. SVGLabel.prototype.alignSetter = function (value) {
  5431. var alignFactor = {
  5432. left: 0,
  5433. center: 0.5,
  5434. right: 1
  5435. }[value];
  5436. if (alignFactor !== this.alignFactor) {
  5437. this.alignFactor = alignFactor;
  5438. // Bounding box exists, means we're dynamically changing
  5439. if (this.bBox && isNumber(this.xSetting)) {
  5440. this.attr({ x: this.xSetting }); // #5134
  5441. }
  5442. }
  5443. };
  5444. SVGLabel.prototype.anchorXSetter = function (value, key) {
  5445. this.anchorX = value;
  5446. this.boxAttr(key, Math.round(value) - this.getCrispAdjust() - this.xSetting);
  5447. };
  5448. SVGLabel.prototype.anchorYSetter = function (value, key) {
  5449. this.anchorY = value;
  5450. this.boxAttr(key, value - this.ySetting);
  5451. };
  5452. /*
  5453. * Set a box attribute, or defer it if the box is not yet created
  5454. */
  5455. SVGLabel.prototype.boxAttr = function (key, value) {
  5456. if (this.box) {
  5457. this.box.attr(key, value);
  5458. }
  5459. else {
  5460. this.deferredAttr[key] = value;
  5461. }
  5462. };
  5463. /*
  5464. * Pick up some properties and apply them to the text instead of the
  5465. * wrapper.
  5466. */
  5467. SVGLabel.prototype.css = function (styles) {
  5468. if (styles) {
  5469. var textStyles = {}, isWidth, isFontStyle;
  5470. // Create a copy to avoid altering the original object
  5471. // (#537)
  5472. styles = merge(styles);
  5473. SVGLabel.textProps.forEach(function (prop) {
  5474. if (typeof styles[prop] !== 'undefined') {
  5475. textStyles[prop] = styles[prop];
  5476. delete styles[prop];
  5477. }
  5478. });
  5479. this.text.css(textStyles);
  5480. isWidth = 'width' in textStyles;
  5481. isFontStyle = 'fontSize' in textStyles ||
  5482. 'fontWeight' in textStyles;
  5483. // Update existing text, box (#9400, #12163)
  5484. if (isWidth || isFontStyle) {
  5485. this.updateBoxSize();
  5486. // Keep updated (#9400, #12163)
  5487. if (isFontStyle) {
  5488. this.updateTextPadding();
  5489. }
  5490. }
  5491. }
  5492. return SVGElement.prototype.css.call(this, styles);
  5493. };
  5494. /*
  5495. * Destroy and release memory.
  5496. */
  5497. SVGLabel.prototype.destroy = function () {
  5498. // Added by button implementation
  5499. removeEvent(this.element, 'mouseenter');
  5500. removeEvent(this.element, 'mouseleave');
  5501. if (this.text) {
  5502. this.text.destroy();
  5503. }
  5504. if (this.box) {
  5505. this.box = this.box.destroy();
  5506. }
  5507. // Call base implementation to destroy the rest
  5508. SVGElement.prototype.destroy.call(this);
  5509. return void 0;
  5510. };
  5511. SVGLabel.prototype.fillSetter = function (value, key) {
  5512. if (value) {
  5513. this.needsBox = true;
  5514. }
  5515. // for animation getter (#6776)
  5516. this.fill = value;
  5517. this.boxAttr(key, value);
  5518. };
  5519. /*
  5520. * Return the bounding box of the box, not the group.
  5521. */
  5522. SVGLabel.prototype.getBBox = function () {
  5523. var bBox = this.bBox;
  5524. var padding = this.padding;
  5525. return {
  5526. width: bBox.width + 2 * padding,
  5527. height: bBox.height + 2 * padding,
  5528. x: bBox.x - padding,
  5529. y: bBox.y - padding
  5530. };
  5531. };
  5532. SVGLabel.prototype.getCrispAdjust = function () {
  5533. return this.renderer.styledMode && this.box ?
  5534. this.box.strokeWidth() % 2 / 2 :
  5535. (this['stroke-width'] ? parseInt(this['stroke-width'], 10) : 0) % 2 / 2;
  5536. };
  5537. SVGLabel.prototype.heightSetter = function (value) {
  5538. this.heightSetting = value;
  5539. };
  5540. // Event handling. In case of useHTML, we need to make sure that events
  5541. // are captured on the span as well, and that mouseenter/mouseleave
  5542. // between the SVG group and the HTML span are not treated as real
  5543. // enter/leave events. #13310.
  5544. SVGLabel.prototype.on = function (eventType, handler) {
  5545. var label = this;
  5546. var text = label.text;
  5547. var span = text && text.element.tagName === 'SPAN' ? text : void 0;
  5548. var selectiveHandler;
  5549. if (span) {
  5550. selectiveHandler = function (e) {
  5551. if ((eventType === 'mouseenter' ||
  5552. eventType === 'mouseleave') &&
  5553. e.relatedTarget instanceof Element &&
  5554. (label.element.contains(e.relatedTarget) ||
  5555. span.element.contains(e.relatedTarget))) {
  5556. return;
  5557. }
  5558. handler.call(label.element, e);
  5559. };
  5560. span.on(eventType, selectiveHandler);
  5561. }
  5562. SVGElement.prototype.on.call(label, eventType, selectiveHandler || handler);
  5563. return label;
  5564. };
  5565. /*
  5566. * After the text element is added, get the desired size of the border
  5567. * box and add it before the text in the DOM.
  5568. */
  5569. SVGLabel.prototype.onAdd = function () {
  5570. var str = this.textStr;
  5571. this.text.add(this);
  5572. this.attr({
  5573. // Alignment is available now (#3295, 0 not rendered if given
  5574. // as a value)
  5575. text: (defined(str) ? str : ''),
  5576. x: this.x,
  5577. y: this.y
  5578. });
  5579. if (this.box && defined(this.anchorX)) {
  5580. this.attr({
  5581. anchorX: this.anchorX,
  5582. anchorY: this.anchorY
  5583. });
  5584. }
  5585. };
  5586. SVGLabel.prototype.paddingSetter = function (value) {
  5587. if (defined(value) && value !== this.padding) {
  5588. this.padding = value;
  5589. this.updateTextPadding();
  5590. }
  5591. };
  5592. SVGLabel.prototype.paddingLeftSetter = function (value) {
  5593. if (defined(value) && value !== this.paddingLeft) {
  5594. this.paddingLeft = value;
  5595. this.updateTextPadding();
  5596. }
  5597. };
  5598. SVGLabel.prototype.rSetter = function (value, key) {
  5599. this.boxAttr(key, value);
  5600. };
  5601. SVGLabel.prototype.shadow = function (b) {
  5602. if (b && !this.renderer.styledMode) {
  5603. this.updateBoxSize();
  5604. if (this.box) {
  5605. this.box.shadow(b);
  5606. }
  5607. }
  5608. return this;
  5609. };
  5610. SVGLabel.prototype.strokeSetter = function (value, key) {
  5611. // for animation getter (#6776)
  5612. this.stroke = value;
  5613. this.boxAttr(key, value);
  5614. };
  5615. SVGLabel.prototype['stroke-widthSetter'] = function (value, key) {
  5616. if (value) {
  5617. this.needsBox = true;
  5618. }
  5619. this['stroke-width'] = value;
  5620. this.boxAttr(key, value);
  5621. };
  5622. SVGLabel.prototype['text-alignSetter'] = function (value) {
  5623. this.textAlign = value;
  5624. };
  5625. SVGLabel.prototype.textSetter = function (text) {
  5626. if (typeof text !== 'undefined') {
  5627. // Must use .attr to ensure transforms are done (#10009)
  5628. this.text.attr({ text: text });
  5629. }
  5630. this.updateBoxSize();
  5631. this.updateTextPadding();
  5632. };
  5633. /*
  5634. * This function runs after the label is added to the DOM (when the bounding
  5635. * box is available), and after the text of the label is updated to detect
  5636. * the new bounding box and reflect it in the border box.
  5637. */
  5638. SVGLabel.prototype.updateBoxSize = function () {
  5639. var style = this.text.element.style, crispAdjust, attribs = {};
  5640. var padding = this.padding;
  5641. var paddingLeft = this.paddingLeft;
  5642. // #12165 error when width is null (auto)
  5643. // #12163 when fontweight: bold, recalculate bBox withot cache
  5644. // #3295 && 3514 box failure when string equals 0
  5645. var bBox = ((!isNumber(this.widthSetting) || !isNumber(this.heightSetting) || this.textAlign) &&
  5646. defined(this.text.textStr)) ?
  5647. this.text.getBBox() : SVGLabel.emptyBBox;
  5648. this.width = ((this.widthSetting || bBox.width || 0) +
  5649. 2 * padding +
  5650. paddingLeft);
  5651. this.height = (this.heightSetting || bBox.height || 0) + 2 * padding;
  5652. // Update the label-scoped y offset. Math.min because of inline
  5653. // style (#9400)
  5654. this.baselineOffset = padding + Math.min(this.renderer.fontMetrics(style && style.fontSize, this.text).b,
  5655. // When the height is 0, there is no bBox, so go with the font
  5656. // metrics. Highmaps CSS demos.
  5657. bBox.height || Infinity);
  5658. if (this.needsBox) {
  5659. // Create the border box if it is not already present
  5660. if (!this.box) {
  5661. // Symbol definition exists (#5324)
  5662. var box = this.box = this.symbolKey ?
  5663. this.renderer.symbol(this.symbolKey) :
  5664. this.renderer.rect();
  5665. box.addClass(// Don't use label className for buttons
  5666. (this.className === 'button' ? '' : 'highcharts-label-box') +
  5667. (this.className ? ' highcharts-' + this.className + '-box' : ''));
  5668. box.add(this);
  5669. crispAdjust = this.getCrispAdjust();
  5670. attribs.x = crispAdjust;
  5671. attribs.y = (this.baseline ? -this.baselineOffset : 0) + crispAdjust;
  5672. }
  5673. // Apply the box attributes
  5674. attribs.width = Math.round(this.width);
  5675. attribs.height = Math.round(this.height);
  5676. this.box.attr(extend(attribs, this.deferredAttr));
  5677. this.deferredAttr = {};
  5678. }
  5679. this.bBox = bBox;
  5680. };
  5681. /*
  5682. * This function runs after setting text or padding, but only if padding
  5683. * is changed.
  5684. */
  5685. SVGLabel.prototype.updateTextPadding = function () {
  5686. var text = this.text;
  5687. // Determine y based on the baseline
  5688. var textY = this.baseline ? 0 : this.baselineOffset;
  5689. var textX = this.paddingLeft + this.padding;
  5690. // compensate for alignment
  5691. if (defined(this.widthSetting) &&
  5692. this.bBox &&
  5693. (this.textAlign === 'center' || this.textAlign === 'right')) {
  5694. textX += { center: 0.5, right: 1 }[this.textAlign] *
  5695. (this.widthSetting - this.bBox.width);
  5696. }
  5697. // update if anything changed
  5698. if (textX !== text.x || textY !== text.y) {
  5699. text.attr('x', textX);
  5700. // #8159 - prevent misplaced data labels in treemap
  5701. // (useHTML: true)
  5702. if (text.hasBoxWidthChanged) {
  5703. this.bBox = text.getBBox(true);
  5704. this.updateBoxSize();
  5705. }
  5706. if (typeof textY !== 'undefined') {
  5707. text.attr('y', textY);
  5708. }
  5709. }
  5710. // record current values
  5711. text.x = textX;
  5712. text.y = textY;
  5713. };
  5714. SVGLabel.prototype.widthSetter = function (value) {
  5715. // width:auto => null
  5716. this.widthSetting = isNumber(value) ? value : void 0;
  5717. };
  5718. SVGLabel.prototype.xSetter = function (value) {
  5719. this.x = value; // for animation getter
  5720. if (this.alignFactor) {
  5721. value -= this.alignFactor * ((this.widthSetting || this.bBox.width) +
  5722. 2 * this.padding);
  5723. // Force animation even when setting to the same value (#7898)
  5724. this['forceAnimate:x'] = true;
  5725. }
  5726. this.xSetting = Math.round(value);
  5727. this.attr('translateX', this.xSetting);
  5728. };
  5729. SVGLabel.prototype.ySetter = function (value) {
  5730. this.ySetting = this.y = Math.round(value);
  5731. this.attr('translateY', this.ySetting);
  5732. };
  5733. /* *
  5734. *
  5735. * Static Properties
  5736. *
  5737. * */
  5738. SVGLabel.emptyBBox = { width: 0, height: 0, x: 0, y: 0 };
  5739. /* *
  5740. *
  5741. * Properties
  5742. *
  5743. * */
  5744. /**
  5745. * For labels, these CSS properties are applied to the `text` node directly.
  5746. *
  5747. * @private
  5748. * @name Highcharts.SVGLabel#textProps
  5749. * @type {Array<string>}
  5750. */
  5751. SVGLabel.textProps = [
  5752. 'color', 'cursor', 'direction', 'fontFamily', 'fontSize', 'fontStyle',
  5753. 'fontWeight', 'lineHeight', 'textAlign', 'textDecoration',
  5754. 'textOutline', 'textOverflow', 'width'
  5755. ];
  5756. return SVGLabel;
  5757. }(SVGElement));
  5758. return SVGLabel;
  5759. });
  5760. _registerModule(_modules, 'parts/SVGRenderer.js', [_modules['parts/Color.js'], _modules['parts/Globals.js'], _modules['parts/SVGElement.js'], _modules['parts/SVGLabel.js'], _modules['parts/Utilities.js']], function (Color, H, SVGElement, SVGLabel, U) {
  5761. /* *
  5762. *
  5763. * (c) 2010-2020 Torstein Honsi
  5764. *
  5765. * License: www.highcharts.com/license
  5766. *
  5767. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5768. *
  5769. * */
  5770. var addEvent = U.addEvent, attr = U.attr, createElement = U.createElement, css = U.css, defined = U.defined, destroyObjectProperties = U.destroyObjectProperties, erase = U.erase, extend = U.extend, isArray = U.isArray, isNumber = U.isNumber, isObject = U.isObject, isString = U.isString, merge = U.merge, objectEach = U.objectEach, pick = U.pick, pInt = U.pInt, removeEvent = U.removeEvent, splat = U.splat, stop = U.stop, uniqueKey = U.uniqueKey;
  5771. /**
  5772. * A clipping rectangle that can be applied to one or more {@link SVGElement}
  5773. * instances. It is instanciated with the {@link SVGRenderer#clipRect} function
  5774. * and applied with the {@link SVGElement#clip} function.
  5775. *
  5776. * @example
  5777. * var circle = renderer.circle(100, 100, 100)
  5778. * .attr({ fill: 'red' })
  5779. * .add();
  5780. * var clipRect = renderer.clipRect(100, 100, 100, 100);
  5781. *
  5782. * // Leave only the lower right quarter visible
  5783. * circle.clip(clipRect);
  5784. *
  5785. * @typedef {Highcharts.SVGElement} Highcharts.ClipRectElement
  5786. */
  5787. /**
  5788. * The font metrics.
  5789. *
  5790. * @interface Highcharts.FontMetricsObject
  5791. */ /**
  5792. * The baseline relative to the top of the box.
  5793. *
  5794. * @name Highcharts.FontMetricsObject#b
  5795. * @type {number}
  5796. */ /**
  5797. * The font size.
  5798. *
  5799. * @name Highcharts.FontMetricsObject#f
  5800. * @type {number}
  5801. */ /**
  5802. * The line height.
  5803. *
  5804. * @name Highcharts.FontMetricsObject#h
  5805. * @type {number}
  5806. */
  5807. /**
  5808. * An object containing `x` and `y` properties for the position of an element.
  5809. *
  5810. * @interface Highcharts.PositionObject
  5811. */ /**
  5812. * X position of the element.
  5813. * @name Highcharts.PositionObject#x
  5814. * @type {number}
  5815. */ /**
  5816. * Y position of the element.
  5817. * @name Highcharts.PositionObject#y
  5818. * @type {number}
  5819. */
  5820. /**
  5821. * A rectangle.
  5822. *
  5823. * @interface Highcharts.RectangleObject
  5824. */ /**
  5825. * Height of the rectangle.
  5826. * @name Highcharts.RectangleObject#height
  5827. * @type {number}
  5828. */ /**
  5829. * Width of the rectangle.
  5830. * @name Highcharts.RectangleObject#width
  5831. * @type {number}
  5832. */ /**
  5833. * Horizontal position of the rectangle.
  5834. * @name Highcharts.RectangleObject#x
  5835. * @type {number}
  5836. */ /**
  5837. * Vertical position of the rectangle.
  5838. * @name Highcharts.RectangleObject#y
  5839. * @type {number}
  5840. */
  5841. /**
  5842. * The shadow options.
  5843. *
  5844. * @interface Highcharts.ShadowOptionsObject
  5845. */ /**
  5846. * The shadow color.
  5847. * @name Highcharts.ShadowOptionsObject#color
  5848. * @type {Highcharts.ColorString|undefined}
  5849. * @default #000000
  5850. */ /**
  5851. * The horizontal offset from the element.
  5852. *
  5853. * @name Highcharts.ShadowOptionsObject#offsetX
  5854. * @type {number|undefined}
  5855. * @default 1
  5856. */ /**
  5857. * The vertical offset from the element.
  5858. * @name Highcharts.ShadowOptionsObject#offsetY
  5859. * @type {number|undefined}
  5860. * @default 1
  5861. */ /**
  5862. * The shadow opacity.
  5863. *
  5864. * @name Highcharts.ShadowOptionsObject#opacity
  5865. * @type {number|undefined}
  5866. * @default 0.15
  5867. */ /**
  5868. * The shadow width or distance from the element.
  5869. * @name Highcharts.ShadowOptionsObject#width
  5870. * @type {number|undefined}
  5871. * @default 3
  5872. */
  5873. /**
  5874. * @interface Highcharts.SizeObject
  5875. */ /**
  5876. * @name Highcharts.SizeObject#height
  5877. * @type {number}
  5878. */ /**
  5879. * @name Highcharts.SizeObject#width
  5880. * @type {number}
  5881. */
  5882. /**
  5883. * Serialized form of an SVG definition, including children. Some key
  5884. * property names are reserved: tagName, textContent, and children.
  5885. *
  5886. * @interface Highcharts.SVGDefinitionObject
  5887. */ /**
  5888. * @name Highcharts.SVGDefinitionObject#[key:string]
  5889. * @type {boolean|number|string|Array<Highcharts.SVGDefinitionObject>|undefined}
  5890. */ /**
  5891. * @name Highcharts.SVGDefinitionObject#children
  5892. * @type {Array<Highcharts.SVGDefinitionObject>|undefined}
  5893. */ /**
  5894. * @name Highcharts.SVGDefinitionObject#tagName
  5895. * @type {string|undefined}
  5896. */ /**
  5897. * @name Highcharts.SVGDefinitionObject#textContent
  5898. * @type {string|undefined}
  5899. */
  5900. /**
  5901. * Array of path commands, that will go into the `d` attribute of an SVG
  5902. * element.
  5903. *
  5904. * @typedef {Array<Array<Highcharts.SVGPathCommand,number?,number?,number?,number?,number?,number?,number?>>} Highcharts.SVGPathArray
  5905. */
  5906. /**
  5907. * Possible path commands in an SVG path array. Valid values are `A`, `C`, `H`,
  5908. * `L`, `M`, `Q`, `S`, `T`, `V`, `Z`.
  5909. *
  5910. * @typedef {string} Highcharts.SVGPathCommand
  5911. * @validvalue ["a","c","h","l","m","q","s","t","v","z","A","C","H","L","M","Q","S","T","V","Z"]
  5912. */
  5913. /**
  5914. * An extendable collection of functions for defining symbol paths. Symbols are
  5915. * used internally for point markers, button and label borders and backgrounds,
  5916. * or custom shapes. Extendable by adding to {@link SVGRenderer#symbols}.
  5917. *
  5918. * @interface Highcharts.SymbolDictionary
  5919. */ /**
  5920. * @name Highcharts.SymbolDictionary#[key:string]
  5921. * @type {Function|undefined}
  5922. */ /**
  5923. * @name Highcharts.SymbolDictionary#arc
  5924. * @type {Function|undefined}
  5925. */ /**
  5926. * @name Highcharts.SymbolDictionary#callout
  5927. * @type {Function|undefined}
  5928. */ /**
  5929. * @name Highcharts.SymbolDictionary#circle
  5930. * @type {Function|undefined}
  5931. */ /**
  5932. * @name Highcharts.SymbolDictionary#diamond
  5933. * @type {Function|undefined}
  5934. */ /**
  5935. * @name Highcharts.SymbolDictionary#square
  5936. * @type {Function|undefined}
  5937. */ /**
  5938. * @name Highcharts.SymbolDictionary#triangle
  5939. * @type {Function|undefined}
  5940. */
  5941. /**
  5942. * Can be one of `arc`, `callout`, `circle`, `diamond`, `square`, `triangle`,
  5943. * and `triangle-down`. Symbols are used internally for point markers, button
  5944. * and label borders and backgrounds, or custom shapes. Extendable by adding to
  5945. * {@link SVGRenderer#symbols}.
  5946. *
  5947. * @typedef {"arc"|"callout"|"circle"|"diamond"|"square"|"triangle"|"triangle-down"} Highcharts.SymbolKeyValue
  5948. */
  5949. /**
  5950. * Additional options, depending on the actual symbol drawn.
  5951. *
  5952. * @interface Highcharts.SymbolOptionsObject
  5953. */ /**
  5954. * The anchor X position for the `callout` symbol. This is where the chevron
  5955. * points to.
  5956. *
  5957. * @name Highcharts.SymbolOptionsObject#anchorX
  5958. * @type {number|undefined}
  5959. */ /**
  5960. * The anchor Y position for the `callout` symbol. This is where the chevron
  5961. * points to.
  5962. *
  5963. * @name Highcharts.SymbolOptionsObject#anchorY
  5964. * @type {number|undefined}
  5965. */ /**
  5966. * The end angle of an `arc` symbol.
  5967. *
  5968. * @name Highcharts.SymbolOptionsObject#end
  5969. * @type {number|undefined}
  5970. */ /**
  5971. * Whether to draw `arc` symbol open or closed.
  5972. *
  5973. * @name Highcharts.SymbolOptionsObject#open
  5974. * @type {boolean|undefined}
  5975. */ /**
  5976. * The radius of an `arc` symbol, or the border radius for the `callout` symbol.
  5977. *
  5978. * @name Highcharts.SymbolOptionsObject#r
  5979. * @type {number|undefined}
  5980. */ /**
  5981. * The start angle of an `arc` symbol.
  5982. *
  5983. * @name Highcharts.SymbolOptionsObject#start
  5984. * @type {number|undefined}
  5985. */
  5986. /* eslint-disable no-invalid-this, valid-jsdoc */
  5987. var charts = H.charts, deg2rad = H.deg2rad, doc = H.doc, isFirefox = H.isFirefox, isMS = H.isMS, isWebKit = H.isWebKit, noop = H.noop, svg = H.svg, SVG_NS = H.SVG_NS, symbolSizes = H.symbolSizes, win = H.win;
  5988. /**
  5989. * Allows direct access to the Highcharts rendering layer in order to draw
  5990. * primitive shapes like circles, rectangles, paths or text directly on a chart,
  5991. * or independent from any chart. The SVGRenderer represents a wrapper object
  5992. * for SVG in modern browsers. Through the VMLRenderer, part of the `oldie.js`
  5993. * module, it also brings vector graphics to IE <= 8.
  5994. *
  5995. * An existing chart's renderer can be accessed through {@link Chart.renderer}.
  5996. * The renderer can also be used completely decoupled from a chart.
  5997. *
  5998. * @sample highcharts/members/renderer-on-chart
  5999. * Annotating a chart programmatically.
  6000. * @sample highcharts/members/renderer-basic
  6001. * Independent SVG drawing.
  6002. *
  6003. * @example
  6004. * // Use directly without a chart object.
  6005. * var renderer = new Highcharts.Renderer(parentNode, 600, 400);
  6006. *
  6007. * @class
  6008. * @name Highcharts.SVGRenderer
  6009. *
  6010. * @param {Highcharts.HTMLDOMElement} container
  6011. * Where to put the SVG in the web page.
  6012. *
  6013. * @param {number} width
  6014. * The width of the SVG.
  6015. *
  6016. * @param {number} height
  6017. * The height of the SVG.
  6018. *
  6019. * @param {Highcharts.CSSObject} [style]
  6020. * The box style, if not in styleMode
  6021. *
  6022. * @param {boolean} [forExport=false]
  6023. * Whether the rendered content is intended for export.
  6024. *
  6025. * @param {boolean} [allowHTML=true]
  6026. * Whether the renderer is allowed to include HTML text, which will be
  6027. * projected on top of the SVG.
  6028. *
  6029. * @param {boolean} [styledMode=false]
  6030. * Whether the renderer belongs to a chart that is in styled mode.
  6031. * If it does, it will avoid setting presentational attributes in
  6032. * some cases, but not when set explicitly through `.attr` and `.css`
  6033. * etc.
  6034. */
  6035. var SVGRenderer = /** @class */ (function () {
  6036. /* *
  6037. *
  6038. * Constructors
  6039. *
  6040. * */
  6041. function SVGRenderer(container, width, height, style, forExport, allowHTML, styledMode) {
  6042. /* *
  6043. *
  6044. * Properties
  6045. *
  6046. * */
  6047. this.alignedObjects = void 0;
  6048. /**
  6049. * The root `svg` node of the renderer.
  6050. *
  6051. * @name Highcharts.SVGRenderer#box
  6052. * @type {Highcharts.SVGDOMElement}
  6053. */
  6054. this.box = void 0;
  6055. /**
  6056. * The wrapper for the root `svg` node of the renderer.
  6057. *
  6058. * @name Highcharts.SVGRenderer#boxWrapper
  6059. * @type {Highcharts.SVGElement}
  6060. */
  6061. this.boxWrapper = void 0;
  6062. this.cache = void 0;
  6063. this.cacheKeys = void 0;
  6064. this.chartIndex = void 0;
  6065. /**
  6066. * A pointer to the `defs` node of the root SVG.
  6067. *
  6068. * @name Highcharts.SVGRenderer#defs
  6069. * @type {Highcharts.SVGElement}
  6070. */
  6071. this.defs = void 0;
  6072. this.globalAnimation = void 0;
  6073. this.gradients = void 0;
  6074. this.height = void 0;
  6075. this.imgCount = void 0;
  6076. this.isSVG = void 0;
  6077. this.style = void 0;
  6078. /**
  6079. * Page url used for internal references.
  6080. *
  6081. * @private
  6082. * @name Highcharts.SVGRenderer#url
  6083. * @type {string}
  6084. */
  6085. this.url = void 0;
  6086. this.width = void 0;
  6087. this.init(container, width, height, style, forExport, allowHTML, styledMode);
  6088. }
  6089. /* *
  6090. *
  6091. * Functions
  6092. *
  6093. * */
  6094. /**
  6095. * Initialize the SVGRenderer. Overridable initializer function that takes
  6096. * the same parameters as the constructor.
  6097. *
  6098. * @function Highcharts.SVGRenderer#init
  6099. *
  6100. * @param {Highcharts.HTMLDOMElement} container
  6101. * Where to put the SVG in the web page.
  6102. *
  6103. * @param {number} width
  6104. * The width of the SVG.
  6105. *
  6106. * @param {number} height
  6107. * The height of the SVG.
  6108. *
  6109. * @param {Highcharts.CSSObject} [style]
  6110. * The box style, if not in styleMode
  6111. *
  6112. * @param {boolean} [forExport=false]
  6113. * Whether the rendered content is intended for export.
  6114. *
  6115. * @param {boolean} [allowHTML=true]
  6116. * Whether the renderer is allowed to include HTML text, which will be
  6117. * projected on top of the SVG.
  6118. *
  6119. * @param {boolean} [styledMode=false]
  6120. * Whether the renderer belongs to a chart that is in styled mode. If it
  6121. * does, it will avoid setting presentational attributes in some cases, but
  6122. * not when set explicitly through `.attr` and `.css` etc.
  6123. */
  6124. SVGRenderer.prototype.init = function (container, width, height, style, forExport, allowHTML, styledMode) {
  6125. var renderer = this, boxWrapper, element, desc;
  6126. boxWrapper = renderer.createElement('svg')
  6127. .attr({
  6128. version: '1.1',
  6129. 'class': 'highcharts-root'
  6130. });
  6131. if (!styledMode) {
  6132. boxWrapper.css(this.getStyle(style));
  6133. }
  6134. element = boxWrapper.element;
  6135. container.appendChild(element);
  6136. // Always use ltr on the container, otherwise text-anchor will be
  6137. // flipped and text appear outside labels, buttons, tooltip etc (#3482)
  6138. attr(container, 'dir', 'ltr');
  6139. // For browsers other than IE, add the namespace attribute (#1978)
  6140. if (container.innerHTML.indexOf('xmlns') === -1) {
  6141. attr(element, 'xmlns', this.SVG_NS);
  6142. }
  6143. // object properties
  6144. renderer.isSVG = true;
  6145. this.box = element;
  6146. this.boxWrapper = boxWrapper;
  6147. renderer.alignedObjects = [];
  6148. // #24, #672, #1070
  6149. this.url = ((isFirefox || isWebKit) &&
  6150. doc.getElementsByTagName('base').length) ?
  6151. win.location.href
  6152. .split('#')[0] // remove the hash
  6153. .replace(/<[^>]*>/g, '') // wing cut HTML
  6154. // escape parantheses and quotes
  6155. .replace(/([\('\)])/g, '\\$1')
  6156. // replace spaces (needed for Safari only)
  6157. .replace(/ /g, '%20') :
  6158. '';
  6159. // Add description
  6160. desc = this.createElement('desc').add();
  6161. desc.element.appendChild(doc.createTextNode('Created with Highcharts 8.1.2'));
  6162. renderer.defs = this.createElement('defs').add();
  6163. renderer.allowHTML = allowHTML;
  6164. renderer.forExport = forExport;
  6165. renderer.styledMode = styledMode;
  6166. renderer.gradients = {}; // Object where gradient SvgElements are stored
  6167. renderer.cache = {}; // Cache for numerical bounding boxes
  6168. renderer.cacheKeys = [];
  6169. renderer.imgCount = 0;
  6170. renderer.setSize(width, height, false);
  6171. // Issue 110 workaround:
  6172. // In Firefox, if a div is positioned by percentage, its pixel position
  6173. // may land between pixels. The container itself doesn't display this,
  6174. // but an SVG element inside this container will be drawn at subpixel
  6175. // precision. In order to draw sharp lines, this must be compensated
  6176. // for. This doesn't seem to work inside iframes though (like in
  6177. // jsFiddle).
  6178. var subPixelFix, rect;
  6179. if (isFirefox && container.getBoundingClientRect) {
  6180. subPixelFix = function () {
  6181. css(container, { left: 0, top: 0 });
  6182. rect = container.getBoundingClientRect();
  6183. css(container, {
  6184. left: (Math.ceil(rect.left) - rect.left) + 'px',
  6185. top: (Math.ceil(rect.top) - rect.top) + 'px'
  6186. });
  6187. };
  6188. // run the fix now
  6189. subPixelFix();
  6190. // run it on resize
  6191. renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
  6192. }
  6193. };
  6194. /**
  6195. * General method for adding a definition to the SVG `defs` tag. Can be used
  6196. * for gradients, fills, filters etc. Styled mode only. A hook for adding
  6197. * general definitions to the SVG's defs tag. Definitions can be referenced
  6198. * from the CSS by its `id`. Read more in
  6199. * [gradients, shadows and patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns).
  6200. * Styled mode only.
  6201. *
  6202. * @function Highcharts.SVGRenderer#definition
  6203. *
  6204. * @param {Highcharts.SVGDefinitionObject} def
  6205. * A serialized form of an SVG definition, including children.
  6206. *
  6207. * @return {Highcharts.SVGElement}
  6208. * The inserted node.
  6209. */
  6210. SVGRenderer.prototype.definition = function (def) {
  6211. var ren = this;
  6212. /**
  6213. * @private
  6214. * @param {Highcharts.SVGDefinitionObject} config - SVG definition
  6215. * @param {Highcharts.SVGElement} [parent] - parent node
  6216. */
  6217. function recurse(config, parent) {
  6218. var ret;
  6219. splat(config).forEach(function (item) {
  6220. var node = ren.createElement(item.tagName), attr = {};
  6221. // Set attributes
  6222. objectEach(item, function (val, key) {
  6223. if (key !== 'tagName' &&
  6224. key !== 'children' &&
  6225. key !== 'textContent') {
  6226. attr[key] = val;
  6227. }
  6228. });
  6229. node.attr(attr);
  6230. // Add to the tree
  6231. node.add(parent || ren.defs);
  6232. // Add text content
  6233. if (item.textContent) {
  6234. node.element.appendChild(doc.createTextNode(item.textContent));
  6235. }
  6236. // Recurse
  6237. recurse(item.children || [], node);
  6238. ret = node;
  6239. });
  6240. // Return last node added (on top level it's the only one)
  6241. return ret;
  6242. }
  6243. return recurse(def);
  6244. };
  6245. /**
  6246. * Get the global style setting for the renderer.
  6247. *
  6248. * @private
  6249. * @function Highcharts.SVGRenderer#getStyle
  6250. *
  6251. * @param {Highcharts.CSSObject} style
  6252. * Style settings.
  6253. *
  6254. * @return {Highcharts.CSSObject}
  6255. * The style settings mixed with defaults.
  6256. */
  6257. SVGRenderer.prototype.getStyle = function (style) {
  6258. this.style = extend({
  6259. fontFamily: '"Lucida Grande", "Lucida Sans Unicode", ' +
  6260. 'Arial, Helvetica, sans-serif',
  6261. fontSize: '12px'
  6262. }, style);
  6263. return this.style;
  6264. };
  6265. /**
  6266. * Apply the global style on the renderer, mixed with the default styles.
  6267. *
  6268. * @function Highcharts.SVGRenderer#setStyle
  6269. *
  6270. * @param {Highcharts.CSSObject} style
  6271. * CSS to apply.
  6272. */
  6273. SVGRenderer.prototype.setStyle = function (style) {
  6274. this.boxWrapper.css(this.getStyle(style));
  6275. };
  6276. /**
  6277. * Detect whether the renderer is hidden. This happens when one of the
  6278. * parent elements has `display: none`. Used internally to detect when we
  6279. * needto render preliminarily in another div to get the text bounding boxes
  6280. * right.
  6281. *
  6282. * @function Highcharts.SVGRenderer#isHidden
  6283. *
  6284. * @return {boolean}
  6285. * True if it is hidden.
  6286. */
  6287. SVGRenderer.prototype.isHidden = function () {
  6288. return !this.boxWrapper.getBBox().width;
  6289. };
  6290. /**
  6291. * Destroys the renderer and its allocated members.
  6292. *
  6293. * @function Highcharts.SVGRenderer#destroy
  6294. *
  6295. * @return {null}
  6296. */
  6297. SVGRenderer.prototype.destroy = function () {
  6298. var renderer = this, rendererDefs = renderer.defs;
  6299. renderer.box = null;
  6300. renderer.boxWrapper = renderer.boxWrapper.destroy();
  6301. // Call destroy on all gradient elements
  6302. destroyObjectProperties(renderer.gradients || {});
  6303. renderer.gradients = null;
  6304. // Defs are null in VMLRenderer
  6305. // Otherwise, destroy them here.
  6306. if (rendererDefs) {
  6307. renderer.defs = rendererDefs.destroy();
  6308. }
  6309. // Remove sub pixel fix handler (#982)
  6310. if (renderer.unSubPixelFix) {
  6311. renderer.unSubPixelFix();
  6312. }
  6313. renderer.alignedObjects = null;
  6314. return null;
  6315. };
  6316. /**
  6317. * Create a wrapper for an SVG element. Serves as a factory for
  6318. * {@link SVGElement}, but this function is itself mostly called from
  6319. * primitive factories like {@link SVGRenderer#path}, {@link
  6320. * SVGRenderer#rect} or {@link SVGRenderer#text}.
  6321. *
  6322. * @function Highcharts.SVGRenderer#createElement
  6323. *
  6324. * @param {string} nodeName
  6325. * The node name, for example `rect`, `g` etc.
  6326. *
  6327. * @return {Highcharts.SVGElement}
  6328. * The generated SVGElement.
  6329. */
  6330. SVGRenderer.prototype.createElement = function (nodeName) {
  6331. var wrapper = new this.Element();
  6332. wrapper.init(this, nodeName);
  6333. return wrapper;
  6334. };
  6335. /**
  6336. * Get converted radial gradient attributes according to the radial
  6337. * reference. Used internally from the {@link SVGElement#colorGradient}
  6338. * function.
  6339. *
  6340. * @private
  6341. * @function Highcharts.SVGRenderer#getRadialAttr
  6342. */
  6343. SVGRenderer.prototype.getRadialAttr = function (radialReference, gradAttr) {
  6344. return {
  6345. cx: (radialReference[0] - radialReference[2] / 2) +
  6346. gradAttr.cx * radialReference[2],
  6347. cy: (radialReference[1] - radialReference[2] / 2) +
  6348. gradAttr.cy * radialReference[2],
  6349. r: gradAttr.r * radialReference[2]
  6350. };
  6351. };
  6352. /**
  6353. * Truncate the text node contents to a given length. Used when the css
  6354. * width is set. If the `textOverflow` is `ellipsis`, the text is truncated
  6355. * character by character to the given length. If not, the text is
  6356. * word-wrapped line by line.
  6357. *
  6358. * @private
  6359. * @function Highcharts.SVGRenderer#truncate
  6360. *
  6361. * @return {boolean}
  6362. * True if tspan is too long.
  6363. */
  6364. SVGRenderer.prototype.truncate = function (wrapper, tspan, text, words, startAt, width, getString) {
  6365. var renderer = this, rotation = wrapper.rotation, str,
  6366. // Word wrap can not be truncated to shorter than one word, ellipsis
  6367. // text can be completely blank.
  6368. minIndex = words ? 1 : 0, maxIndex = (text || words).length, currentIndex = maxIndex,
  6369. // Cache the lengths to avoid checking the same twice
  6370. lengths = [], updateTSpan = function (s) {
  6371. if (tspan.firstChild) {
  6372. tspan.removeChild(tspan.firstChild);
  6373. }
  6374. if (s) {
  6375. tspan.appendChild(doc.createTextNode(s));
  6376. }
  6377. }, getSubStringLength = function (charEnd, concatenatedEnd) {
  6378. // charEnd is useed when finding the character-by-character
  6379. // break for ellipsis, concatenatedEnd is used for word-by-word
  6380. // break for word wrapping.
  6381. var end = concatenatedEnd || charEnd;
  6382. if (typeof lengths[end] === 'undefined') {
  6383. // Modern browsers
  6384. if (tspan.getSubStringLength) {
  6385. // Fails with DOM exception on unit-tests/legend/members
  6386. // of unknown reason. Desired width is 0, text content
  6387. // is "5" and end is 1.
  6388. try {
  6389. lengths[end] = startAt +
  6390. tspan.getSubStringLength(0, words ? end + 1 : end);
  6391. }
  6392. catch (e) {
  6393. '';
  6394. }
  6395. // Legacy
  6396. }
  6397. else if (renderer.getSpanWidth) { // #9058 jsdom
  6398. updateTSpan(getString(text || words, charEnd));
  6399. lengths[end] = startAt +
  6400. renderer.getSpanWidth(wrapper, tspan);
  6401. }
  6402. }
  6403. return lengths[end];
  6404. }, actualWidth, truncated;
  6405. wrapper.rotation = 0; // discard rotation when computing box
  6406. actualWidth = getSubStringLength(tspan.textContent.length);
  6407. truncated = startAt + actualWidth > width;
  6408. if (truncated) {
  6409. // Do a binary search for the index where to truncate the text
  6410. while (minIndex <= maxIndex) {
  6411. currentIndex = Math.ceil((minIndex + maxIndex) / 2);
  6412. // When checking words for word-wrap, we need to build the
  6413. // string and measure the subStringLength at the concatenated
  6414. // word length.
  6415. if (words) {
  6416. str = getString(words, currentIndex);
  6417. }
  6418. actualWidth = getSubStringLength(currentIndex, str && str.length - 1);
  6419. if (minIndex === maxIndex) {
  6420. // Complete
  6421. minIndex = maxIndex + 1;
  6422. }
  6423. else if (actualWidth > width) {
  6424. // Too large. Set max index to current.
  6425. maxIndex = currentIndex - 1;
  6426. }
  6427. else {
  6428. // Within width. Set min index to current.
  6429. minIndex = currentIndex;
  6430. }
  6431. }
  6432. // If max index was 0 it means the shortest possible text was also
  6433. // too large. For ellipsis that means only the ellipsis, while for
  6434. // word wrap it means the whole first word.
  6435. if (maxIndex === 0) {
  6436. // Remove ellipsis
  6437. updateTSpan('');
  6438. // If the new text length is one less than the original, we don't
  6439. // need the ellipsis
  6440. }
  6441. else if (!(text && maxIndex === text.length - 1)) {
  6442. updateTSpan(str || getString(text || words, currentIndex));
  6443. }
  6444. }
  6445. // When doing line wrapping, prepare for the next line by removing the
  6446. // items from this line.
  6447. if (words) {
  6448. words.splice(0, currentIndex);
  6449. }
  6450. wrapper.actualWidth = actualWidth;
  6451. wrapper.rotation = rotation; // Apply rotation again.
  6452. return truncated;
  6453. };
  6454. /**
  6455. * Parse a simple HTML string into SVG tspans. Called internally when text
  6456. * is set on an SVGElement. The function supports a subset of HTML tags, CSS
  6457. * text features like `width`, `text-overflow`, `white-space`, and also
  6458. * attributes like `href` and `style`.
  6459. *
  6460. * @private
  6461. * @function Highcharts.SVGRenderer#buildText
  6462. *
  6463. * @param {Highcharts.SVGElement} wrapper
  6464. * The parent SVGElement.
  6465. */
  6466. SVGRenderer.prototype.buildText = function (wrapper) {
  6467. 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) {
  6468. var fontSizeStyle;
  6469. if (!renderer.styledMode) {
  6470. fontSizeStyle =
  6471. /(px|em)$/.test(tspan && tspan.style.fontSize) ?
  6472. tspan.style.fontSize :
  6473. (fontSize || renderer.style.fontSize || 12);
  6474. }
  6475. return textLineHeight ?
  6476. pInt(textLineHeight) :
  6477. renderer.fontMetrics(fontSizeStyle,
  6478. // Get the computed size from parent if not explicit
  6479. (tspan.getAttribute('style') ? tspan : textNode)).h;
  6480. }, unescapeEntities = function (inputStr, except) {
  6481. objectEach(renderer.escapes, function (value, key) {
  6482. if (!except || except.indexOf(value) === -1) {
  6483. inputStr = inputStr.toString().replace(new RegExp(value, 'g'), key);
  6484. }
  6485. });
  6486. return inputStr;
  6487. }, parseAttribute = function (s, attr) {
  6488. var start, delimiter;
  6489. start = s.indexOf('<');
  6490. s = s.substring(start, s.indexOf('>') - start);
  6491. start = s.indexOf(attr + '=');
  6492. if (start !== -1) {
  6493. start = start + attr.length + 1;
  6494. delimiter = s.charAt(start);
  6495. if (delimiter === '"' || delimiter === "'") { // eslint-disable-line quotes
  6496. s = s.substring(start + 1);
  6497. return s.substring(0, s.indexOf(delimiter));
  6498. }
  6499. }
  6500. };
  6501. var regexMatchBreaks = /<br.*?>/g;
  6502. // The buildText code is quite heavy, so if we're not changing something
  6503. // that affects the text, skip it (#6113).
  6504. textCache = [
  6505. textStr,
  6506. ellipsis,
  6507. noWrap,
  6508. textLineHeight,
  6509. textOutline,
  6510. fontSize,
  6511. width
  6512. ].join(',');
  6513. if (textCache === wrapper.textCache) {
  6514. return;
  6515. }
  6516. wrapper.textCache = textCache;
  6517. // Remove old text
  6518. while (i--) {
  6519. textNode.removeChild(childNodes[i]);
  6520. }
  6521. // Skip tspans, add text directly to text node. The forceTSpan is a hook
  6522. // used in text outline hack.
  6523. if (!hasMarkup &&
  6524. !textOutline &&
  6525. !ellipsis &&
  6526. !width &&
  6527. (textStr.indexOf(' ') === -1 ||
  6528. (noWrap && !regexMatchBreaks.test(textStr)))) {
  6529. textNode.appendChild(doc.createTextNode(unescapeEntities(textStr)));
  6530. // Complex strings, add more logic
  6531. }
  6532. else {
  6533. if (tempParent) {
  6534. // attach it to the DOM to read offset width
  6535. tempParent.appendChild(textNode);
  6536. }
  6537. if (hasMarkup) {
  6538. lines = renderer.styledMode ? (textStr
  6539. .replace(/<(b|strong)>/g, '<span class="highcharts-strong">')
  6540. .replace(/<(i|em)>/g, '<span class="highcharts-emphasized">')) : (textStr
  6541. .replace(/<(b|strong)>/g, '<span style="font-weight:bold">')
  6542. .replace(/<(i|em)>/g, '<span style="font-style:italic">'));
  6543. lines = lines
  6544. .replace(/<a/g, '<span')
  6545. .replace(/<\/(b|strong|i|em|a)>/g, '</span>')
  6546. .split(regexMatchBreaks);
  6547. }
  6548. else {
  6549. lines = [textStr];
  6550. }
  6551. // Trim empty lines (#5261)
  6552. lines = lines.filter(function (line) {
  6553. return line !== '';
  6554. });
  6555. // build the lines
  6556. lines.forEach(function (line, lineNo) {
  6557. var spans, spanNo = 0, lineLength = 0;
  6558. line = line
  6559. // Trim to prevent useless/costly process on the spaces
  6560. // (#5258)
  6561. .replace(/^\s+|\s+$/g, '')
  6562. .replace(/<span/g, '|||<span')
  6563. .replace(/<\/span>/g, '</span>|||');
  6564. spans = line.split('|||');
  6565. spans.forEach(function buildTextSpans(span) {
  6566. if (span !== '' || spans.length === 1) {
  6567. var attributes = {}, tspan = doc.createElementNS(renderer.SVG_NS, 'tspan'), a, classAttribute, styleAttribute, // #390
  6568. hrefAttribute;
  6569. classAttribute = parseAttribute(span, 'class');
  6570. if (classAttribute) {
  6571. attr(tspan, 'class', classAttribute);
  6572. }
  6573. styleAttribute = parseAttribute(span, 'style');
  6574. if (styleAttribute) {
  6575. styleAttribute = styleAttribute.replace(/(;| |^)color([ :])/, '$1fill$2');
  6576. attr(tspan, 'style', styleAttribute);
  6577. }
  6578. // For anchors, wrap the tspan in an <a> tag and apply
  6579. // the href attribute as is (#13559). Not for export
  6580. // (#1529)
  6581. hrefAttribute = parseAttribute(span, 'href');
  6582. if (hrefAttribute && !forExport) {
  6583. if (
  6584. // Stop JavaScript links, vulnerable to XSS
  6585. hrefAttribute.split(':')[0].toLowerCase()
  6586. .indexOf('javascript') === -1) {
  6587. a = doc.createElementNS(renderer.SVG_NS, 'a');
  6588. attr(a, 'href', hrefAttribute);
  6589. attr(tspan, 'class', 'highcharts-anchor');
  6590. a.appendChild(tspan);
  6591. if (!renderer.styledMode) {
  6592. css(tspan, { cursor: 'pointer' });
  6593. }
  6594. }
  6595. }
  6596. // Strip away unsupported HTML tags (#7126)
  6597. span = unescapeEntities(span.replace(/<[a-zA-Z\/](.|\n)*?>/g, '') || ' ');
  6598. // Nested tags aren't supported, and cause crash in
  6599. // Safari (#1596)
  6600. if (span !== ' ') {
  6601. // add the text node
  6602. tspan.appendChild(doc.createTextNode(span));
  6603. // First span in a line, align it to the left
  6604. if (!spanNo) {
  6605. if (lineNo && parentX !== null) {
  6606. attributes.x = parentX;
  6607. }
  6608. }
  6609. else {
  6610. attributes.dx = 0; // #16
  6611. }
  6612. // add attributes
  6613. attr(tspan, attributes);
  6614. // Append it
  6615. textNode.appendChild(a || tspan);
  6616. // first span on subsequent line, add the line
  6617. // height
  6618. if (!spanNo && isSubsequentLine) {
  6619. // allow getting the right offset height in
  6620. // exporting in IE
  6621. if (!svg && forExport) {
  6622. css(tspan, { display: 'block' });
  6623. }
  6624. // Set the line height based on the font size of
  6625. // either the text element or the tspan element
  6626. attr(tspan, 'dy', getLineHeight(tspan));
  6627. }
  6628. // Check width and apply soft breaks or ellipsis
  6629. if (width) {
  6630. var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
  6631. hasWhiteSpace = !noWrap && (spans.length > 1 ||
  6632. lineNo ||
  6633. words.length > 1), wrapLineNo = 0, dy = getLineHeight(tspan);
  6634. if (ellipsis) {
  6635. truncated = renderer.truncate(wrapper, tspan, span, void 0, 0,
  6636. // Target width
  6637. Math.max(0,
  6638. // Substract the font face to make
  6639. // room for the ellipsis itself
  6640. width - parseInt(fontSize || 12, 10)),
  6641. // Build the text to test for
  6642. function (text, currentIndex) {
  6643. return text.substring(0, currentIndex) + '\u2026';
  6644. });
  6645. }
  6646. else if (hasWhiteSpace) {
  6647. while (words.length) {
  6648. // For subsequent lines, create tspans
  6649. // with the same style attributes as the
  6650. // parent text node.
  6651. if (words.length &&
  6652. !noWrap &&
  6653. wrapLineNo > 0) {
  6654. tspan = doc.createElementNS(SVG_NS, 'tspan');
  6655. attr(tspan, {
  6656. dy: dy,
  6657. x: parentX
  6658. });
  6659. if (styleAttribute) { // #390
  6660. attr(tspan, 'style', styleAttribute);
  6661. }
  6662. // Start by appending the full
  6663. // remaining text
  6664. tspan.appendChild(doc.createTextNode(words.join(' ')
  6665. .replace(/- /g, '-')));
  6666. textNode.appendChild(tspan);
  6667. }
  6668. // For each line, truncate the remaining
  6669. // words into the line length.
  6670. renderer.truncate(wrapper, tspan, null, words, wrapLineNo === 0 ? lineLength : 0, width,
  6671. // Build the text to test for
  6672. function (text, currentIndex) {
  6673. return words
  6674. .slice(0, currentIndex)
  6675. .join(' ')
  6676. .replace(/- /g, '-');
  6677. });
  6678. lineLength = wrapper.actualWidth;
  6679. wrapLineNo++;
  6680. }
  6681. }
  6682. }
  6683. spanNo++;
  6684. }
  6685. }
  6686. });
  6687. // To avoid beginning lines that doesn't add to the textNode
  6688. // (#6144)
  6689. isSubsequentLine = (isSubsequentLine ||
  6690. textNode.childNodes.length);
  6691. });
  6692. if (ellipsis && truncated) {
  6693. wrapper.attr('title', unescapeEntities(wrapper.textStr || '', ['&lt;', '&gt;']) // #7179
  6694. );
  6695. }
  6696. if (tempParent) {
  6697. tempParent.removeChild(textNode);
  6698. }
  6699. // Apply the text outline
  6700. if (isString(textOutline) && wrapper.applyTextOutline) {
  6701. wrapper.applyTextOutline(textOutline);
  6702. }
  6703. }
  6704. };
  6705. /**
  6706. * Returns white for dark colors and black for bright colors.
  6707. *
  6708. * @function Highcharts.SVGRenderer#getContrast
  6709. *
  6710. * @param {Highcharts.ColorString} rgba
  6711. * The color to get the contrast for.
  6712. *
  6713. * @return {Highcharts.ColorString}
  6714. * The contrast color, either `#000000` or `#FFFFFF`.
  6715. */
  6716. SVGRenderer.prototype.getContrast = function (rgba) {
  6717. rgba = Color.parse(rgba).rgba;
  6718. // The threshold may be discussed. Here's a proposal for adding
  6719. // different weight to the color channels (#6216)
  6720. rgba[0] *= 1; // red
  6721. rgba[1] *= 1.2; // green
  6722. rgba[2] *= 0.5; // blue
  6723. return rgba[0] + rgba[1] + rgba[2] >
  6724. 1.8 * 255 ?
  6725. '#000000' :
  6726. '#FFFFFF';
  6727. };
  6728. /**
  6729. * Create a button with preset states.
  6730. *
  6731. * @function Highcharts.SVGRenderer#button
  6732. *
  6733. * @param {string} text
  6734. * The text or HTML to draw.
  6735. *
  6736. * @param {number} x
  6737. * The x position of the button's left side.
  6738. *
  6739. * @param {number} y
  6740. * The y position of the button's top side.
  6741. *
  6742. * @param {Highcharts.EventCallbackFunction<Highcharts.SVGElement>} callback
  6743. * The function to execute on button click or touch.
  6744. *
  6745. * @param {Highcharts.SVGAttributes} [normalState]
  6746. * SVG attributes for the normal state.
  6747. *
  6748. * @param {Highcharts.SVGAttributes} [hoverState]
  6749. * SVG attributes for the hover state.
  6750. *
  6751. * @param {Highcharts.SVGAttributes} [pressedState]
  6752. * SVG attributes for the pressed state.
  6753. *
  6754. * @param {Highcharts.SVGAttributes} [disabledState]
  6755. * SVG attributes for the disabled state.
  6756. *
  6757. * @param {Highcharts.SymbolKeyValue} [shape=rect]
  6758. * The shape type.
  6759. *
  6760. * @param {boolean} [useHTML=false]
  6761. * Wether to use HTML to render the label.
  6762. *
  6763. * @return {Highcharts.SVGElement}
  6764. * The button element.
  6765. */
  6766. SVGRenderer.prototype.button = function (text, x, y, callback, normalState, hoverState, pressedState, disabledState, shape, useHTML) {
  6767. var label = this.label(text, x, y, shape, void 0, void 0, useHTML, void 0, 'button'), curState = 0, styledMode = this.styledMode, userNormalStyle = normalState && normalState.style || {};
  6768. // Remove stylable attributes
  6769. if (normalState && normalState.style) {
  6770. delete normalState.style;
  6771. }
  6772. // Default, non-stylable attributes
  6773. label.attr(merge({ padding: 8, r: 2 }, normalState));
  6774. if (!styledMode) {
  6775. // Presentational
  6776. var normalStyle, hoverStyle, pressedStyle, disabledStyle;
  6777. // Normal state - prepare the attributes
  6778. normalState = merge({
  6779. fill: '#f7f7f7',
  6780. stroke: '#cccccc',
  6781. 'stroke-width': 1,
  6782. style: {
  6783. color: '#333333',
  6784. cursor: 'pointer',
  6785. fontWeight: 'normal'
  6786. }
  6787. }, {
  6788. style: userNormalStyle
  6789. }, normalState);
  6790. normalStyle = normalState.style;
  6791. delete normalState.style;
  6792. // Hover state
  6793. hoverState = merge(normalState, {
  6794. fill: '#e6e6e6'
  6795. }, hoverState);
  6796. hoverStyle = hoverState.style;
  6797. delete hoverState.style;
  6798. // Pressed state
  6799. pressedState = merge(normalState, {
  6800. fill: '#e6ebf5',
  6801. style: {
  6802. color: '#000000',
  6803. fontWeight: 'bold'
  6804. }
  6805. }, pressedState);
  6806. pressedStyle = pressedState.style;
  6807. delete pressedState.style;
  6808. // Disabled state
  6809. disabledState = merge(normalState, {
  6810. style: {
  6811. color: '#cccccc'
  6812. }
  6813. }, disabledState);
  6814. disabledStyle = disabledState.style;
  6815. delete disabledState.style;
  6816. }
  6817. // Add the events. IE9 and IE10 need mouseover and mouseout to funciton
  6818. // (#667).
  6819. addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function () {
  6820. if (curState !== 3) {
  6821. label.setState(1);
  6822. }
  6823. });
  6824. addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function () {
  6825. if (curState !== 3) {
  6826. label.setState(curState);
  6827. }
  6828. });
  6829. label.setState = function (state) {
  6830. // Hover state is temporary, don't record it
  6831. if (state !== 1) {
  6832. label.state = curState = state;
  6833. }
  6834. // Update visuals
  6835. label
  6836. .removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
  6837. .addClass('highcharts-button-' +
  6838. ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
  6839. if (!styledMode) {
  6840. label
  6841. .attr([
  6842. normalState,
  6843. hoverState,
  6844. pressedState,
  6845. disabledState
  6846. ][state || 0])
  6847. .css([
  6848. normalStyle,
  6849. hoverStyle,
  6850. pressedStyle,
  6851. disabledStyle
  6852. ][state || 0]);
  6853. }
  6854. };
  6855. // Presentational attributes
  6856. if (!styledMode) {
  6857. label
  6858. .attr(normalState)
  6859. .css(extend({ cursor: 'default' }, normalStyle));
  6860. }
  6861. return label
  6862. .on('click', function (e) {
  6863. if (curState !== 3) {
  6864. callback.call(label, e);
  6865. }
  6866. });
  6867. };
  6868. /**
  6869. * Make a straight line crisper by not spilling out to neighbour pixels.
  6870. *
  6871. * @function Highcharts.SVGRenderer#crispLine
  6872. *
  6873. * @param {Highcharts.SVGPathArray} points
  6874. * The original points on the format `[['M', 0, 0], ['L', 100, 0]]`.
  6875. *
  6876. * @param {number} width
  6877. * The width of the line.
  6878. *
  6879. * @param {string} roundingFunction
  6880. * The rounding function name on the `Math` object, can be one of
  6881. * `round`, `floor` or `ceil`.
  6882. *
  6883. * @return {Highcharts.SVGPathArray}
  6884. * The original points array, but modified to render crisply.
  6885. */
  6886. SVGRenderer.prototype.crispLine = function (points, width, roundingFunction) {
  6887. if (roundingFunction === void 0) { roundingFunction = 'round'; }
  6888. var start = points[0];
  6889. var end = points[1];
  6890. // Normalize to a crisp line
  6891. if (start[1] === end[1]) {
  6892. // Substract due to #1129. Now bottom and left axis gridlines behave
  6893. // the same.
  6894. start[1] = end[1] =
  6895. Math[roundingFunction](start[1]) - (width % 2 / 2);
  6896. }
  6897. if (start[2] === end[2]) {
  6898. start[2] = end[2] =
  6899. Math[roundingFunction](start[2]) + (width % 2 / 2);
  6900. }
  6901. return points;
  6902. };
  6903. /**
  6904. * Draw a path, wraps the SVG `path` element.
  6905. *
  6906. * @sample highcharts/members/renderer-path-on-chart/
  6907. * Draw a path in a chart
  6908. * @sample highcharts/members/renderer-path/
  6909. * Draw a path independent from a chart
  6910. *
  6911. * @example
  6912. * var path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
  6913. * .attr({ stroke: '#ff00ff' })
  6914. * .add();
  6915. *
  6916. * @function Highcharts.SVGRenderer#path
  6917. *
  6918. * @param {Highcharts.SVGPathArray} [path]
  6919. * An SVG path definition in array form.
  6920. *
  6921. * @return {Highcharts.SVGElement}
  6922. * The generated wrapper element.
  6923. *
  6924. */ /**
  6925. * Draw a path, wraps the SVG `path` element.
  6926. *
  6927. * @function Highcharts.SVGRenderer#path
  6928. *
  6929. * @param {Highcharts.SVGAttributes} [attribs]
  6930. * The initial attributes.
  6931. *
  6932. * @return {Highcharts.SVGElement}
  6933. * The generated wrapper element.
  6934. */
  6935. SVGRenderer.prototype.path = function (path) {
  6936. var attribs = (this.styledMode ? {} : {
  6937. fill: 'none'
  6938. });
  6939. if (isArray(path)) {
  6940. attribs.d = path;
  6941. }
  6942. else if (isObject(path)) { // attributes
  6943. extend(attribs, path);
  6944. }
  6945. return this.createElement('path').attr(attribs);
  6946. };
  6947. /**
  6948. * Draw a circle, wraps the SVG `circle` element.
  6949. *
  6950. * @sample highcharts/members/renderer-circle/
  6951. * Drawing a circle
  6952. *
  6953. * @function Highcharts.SVGRenderer#circle
  6954. *
  6955. * @param {number} [x]
  6956. * The center x position.
  6957. *
  6958. * @param {number} [y]
  6959. * The center y position.
  6960. *
  6961. * @param {number} [r]
  6962. * The radius.
  6963. *
  6964. * @return {Highcharts.SVGElement}
  6965. * The generated wrapper element.
  6966. */ /**
  6967. * Draw a circle, wraps the SVG `circle` element.
  6968. *
  6969. * @function Highcharts.SVGRenderer#circle
  6970. *
  6971. * @param {Highcharts.SVGAttributes} [attribs]
  6972. * The initial attributes.
  6973. *
  6974. * @return {Highcharts.SVGElement}
  6975. * The generated wrapper element.
  6976. */
  6977. SVGRenderer.prototype.circle = function (x, y, r) {
  6978. var attribs = (isObject(x) ?
  6979. x :
  6980. typeof x === 'undefined' ? {} : { x: x, y: y, r: r }), wrapper = this.createElement('circle');
  6981. // Setting x or y translates to cx and cy
  6982. wrapper.xSetter = wrapper.ySetter = function (value, key, element) {
  6983. element.setAttribute('c' + key, value);
  6984. };
  6985. return wrapper.attr(attribs);
  6986. };
  6987. /**
  6988. * Draw and return an arc.
  6989. *
  6990. * @sample highcharts/members/renderer-arc/
  6991. * Drawing an arc
  6992. *
  6993. * @function Highcharts.SVGRenderer#arc
  6994. *
  6995. * @param {number} [x=0]
  6996. * Center X position.
  6997. *
  6998. * @param {number} [y=0]
  6999. * Center Y position.
  7000. *
  7001. * @param {number} [r=0]
  7002. * The outer radius' of the arc.
  7003. *
  7004. * @param {number} [innerR=0]
  7005. * Inner radius like used in donut charts.
  7006. *
  7007. * @param {number} [start=0]
  7008. * The starting angle of the arc in radians, where 0 is to the right and
  7009. * `-Math.PI/2` is up.
  7010. *
  7011. * @param {number} [end=0]
  7012. * The ending angle of the arc in radians, where 0 is to the right and
  7013. * `-Math.PI/2` is up.
  7014. *
  7015. * @return {Highcharts.SVGElement}
  7016. * The generated wrapper element.
  7017. */ /**
  7018. * Draw and return an arc. Overloaded function that takes arguments object.
  7019. *
  7020. * @function Highcharts.SVGRenderer#arc
  7021. *
  7022. * @param {Highcharts.SVGAttributes} attribs
  7023. * Initial SVG attributes.
  7024. *
  7025. * @return {Highcharts.SVGElement}
  7026. * The generated wrapper element.
  7027. */
  7028. SVGRenderer.prototype.arc = function (x, y, r, innerR, start, end) {
  7029. var arc, options;
  7030. if (isObject(x)) {
  7031. options = x;
  7032. y = options.y;
  7033. r = options.r;
  7034. innerR = options.innerR;
  7035. start = options.start;
  7036. end = options.end;
  7037. x = options.x;
  7038. }
  7039. else {
  7040. options = {
  7041. innerR: innerR,
  7042. start: start,
  7043. end: end
  7044. };
  7045. }
  7046. // Arcs are defined as symbols for the ability to set
  7047. // attributes in attr and animate
  7048. arc = this.symbol('arc', x, y, r, r, options);
  7049. arc.r = r; // #959
  7050. return arc;
  7051. };
  7052. /**
  7053. * Draw and return a rectangle.
  7054. *
  7055. * @function Highcharts.SVGRenderer#rect
  7056. *
  7057. * @param {number} [x]
  7058. * Left position.
  7059. *
  7060. * @param {number} [y]
  7061. * Top position.
  7062. *
  7063. * @param {number} [width]
  7064. * Width of the rectangle.
  7065. *
  7066. * @param {number} [height]
  7067. * Height of the rectangle.
  7068. *
  7069. * @param {number} [r]
  7070. * Border corner radius.
  7071. *
  7072. * @param {number} [strokeWidth]
  7073. * A stroke width can be supplied to allow crisp drawing.
  7074. *
  7075. * @return {Highcharts.SVGElement}
  7076. * The generated wrapper element.
  7077. */ /**
  7078. * Draw and return a rectangle.
  7079. *
  7080. * @sample highcharts/members/renderer-rect-on-chart/
  7081. * Draw a rectangle in a chart
  7082. * @sample highcharts/members/renderer-rect/
  7083. * Draw a rectangle independent from a chart
  7084. *
  7085. * @function Highcharts.SVGRenderer#rect
  7086. *
  7087. * @param {Highcharts.SVGAttributes} [attributes]
  7088. * General SVG attributes for the rectangle.
  7089. *
  7090. * @return {Highcharts.SVGElement}
  7091. * The generated wrapper element.
  7092. */
  7093. SVGRenderer.prototype.rect = function (x, y, width, height, r, strokeWidth) {
  7094. r = isObject(x) ? x.r : r;
  7095. var wrapper = this.createElement('rect'), attribs = isObject(x) ?
  7096. x :
  7097. typeof x === 'undefined' ?
  7098. {} :
  7099. {
  7100. x: x,
  7101. y: y,
  7102. width: Math.max(width, 0),
  7103. height: Math.max(height, 0)
  7104. };
  7105. if (!this.styledMode) {
  7106. if (typeof strokeWidth !== 'undefined') {
  7107. attribs.strokeWidth = strokeWidth;
  7108. attribs = wrapper.crisp(attribs);
  7109. }
  7110. attribs.fill = 'none';
  7111. }
  7112. if (r) {
  7113. attribs.r = r;
  7114. }
  7115. wrapper.rSetter = function (value, key, element) {
  7116. wrapper.r = value;
  7117. attr(element, {
  7118. rx: value,
  7119. ry: value
  7120. });
  7121. };
  7122. wrapper.rGetter = function () {
  7123. return wrapper.r;
  7124. };
  7125. return wrapper.attr(attribs);
  7126. };
  7127. /**
  7128. * Resize the {@link SVGRenderer#box} and re-align all aligned child
  7129. * elements.
  7130. *
  7131. * @sample highcharts/members/renderer-g/
  7132. * Show and hide grouped objects
  7133. *
  7134. * @function Highcharts.SVGRenderer#setSize
  7135. *
  7136. * @param {number} width
  7137. * The new pixel width.
  7138. *
  7139. * @param {number} height
  7140. * The new pixel height.
  7141. *
  7142. * @param {boolean|Highcharts.AnimationOptionsObject} [animate=true]
  7143. * Whether and how to animate.
  7144. */
  7145. SVGRenderer.prototype.setSize = function (width, height, animate) {
  7146. var renderer = this, alignedObjects = renderer.alignedObjects, i = alignedObjects.length;
  7147. renderer.width = width;
  7148. renderer.height = height;
  7149. renderer.boxWrapper.animate({
  7150. width: width,
  7151. height: height
  7152. }, {
  7153. step: function () {
  7154. this.attr({
  7155. viewBox: '0 0 ' + this.attr('width') + ' ' +
  7156. this.attr('height')
  7157. });
  7158. },
  7159. duration: pick(animate, true) ? void 0 : 0
  7160. });
  7161. while (i--) {
  7162. alignedObjects[i].align();
  7163. }
  7164. };
  7165. /**
  7166. * Create and return an svg group element. Child
  7167. * {@link Highcharts.SVGElement} objects are added to the group by using the
  7168. * group as the first parameter in {@link Highcharts.SVGElement#add|add()}.
  7169. *
  7170. * @function Highcharts.SVGRenderer#g
  7171. *
  7172. * @param {string} [name]
  7173. * The group will be given a class name of `highcharts-{name}`. This
  7174. * can be used for styling and scripting.
  7175. *
  7176. * @return {Highcharts.SVGElement}
  7177. * The generated wrapper element.
  7178. */
  7179. SVGRenderer.prototype.g = function (name) {
  7180. var elem = this.createElement('g');
  7181. return name ?
  7182. elem.attr({ 'class': 'highcharts-' + name }) :
  7183. elem;
  7184. };
  7185. /**
  7186. * Display an image.
  7187. *
  7188. * @sample highcharts/members/renderer-image-on-chart/
  7189. * Add an image in a chart
  7190. * @sample highcharts/members/renderer-image/
  7191. * Add an image independent of a chart
  7192. *
  7193. * @function Highcharts.SVGRenderer#image
  7194. *
  7195. * @param {string} src
  7196. * The image source.
  7197. *
  7198. * @param {number} [x]
  7199. * The X position.
  7200. *
  7201. * @param {number} [y]
  7202. * The Y position.
  7203. *
  7204. * @param {number} [width]
  7205. * The image width. If omitted, it defaults to the image file width.
  7206. *
  7207. * @param {number} [height]
  7208. * The image height. If omitted it defaults to the image file
  7209. * height.
  7210. *
  7211. * @param {Function} [onload]
  7212. * Event handler for image load.
  7213. *
  7214. * @return {Highcharts.SVGElement}
  7215. * The generated wrapper element.
  7216. */
  7217. SVGRenderer.prototype.image = function (src, x, y, width, height, onload) {
  7218. var attribs = { preserveAspectRatio: 'none' }, elemWrapper, dummy, setSVGImageSource = function (el, src) {
  7219. // Set the href in the xlink namespace
  7220. if (el.setAttributeNS) {
  7221. el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', src);
  7222. }
  7223. else {
  7224. // could be exporting in IE
  7225. // using href throws "not supported" in ie7 and under,
  7226. // requries regex shim to fix later
  7227. el.setAttribute('hc-svg-href', src);
  7228. }
  7229. }, onDummyLoad = function (e) {
  7230. setSVGImageSource(elemWrapper.element, src);
  7231. onload.call(elemWrapper, e);
  7232. };
  7233. // optional properties
  7234. if (arguments.length > 1) {
  7235. extend(attribs, {
  7236. x: x,
  7237. y: y,
  7238. width: width,
  7239. height: height
  7240. });
  7241. }
  7242. elemWrapper = this.createElement('image').attr(attribs);
  7243. // Add load event if supplied
  7244. if (onload) {
  7245. // We have to use a dummy HTML image since IE support for SVG image
  7246. // load events is very buggy. First set a transparent src, wait for
  7247. // dummy to load, and then add the real src to the SVG image.
  7248. setSVGImageSource(elemWrapper.element, 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' /* eslint-disable-line */);
  7249. dummy = new win.Image();
  7250. addEvent(dummy, 'load', onDummyLoad);
  7251. dummy.src = src;
  7252. if (dummy.complete) {
  7253. onDummyLoad({});
  7254. }
  7255. }
  7256. else {
  7257. setSVGImageSource(elemWrapper.element, src);
  7258. }
  7259. return elemWrapper;
  7260. };
  7261. /**
  7262. * Draw a symbol out of pre-defined shape paths from
  7263. * {@link SVGRenderer#symbols}.
  7264. * It is used in Highcharts for point makers, which cake a `symbol` option,
  7265. * and label and button backgrounds like in the tooltip and stock flags.
  7266. *
  7267. * @function Highcharts.SVGRenderer#symbol
  7268. *
  7269. * @param {string} symbol
  7270. * The symbol name.
  7271. *
  7272. * @param {number} [x]
  7273. * The X coordinate for the top left position.
  7274. *
  7275. * @param {number} [y]
  7276. * The Y coordinate for the top left position.
  7277. *
  7278. * @param {number} [width]
  7279. * The pixel width.
  7280. *
  7281. * @param {number} [height]
  7282. * The pixel height.
  7283. *
  7284. * @param {Highcharts.SymbolOptionsObject} [options]
  7285. * Additional options, depending on the actual symbol drawn.
  7286. *
  7287. * @return {Highcharts.SVGElement}
  7288. */
  7289. SVGRenderer.prototype.symbol = function (symbol, x, y, width, height, options) {
  7290. var ren = this, obj, imageRegex = /^url\((.*?)\)$/, isImage = imageRegex.test(symbol), sym = (!isImage && (this.symbols[symbol] ? symbol : 'circle')),
  7291. // get the symbol definition function
  7292. symbolFn = (sym && this.symbols[sym]), path, imageSrc, centerImage;
  7293. if (symbolFn) {
  7294. // Check if there's a path defined for this symbol
  7295. if (typeof x === 'number') {
  7296. path = symbolFn.call(this.symbols, Math.round(x || 0), Math.round(y || 0), width || 0, height || 0, options);
  7297. }
  7298. obj = this.path(path);
  7299. if (!ren.styledMode) {
  7300. obj.attr('fill', 'none');
  7301. }
  7302. // expando properties for use in animate and attr
  7303. extend(obj, {
  7304. symbolName: sym,
  7305. x: x,
  7306. y: y,
  7307. width: width,
  7308. height: height
  7309. });
  7310. if (options) {
  7311. extend(obj, options);
  7312. }
  7313. // Image symbols
  7314. }
  7315. else if (isImage) {
  7316. imageSrc = symbol.match(imageRegex)[1];
  7317. // Create the image synchronously, add attribs async
  7318. obj = this.image(imageSrc);
  7319. // The image width is not always the same as the symbol width. The
  7320. // image may be centered within the symbol, as is the case when
  7321. // image shapes are used as label backgrounds, for example in flags.
  7322. obj.imgwidth = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].width, options && options.width);
  7323. obj.imgheight = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].height, options && options.height);
  7324. /**
  7325. * Set the size and position
  7326. */
  7327. centerImage = function () {
  7328. obj.attr({
  7329. width: obj.width,
  7330. height: obj.height
  7331. });
  7332. };
  7333. /**
  7334. * Width and height setters that take both the image's physical size
  7335. * and the label size into consideration, and translates the image
  7336. * to center within the label.
  7337. */
  7338. ['width', 'height'].forEach(function (key) {
  7339. obj[key + 'Setter'] = function (value, key) {
  7340. var attribs = {}, imgSize = this['img' + key], trans = key === 'width' ? 'translateX' : 'translateY';
  7341. this[key] = value;
  7342. if (defined(imgSize)) {
  7343. // Scale and center the image within its container.
  7344. // The name `backgroundSize` is taken from the CSS spec,
  7345. // but the value `within` is made up. Other possible
  7346. // values in the spec, `cover` and `contain`, can be
  7347. // implemented if needed.
  7348. if (options &&
  7349. options.backgroundSize === 'within' &&
  7350. this.width &&
  7351. this.height) {
  7352. imgSize = Math.round(imgSize * Math.min(this.width / this.imgwidth, this.height / this.imgheight));
  7353. }
  7354. if (this.element) {
  7355. this.element.setAttribute(key, imgSize);
  7356. }
  7357. if (!this.alignByTranslate) {
  7358. attribs[trans] = ((this[key] || 0) - imgSize) / 2;
  7359. this.attr(attribs);
  7360. }
  7361. }
  7362. };
  7363. });
  7364. if (defined(x)) {
  7365. obj.attr({
  7366. x: x,
  7367. y: y
  7368. });
  7369. }
  7370. obj.isImg = true;
  7371. if (defined(obj.imgwidth) && defined(obj.imgheight)) {
  7372. centerImage();
  7373. }
  7374. else {
  7375. // Initialize image to be 0 size so export will still function
  7376. // if there's no cached sizes.
  7377. obj.attr({ width: 0, height: 0 });
  7378. // Create a dummy JavaScript image to get the width and height.
  7379. createElement('img', {
  7380. onload: function () {
  7381. var chart = charts[ren.chartIndex];
  7382. // Special case for SVGs on IE11, the width is not
  7383. // accessible until the image is part of the DOM
  7384. // (#2854).
  7385. if (this.width === 0) {
  7386. css(this, {
  7387. position: 'absolute',
  7388. top: '-999em'
  7389. });
  7390. doc.body.appendChild(this);
  7391. }
  7392. // Center the image
  7393. symbolSizes[imageSrc] = {
  7394. width: this.width,
  7395. height: this.height
  7396. };
  7397. obj.imgwidth = this.width;
  7398. obj.imgheight = this.height;
  7399. if (obj.element) {
  7400. centerImage();
  7401. }
  7402. // Clean up after #2854 workaround.
  7403. if (this.parentNode) {
  7404. this.parentNode.removeChild(this);
  7405. }
  7406. // Fire the load event when all external images are
  7407. // loaded
  7408. ren.imgCount--;
  7409. if (!ren.imgCount && chart && !chart.hasLoaded) {
  7410. chart.onload();
  7411. }
  7412. },
  7413. src: imageSrc
  7414. });
  7415. this.imgCount++;
  7416. }
  7417. }
  7418. return obj;
  7419. };
  7420. /**
  7421. * Define a clipping rectangle. The clipping rectangle is later applied
  7422. * to {@link SVGElement} objects through the {@link SVGElement#clip}
  7423. * function.
  7424. *
  7425. * @example
  7426. * var circle = renderer.circle(100, 100, 100)
  7427. * .attr({ fill: 'red' })
  7428. * .add();
  7429. * var clipRect = renderer.clipRect(100, 100, 100, 100);
  7430. *
  7431. * // Leave only the lower right quarter visible
  7432. * circle.clip(clipRect);
  7433. *
  7434. * @function Highcharts.SVGRenderer#clipRect
  7435. *
  7436. * @param {number} [x]
  7437. *
  7438. * @param {number} [y]
  7439. *
  7440. * @param {number} [width]
  7441. *
  7442. * @param {number} [height]
  7443. *
  7444. * @return {Highcharts.ClipRectElement}
  7445. * A clipping rectangle.
  7446. */
  7447. SVGRenderer.prototype.clipRect = function (x, y, width, height) {
  7448. var wrapper,
  7449. // Add a hyphen at the end to avoid confusion in testing indexes
  7450. // -1 and -10, -11 etc (#6550)
  7451. id = uniqueKey() + '-', clipPath = this.createElement('clipPath').attr({
  7452. id: id
  7453. }).add(this.defs);
  7454. wrapper = this.rect(x, y, width, height, 0).add(clipPath);
  7455. wrapper.id = id;
  7456. wrapper.clipPath = clipPath;
  7457. wrapper.count = 0;
  7458. return wrapper;
  7459. };
  7460. /**
  7461. * Draw text. The text can contain a subset of HTML, like spans and anchors
  7462. * and some basic text styling of these. For more advanced features like
  7463. * border and background, use {@link Highcharts.SVGRenderer#label} instead.
  7464. * To update the text after render, run `text.attr({ text: 'New text' })`.
  7465. *
  7466. * @sample highcharts/members/renderer-text-on-chart/
  7467. * Annotate the chart freely
  7468. * @sample highcharts/members/renderer-on-chart/
  7469. * Annotate with a border and in response to the data
  7470. * @sample highcharts/members/renderer-text/
  7471. * Formatted text
  7472. *
  7473. * @function Highcharts.SVGRenderer#text
  7474. *
  7475. * @param {string} [str]
  7476. * The text of (subset) HTML to draw.
  7477. *
  7478. * @param {number} [x]
  7479. * The x position of the text's lower left corner.
  7480. *
  7481. * @param {number} [y]
  7482. * The y position of the text's lower left corner.
  7483. *
  7484. * @param {boolean} [useHTML=false]
  7485. * Use HTML to render the text.
  7486. *
  7487. * @return {Highcharts.SVGElement}
  7488. * The text object.
  7489. */
  7490. SVGRenderer.prototype.text = function (str, x, y, useHTML) {
  7491. // declare variables
  7492. var renderer = this, wrapper, attribs = {};
  7493. if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
  7494. return renderer.html(str, x, y);
  7495. }
  7496. attribs.x = Math.round(x || 0); // X always needed for line-wrap logic
  7497. if (y) {
  7498. attribs.y = Math.round(y);
  7499. }
  7500. if (defined(str)) {
  7501. attribs.text = str;
  7502. }
  7503. wrapper = renderer.createElement('text')
  7504. .attr(attribs);
  7505. if (!useHTML) {
  7506. wrapper.xSetter = function (value, key, element) {
  7507. var tspans = element.getElementsByTagName('tspan'), tspan, parentVal = element.getAttribute(key), i;
  7508. for (i = 0; i < tspans.length; i++) {
  7509. tspan = tspans[i];
  7510. // If the x values are equal, the tspan represents a
  7511. // linebreak
  7512. if (tspan.getAttribute(key) === parentVal) {
  7513. tspan.setAttribute(key, value);
  7514. }
  7515. }
  7516. element.setAttribute(key, value);
  7517. };
  7518. }
  7519. return wrapper;
  7520. };
  7521. /**
  7522. * Utility to return the baseline offset and total line height from the font
  7523. * size.
  7524. *
  7525. * @function Highcharts.SVGRenderer#fontMetrics
  7526. *
  7527. * @param {number|string} [fontSize]
  7528. * The current font size to inspect. If not given, the font size
  7529. * will be found from the DOM element.
  7530. *
  7531. * @param {Highcharts.SVGElement|Highcharts.SVGDOMElement} [elem]
  7532. * The element to inspect for a current font size.
  7533. *
  7534. * @return {Highcharts.FontMetricsObject}
  7535. * The font metrics.
  7536. */
  7537. SVGRenderer.prototype.fontMetrics = function (fontSize, elem) {
  7538. var lineHeight, baseline;
  7539. if ((this.styledMode || !/px/.test(fontSize)) &&
  7540. win.getComputedStyle // old IE doesn't support it
  7541. ) {
  7542. fontSize = elem && SVGElement.prototype.getStyle.call(elem, 'font-size');
  7543. }
  7544. else {
  7545. fontSize = fontSize ||
  7546. // When the elem is a DOM element (#5932)
  7547. (elem && elem.style && elem.style.fontSize) ||
  7548. // Fall back on the renderer style default
  7549. (this.style && this.style.fontSize);
  7550. }
  7551. // Handle different units
  7552. if (/px/.test(fontSize)) {
  7553. fontSize = pInt(fontSize);
  7554. }
  7555. else {
  7556. fontSize = 12;
  7557. }
  7558. // Empirical values found by comparing font size and bounding box
  7559. // height. Applies to the default font family.
  7560. // https://jsfiddle.net/highcharts/7xvn7/
  7561. lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
  7562. baseline = Math.round(lineHeight * 0.8);
  7563. return {
  7564. h: lineHeight,
  7565. b: baseline,
  7566. f: fontSize
  7567. };
  7568. };
  7569. /**
  7570. * Correct X and Y positioning of a label for rotation (#1764).
  7571. *
  7572. * @private
  7573. * @function Highcharts.SVGRenderer#rotCorr
  7574. *
  7575. * @param {number} baseline
  7576. *
  7577. * @param {number} rotation
  7578. *
  7579. * @param {boolean} [alterY]
  7580. *
  7581. * @param {Highcharts.PositionObject}
  7582. */
  7583. SVGRenderer.prototype.rotCorr = function (baseline, rotation, alterY) {
  7584. var y = baseline;
  7585. if (rotation && alterY) {
  7586. y = Math.max(y * Math.cos(rotation * deg2rad), 4);
  7587. }
  7588. return {
  7589. x: (-baseline / 3) * Math.sin(rotation * deg2rad),
  7590. y: y
  7591. };
  7592. };
  7593. /**
  7594. * Compatibility function to convert the legacy one-dimensional path array
  7595. * into an array of segments.
  7596. *
  7597. * It is used in maps to parse the `path` option, and in SVGRenderer.dSetter
  7598. * to support legacy paths from demos.
  7599. *
  7600. * @private
  7601. * @function Highcharts.SVGRenderer#pathToSegments
  7602. */
  7603. SVGRenderer.prototype.pathToSegments = function (path) {
  7604. var ret = [];
  7605. var segment = [];
  7606. var commandLength = {
  7607. A: 8,
  7608. C: 7,
  7609. H: 2,
  7610. L: 3,
  7611. M: 3,
  7612. Q: 5,
  7613. S: 5,
  7614. T: 3,
  7615. V: 2
  7616. };
  7617. // Short, non-typesafe parsing of the one-dimensional array. It splits
  7618. // the path on any string. This is not type checked against the tuple
  7619. // types, but is shorter, and doesn't require specific checks for any
  7620. // command type in SVG.
  7621. for (var i = 0; i < path.length; i++) {
  7622. // Command skipped, repeat previous or insert L/l for M/m
  7623. if (isString(segment[0]) &&
  7624. isNumber(path[i]) &&
  7625. segment.length === commandLength[(segment[0].toUpperCase())]) {
  7626. path.splice(i, 0, segment[0].replace('M', 'L').replace('m', 'l'));
  7627. }
  7628. // Split on string
  7629. if (typeof path[i] === 'string') {
  7630. if (segment.length) {
  7631. ret.push(segment.slice(0));
  7632. }
  7633. segment.length = 0;
  7634. }
  7635. segment.push(path[i]);
  7636. }
  7637. ret.push(segment.slice(0));
  7638. return ret;
  7639. /*
  7640. // Fully type-safe version where each tuple type is checked. The
  7641. // downside is filesize and a lack of flexibility for unsupported
  7642. // commands
  7643. const ret: SVGPath = [],
  7644. commands = {
  7645. A: 7,
  7646. C: 6,
  7647. H: 1,
  7648. L: 2,
  7649. M: 2,
  7650. Q: 4,
  7651. S: 4,
  7652. T: 2,
  7653. V: 1,
  7654. Z: 0
  7655. };
  7656. let i = 0,
  7657. lastI = 0,
  7658. lastCommand;
  7659. while (i < path.length) {
  7660. const item = path[i];
  7661. let command;
  7662. if (typeof item === 'string') {
  7663. command = item;
  7664. i += 1;
  7665. } else {
  7666. command = lastCommand || 'M';
  7667. }
  7668. // Upper case
  7669. const commandUC = command.toUpperCase();
  7670. if (commandUC in commands) {
  7671. // No numeric parameters
  7672. if (command === 'Z' || command === 'z') {
  7673. ret.push([command]);
  7674. // One numeric parameter
  7675. } else {
  7676. const val0 = path[i];
  7677. if (typeof val0 === 'number') {
  7678. // Horizontal line to
  7679. if (command === 'H' || command === 'h') {
  7680. ret.push([command, val0]);
  7681. i += 1;
  7682. // Vertical line to
  7683. } else if (command === 'V' || command === 'v') {
  7684. ret.push([command, val0]);
  7685. i += 1;
  7686. // Two numeric parameters
  7687. } else {
  7688. const val1 = path[i + 1];
  7689. if (typeof val1 === 'number') {
  7690. // lineTo
  7691. if (command === 'L' || command === 'l') {
  7692. ret.push([command, val0, val1]);
  7693. i += 2;
  7694. // moveTo
  7695. } else if (command === 'M' || command === 'm') {
  7696. ret.push([command, val0, val1]);
  7697. i += 2;
  7698. // Smooth quadratic bezier
  7699. } else if (command === 'T' || command === 't') {
  7700. ret.push([command, val0, val1]);
  7701. i += 2;
  7702. // Four numeric parameters
  7703. } else {
  7704. const val2 = path[i + 2],
  7705. val3 = path[i + 3];
  7706. if (
  7707. typeof val2 === 'number' &&
  7708. typeof val3 === 'number'
  7709. ) {
  7710. // Quadratic bezier to
  7711. if (
  7712. command === 'Q' ||
  7713. command === 'q'
  7714. ) {
  7715. ret.push([
  7716. command,
  7717. val0,
  7718. val1,
  7719. val2,
  7720. val3
  7721. ]);
  7722. i += 4;
  7723. // Smooth cubic bezier to
  7724. } else if (
  7725. command === 'S' ||
  7726. command === 's'
  7727. ) {
  7728. ret.push([
  7729. command,
  7730. val0,
  7731. val1,
  7732. val2,
  7733. val3
  7734. ]);
  7735. i += 4;
  7736. // Six numeric parameters
  7737. } else {
  7738. const val4 = path[i + 4],
  7739. val5 = path[i + 5];
  7740. if (
  7741. typeof val4 === 'number' &&
  7742. typeof val5 === 'number'
  7743. ) {
  7744. // Curve to
  7745. if (
  7746. command === 'C' ||
  7747. command === 'c'
  7748. ) {
  7749. ret.push([
  7750. command,
  7751. val0,
  7752. val1,
  7753. val2,
  7754. val3,
  7755. val4,
  7756. val5
  7757. ]);
  7758. i += 6;
  7759. // Seven numeric parameters
  7760. } else {
  7761. const val6 = path[i + 6];
  7762. // Arc to
  7763. if (
  7764. typeof val6 ===
  7765. 'number' &&
  7766. (
  7767. command === 'A' ||
  7768. command === 'a'
  7769. )
  7770. ) {
  7771. ret.push([
  7772. command,
  7773. val0,
  7774. val1,
  7775. val2,
  7776. val3,
  7777. val4,
  7778. val5,
  7779. val6
  7780. ]);
  7781. i += 7;
  7782. }
  7783. }
  7784. }
  7785. }
  7786. }
  7787. }
  7788. }
  7789. }
  7790. }
  7791. }
  7792. }
  7793. // An unmarked command following a moveTo is a lineTo
  7794. lastCommand = command === 'M' ? 'L' : command;
  7795. if (i === lastI) {
  7796. break;
  7797. }
  7798. lastI = i;
  7799. }
  7800. return ret;
  7801. */
  7802. };
  7803. /**
  7804. * Draw a label, which is an extended text element with support for border
  7805. * and background. Highcharts creates a `g` element with a text and a `path`
  7806. * or `rect` inside, to make it behave somewhat like a HTML div. Border and
  7807. * background are set through `stroke`, `stroke-width` and `fill` attributes
  7808. * using the {@link Highcharts.SVGElement#attr|attr} method. To update the
  7809. * text after render, run `label.attr({ text: 'New text' })`.
  7810. *
  7811. * @sample highcharts/members/renderer-label-on-chart/
  7812. * A label on the chart
  7813. *
  7814. * @function Highcharts.SVGRenderer#label
  7815. *
  7816. * @param {string} str
  7817. * The initial text string or (subset) HTML to render.
  7818. *
  7819. * @param {number} x
  7820. * The x position of the label's left side.
  7821. *
  7822. * @param {number} [y]
  7823. * The y position of the label's top side or baseline, depending on
  7824. * the `baseline` parameter.
  7825. *
  7826. * @param {string} [shape='rect']
  7827. * The shape of the label's border/background, if any. Defaults to
  7828. * `rect`. Other possible values are `callout` or other shapes
  7829. * defined in {@link Highcharts.SVGRenderer#symbols}.
  7830. *
  7831. * @param {number} [anchorX]
  7832. * In case the `shape` has a pointer, like a flag, this is the
  7833. * coordinates it should be pinned to.
  7834. *
  7835. * @param {number} [anchorY]
  7836. * In case the `shape` has a pointer, like a flag, this is the
  7837. * coordinates it should be pinned to.
  7838. *
  7839. * @param {boolean} [useHTML=false]
  7840. * Wether to use HTML to render the label.
  7841. *
  7842. * @param {boolean} [baseline=false]
  7843. * Whether to position the label relative to the text baseline,
  7844. * like {@link Highcharts.SVGRenderer#text|renderer.text}, or to the
  7845. * upper border of the rectangle.
  7846. *
  7847. * @param {string} [className]
  7848. * Class name for the group.
  7849. *
  7850. * @return {Highcharts.SVGElement}
  7851. * The generated label.
  7852. */
  7853. SVGRenderer.prototype.label = function (str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  7854. return new SVGLabel(this, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className);
  7855. };
  7856. return SVGRenderer;
  7857. }());
  7858. /**
  7859. * A pointer to the renderer's associated Element class. The VMLRenderer
  7860. * will have a pointer to VMLElement here.
  7861. *
  7862. * @name Highcharts.SVGRenderer#Element
  7863. * @type {Highcharts.SVGElement}
  7864. */
  7865. SVGRenderer.prototype.Element = SVGElement;
  7866. /**
  7867. * @private
  7868. */
  7869. SVGRenderer.prototype.SVG_NS = SVG_NS;
  7870. /**
  7871. * Dummy function for plugins, called every time the renderer is updated.
  7872. * Prior to Highcharts 5, this was used for the canvg renderer.
  7873. *
  7874. * @deprecated
  7875. * @function Highcharts.SVGRenderer#draw
  7876. */
  7877. SVGRenderer.prototype.draw = noop;
  7878. /**
  7879. * A collection of characters mapped to HTML entities. When `useHTML` on an
  7880. * element is true, these entities will be rendered correctly by HTML. In
  7881. * the SVG pseudo-HTML, they need to be unescaped back to simple characters,
  7882. * so for example `&lt;` will render as `<`.
  7883. *
  7884. * @example
  7885. * // Add support for unescaping quotes
  7886. * Highcharts.SVGRenderer.prototype.escapes['"'] = '&quot;';
  7887. *
  7888. * @name Highcharts.SVGRenderer#escapes
  7889. * @type {Highcharts.Dictionary<string>}
  7890. */
  7891. SVGRenderer.prototype.escapes = {
  7892. '&': '&amp;',
  7893. '<': '&lt;',
  7894. '>': '&gt;',
  7895. "'": '&#39;',
  7896. '"': '&quot;'
  7897. };
  7898. /**
  7899. * An extendable collection of functions for defining symbol paths.
  7900. *
  7901. * @name Highcharts.SVGRenderer#symbols
  7902. * @type {Highcharts.SymbolDictionary}
  7903. */
  7904. SVGRenderer.prototype.symbols = {
  7905. circle: function (x, y, w, h) {
  7906. // Return a full arc
  7907. return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
  7908. start: Math.PI * 0.5,
  7909. end: Math.PI * 2.5,
  7910. open: false
  7911. });
  7912. },
  7913. square: function (x, y, w, h) {
  7914. return [
  7915. ['M', x, y],
  7916. ['L', x + w, y],
  7917. ['L', x + w, y + h],
  7918. ['L', x, y + h],
  7919. ['Z']
  7920. ];
  7921. },
  7922. triangle: function (x, y, w, h) {
  7923. return [
  7924. ['M', x + w / 2, y],
  7925. ['L', x + w, y + h],
  7926. ['L', x, y + h],
  7927. ['Z']
  7928. ];
  7929. },
  7930. 'triangle-down': function (x, y, w, h) {
  7931. return [
  7932. ['M', x, y],
  7933. ['L', x + w, y],
  7934. ['L', x + w / 2, y + h],
  7935. ['Z']
  7936. ];
  7937. },
  7938. diamond: function (x, y, w, h) {
  7939. return [
  7940. ['M', x + w / 2, y],
  7941. ['L', x + w, y + h / 2],
  7942. ['L', x + w / 2, y + h],
  7943. ['L', x, y + h / 2],
  7944. ['Z']
  7945. ];
  7946. },
  7947. arc: function (x, y, w, h, options) {
  7948. var arc = [];
  7949. if (options) {
  7950. var start = options.start || 0, end = options.end || 0, rx = options.r || w, ry = options.r || h || w, proximity = 0.001, fullCircle = Math.abs(end - start - 2 * Math.PI) <
  7951. proximity,
  7952. // Substract a small number to prevent cos and sin of start and
  7953. // end from becoming equal on 360 arcs (related: #1561)
  7954. end = end - proximity, innerRadius = options.innerR, open = pick(options.open, fullCircle), cosStart = Math.cos(start), sinStart = Math.sin(start), cosEnd = Math.cos(end), sinEnd = Math.sin(end),
  7955. // Proximity takes care of rounding errors around PI (#6971)
  7956. longArc = pick(options.longArc, end - start - Math.PI < proximity ? 0 : 1);
  7957. arc.push([
  7958. 'M',
  7959. x + rx * cosStart,
  7960. y + ry * sinStart
  7961. ], [
  7962. 'A',
  7963. rx,
  7964. ry,
  7965. 0,
  7966. longArc,
  7967. pick(options.clockwise, 1),
  7968. x + rx * cosEnd,
  7969. y + ry * sinEnd
  7970. ]);
  7971. if (defined(innerRadius)) {
  7972. arc.push(open ?
  7973. [
  7974. 'M',
  7975. x + innerRadius * cosEnd,
  7976. y + innerRadius * sinEnd
  7977. ] : [
  7978. 'L',
  7979. x + innerRadius * cosEnd,
  7980. y + innerRadius * sinEnd
  7981. ], [
  7982. 'A',
  7983. innerRadius,
  7984. innerRadius,
  7985. 0,
  7986. longArc,
  7987. // Clockwise - opposite to the outer arc clockwise
  7988. defined(options.clockwise) ? 1 - options.clockwise : 0,
  7989. x + innerRadius * cosStart,
  7990. y + innerRadius * sinStart
  7991. ]);
  7992. }
  7993. if (!open) {
  7994. arc.push(['Z']);
  7995. }
  7996. }
  7997. return arc;
  7998. },
  7999. /**
  8000. * Callout shape used for default tooltips, also used for rounded
  8001. * rectangles in VML
  8002. */
  8003. callout: function (x, y, w, h, options) {
  8004. var arrowLength = 6, halfDistance = 6, r = Math.min((options && options.r) || 0, w, h), safeDistance = r + halfDistance, anchorX = options && options.anchorX || 0, anchorY = options && options.anchorY || 0, path;
  8005. path = [
  8006. ['M', x + r, y],
  8007. ['L', x + w - r, y],
  8008. ['C', x + w, y, x + w, y, x + w, y + r],
  8009. ['L', x + w, y + h - r],
  8010. ['C', x + w, y + h, x + w, y + h, x + w - r, y + h],
  8011. ['L', x + r, y + h],
  8012. ['C', x, y + h, x, y + h, x, y + h - r],
  8013. ['L', x, y + r],
  8014. ['C', x, y, x, y, x + r, y] // top-left corner
  8015. ];
  8016. // Anchor on right side
  8017. if (anchorX && anchorX > w) {
  8018. // Chevron
  8019. if (anchorY > y + safeDistance &&
  8020. anchorY < y + h - safeDistance) {
  8021. 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]);
  8022. // Simple connector
  8023. }
  8024. else {
  8025. path.splice(3, 1, ['L', x + w, h / 2], ['L', anchorX, anchorY], ['L', x + w, h / 2], ['L', x + w, y + h - r]);
  8026. }
  8027. // Anchor on left side
  8028. }
  8029. else if (anchorX && anchorX < 0) {
  8030. // Chevron
  8031. if (anchorY > y + safeDistance &&
  8032. anchorY < y + h - safeDistance) {
  8033. path.splice(7, 1, ['L', x, anchorY + halfDistance], ['L', x - arrowLength, anchorY], ['L', x, anchorY - halfDistance], ['L', x, y + r]);
  8034. // Simple connector
  8035. }
  8036. else {
  8037. path.splice(7, 1, ['L', x, h / 2], ['L', anchorX, anchorY], ['L', x, h / 2], ['L', x, y + r]);
  8038. }
  8039. }
  8040. else if ( // replace bottom
  8041. anchorY &&
  8042. anchorY > h &&
  8043. anchorX > x + safeDistance &&
  8044. anchorX < x + w - safeDistance) {
  8045. path.splice(5, 1, ['L', anchorX + halfDistance, y + h], ['L', anchorX, y + h + arrowLength], ['L', anchorX - halfDistance, y + h], ['L', x + r, y + h]);
  8046. }
  8047. else if ( // replace top
  8048. anchorY &&
  8049. anchorY < 0 &&
  8050. anchorX > x + safeDistance &&
  8051. anchorX < x + w - safeDistance) {
  8052. path.splice(1, 1, ['L', anchorX - halfDistance, y], ['L', anchorX, y - arrowLength], ['L', anchorX + halfDistance, y], ['L', w - r, y]);
  8053. }
  8054. return path;
  8055. }
  8056. };
  8057. H.SVGRenderer = SVGRenderer;
  8058. H.Renderer = H.SVGRenderer;
  8059. return H.Renderer;
  8060. });
  8061. _registerModule(_modules, 'parts/Html.js', [_modules['parts/Globals.js'], _modules['parts/SVGElement.js'], _modules['parts/SVGRenderer.js'], _modules['parts/Utilities.js']], function (H, SVGElement, SVGRenderer, U) {
  8062. /* *
  8063. *
  8064. * (c) 2010-2020 Torstein Honsi
  8065. *
  8066. * License: www.highcharts.com/license
  8067. *
  8068. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8069. *
  8070. * */
  8071. var attr = U.attr, createElement = U.createElement, css = U.css, defined = U.defined, extend = U.extend, pick = U.pick, pInt = U.pInt;
  8072. var isFirefox = H.isFirefox, isMS = H.isMS, isWebKit = H.isWebKit, win = H.win;
  8073. /* eslint-disable valid-jsdoc */
  8074. // Extend SvgElement for useHTML option.
  8075. extend(SVGElement.prototype, /** @lends SVGElement.prototype */ {
  8076. /**
  8077. * Apply CSS to HTML elements. This is used in text within SVG rendering and
  8078. * by the VML renderer
  8079. *
  8080. * @private
  8081. * @function Highcharts.SVGElement#htmlCss
  8082. *
  8083. * @param {Highcharts.CSSObject} styles
  8084. *
  8085. * @return {Highcharts.SVGElement}
  8086. */
  8087. htmlCss: function (styles) {
  8088. var wrapper = this, element = wrapper.element,
  8089. // When setting or unsetting the width style, we need to update
  8090. // transform (#8809)
  8091. isSettingWidth = (element.tagName === 'SPAN' &&
  8092. styles &&
  8093. 'width' in styles), textWidth = pick(isSettingWidth && styles.width, void 0), doTransform;
  8094. if (isSettingWidth) {
  8095. delete styles.width;
  8096. wrapper.textWidth = textWidth;
  8097. doTransform = true;
  8098. }
  8099. if (styles && styles.textOverflow === 'ellipsis') {
  8100. styles.whiteSpace = 'nowrap';
  8101. styles.overflow = 'hidden';
  8102. }
  8103. wrapper.styles = extend(wrapper.styles, styles);
  8104. css(wrapper.element, styles);
  8105. // Now that all styles are applied, to the transform
  8106. if (doTransform) {
  8107. wrapper.htmlUpdateTransform();
  8108. }
  8109. return wrapper;
  8110. },
  8111. /**
  8112. * VML and useHTML method for calculating the bounding box based on offsets.
  8113. *
  8114. * @private
  8115. * @function Highcharts.SVGElement#htmlGetBBox
  8116. *
  8117. * @param {boolean} refresh
  8118. * Whether to force a fresh value from the DOM or to use the cached
  8119. * value.
  8120. *
  8121. * @return {Highcharts.BBoxObject}
  8122. * A hash containing values for x, y, width and height.
  8123. */
  8124. htmlGetBBox: function () {
  8125. var wrapper = this, element = wrapper.element;
  8126. return {
  8127. x: element.offsetLeft,
  8128. y: element.offsetTop,
  8129. width: element.offsetWidth,
  8130. height: element.offsetHeight
  8131. };
  8132. },
  8133. /**
  8134. * VML override private method to update elements based on internal
  8135. * properties based on SVG transform.
  8136. *
  8137. * @private
  8138. * @function Highcharts.SVGElement#htmlUpdateTransform
  8139. * @return {void}
  8140. */
  8141. htmlUpdateTransform: function () {
  8142. // aligning non added elements is expensive
  8143. if (!this.added) {
  8144. this.alignOnAdd = true;
  8145. return;
  8146. }
  8147. var wrapper = this, renderer = wrapper.renderer, elem = wrapper.element, translateX = wrapper.translateX || 0, translateY = wrapper.translateY || 0, x = wrapper.x || 0, y = wrapper.y || 0, align = wrapper.textAlign || 'left', alignCorrection = {
  8148. left: 0, center: 0.5, right: 1
  8149. }[align], styles = wrapper.styles, whiteSpace = styles && styles.whiteSpace;
  8150. /**
  8151. * @private
  8152. * @return {number}
  8153. */
  8154. function getTextPxLength() {
  8155. // Reset multiline/ellipsis in order to read width (#4928,
  8156. // #5417)
  8157. css(elem, {
  8158. width: '',
  8159. whiteSpace: whiteSpace || 'nowrap'
  8160. });
  8161. return elem.offsetWidth;
  8162. }
  8163. // apply translate
  8164. css(elem, {
  8165. marginLeft: translateX,
  8166. marginTop: translateY
  8167. });
  8168. if (!renderer.styledMode && wrapper.shadows) { // used in labels/tooltip
  8169. wrapper.shadows.forEach(function (shadow) {
  8170. css(shadow, {
  8171. marginLeft: translateX + 1,
  8172. marginTop: translateY + 1
  8173. });
  8174. });
  8175. }
  8176. // apply inversion
  8177. if (wrapper.inverted) { // wrapper is a group
  8178. [].forEach.call(elem.childNodes, function (child) {
  8179. renderer.invertChild(child, elem);
  8180. });
  8181. }
  8182. if (elem.tagName === 'SPAN') {
  8183. var rotation = wrapper.rotation, baseline, textWidth = wrapper.textWidth && pInt(wrapper.textWidth), currentTextTransform = [
  8184. rotation,
  8185. align,
  8186. elem.innerHTML,
  8187. wrapper.textWidth,
  8188. wrapper.textAlign
  8189. ].join(',');
  8190. // Update textWidth. Use the memoized textPxLength if possible, to
  8191. // avoid the getTextPxLength function using elem.offsetWidth.
  8192. // Calling offsetWidth affects rendering time as it forces layout
  8193. // (#7656).
  8194. if (textWidth !== wrapper.oldTextWidth &&
  8195. ((textWidth > wrapper.oldTextWidth) ||
  8196. (wrapper.textPxLength || getTextPxLength()) > textWidth) && (
  8197. // Only set the width if the text is able to word-wrap, or
  8198. // text-overflow is ellipsis (#9537)
  8199. /[ \-]/.test(elem.textContent || elem.innerText) ||
  8200. elem.style.textOverflow === 'ellipsis')) { // #983, #1254
  8201. css(elem, {
  8202. width: textWidth + 'px',
  8203. display: 'block',
  8204. whiteSpace: whiteSpace || 'normal' // #3331
  8205. });
  8206. wrapper.oldTextWidth = textWidth;
  8207. wrapper.hasBoxWidthChanged = true; // #8159
  8208. }
  8209. else {
  8210. wrapper.hasBoxWidthChanged = false; // #8159
  8211. }
  8212. // Do the calculations and DOM access only if properties changed
  8213. if (currentTextTransform !== wrapper.cTT) {
  8214. baseline = renderer.fontMetrics(elem.style.fontSize, elem).b;
  8215. // Renderer specific handling of span rotation, but only if we
  8216. // have something to update.
  8217. if (defined(rotation) &&
  8218. ((rotation !== (wrapper.oldRotation || 0)) ||
  8219. (align !== wrapper.oldAlign))) {
  8220. wrapper.setSpanRotation(rotation, alignCorrection, baseline);
  8221. }
  8222. wrapper.getSpanCorrection(
  8223. // Avoid elem.offsetWidth if we can, it affects rendering
  8224. // time heavily (#7656)
  8225. ((!defined(rotation) && wrapper.textPxLength) || // #7920
  8226. elem.offsetWidth), baseline, alignCorrection, rotation, align);
  8227. }
  8228. // apply position with correction
  8229. css(elem, {
  8230. left: (x + (wrapper.xCorr || 0)) + 'px',
  8231. top: (y + (wrapper.yCorr || 0)) + 'px'
  8232. });
  8233. // record current text transform
  8234. wrapper.cTT = currentTextTransform;
  8235. wrapper.oldRotation = rotation;
  8236. wrapper.oldAlign = align;
  8237. }
  8238. },
  8239. /**
  8240. * Set the rotation of an individual HTML span.
  8241. *
  8242. * @private
  8243. * @function Highcharts.SVGElement#setSpanRotation
  8244. * @param {number} rotation
  8245. * @param {number} alignCorrection
  8246. * @param {number} baseline
  8247. * @return {void}
  8248. */
  8249. setSpanRotation: function (rotation, alignCorrection, baseline) {
  8250. var rotationStyle = {}, cssTransformKey = this.renderer.getTransformKey();
  8251. rotationStyle[cssTransformKey] = rotationStyle.transform =
  8252. 'rotate(' + rotation + 'deg)';
  8253. rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] =
  8254. rotationStyle.transformOrigin =
  8255. (alignCorrection * 100) + '% ' + baseline + 'px';
  8256. css(this.element, rotationStyle);
  8257. },
  8258. /**
  8259. * Get the correction in X and Y positioning as the element is rotated.
  8260. *
  8261. * @private
  8262. * @function Highcharts.SVGElement#getSpanCorrection
  8263. * @param {number} width
  8264. * @param {number} baseline
  8265. * @param {number} alignCorrection
  8266. * @return {void}
  8267. */
  8268. getSpanCorrection: function (width, baseline, alignCorrection) {
  8269. this.xCorr = -width * alignCorrection;
  8270. this.yCorr = -baseline;
  8271. }
  8272. });
  8273. // Extend SvgRenderer for useHTML option.
  8274. extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {
  8275. /**
  8276. * @private
  8277. * @function Highcharts.SVGRenderer#getTransformKey
  8278. *
  8279. * @return {string}
  8280. */
  8281. getTransformKey: function () {
  8282. return isMS && !/Edge/.test(win.navigator.userAgent) ?
  8283. '-ms-transform' :
  8284. isWebKit ?
  8285. '-webkit-transform' :
  8286. isFirefox ?
  8287. 'MozTransform' :
  8288. win.opera ?
  8289. '-o-transform' :
  8290. '';
  8291. },
  8292. /**
  8293. * Create HTML text node. This is used by the VML renderer as well as the
  8294. * SVG renderer through the useHTML option.
  8295. *
  8296. * @private
  8297. * @function Highcharts.SVGRenderer#html
  8298. *
  8299. * @param {string} str
  8300. * The text of (subset) HTML to draw.
  8301. *
  8302. * @param {number} x
  8303. * The x position of the text's lower left corner.
  8304. *
  8305. * @param {number} y
  8306. * The y position of the text's lower left corner.
  8307. *
  8308. * @return {Highcharts.HTMLDOMElement}
  8309. */
  8310. html: function (str, x, y) {
  8311. var wrapper = this.createElement('span'), element = wrapper.element, renderer = wrapper.renderer, isSVG = renderer.isSVG, addSetters = function (gWrapper, style) {
  8312. // These properties are set as attributes on the SVG group, and
  8313. // as identical CSS properties on the div. (#3542)
  8314. ['opacity', 'visibility'].forEach(function (prop) {
  8315. gWrapper[prop + 'Setter'] = function (value, key, elem) {
  8316. var styleObject = gWrapper.div ?
  8317. gWrapper.div.style :
  8318. style;
  8319. SVGElement.prototype[prop + 'Setter']
  8320. .call(this, value, key, elem);
  8321. if (styleObject) {
  8322. styleObject[key] = value;
  8323. }
  8324. };
  8325. });
  8326. gWrapper.addedSetters = true;
  8327. };
  8328. // Text setter
  8329. wrapper.textSetter = function (value) {
  8330. if (value !== element.innerHTML) {
  8331. delete this.bBox;
  8332. delete this.oldTextWidth;
  8333. }
  8334. this.textStr = value;
  8335. element.innerHTML = pick(value, '');
  8336. wrapper.doTransform = true;
  8337. };
  8338. // Add setters for the element itself (#4938)
  8339. if (isSVG) { // #4938, only for HTML within SVG
  8340. addSetters(wrapper, wrapper.element.style);
  8341. }
  8342. // Various setters which rely on update transform
  8343. wrapper.xSetter =
  8344. wrapper.ySetter =
  8345. wrapper.alignSetter =
  8346. wrapper.rotationSetter =
  8347. function (value, key) {
  8348. if (key === 'align') {
  8349. // Do not overwrite the SVGElement.align method. Same as VML.
  8350. key = 'textAlign';
  8351. }
  8352. wrapper[key] = value;
  8353. wrapper.doTransform = true;
  8354. };
  8355. // Runs at the end of .attr()
  8356. wrapper.afterSetters = function () {
  8357. // Update transform. Do this outside the loop to prevent redundant
  8358. // updating for batch setting of attributes.
  8359. if (this.doTransform) {
  8360. this.htmlUpdateTransform();
  8361. this.doTransform = false;
  8362. }
  8363. };
  8364. // Set the default attributes
  8365. wrapper
  8366. .attr({
  8367. text: str,
  8368. x: Math.round(x),
  8369. y: Math.round(y)
  8370. })
  8371. .css({
  8372. position: 'absolute'
  8373. });
  8374. if (!renderer.styledMode) {
  8375. wrapper.css({
  8376. fontFamily: this.style.fontFamily,
  8377. fontSize: this.style.fontSize
  8378. });
  8379. }
  8380. // Keep the whiteSpace style outside the wrapper.styles collection
  8381. element.style.whiteSpace = 'nowrap';
  8382. // Use the HTML specific .css method
  8383. wrapper.css = wrapper.htmlCss;
  8384. // This is specific for HTML within SVG
  8385. if (isSVG) {
  8386. wrapper.add = function (svgGroupWrapper) {
  8387. var htmlGroup, container = renderer.box.parentNode, parentGroup, parents = [];
  8388. this.parentGroup = svgGroupWrapper;
  8389. // Create a mock group to hold the HTML elements
  8390. if (svgGroupWrapper) {
  8391. htmlGroup = svgGroupWrapper.div;
  8392. if (!htmlGroup) {
  8393. // Read the parent chain into an array and read from top
  8394. // down
  8395. parentGroup = svgGroupWrapper;
  8396. while (parentGroup) {
  8397. parents.push(parentGroup);
  8398. // Move up to the next parent group
  8399. parentGroup = parentGroup.parentGroup;
  8400. }
  8401. // Ensure dynamically updating position when any parent
  8402. // is translated
  8403. parents.reverse().forEach(function (parentGroup) {
  8404. var htmlGroupStyle, cls = attr(parentGroup.element, 'class');
  8405. /**
  8406. * Common translate setter for X and Y on the HTML
  8407. * group. Reverted the fix for #6957 du to
  8408. * positioning problems and offline export (#7254,
  8409. * #7280, #7529)
  8410. * @private
  8411. * @param {*} value
  8412. * @param {string} key
  8413. * @return {void}
  8414. */
  8415. function translateSetter(value, key) {
  8416. parentGroup[key] = value;
  8417. if (key === 'translateX') {
  8418. htmlGroupStyle.left = value + 'px';
  8419. }
  8420. else {
  8421. htmlGroupStyle.top = value + 'px';
  8422. }
  8423. parentGroup.doTransform = true;
  8424. }
  8425. // Create a HTML div and append it to the parent div
  8426. // to emulate the SVG group structure
  8427. htmlGroup =
  8428. parentGroup.div =
  8429. parentGroup.div || createElement('div', cls ? { className: cls } : void 0, {
  8430. position: 'absolute',
  8431. left: (parentGroup.translateX || 0) + 'px',
  8432. top: (parentGroup.translateY || 0) + 'px',
  8433. display: parentGroup.display,
  8434. opacity: parentGroup.opacity,
  8435. pointerEvents: (parentGroup.styles &&
  8436. parentGroup.styles.pointerEvents) // #5595
  8437. // the top group is appended to container
  8438. }, htmlGroup || container);
  8439. // Shortcut
  8440. htmlGroupStyle = htmlGroup.style;
  8441. // Set listeners to update the HTML div's position
  8442. // whenever the SVG group position is changed.
  8443. extend(parentGroup, {
  8444. // (#7287) Pass htmlGroup to use
  8445. // the related group
  8446. classSetter: (function (htmlGroup) {
  8447. return function (value) {
  8448. this.element.setAttribute('class', value);
  8449. htmlGroup.className = value;
  8450. };
  8451. }(htmlGroup)),
  8452. on: function () {
  8453. if (parents[0].div) { // #6418
  8454. wrapper.on.apply({ element: parents[0].div }, arguments);
  8455. }
  8456. return parentGroup;
  8457. },
  8458. translateXSetter: translateSetter,
  8459. translateYSetter: translateSetter
  8460. });
  8461. if (!parentGroup.addedSetters) {
  8462. addSetters(parentGroup);
  8463. }
  8464. });
  8465. }
  8466. }
  8467. else {
  8468. htmlGroup = container;
  8469. }
  8470. htmlGroup.appendChild(element);
  8471. // Shared with VML:
  8472. wrapper.added = true;
  8473. if (wrapper.alignOnAdd) {
  8474. wrapper.htmlUpdateTransform();
  8475. }
  8476. return wrapper;
  8477. };
  8478. }
  8479. return wrapper;
  8480. }
  8481. });
  8482. });
  8483. _registerModule(_modules, 'parts/Tick.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  8484. /* *
  8485. *
  8486. * (c) 2010-2020 Torstein Honsi
  8487. *
  8488. * License: www.highcharts.com/license
  8489. *
  8490. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8491. *
  8492. * */
  8493. /**
  8494. * Optional parameters for the tick.
  8495. * @private
  8496. * @interface Highcharts.TickParametersObject
  8497. */ /**
  8498. * Set category for the tick.
  8499. * @name Highcharts.TickParametersObject#category
  8500. * @type {string|undefined}
  8501. */ /**
  8502. * @name Highcharts.TickParametersObject#options
  8503. * @type {Highcharts.Dictionary<any>|undefined}
  8504. */ /**
  8505. * Set tickmarkOffset for the tick.
  8506. * @name Highcharts.TickParametersObject#tickmarkOffset
  8507. * @type {number|undefined}
  8508. */
  8509. var clamp = U.clamp, correctFloat = U.correctFloat, defined = U.defined, destroyObjectProperties = U.destroyObjectProperties, extend = U.extend, fireEvent = U.fireEvent, isNumber = U.isNumber, merge = U.merge, objectEach = U.objectEach, pick = U.pick;
  8510. var deg2rad = H.deg2rad;
  8511. /* eslint-disable no-invalid-this, valid-jsdoc */
  8512. /**
  8513. * The Tick class.
  8514. *
  8515. * @class
  8516. * @name Highcharts.Tick
  8517. *
  8518. * @param {Highcharts.Axis} axis
  8519. * The axis of the tick.
  8520. *
  8521. * @param {number} pos
  8522. * The position of the tick on the axis in terms of axis values.
  8523. *
  8524. * @param {string} [type]
  8525. * The type of tick, either 'minor' or an empty string
  8526. *
  8527. * @param {boolean} [noLabel=false]
  8528. * Whether to disable the label or not. Defaults to false.
  8529. *
  8530. * @param {object} [parameters]
  8531. * Optional parameters for the tick.
  8532. */
  8533. var Tick = /** @class */ (function () {
  8534. /* *
  8535. *
  8536. * Constructors
  8537. *
  8538. * */
  8539. function Tick(axis, pos, type, noLabel, parameters) {
  8540. this.isNew = true;
  8541. this.isNewLabel = true;
  8542. /**
  8543. * The related axis of the tick.
  8544. * @name Highcharts.Tick#axis
  8545. * @type {Highcharts.Axis}
  8546. */
  8547. this.axis = axis;
  8548. /**
  8549. * The logical position of the tick on the axis in terms of axis values.
  8550. * @name Highcharts.Tick#pos
  8551. * @type {number}
  8552. */
  8553. this.pos = pos;
  8554. /**
  8555. * The tick type, which can be `"minor"`, or an empty string.
  8556. * @name Highcharts.Tick#type
  8557. * @type {string}
  8558. */
  8559. this.type = type || '';
  8560. this.parameters = parameters || {};
  8561. /**
  8562. * The mark offset of the tick on the axis. Usually `undefined`, numeric
  8563. * for grid axes.
  8564. * @name Highcharts.Tick#tickmarkOffset
  8565. * @type {number|undefined}
  8566. */
  8567. this.tickmarkOffset = this.parameters.tickmarkOffset;
  8568. this.options = this.parameters.options;
  8569. fireEvent(this, 'init');
  8570. if (!type && !noLabel) {
  8571. this.addLabel();
  8572. }
  8573. }
  8574. /* *
  8575. *
  8576. * Functions
  8577. *
  8578. * */
  8579. /**
  8580. * Write the tick label.
  8581. *
  8582. * @private
  8583. * @function Highcharts.Tick#addLabel
  8584. * @return {void}
  8585. */
  8586. Tick.prototype.addLabel = function () {
  8587. var tick = this, axis = tick.axis, options = axis.options, chart = axis.chart, categories = axis.categories, log = axis.logarithmic, names = axis.names, pos = tick.pos, labelOptions = pick(tick.options && tick.options.labels, options.labels), str, tickPositions = axis.tickPositions, isFirst = pos === tickPositions[0], isLast = pos === tickPositions[tickPositions.length - 1], value = this.parameters.category || (categories ?
  8588. pick(categories[pos], names[pos], pos) :
  8589. pos), label = tick.label, animateLabels = (!labelOptions.step || labelOptions.step === 1) &&
  8590. axis.tickInterval === 1, tickPositionInfo = tickPositions.info, dateTimeLabelFormat, dateTimeLabelFormats, i, list;
  8591. // Set the datetime label format. If a higher rank is set for this
  8592. // position, use that. If not, use the general format.
  8593. if (axis.dateTime && tickPositionInfo) {
  8594. dateTimeLabelFormats = chart.time.resolveDTLFormat(options.dateTimeLabelFormats[(!options.grid &&
  8595. tickPositionInfo.higherRanks[pos]) ||
  8596. tickPositionInfo.unitName]);
  8597. dateTimeLabelFormat = dateTimeLabelFormats.main;
  8598. }
  8599. // set properties for access in render method
  8600. /**
  8601. * True if the tick is the first one on the axis.
  8602. * @name Highcharts.Tick#isFirst
  8603. * @readonly
  8604. * @type {boolean|undefined}
  8605. */
  8606. tick.isFirst = isFirst;
  8607. /**
  8608. * True if the tick is the last one on the axis.
  8609. * @name Highcharts.Tick#isLast
  8610. * @readonly
  8611. * @type {boolean|undefined}
  8612. */
  8613. tick.isLast = isLast;
  8614. // Get the string
  8615. tick.formatCtx = {
  8616. axis: axis,
  8617. chart: chart,
  8618. isFirst: isFirst,
  8619. isLast: isLast,
  8620. dateTimeLabelFormat: dateTimeLabelFormat,
  8621. tickPositionInfo: tickPositionInfo,
  8622. value: log ? correctFloat(log.lin2log(value)) : value,
  8623. pos: pos
  8624. };
  8625. str = axis.labelFormatter.call(tick.formatCtx, this.formatCtx);
  8626. // Set up conditional formatting based on the format list if existing.
  8627. list = dateTimeLabelFormats && dateTimeLabelFormats.list;
  8628. if (list) {
  8629. tick.shortenLabel = function () {
  8630. for (i = 0; i < list.length; i++) {
  8631. label.attr({
  8632. text: axis.labelFormatter.call(extend(tick.formatCtx, { dateTimeLabelFormat: list[i] }))
  8633. });
  8634. if (label.getBBox().width <
  8635. axis.getSlotWidth(tick) - 2 *
  8636. pick(labelOptions.padding, 5)) {
  8637. return;
  8638. }
  8639. }
  8640. label.attr({
  8641. text: ''
  8642. });
  8643. };
  8644. }
  8645. // Call only after first render
  8646. if (animateLabels && axis._addedPlotLB && axis.isXAxis) {
  8647. tick.moveLabel(str, labelOptions);
  8648. }
  8649. // First call
  8650. if (!defined(label) && !tick.movedLabel) {
  8651. /**
  8652. * The rendered text label of the tick.
  8653. * @name Highcharts.Tick#label
  8654. * @type {Highcharts.SVGElement|undefined}
  8655. */
  8656. tick.label = label = tick.createLabel({ x: 0, y: 0 }, str, labelOptions);
  8657. // Base value to detect change for new calls to getBBox
  8658. tick.rotation = 0;
  8659. // update
  8660. }
  8661. else if (label && label.textStr !== str && !animateLabels) {
  8662. // When resetting text, also reset the width if dynamically set
  8663. // (#8809)
  8664. if (label.textWidth &&
  8665. !(labelOptions.style && labelOptions.style.width) &&
  8666. !label.styles.width) {
  8667. label.css({ width: null });
  8668. }
  8669. label.attr({ text: str });
  8670. label.textPxLength = label.getBBox().width;
  8671. }
  8672. };
  8673. /**
  8674. * Render and return the label of the tick.
  8675. *
  8676. * @private
  8677. * @function Highcharts.Tick#createLabel
  8678. * @param {Highcharts.PositionObject} xy
  8679. * @param {string} str
  8680. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  8681. * @return {Highcharts.SVGElement|undefined}
  8682. */
  8683. Tick.prototype.createLabel = function (xy, str, labelOptions) {
  8684. var axis = this.axis, chart = axis.chart, label = defined(str) && labelOptions.enabled ?
  8685. chart.renderer
  8686. .text(str, xy.x, xy.y, labelOptions.useHTML)
  8687. .add(axis.labelGroup) :
  8688. null;
  8689. // Un-rotated length
  8690. if (label) {
  8691. // Without position absolute, IE export sometimes is wrong
  8692. if (!chart.styledMode) {
  8693. label.css(merge(labelOptions.style));
  8694. }
  8695. label.textPxLength = label.getBBox().width;
  8696. }
  8697. return label;
  8698. };
  8699. /**
  8700. * Destructor for the tick prototype
  8701. *
  8702. * @private
  8703. * @function Highcharts.Tick#destroy
  8704. * @return {void}
  8705. */
  8706. Tick.prototype.destroy = function () {
  8707. destroyObjectProperties(this, this.axis);
  8708. };
  8709. /**
  8710. * Gets the x and y positions for ticks in terms of pixels.
  8711. *
  8712. * @private
  8713. * @function Highcharts.Tick#getPosition
  8714. *
  8715. * @param {boolean} horiz
  8716. * Whether the tick is on an horizontal axis or not.
  8717. *
  8718. * @param {number} tickPos
  8719. * Position of the tick.
  8720. *
  8721. * @param {number} tickmarkOffset
  8722. * Tickmark offset for all ticks.
  8723. *
  8724. * @param {boolean} [old]
  8725. * Whether the axis has changed or not.
  8726. *
  8727. * @return {Highcharts.PositionObject}
  8728. * The tick position.
  8729. *
  8730. * @fires Highcharts.Tick#event:afterGetPosition
  8731. */
  8732. Tick.prototype.getPosition = function (horiz, tickPos, tickmarkOffset, old) {
  8733. var axis = this.axis, chart = axis.chart, cHeight = (old && chart.oldChartHeight) || chart.chartHeight, pos;
  8734. pos = {
  8735. x: horiz ?
  8736. correctFloat(axis.translate(tickPos + tickmarkOffset, null, null, old) +
  8737. axis.transB) :
  8738. (axis.left +
  8739. axis.offset +
  8740. (axis.opposite ?
  8741. (((old && chart.oldChartWidth) ||
  8742. chart.chartWidth) -
  8743. axis.right -
  8744. axis.left) :
  8745. 0)),
  8746. y: horiz ?
  8747. (cHeight -
  8748. axis.bottom +
  8749. axis.offset -
  8750. (axis.opposite ? axis.height : 0)) :
  8751. correctFloat(cHeight -
  8752. axis.translate(tickPos + tickmarkOffset, null, null, old) -
  8753. axis.transB)
  8754. };
  8755. // Chrome workaround for #10516
  8756. pos.y = clamp(pos.y, -1e5, 1e5);
  8757. fireEvent(this, 'afterGetPosition', { pos: pos });
  8758. return pos;
  8759. };
  8760. /**
  8761. * Get the x, y position of the tick label
  8762. *
  8763. * @private
  8764. * @return {Highcharts.PositionObject}
  8765. */
  8766. Tick.prototype.getLabelPosition = function (x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
  8767. var axis = this.axis, transA = axis.transA, reversed = ( // #7911
  8768. axis.isLinked && axis.linkedParent ?
  8769. axis.linkedParent.reversed :
  8770. axis.reversed), staggerLines = axis.staggerLines, rotCorr = axis.tickRotCorr || { x: 0, y: 0 }, yOffset = labelOptions.y,
  8771. // Adjust for label alignment if we use reserveSpace: true (#5286)
  8772. labelOffsetCorrection = (!horiz && !axis.reserveSpaceDefault ?
  8773. -axis.labelOffset * (axis.labelAlign === 'center' ? 0.5 : 1) :
  8774. 0), line, pos = {};
  8775. if (!defined(yOffset)) {
  8776. if (axis.side === 0) {
  8777. yOffset = label.rotation ? -8 : -label.getBBox().height;
  8778. }
  8779. else if (axis.side === 2) {
  8780. yOffset = rotCorr.y + 8;
  8781. }
  8782. else {
  8783. // #3140, #3140
  8784. yOffset = Math.cos(label.rotation * deg2rad) *
  8785. (rotCorr.y - label.getBBox(false, 0).height / 2);
  8786. }
  8787. }
  8788. x = x +
  8789. labelOptions.x +
  8790. labelOffsetCorrection +
  8791. rotCorr.x -
  8792. (tickmarkOffset && horiz ?
  8793. tickmarkOffset * transA * (reversed ? -1 : 1) :
  8794. 0);
  8795. y = y + yOffset - (tickmarkOffset && !horiz ?
  8796. tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
  8797. // Correct for staggered labels
  8798. if (staggerLines) {
  8799. line = (index / (step || 1) % staggerLines);
  8800. if (axis.opposite) {
  8801. line = staggerLines - line - 1;
  8802. }
  8803. y += line * (axis.labelOffset / staggerLines);
  8804. }
  8805. pos.x = x;
  8806. pos.y = Math.round(y);
  8807. fireEvent(this, 'afterGetLabelPosition', { pos: pos, tickmarkOffset: tickmarkOffset, index: index });
  8808. return pos;
  8809. };
  8810. /**
  8811. * Get the offset height or width of the label
  8812. *
  8813. * @private
  8814. * @function Highcharts.Tick#getLabelSize
  8815. * @return {number}
  8816. */
  8817. Tick.prototype.getLabelSize = function () {
  8818. return this.label ?
  8819. this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
  8820. 0;
  8821. };
  8822. /**
  8823. * Extendible method to return the path of the marker
  8824. *
  8825. * @private
  8826. *
  8827. */
  8828. Tick.prototype.getMarkPath = function (x, y, tickLength, tickWidth, horiz, renderer) {
  8829. return renderer.crispLine([[
  8830. 'M',
  8831. x,
  8832. y
  8833. ], [
  8834. 'L',
  8835. x + (horiz ? 0 : -tickLength),
  8836. y + (horiz ? tickLength : 0)
  8837. ]], tickWidth);
  8838. };
  8839. /**
  8840. * Handle the label overflow by adjusting the labels to the left and right
  8841. * edge, or hide them if they collide into the neighbour label.
  8842. *
  8843. * @private
  8844. * @function Highcharts.Tick#handleOverflow
  8845. * @param {Highcharts.PositionObject} xy
  8846. * @return {void}
  8847. */
  8848. Tick.prototype.handleOverflow = function (xy) {
  8849. var tick = this, axis = this.axis, labelOptions = axis.options.labels, pxPos = xy.x, chartWidth = axis.chart.chartWidth, spacing = axis.chart.spacing, leftBound = pick(axis.labelLeft, Math.min(axis.pos, spacing[3])), rightBound = pick(axis.labelRight, Math.max(!axis.isRadial ? axis.pos + axis.len : 0, chartWidth - spacing[1])), label = this.label, rotation = this.rotation, factor = {
  8850. left: 0,
  8851. center: 0.5,
  8852. right: 1
  8853. }[axis.labelAlign || label.attr('align')], labelWidth = label.getBBox().width, slotWidth = axis.getSlotWidth(tick), modifiedSlotWidth = slotWidth, xCorrection = factor, goRight = 1, leftPos, rightPos, textWidth, css = {};
  8854. // Check if the label overshoots the chart spacing box. If it does, move
  8855. // it. If it now overshoots the slotWidth, add ellipsis.
  8856. if (!rotation &&
  8857. pick(labelOptions.overflow, 'justify') === 'justify') {
  8858. leftPos = pxPos - factor * labelWidth;
  8859. rightPos = pxPos + (1 - factor) * labelWidth;
  8860. if (leftPos < leftBound) {
  8861. modifiedSlotWidth =
  8862. xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
  8863. }
  8864. else if (rightPos > rightBound) {
  8865. modifiedSlotWidth =
  8866. rightBound - xy.x + modifiedSlotWidth * factor;
  8867. goRight = -1;
  8868. }
  8869. modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
  8870. if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
  8871. xy.x += (goRight *
  8872. (slotWidth -
  8873. modifiedSlotWidth -
  8874. xCorrection * (slotWidth - Math.min(labelWidth, modifiedSlotWidth))));
  8875. }
  8876. // If the label width exceeds the available space, set a text width
  8877. // to be picked up below. Also, if a width has been set before, we
  8878. // need to set a new one because the reported labelWidth will be
  8879. // limited by the box (#3938).
  8880. if (labelWidth > modifiedSlotWidth ||
  8881. (axis.autoRotation && (label.styles || {}).width)) {
  8882. textWidth = modifiedSlotWidth;
  8883. }
  8884. // Add ellipsis to prevent rotated labels to be clipped against the edge
  8885. // of the chart
  8886. }
  8887. else if (rotation < 0 &&
  8888. pxPos - factor * labelWidth < leftBound) {
  8889. textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
  8890. }
  8891. else if (rotation > 0 &&
  8892. pxPos + factor * labelWidth > rightBound) {
  8893. textWidth = Math.round((chartWidth - pxPos) /
  8894. Math.cos(rotation * deg2rad));
  8895. }
  8896. if (textWidth) {
  8897. if (tick.shortenLabel) {
  8898. tick.shortenLabel();
  8899. }
  8900. else {
  8901. css.width = Math.floor(textWidth) + 'px';
  8902. if (!(labelOptions.style || {}).textOverflow) {
  8903. css.textOverflow = 'ellipsis';
  8904. }
  8905. label.css(css);
  8906. }
  8907. }
  8908. };
  8909. /**
  8910. * Try to replace the label if the same one already exists.
  8911. *
  8912. * @private
  8913. * @function Highcharts.Tick#moveLabel
  8914. * @param {string} str
  8915. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  8916. *
  8917. * @return {void}
  8918. */
  8919. Tick.prototype.moveLabel = function (str, labelOptions) {
  8920. var tick = this, label = tick.label, moved = false, xAxis = tick.axis, chart = xAxis.chart, labelPos, reversed = xAxis.reversed, inverted = chart.inverted, xPos, yPos;
  8921. if (label && label.textStr === str) {
  8922. tick.movedLabel = label;
  8923. moved = true;
  8924. delete tick.label;
  8925. }
  8926. else { // Find a label with the same string
  8927. objectEach(xAxis.ticks, function (currentTick) {
  8928. if (!moved &&
  8929. !currentTick.isNew &&
  8930. currentTick !== tick &&
  8931. currentTick.label &&
  8932. currentTick.label.textStr === str) {
  8933. tick.movedLabel = currentTick.label;
  8934. moved = true;
  8935. currentTick.labelPos = tick.movedLabel.xy;
  8936. delete currentTick.label;
  8937. }
  8938. });
  8939. }
  8940. // Create new label if the actual one is moved
  8941. if (!moved && (tick.labelPos || label)) {
  8942. labelPos = tick.labelPos || label.xy;
  8943. xPos = inverted ?
  8944. labelPos.x : (reversed ? 0 : xAxis.width + xAxis.left);
  8945. yPos = inverted ?
  8946. (reversed ? (xAxis.width + xAxis.left) : 0) : labelPos.y;
  8947. tick.movedLabel = tick.createLabel({ x: xPos, y: yPos }, str, labelOptions);
  8948. if (tick.movedLabel) {
  8949. tick.movedLabel.attr({ opacity: 0 });
  8950. }
  8951. }
  8952. };
  8953. /**
  8954. * Put everything in place
  8955. *
  8956. * @private
  8957. * @param {number} index
  8958. * @param {boolean} [old]
  8959. * Use old coordinates to prepare an animation into new position
  8960. * @param {number} [opacity]
  8961. * @return {voids}
  8962. */
  8963. Tick.prototype.render = function (index, old, opacity) {
  8964. var tick = this, axis = tick.axis, horiz = axis.horiz, pos = tick.pos, tickmarkOffset = pick(tick.tickmarkOffset, axis.tickmarkOffset), xy = tick.getPosition(horiz, pos, tickmarkOffset, old), x = xy.x, y = xy.y, reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
  8965. (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
  8966. opacity = pick(opacity, 1);
  8967. this.isActive = true;
  8968. // Create the grid line
  8969. this.renderGridLine(old, opacity, reverseCrisp);
  8970. // create the tick mark
  8971. this.renderMark(xy, opacity, reverseCrisp);
  8972. // the label is created on init - now move it into place
  8973. this.renderLabel(xy, old, opacity, index);
  8974. tick.isNew = false;
  8975. fireEvent(this, 'afterRender');
  8976. };
  8977. /**
  8978. * Renders the gridLine.
  8979. *
  8980. * @private
  8981. * @param {boolean} old Whether or not the tick is old
  8982. * @param {number} opacity The opacity of the grid line
  8983. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  8984. * @return {void}
  8985. */
  8986. Tick.prototype.renderGridLine = function (old, opacity, reverseCrisp) {
  8987. 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'];
  8988. if (!gridLine) {
  8989. if (!axis.chart.styledMode) {
  8990. attribs.stroke = gridLineColor;
  8991. attribs['stroke-width'] = gridLineWidth;
  8992. if (dashStyle) {
  8993. attribs.dashstyle = dashStyle;
  8994. }
  8995. }
  8996. if (!type) {
  8997. attribs.zIndex = 1;
  8998. }
  8999. if (old) {
  9000. opacity = 0;
  9001. }
  9002. /**
  9003. * The rendered grid line of the tick.
  9004. * @name Highcharts.Tick#gridLine
  9005. * @type {Highcharts.SVGElement|undefined}
  9006. */
  9007. tick.gridLine = gridLine = renderer.path()
  9008. .attr(attribs)
  9009. .addClass('highcharts-' + (type ? type + '-' : '') + 'grid-line')
  9010. .add(axis.gridGroup);
  9011. }
  9012. if (gridLine) {
  9013. gridLinePath = axis.getPlotLinePath({
  9014. value: pos + tickmarkOffset,
  9015. lineWidth: gridLine.strokeWidth() * reverseCrisp,
  9016. force: 'pass',
  9017. old: old
  9018. });
  9019. // If the parameter 'old' is set, the current call will be followed
  9020. // by another call, therefore do not do any animations this time
  9021. if (gridLinePath) {
  9022. gridLine[old || tick.isNew ? 'attr' : 'animate']({
  9023. d: gridLinePath,
  9024. opacity: opacity
  9025. });
  9026. }
  9027. }
  9028. };
  9029. /**
  9030. * Renders the tick mark.
  9031. *
  9032. * @private
  9033. * @param {Highcharts.PositionObject} xy The position vector of the mark
  9034. * @param {number} opacity The opacity of the mark
  9035. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  9036. * @return {void}
  9037. */
  9038. Tick.prototype.renderMark = function (xy, opacity, reverseCrisp) {
  9039. 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
  9040. tickColor = options[tickPrefix + 'Color'];
  9041. if (tickSize) {
  9042. // negate the length
  9043. if (axis.opposite) {
  9044. tickSize[0] = -tickSize[0];
  9045. }
  9046. // First time, create it
  9047. if (isNewMark) {
  9048. /**
  9049. * The rendered mark of the tick.
  9050. * @name Highcharts.Tick#mark
  9051. * @type {Highcharts.SVGElement|undefined}
  9052. */
  9053. tick.mark = mark = renderer.path()
  9054. .addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
  9055. .add(axis.axisGroup);
  9056. if (!axis.chart.styledMode) {
  9057. mark.attr({
  9058. stroke: tickColor,
  9059. 'stroke-width': tickWidth
  9060. });
  9061. }
  9062. }
  9063. mark[isNewMark ? 'attr' : 'animate']({
  9064. d: tick.getMarkPath(x, y, tickSize[0], mark.strokeWidth() * reverseCrisp, axis.horiz, renderer),
  9065. opacity: opacity
  9066. });
  9067. }
  9068. };
  9069. /**
  9070. * Renders the tick label.
  9071. * Note: The label should already be created in init(), so it should only
  9072. * have to be moved into place.
  9073. *
  9074. * @private
  9075. * @param {Highcharts.PositionObject} xy The position vector of the label
  9076. * @param {boolean} old Whether or not the tick is old
  9077. * @param {number} opacity The opacity of the label
  9078. * @param {number} index The index of the tick
  9079. * @return {void}
  9080. */
  9081. Tick.prototype.renderLabel = function (xy, old, opacity, index) {
  9082. var tick = this, axis = tick.axis, horiz = axis.horiz, options = axis.options, label = tick.label, labelOptions = options.labels, step = labelOptions.step, tickmarkOffset = pick(tick.tickmarkOffset, axis.tickmarkOffset), show = true, x = xy.x, y = xy.y;
  9083. if (label && isNumber(x)) {
  9084. label.xy = xy = tick.getLabelPosition(x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
  9085. // Apply show first and show last. If the tick is both first and
  9086. // last, it is a single centered tick, in which case we show the
  9087. // label anyway (#2100).
  9088. if ((tick.isFirst &&
  9089. !tick.isLast &&
  9090. !pick(options.showFirstLabel, 1)) ||
  9091. (tick.isLast &&
  9092. !tick.isFirst &&
  9093. !pick(options.showLastLabel, 1))) {
  9094. show = false;
  9095. // Handle label overflow and show or hide accordingly
  9096. }
  9097. else if (horiz &&
  9098. !labelOptions.step &&
  9099. !labelOptions.rotation &&
  9100. !old &&
  9101. opacity !== 0) {
  9102. tick.handleOverflow(xy);
  9103. }
  9104. // apply step
  9105. if (step && index % step) {
  9106. // show those indices dividable by step
  9107. show = false;
  9108. }
  9109. // Set the new position, and show or hide
  9110. if (show && isNumber(xy.y)) {
  9111. xy.opacity = opacity;
  9112. label[tick.isNewLabel ? 'attr' : 'animate'](xy);
  9113. tick.isNewLabel = false;
  9114. }
  9115. else {
  9116. label.attr('y', -9999); // #1338
  9117. tick.isNewLabel = true;
  9118. }
  9119. }
  9120. };
  9121. /**
  9122. * Replace labels with the moved ones to perform animation. Additionally
  9123. * destroy unused labels.
  9124. *
  9125. * @private
  9126. * @function Highcharts.Tick#replaceMovedLabel
  9127. * @return {void}
  9128. */
  9129. Tick.prototype.replaceMovedLabel = function () {
  9130. var tick = this, label = tick.label, axis = tick.axis, reversed = axis.reversed, chart = tick.axis.chart, inverted = chart.inverted, x, y;
  9131. // Animate and destroy
  9132. if (label && !tick.isNew) {
  9133. x = inverted ? label.xy.x : (reversed ? axis.left : axis.width + axis.left);
  9134. y = inverted ?
  9135. (reversed ? axis.width + axis.top : axis.top) :
  9136. label.xy.y;
  9137. label.animate({ x: x, y: y, opacity: 0 }, void 0, label.destroy);
  9138. delete tick.label;
  9139. }
  9140. axis.isDirty = true;
  9141. tick.label = tick.movedLabel;
  9142. delete tick.movedLabel;
  9143. };
  9144. return Tick;
  9145. }());
  9146. H.Tick = Tick;
  9147. return H.Tick;
  9148. });
  9149. _registerModule(_modules, 'parts/Time.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (Highcharts, U) {
  9150. /* *
  9151. *
  9152. * (c) 2010-2020 Torstein Honsi
  9153. *
  9154. * License: www.highcharts.com/license
  9155. *
  9156. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9157. *
  9158. * */
  9159. /**
  9160. * Normalized interval.
  9161. *
  9162. * @interface Highcharts.TimeNormalizedObject
  9163. */ /**
  9164. * The count.
  9165. *
  9166. * @name Highcharts.TimeNormalizedObject#count
  9167. * @type {number}
  9168. */ /**
  9169. * The interval in axis values (ms).
  9170. *
  9171. * @name Highcharts.TimeNormalizedObject#unitRange
  9172. * @type {number}
  9173. */
  9174. /**
  9175. * Function of an additional date format specifier.
  9176. *
  9177. * @callback Highcharts.TimeFormatCallbackFunction
  9178. *
  9179. * @param {number} timestamp
  9180. * The time to format.
  9181. *
  9182. * @return {string}
  9183. * The formatted portion of the date.
  9184. */
  9185. /**
  9186. * Additonal time tick information.
  9187. *
  9188. * @interface Highcharts.TimeTicksInfoObject
  9189. * @extends Highcharts.TimeNormalizedObject
  9190. */ /**
  9191. * @name Highcharts.TimeTicksInfoObject#higherRanks
  9192. * @type {Array<string>}
  9193. */ /**
  9194. * @name Highcharts.TimeTicksInfoObject#totalRange
  9195. * @type {number}
  9196. */
  9197. /**
  9198. * Time ticks.
  9199. *
  9200. * @interface Highcharts.AxisTickPositionsArray
  9201. * @extends global.Array<number>
  9202. */ /**
  9203. * @name Highcharts.AxisTickPositionsArray#info
  9204. * @type {Highcharts.TimeTicksInfoObject|undefined}
  9205. */
  9206. /**
  9207. * A callback to return the time zone offset for a given datetime. It
  9208. * takes the timestamp in terms of milliseconds since January 1 1970,
  9209. * and returns the timezone offset in minutes. This provides a hook
  9210. * for drawing time based charts in specific time zones using their
  9211. * local DST crossover dates, with the help of external libraries.
  9212. *
  9213. * @callback Highcharts.TimezoneOffsetCallbackFunction
  9214. *
  9215. * @param {number} timestamp
  9216. * Timestamp in terms of milliseconds since January 1 1970.
  9217. *
  9218. * @return {number}
  9219. * Timezone offset in minutes.
  9220. */
  9221. var defined = U.defined, error = U.error, extend = U.extend, isObject = U.isObject, merge = U.merge, objectEach = U.objectEach, pad = U.pad, pick = U.pick, splat = U.splat, timeUnits = U.timeUnits;
  9222. var H = Highcharts, win = H.win;
  9223. /* eslint-disable no-invalid-this, valid-jsdoc */
  9224. /**
  9225. * The Time class. Time settings are applied in general for each page using
  9226. * `Highcharts.setOptions`, or individually for each Chart item through the
  9227. * [time](https://api.highcharts.com/highcharts/time) options set.
  9228. *
  9229. * The Time object is available from {@link Highcharts.Chart#time},
  9230. * which refers to `Highcharts.time` if no individual time settings are
  9231. * applied.
  9232. *
  9233. * @example
  9234. * // Apply time settings globally
  9235. * Highcharts.setOptions({
  9236. * time: {
  9237. * timezone: 'Europe/London'
  9238. * }
  9239. * });
  9240. *
  9241. * // Apply time settings by instance
  9242. * var chart = Highcharts.chart('container', {
  9243. * time: {
  9244. * timezone: 'America/New_York'
  9245. * },
  9246. * series: [{
  9247. * data: [1, 4, 3, 5]
  9248. * }]
  9249. * });
  9250. *
  9251. * // Use the Time object
  9252. * console.log(
  9253. * 'Current time in New York',
  9254. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  9255. * );
  9256. *
  9257. * @since 6.0.5
  9258. *
  9259. * @class
  9260. * @name Highcharts.Time
  9261. *
  9262. * @param {Highcharts.TimeOptions} options
  9263. * Time options as defined in [chart.options.time](/highcharts/time).
  9264. */
  9265. var Time = /** @class */ (function () {
  9266. /* *
  9267. *
  9268. * Constructors
  9269. *
  9270. * */
  9271. function Time(options) {
  9272. /* *
  9273. *
  9274. * Properties
  9275. *
  9276. * */
  9277. this.options = {};
  9278. this.useUTC = false;
  9279. this.variableTimezone = false;
  9280. this.Date = win.Date;
  9281. /**
  9282. * Get the time zone offset based on the current timezone information as
  9283. * set in the global options.
  9284. *
  9285. * @function Highcharts.Time#getTimezoneOffset
  9286. *
  9287. * @param {number} timestamp
  9288. * The JavaScript timestamp to inspect.
  9289. *
  9290. * @return {number}
  9291. * The timezone offset in minutes compared to UTC.
  9292. */
  9293. this.getTimezoneOffset = this.timezoneOffsetFunction();
  9294. this.update(options);
  9295. }
  9296. /* *
  9297. *
  9298. * Functions
  9299. *
  9300. * */
  9301. /**
  9302. * Time units used in `Time.get` and `Time.set`
  9303. *
  9304. * @typedef {"Date"|"Day"|"FullYear"|"Hours"|"Milliseconds"|"Minutes"|"Month"|"Seconds"} Highcharts.TimeUnitValue
  9305. */
  9306. /**
  9307. * Get the value of a date object in given units, and subject to the Time
  9308. * object's current timezone settings. This function corresponds directly to
  9309. * JavaScripts `Date.getXXX / Date.getUTCXXX`, so instead of calling
  9310. * `date.getHours()` or `date.getUTCHours()` we will call
  9311. * `time.get('Hours')`.
  9312. *
  9313. * @function Highcharts.Time#get
  9314. *
  9315. * @param {Highcharts.TimeUnitValue} unit
  9316. * @param {Date} date
  9317. *
  9318. * @return {number}
  9319. * The given time unit
  9320. */
  9321. Time.prototype.get = function (unit, date) {
  9322. if (this.variableTimezone || this.timezoneOffset) {
  9323. var realMs = date.getTime();
  9324. var ms = realMs - this.getTimezoneOffset(date);
  9325. date.setTime(ms); // Temporary adjust to timezone
  9326. var ret = date['getUTC' + unit]();
  9327. date.setTime(realMs); // Reset
  9328. return ret;
  9329. }
  9330. // UTC time with no timezone handling
  9331. if (this.useUTC) {
  9332. return date['getUTC' + unit]();
  9333. }
  9334. // Else, local time
  9335. return date['get' + unit]();
  9336. };
  9337. /**
  9338. * Set the value of a date object in given units, and subject to the Time
  9339. * object's current timezone settings. This function corresponds directly to
  9340. * JavaScripts `Date.setXXX / Date.setUTCXXX`, so instead of calling
  9341. * `date.setHours(0)` or `date.setUTCHours(0)` we will call
  9342. * `time.set('Hours', 0)`.
  9343. *
  9344. * @function Highcharts.Time#set
  9345. *
  9346. * @param {Highcharts.TimeUnitValue} unit
  9347. * @param {Date} date
  9348. * @param {number} value
  9349. *
  9350. * @return {number}
  9351. * The epoch milliseconds of the updated date
  9352. */
  9353. Time.prototype.set = function (unit, date, value) {
  9354. // UTC time with timezone handling
  9355. if (this.variableTimezone || this.timezoneOffset) {
  9356. // For lower order time units, just set it directly using UTC
  9357. // time
  9358. if (unit === 'Milliseconds' ||
  9359. unit === 'Seconds' ||
  9360. unit === 'Minutes') {
  9361. return date['setUTC' + unit](value);
  9362. }
  9363. // Higher order time units need to take the time zone into
  9364. // account
  9365. // Adjust by timezone
  9366. var offset = this.getTimezoneOffset(date);
  9367. var ms = date.getTime() - offset;
  9368. date.setTime(ms);
  9369. date['setUTC' + unit](value);
  9370. var newOffset = this.getTimezoneOffset(date);
  9371. ms = date.getTime() + newOffset;
  9372. return date.setTime(ms);
  9373. }
  9374. // UTC time with no timezone handling
  9375. if (this.useUTC) {
  9376. return date['setUTC' + unit](value);
  9377. }
  9378. // Else, local time
  9379. return date['set' + unit](value);
  9380. };
  9381. /**
  9382. * Update the Time object with current options. It is called internally on
  9383. * initializing Highcharts, after running `Highcharts.setOptions` and on
  9384. * `Chart.update`.
  9385. *
  9386. * @private
  9387. * @function Highcharts.Time#update
  9388. *
  9389. * @param {Highcharts.TimeOptions} options
  9390. *
  9391. * @return {void}
  9392. */
  9393. Time.prototype.update = function (options) {
  9394. var useUTC = pick(options && options.useUTC, true), time = this;
  9395. this.options = options = merge(true, this.options || {}, options);
  9396. // Allow using a different Date class
  9397. this.Date = options.Date || win.Date || Date;
  9398. this.useUTC = useUTC;
  9399. this.timezoneOffset = (useUTC && options.timezoneOffset);
  9400. this.getTimezoneOffset = this.timezoneOffsetFunction();
  9401. /*
  9402. * The time object has options allowing for variable time zones, meaning
  9403. * the axis ticks or series data needs to consider this.
  9404. */
  9405. this.variableTimezone = !!(!useUTC ||
  9406. options.getTimezoneOffset ||
  9407. options.timezone);
  9408. };
  9409. /**
  9410. * Make a time and returns milliseconds. Interprets the inputs as UTC time,
  9411. * local time or a specific timezone time depending on the current time
  9412. * settings.
  9413. *
  9414. * @function Highcharts.Time#makeTime
  9415. *
  9416. * @param {number} year
  9417. * The year
  9418. *
  9419. * @param {number} month
  9420. * The month. Zero-based, so January is 0.
  9421. *
  9422. * @param {number} [date=1]
  9423. * The day of the month
  9424. *
  9425. * @param {number} [hours=0]
  9426. * The hour of the day, 0-23.
  9427. *
  9428. * @param {number} [minutes=0]
  9429. * The minutes
  9430. *
  9431. * @param {number} [seconds=0]
  9432. * The seconds
  9433. *
  9434. * @return {number}
  9435. * The time in milliseconds since January 1st 1970.
  9436. */
  9437. Time.prototype.makeTime = function (year, month, date, hours, minutes, seconds) {
  9438. var d, offset, newOffset;
  9439. if (this.useUTC) {
  9440. d = this.Date.UTC.apply(0, arguments);
  9441. offset = this.getTimezoneOffset(d);
  9442. d += offset;
  9443. newOffset = this.getTimezoneOffset(d);
  9444. if (offset !== newOffset) {
  9445. d += newOffset - offset;
  9446. // A special case for transitioning from summer time to winter time.
  9447. // When the clock is set back, the same time is repeated twice, i.e.
  9448. // 02:30 am is repeated since the clock is set back from 3 am to
  9449. // 2 am. We need to make the same time as local Date does.
  9450. }
  9451. else if (offset - 36e5 === this.getTimezoneOffset(d - 36e5) &&
  9452. !H.isSafari) {
  9453. d -= 36e5;
  9454. }
  9455. }
  9456. else {
  9457. d = new this.Date(year, month, pick(date, 1), pick(hours, 0), pick(minutes, 0), pick(seconds, 0)).getTime();
  9458. }
  9459. return d;
  9460. };
  9461. /**
  9462. * Sets the getTimezoneOffset function. If the `timezone` option is set, a
  9463. * default getTimezoneOffset function with that timezone is returned. If
  9464. * a `getTimezoneOffset` option is defined, it is returned. If neither are
  9465. * specified, the function using the `timezoneOffset` option or 0 offset is
  9466. * returned.
  9467. *
  9468. * @private
  9469. * @function Highcharts.Time#timezoneOffsetFunction
  9470. *
  9471. * @return {Function}
  9472. * A getTimezoneOffset function
  9473. */
  9474. Time.prototype.timezoneOffsetFunction = function () {
  9475. var time = this, options = this.options, moment = win.moment;
  9476. if (!this.useUTC) {
  9477. return function (timestamp) {
  9478. return new Date(timestamp.toString()).getTimezoneOffset() * 60000;
  9479. };
  9480. }
  9481. if (options.timezone) {
  9482. if (!moment) {
  9483. // getTimezoneOffset-function stays undefined because it depends
  9484. // on Moment.js
  9485. error(25);
  9486. }
  9487. else {
  9488. return function (timestamp) {
  9489. return -moment.tz(timestamp, options.timezone).utcOffset() * 60000;
  9490. };
  9491. }
  9492. }
  9493. // If not timezone is set, look for the getTimezoneOffset callback
  9494. if (this.useUTC && options.getTimezoneOffset) {
  9495. return function (timestamp) {
  9496. return options.getTimezoneOffset(timestamp.valueOf()) * 60000;
  9497. };
  9498. }
  9499. // Last, use the `timezoneOffset` option if set
  9500. return function () {
  9501. return (time.timezoneOffset || 0) * 60000;
  9502. };
  9503. };
  9504. /**
  9505. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970)
  9506. * into a human readable date string. The available format keys are listed
  9507. * below. Additional formats can be given in the
  9508. * {@link Highcharts.dateFormats} hook.
  9509. *
  9510. * Supported format keys:
  9511. * - `%a`: Short weekday, like 'Mon'
  9512. * - `%A`: Long weekday, like 'Monday'
  9513. * - `%d`: Two digit day of the month, 01 to 31
  9514. * - `%e`: Day of the month, 1 through 31
  9515. * - `%w`: Day of the week, 0 through 6
  9516. * - `%b`: Short month, like 'Jan'
  9517. * - `%B`: Long month, like 'January'
  9518. * - `%m`: Two digit month number, 01 through 12
  9519. * - `%y`: Two digits year, like 09 for 2009
  9520. * - `%Y`: Four digits year, like 2009
  9521. * - `%H`: Two digits hours in 24h format, 00 through 23
  9522. * - `%k`: Hours in 24h format, 0 through 23
  9523. * - `%I`: Two digits hours in 12h format, 00 through 11
  9524. * - `%l`: Hours in 12h format, 1 through 12
  9525. * - `%M`: Two digits minutes, 00 through 59
  9526. * - `%p`: Upper case AM or PM
  9527. * - `%P`: Lower case AM or PM
  9528. * - `%S`: Two digits seconds, 00 through 59
  9529. * - `%L`: Milliseconds (naming from Ruby)
  9530. *
  9531. * @example
  9532. * const time = new Highcharts.Time();
  9533. * const s = time.dateFormat('%Y-%m-%d %H:%M:%S', Date.UTC(2020, 0, 1));
  9534. * console.log(s); // => 2020-01-01 00:00:00
  9535. *
  9536. * @function Highcharts.Time#dateFormat
  9537. *
  9538. * @param {string} format
  9539. * The desired format where various time representations are
  9540. * prefixed with %.
  9541. *
  9542. * @param {number} timestamp
  9543. * The JavaScript timestamp.
  9544. *
  9545. * @param {boolean} [capitalize=false]
  9546. * Upper case first letter in the return.
  9547. *
  9548. * @return {string}
  9549. * The formatted date.
  9550. */
  9551. Time.prototype.dateFormat = function (format, timestamp, capitalize) {
  9552. var _a;
  9553. if (!defined(timestamp) || isNaN(timestamp)) {
  9554. return ((_a = H.defaultOptions.lang) === null || _a === void 0 ? void 0 : _a.invalidDate) || '';
  9555. }
  9556. format = pick(format, '%Y-%m-%d %H:%M:%S');
  9557. var time = this, date = new this.Date(timestamp),
  9558. // get the basic time values
  9559. 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,
  9560. // List all format keys. Custom formats can be added from the
  9561. // outside.
  9562. replacements = extend({
  9563. // Day
  9564. // Short weekday, like 'Mon'
  9565. a: shortWeekdays ?
  9566. shortWeekdays[day] :
  9567. langWeekdays[day].substr(0, 3),
  9568. // Long weekday, like 'Monday'
  9569. A: langWeekdays[day],
  9570. // Two digit day of the month, 01 to 31
  9571. d: pad(dayOfMonth),
  9572. // Day of the month, 1 through 31
  9573. e: pad(dayOfMonth, 2, ' '),
  9574. // Day of the week, 0 through 6
  9575. w: day,
  9576. // Week (none implemented)
  9577. // 'W': weekNumber(),
  9578. // Month
  9579. // Short month, like 'Jan'
  9580. b: lang.shortMonths[month],
  9581. // Long month, like 'January'
  9582. B: lang.months[month],
  9583. // Two digit month number, 01 through 12
  9584. m: pad(month + 1),
  9585. // Month number, 1 through 12 (#8150)
  9586. o: month + 1,
  9587. // Year
  9588. // Two digits year, like 09 for 2009
  9589. y: fullYear.toString().substr(2, 2),
  9590. // Four digits year, like 2009
  9591. Y: fullYear,
  9592. // Time
  9593. // Two digits hours in 24h format, 00 through 23
  9594. H: pad(hours),
  9595. // Hours in 24h format, 0 through 23
  9596. k: hours,
  9597. // Two digits hours in 12h format, 00 through 11
  9598. I: pad((hours % 12) || 12),
  9599. // Hours in 12h format, 1 through 12
  9600. l: (hours % 12) || 12,
  9601. // Two digits minutes, 00 through 59
  9602. M: pad(this.get('Minutes', date)),
  9603. // Upper case AM or PM
  9604. p: hours < 12 ? 'AM' : 'PM',
  9605. // Lower case AM or PM
  9606. P: hours < 12 ? 'am' : 'pm',
  9607. // Two digits seconds, 00 through 59
  9608. S: pad(date.getSeconds()),
  9609. // Milliseconds (naming from Ruby)
  9610. L: pad(Math.floor(timestamp % 1000), 3)
  9611. }, H.dateFormats);
  9612. // Do the replaces
  9613. objectEach(replacements, function (val, key) {
  9614. // Regex would do it in one line, but this is faster
  9615. while (format.indexOf('%' + key) !== -1) {
  9616. format = format.replace('%' + key, typeof val === 'function' ? val.call(time, timestamp) : val);
  9617. }
  9618. });
  9619. // Optionally capitalize the string and return
  9620. return capitalize ?
  9621. (format.substr(0, 1).toUpperCase() +
  9622. format.substr(1)) :
  9623. format;
  9624. };
  9625. /**
  9626. * Resolve legacy formats of dateTimeLabelFormats (strings and arrays) into
  9627. * an object.
  9628. * @private
  9629. * @param {string|Array<T>|Highcharts.Dictionary<T>} f - General format description
  9630. * @return {Highcharts.Dictionary<T>} - The object definition
  9631. */
  9632. Time.prototype.resolveDTLFormat = function (f) {
  9633. if (!isObject(f, true)) { // check for string or array
  9634. f = splat(f);
  9635. return {
  9636. main: f[0],
  9637. from: f[1],
  9638. to: f[2]
  9639. };
  9640. }
  9641. return f;
  9642. };
  9643. /**
  9644. * Return an array with time positions distributed on round time values
  9645. * right and right after min and max. Used in datetime axes as well as for
  9646. * grouping data on a datetime axis.
  9647. *
  9648. * @function Highcharts.Time#getTimeTicks
  9649. *
  9650. * @param {Highcharts.TimeNormalizedObject} normalizedInterval
  9651. * The interval in axis values (ms) and the count
  9652. *
  9653. * @param {number} [min]
  9654. * The minimum in axis values
  9655. *
  9656. * @param {number} [max]
  9657. * The maximum in axis values
  9658. *
  9659. * @param {number} [startOfWeek=1]
  9660. *
  9661. * @return {Highcharts.AxisTickPositionsArray}
  9662. */
  9663. Time.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek) {
  9664. var time = this, Date = time.Date, tickPositions = [], i, higherRanks = {}, minYear, // used in months and years as a basis for Date.UTC()
  9665. // When crossing DST, use the max. Resolves #6278.
  9666. minDate = new Date(min), interval = normalizedInterval.unitRange, count = normalizedInterval.count || 1, variableDayLength, minDay;
  9667. startOfWeek = pick(startOfWeek, 1);
  9668. if (defined(min)) { // #1300
  9669. time.set('Milliseconds', minDate, interval >= timeUnits.second ?
  9670. 0 : // #3935
  9671. count * Math.floor(time.get('Milliseconds', minDate) / count)); // #3652, #3654
  9672. if (interval >= timeUnits.second) { // second
  9673. time.set('Seconds', minDate, interval >= timeUnits.minute ?
  9674. 0 : // #3935
  9675. count * Math.floor(time.get('Seconds', minDate) / count));
  9676. }
  9677. if (interval >= timeUnits.minute) { // minute
  9678. time.set('Minutes', minDate, interval >= timeUnits.hour ?
  9679. 0 :
  9680. count * Math.floor(time.get('Minutes', minDate) / count));
  9681. }
  9682. if (interval >= timeUnits.hour) { // hour
  9683. time.set('Hours', minDate, interval >= timeUnits.day ?
  9684. 0 :
  9685. count * Math.floor(time.get('Hours', minDate) / count));
  9686. }
  9687. if (interval >= timeUnits.day) { // day
  9688. time.set('Date', minDate, interval >= timeUnits.month ?
  9689. 1 :
  9690. Math.max(1, count * Math.floor(time.get('Date', minDate) / count)));
  9691. }
  9692. if (interval >= timeUnits.month) { // month
  9693. time.set('Month', minDate, interval >= timeUnits.year ? 0 :
  9694. count * Math.floor(time.get('Month', minDate) / count));
  9695. minYear = time.get('FullYear', minDate);
  9696. }
  9697. if (interval >= timeUnits.year) { // year
  9698. minYear -= minYear % count;
  9699. time.set('FullYear', minDate, minYear);
  9700. }
  9701. // week is a special case that runs outside the hierarchy
  9702. if (interval === timeUnits.week) {
  9703. // get start of current week, independent of count
  9704. minDay = time.get('Day', minDate);
  9705. time.set('Date', minDate, (time.get('Date', minDate) -
  9706. minDay + startOfWeek +
  9707. // We don't want to skip days that are before
  9708. // startOfWeek (#7051)
  9709. (minDay < startOfWeek ? -7 : 0)));
  9710. }
  9711. // Get basics for variable time spans
  9712. minYear = time.get('FullYear', minDate);
  9713. var minMonth = time.get('Month', minDate), minDateDate = time.get('Date', minDate), minHours = time.get('Hours', minDate);
  9714. // Redefine min to the floored/rounded minimum time (#7432)
  9715. min = minDate.getTime();
  9716. // Handle local timezone offset
  9717. if (time.variableTimezone) {
  9718. // Detect whether we need to take the DST crossover into
  9719. // consideration. If we're crossing over DST, the day length may
  9720. // be 23h or 25h and we need to compute the exact clock time for
  9721. // each tick instead of just adding hours. This comes at a cost,
  9722. // so first we find out if it is needed (#4951).
  9723. variableDayLength = (
  9724. // Long range, assume we're crossing over.
  9725. max - min > 4 * timeUnits.month ||
  9726. // Short range, check if min and max are in different time
  9727. // zones.
  9728. time.getTimezoneOffset(min) !==
  9729. time.getTimezoneOffset(max));
  9730. }
  9731. // Iterate and add tick positions at appropriate values
  9732. var t = minDate.getTime();
  9733. i = 1;
  9734. while (t < max) {
  9735. tickPositions.push(t);
  9736. // if the interval is years, use Date.UTC to increase years
  9737. if (interval === timeUnits.year) {
  9738. t = time.makeTime(minYear + i * count, 0);
  9739. // if the interval is months, use Date.UTC to increase months
  9740. }
  9741. else if (interval === timeUnits.month) {
  9742. t = time.makeTime(minYear, minMonth + i * count);
  9743. // if we're using global time, the interval is not fixed as it
  9744. // jumps one hour at the DST crossover
  9745. }
  9746. else if (variableDayLength &&
  9747. (interval === timeUnits.day || interval === timeUnits.week)) {
  9748. t = time.makeTime(minYear, minMonth, minDateDate +
  9749. i * count * (interval === timeUnits.day ? 1 : 7));
  9750. }
  9751. else if (variableDayLength &&
  9752. interval === timeUnits.hour &&
  9753. count > 1) {
  9754. // make sure higher ranks are preserved across DST (#6797,
  9755. // #7621)
  9756. t = time.makeTime(minYear, minMonth, minDateDate, minHours + i * count);
  9757. // else, the interval is fixed and we use simple addition
  9758. }
  9759. else {
  9760. t += interval * count;
  9761. }
  9762. i++;
  9763. }
  9764. // push the last time
  9765. tickPositions.push(t);
  9766. // Handle higher ranks. Mark new days if the time is on midnight
  9767. // (#950, #1649, #1760, #3349). Use a reasonable dropout threshold
  9768. // to prevent looping over dense data grouping (#6156).
  9769. if (interval <= timeUnits.hour && tickPositions.length < 10000) {
  9770. tickPositions.forEach(function (t) {
  9771. if (
  9772. // Speed optimization, no need to run dateFormat unless
  9773. // we're on a full or half hour
  9774. t % 1800000 === 0 &&
  9775. // Check for local or global midnight
  9776. time.dateFormat('%H%M%S%L', t) === '000000000') {
  9777. higherRanks[t] = 'day';
  9778. }
  9779. });
  9780. }
  9781. }
  9782. // record information on the chosen unit - for dynamic label formatter
  9783. tickPositions.info = extend(normalizedInterval, {
  9784. higherRanks: higherRanks,
  9785. totalRange: interval * count
  9786. });
  9787. return tickPositions;
  9788. };
  9789. return Time;
  9790. }());
  9791. H.Time = Time;
  9792. return H.Time;
  9793. });
  9794. _registerModule(_modules, 'parts/Options.js', [_modules['parts/Globals.js'], _modules['parts/Time.js'], _modules['parts/Color.js'], _modules['parts/Utilities.js']], function (H, Time, Color, U) {
  9795. /* *
  9796. *
  9797. * (c) 2010-2020 Torstein Honsi
  9798. *
  9799. * License: www.highcharts.com/license
  9800. *
  9801. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9802. *
  9803. * */
  9804. /**
  9805. * @typedef {"plotBox"|"spacingBox"} Highcharts.ButtonRelativeToValue
  9806. */
  9807. /**
  9808. * Gets fired when a series is added to the chart after load time, using the
  9809. * `addSeries` method. Returning `false` prevents the series from being added.
  9810. *
  9811. * @callback Highcharts.ChartAddSeriesCallbackFunction
  9812. *
  9813. * @param {Highcharts.Chart} this
  9814. * The chart on which the event occured.
  9815. *
  9816. * @param {Highcharts.ChartAddSeriesEventObject} event
  9817. * The event that occured.
  9818. */
  9819. /**
  9820. * Contains common event information. Through the `options` property you can
  9821. * access the series options that were passed to the `addSeries` method.
  9822. *
  9823. * @interface Highcharts.ChartAddSeriesEventObject
  9824. */ /**
  9825. * The series options that were passed to the `addSeries` method.
  9826. * @name Highcharts.ChartAddSeriesEventObject#options
  9827. * @type {Highcharts.SeriesOptionsType}
  9828. */ /**
  9829. * Prevents the default behaviour of the event.
  9830. * @name Highcharts.ChartAddSeriesEventObject#preventDefault
  9831. * @type {Function}
  9832. */ /**
  9833. * The event target.
  9834. * @name Highcharts.ChartAddSeriesEventObject#target
  9835. * @type {Highcharts.Chart}
  9836. */ /**
  9837. * The event type.
  9838. * @name Highcharts.ChartAddSeriesEventObject#type
  9839. * @type {"addSeries"}
  9840. */
  9841. /**
  9842. * Gets fired when clicking on the plot background.
  9843. *
  9844. * @callback Highcharts.ChartClickCallbackFunction
  9845. *
  9846. * @param {Highcharts.Chart} this
  9847. * The chart on which the event occured.
  9848. *
  9849. * @param {Highcharts.PointerEventObject} event
  9850. * The event that occured.
  9851. */
  9852. /**
  9853. * Contains an axes of the clicked spot.
  9854. *
  9855. * @interface Highcharts.ChartClickEventAxisObject
  9856. */ /**
  9857. * Axis at the clicked spot.
  9858. * @name Highcharts.ChartClickEventAxisObject#axis
  9859. * @type {Highcharts.Axis}
  9860. */ /**
  9861. * Axis value at the clicked spot.
  9862. * @name Highcharts.ChartClickEventAxisObject#value
  9863. * @type {number}
  9864. */
  9865. /**
  9866. * Contains information about the clicked spot on the chart. Remember the unit
  9867. * of a datetime axis is milliseconds since 1970-01-01 00:00:00.
  9868. *
  9869. * @interface Highcharts.ChartClickEventObject
  9870. * @extends Highcharts.PointerEventObject
  9871. */ /**
  9872. * Information about the x-axis on the clicked spot.
  9873. * @name Highcharts.ChartClickEventObject#xAxis
  9874. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  9875. */ /**
  9876. * Information about the y-axis on the clicked spot.
  9877. * @name Highcharts.ChartClickEventObject#yAxis
  9878. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  9879. */ /**
  9880. * Information about the z-axis on the clicked spot.
  9881. * @name Highcharts.ChartClickEventObject#zAxis
  9882. * @type {Array<Highcharts.ChartClickEventAxisObject>|undefined}
  9883. */
  9884. /**
  9885. * Gets fired when the chart is finished loading.
  9886. *
  9887. * @callback Highcharts.ChartLoadCallbackFunction
  9888. *
  9889. * @param {Highcharts.Chart} this
  9890. * The chart on which the event occured.
  9891. *
  9892. * @param {global.Event} event
  9893. * The event that occured.
  9894. */
  9895. /**
  9896. * Fires when the chart is redrawn, either after a call to `chart.redraw()` or
  9897. * after an axis, series or point is modified with the `redraw` option set to
  9898. * `true`.
  9899. *
  9900. * @callback Highcharts.ChartRedrawCallbackFunction
  9901. *
  9902. * @param {Highcharts.Chart} this
  9903. * The chart on which the event occured.
  9904. *
  9905. * @param {global.Event} event
  9906. * The event that occured.
  9907. */
  9908. /**
  9909. * Gets fired after initial load of the chart (directly after the `load` event),
  9910. * and after each redraw (directly after the `redraw` event).
  9911. *
  9912. * @callback Highcharts.ChartRenderCallbackFunction
  9913. *
  9914. * @param {Highcharts.Chart} this
  9915. * The chart on which the event occured.
  9916. *
  9917. * @param {global.Event} event
  9918. * The event that occured.
  9919. */
  9920. /**
  9921. * Gets fired when an area of the chart has been selected. The default action
  9922. * for the selection event is to zoom the chart to the selected area. It can be
  9923. * prevented by calling `event.preventDefault()` or return false.
  9924. *
  9925. * @callback Highcharts.ChartSelectionCallbackFunction
  9926. *
  9927. * @param {Highcharts.Chart} this
  9928. * The chart on which the event occured.
  9929. *
  9930. * @param {global.ChartSelectionContextObject} event
  9931. * Event informations
  9932. *
  9933. * @return {boolean|undefined}
  9934. * Return false to prevent the default action, usually zoom.
  9935. */
  9936. /**
  9937. * The primary axes are `xAxis[0]` and `yAxis[0]`. Remember the unit of a
  9938. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  9939. *
  9940. * @interface Highcharts.ChartSelectionContextObject
  9941. * @extends global.Event
  9942. */ /**
  9943. * Arrays containing the axes of each dimension and each axis' min and max
  9944. * values.
  9945. * @name Highcharts.ChartSelectionContextObject#xAxis
  9946. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  9947. */ /**
  9948. * Arrays containing the axes of each dimension and each axis' min and max
  9949. * values.
  9950. * @name Highcharts.ChartSelectionContextObject#yAxis
  9951. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  9952. */
  9953. /**
  9954. * Axis context of the selection.
  9955. *
  9956. * @interface Highcharts.ChartSelectionAxisContextObject
  9957. */ /**
  9958. * The selected Axis.
  9959. * @name Highcharts.ChartSelectionAxisContextObject#axis
  9960. * @type {Highcharts.Axis}
  9961. */ /**
  9962. * The maximum axis value, either automatic or set manually.
  9963. * @name Highcharts.ChartSelectionAxisContextObject#max
  9964. * @type {number}
  9965. */ /**
  9966. * The minimum axis value, either automatic or set manually.
  9967. * @name Highcharts.ChartSelectionAxisContextObject#min
  9968. * @type {number}
  9969. */
  9970. var color = Color.parse;
  9971. var merge = U.merge;
  9972. var isTouchDevice = H.isTouchDevice, svg = H.svg;
  9973. /* ************************************************************************** *
  9974. * Handle the options *
  9975. * ************************************************************************** */
  9976. /**
  9977. * Global default settings.
  9978. *
  9979. * @name Highcharts.defaultOptions
  9980. * @type {Highcharts.Options}
  9981. */ /**
  9982. * @optionparent
  9983. */
  9984. H.defaultOptions = {
  9985. /**
  9986. * An array containing the default colors for the chart's series. When
  9987. * all colors are used, new colors are pulled from the start again.
  9988. *
  9989. * Default colors can also be set on a series or series.type basis,
  9990. * see [column.colors](#plotOptions.column.colors),
  9991. * [pie.colors](#plotOptions.pie.colors).
  9992. *
  9993. * In styled mode, the colors option doesn't exist. Instead, colors
  9994. * are defined in CSS and applied either through series or point class
  9995. * names, or through the [chart.colorCount](#chart.colorCount) option.
  9996. *
  9997. *
  9998. * ### Legacy
  9999. *
  10000. * In Highcharts 3.x, the default colors were:
  10001. * ```js
  10002. * colors: ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce',
  10003. * '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']
  10004. * ```
  10005. *
  10006. * In Highcharts 2.x, the default colors were:
  10007. * ```js
  10008. * colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE',
  10009. * '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
  10010. * ```
  10011. *
  10012. * @sample {highcharts} highcharts/chart/colors/
  10013. * Assign a global color theme
  10014. *
  10015. * @type {Array<Highcharts.ColorString>}
  10016. * @default ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9",
  10017. * "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
  10018. */
  10019. colors: '#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1'.split(' '),
  10020. /**
  10021. * Styled mode only. Configuration object for adding SVG definitions for
  10022. * reusable elements. See [gradients, shadows and
  10023. * patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns)
  10024. * for more information and code examples.
  10025. *
  10026. * @type {*}
  10027. * @since 5.0.0
  10028. * @apioption defs
  10029. */
  10030. /**
  10031. * @ignore-option
  10032. */
  10033. symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
  10034. /**
  10035. * The language object is global and it can't be set on each chart
  10036. * initialization. Instead, use `Highcharts.setOptions` to set it before any
  10037. * chart is initialized.
  10038. *
  10039. * ```js
  10040. * Highcharts.setOptions({
  10041. * lang: {
  10042. * months: [
  10043. * 'Janvier', 'Février', 'Mars', 'Avril',
  10044. * 'Mai', 'Juin', 'Juillet', 'Août',
  10045. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  10046. * ],
  10047. * weekdays: [
  10048. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  10049. * 'Jeudi', 'Vendredi', 'Samedi'
  10050. * ]
  10051. * }
  10052. * });
  10053. * ```
  10054. */
  10055. lang: {
  10056. /**
  10057. * The loading text that appears when the chart is set into the loading
  10058. * state following a call to `chart.showLoading`.
  10059. */
  10060. loading: 'Loading...',
  10061. /**
  10062. * An array containing the months names. Corresponds to the `%B` format
  10063. * in `Highcharts.dateFormat()`.
  10064. *
  10065. * @type {Array<string>}
  10066. * @default ["January", "February", "March", "April", "May", "June",
  10067. * "July", "August", "September", "October", "November",
  10068. * "December"]
  10069. */
  10070. months: [
  10071. 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  10072. 'August', 'September', 'October', 'November', 'December'
  10073. ],
  10074. /**
  10075. * An array containing the months names in abbreviated form. Corresponds
  10076. * to the `%b` format in `Highcharts.dateFormat()`.
  10077. *
  10078. * @type {Array<string>}
  10079. * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  10080. * "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  10081. */
  10082. shortMonths: [
  10083. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
  10084. 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
  10085. ],
  10086. /**
  10087. * An array containing the weekday names.
  10088. *
  10089. * @type {Array<string>}
  10090. * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
  10091. * "Friday", "Saturday"]
  10092. */
  10093. weekdays: [
  10094. 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  10095. 'Thursday', 'Friday', 'Saturday'
  10096. ],
  10097. /**
  10098. * Short week days, starting Sunday. If not specified, Highcharts uses
  10099. * the first three letters of the `lang.weekdays` option.
  10100. *
  10101. * @sample highcharts/lang/shortweekdays/
  10102. * Finnish two-letter abbreviations
  10103. *
  10104. * @type {Array<string>}
  10105. * @since 4.2.4
  10106. * @apioption lang.shortWeekdays
  10107. */
  10108. /**
  10109. * What to show in a date field for invalid dates. Defaults to an empty
  10110. * string.
  10111. *
  10112. * @type {string}
  10113. * @since 4.1.8
  10114. * @product highcharts highstock
  10115. * @apioption lang.invalidDate
  10116. */
  10117. /**
  10118. * The title appearing on hovering the zoom in button. The text itself
  10119. * defaults to "+" and can be changed in the button options.
  10120. *
  10121. * @type {string}
  10122. * @default Zoom in
  10123. * @product highmaps
  10124. * @apioption lang.zoomIn
  10125. */
  10126. /**
  10127. * The title appearing on hovering the zoom out button. The text itself
  10128. * defaults to "-" and can be changed in the button options.
  10129. *
  10130. * @type {string}
  10131. * @default Zoom out
  10132. * @product highmaps
  10133. * @apioption lang.zoomOut
  10134. */
  10135. /**
  10136. * The default decimal point used in the `Highcharts.numberFormat`
  10137. * method unless otherwise specified in the function arguments.
  10138. *
  10139. * @since 1.2.2
  10140. */
  10141. decimalPoint: '.',
  10142. /**
  10143. * [Metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) used
  10144. * to shorten high numbers in axis labels. Replacing any of the
  10145. * positions with `null` causes the full number to be written. Setting
  10146. * `numericSymbols` to `null` disables shortening altogether.
  10147. *
  10148. * @sample {highcharts} highcharts/lang/numericsymbols/
  10149. * Replacing the symbols with text
  10150. * @sample {highstock} highcharts/lang/numericsymbols/
  10151. * Replacing the symbols with text
  10152. *
  10153. * @type {Array<string>}
  10154. * @default ["k", "M", "G", "T", "P", "E"]
  10155. * @since 2.3.0
  10156. */
  10157. numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'],
  10158. /**
  10159. * The magnitude of [numericSymbols](#lang.numericSymbol) replacements.
  10160. * Use 10000 for Japanese, Korean and various Chinese locales, which
  10161. * use symbols for 10^4, 10^8 and 10^12.
  10162. *
  10163. * @sample highcharts/lang/numericsymbolmagnitude/
  10164. * 10000 magnitude for Japanese
  10165. *
  10166. * @type {number}
  10167. * @default 1000
  10168. * @since 5.0.3
  10169. * @apioption lang.numericSymbolMagnitude
  10170. */
  10171. /**
  10172. * The text for the label appearing when a chart is zoomed.
  10173. *
  10174. * @since 1.2.4
  10175. */
  10176. resetZoom: 'Reset zoom',
  10177. /**
  10178. * The tooltip title for the label appearing when a chart is zoomed.
  10179. *
  10180. * @since 1.2.4
  10181. */
  10182. resetZoomTitle: 'Reset zoom level 1:1',
  10183. /**
  10184. * The default thousands separator used in the `Highcharts.numberFormat`
  10185. * method unless otherwise specified in the function arguments. Defaults
  10186. * to a single space character, which is recommended in
  10187. * [ISO 31-0](https://en.wikipedia.org/wiki/ISO_31-0#Numbers) and works
  10188. * across Anglo-American and continental European languages.
  10189. *
  10190. * @default \u0020
  10191. * @since 1.2.2
  10192. */
  10193. thousandsSep: ' '
  10194. },
  10195. /**
  10196. * Global options that don't apply to each chart. These options, like
  10197. * the `lang` options, must be set using the `Highcharts.setOptions`
  10198. * method.
  10199. *
  10200. * ```js
  10201. * Highcharts.setOptions({
  10202. * global: {
  10203. * useUTC: false
  10204. * }
  10205. * });
  10206. * ```
  10207. */
  10208. /**
  10209. * _Canvg rendering for Android 2.x is removed as of Highcharts 5.0\.
  10210. * Use the [libURL](#exporting.libURL) option to configure exporting._
  10211. *
  10212. * The URL to the additional file to lazy load for Android 2.x devices.
  10213. * These devices don't support SVG, so we download a helper file that
  10214. * contains [canvg](https://github.com/canvg/canvg), its dependency
  10215. * rbcolor, and our own CanVG Renderer class. To avoid hotlinking to
  10216. * our site, you can install canvas-tools.js on your own server and
  10217. * change this option accordingly.
  10218. *
  10219. * @deprecated
  10220. *
  10221. * @type {string}
  10222. * @default https://code.highcharts.com/{version}/modules/canvas-tools.js
  10223. * @product highcharts highmaps
  10224. * @apioption global.canvasToolsURL
  10225. */
  10226. /**
  10227. * This option is deprecated since v6.0.5. Instead, use
  10228. * [time.useUTC](#time.useUTC) that supports individual time settings
  10229. * per chart.
  10230. *
  10231. * @deprecated
  10232. *
  10233. * @type {boolean}
  10234. * @apioption global.useUTC
  10235. */
  10236. /**
  10237. * This option is deprecated since v6.0.5. Instead, use
  10238. * [time.Date](#time.Date) that supports individual time settings
  10239. * per chart.
  10240. *
  10241. * @deprecated
  10242. *
  10243. * @type {Function}
  10244. * @product highcharts highstock
  10245. * @apioption global.Date
  10246. */
  10247. /**
  10248. * This option is deprecated since v6.0.5. Instead, use
  10249. * [time.getTimezoneOffset](#time.getTimezoneOffset) that supports
  10250. * individual time settings per chart.
  10251. *
  10252. * @deprecated
  10253. *
  10254. * @type {Function}
  10255. * @product highcharts highstock
  10256. * @apioption global.getTimezoneOffset
  10257. */
  10258. /**
  10259. * This option is deprecated since v6.0.5. Instead, use
  10260. * [time.timezone](#time.timezone) that supports individual time
  10261. * settings per chart.
  10262. *
  10263. * @deprecated
  10264. *
  10265. * @type {string}
  10266. * @product highcharts highstock
  10267. * @apioption global.timezone
  10268. */
  10269. /**
  10270. * This option is deprecated since v6.0.5. Instead, use
  10271. * [time.timezoneOffset](#time.timezoneOffset) that supports individual
  10272. * time settings per chart.
  10273. *
  10274. * @deprecated
  10275. *
  10276. * @type {number}
  10277. * @product highcharts highstock
  10278. * @apioption global.timezoneOffset
  10279. */
  10280. global: {},
  10281. /**
  10282. * Time options that can apply globally or to individual charts. These
  10283. * settings affect how `datetime` axes are laid out, how tooltips are
  10284. * formatted, how series
  10285. * [pointIntervalUnit](#plotOptions.series.pointIntervalUnit) works and how
  10286. * the Highstock range selector handles time.
  10287. *
  10288. * The common use case is that all charts in the same Highcharts object
  10289. * share the same time settings, in which case the global settings are set
  10290. * using `setOptions`.
  10291. *
  10292. * ```js
  10293. * // Apply time settings globally
  10294. * Highcharts.setOptions({
  10295. * time: {
  10296. * timezone: 'Europe/London'
  10297. * }
  10298. * });
  10299. * // Apply time settings by instance
  10300. * var chart = Highcharts.chart('container', {
  10301. * time: {
  10302. * timezone: 'America/New_York'
  10303. * },
  10304. * series: [{
  10305. * data: [1, 4, 3, 5]
  10306. * }]
  10307. * });
  10308. *
  10309. * // Use the Time object
  10310. * console.log(
  10311. * 'Current time in New York',
  10312. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  10313. * );
  10314. * ```
  10315. *
  10316. * Since v6.0.5, the time options were moved from the `global` obect to the
  10317. * `time` object, and time options can be set on each individual chart.
  10318. *
  10319. * @sample {highcharts|highstock}
  10320. * highcharts/time/timezone/
  10321. * Set the timezone globally
  10322. * @sample {highcharts}
  10323. * highcharts/time/individual/
  10324. * Set the timezone per chart instance
  10325. * @sample {highstock}
  10326. * stock/time/individual/
  10327. * Set the timezone per chart instance
  10328. *
  10329. * @since 6.0.5
  10330. * @optionparent time
  10331. */
  10332. time: {
  10333. /**
  10334. * A custom `Date` class for advanced date handling. For example,
  10335. * [JDate](https://github.com/tahajahangir/jdate) can be hooked in to
  10336. * handle Jalali dates.
  10337. *
  10338. * @type {*}
  10339. * @since 4.0.4
  10340. * @product highcharts highstock gantt
  10341. */
  10342. Date: void 0,
  10343. /**
  10344. * A callback to return the time zone offset for a given datetime. It
  10345. * takes the timestamp in terms of milliseconds since January 1 1970,
  10346. * and returns the timezone offset in minutes. This provides a hook
  10347. * for drawing time based charts in specific time zones using their
  10348. * local DST crossover dates, with the help of external libraries.
  10349. *
  10350. * @see [global.timezoneOffset](#global.timezoneOffset)
  10351. *
  10352. * @sample {highcharts|highstock} highcharts/time/gettimezoneoffset/
  10353. * Use moment.js to draw Oslo time regardless of browser locale
  10354. *
  10355. * @type {Highcharts.TimezoneOffsetCallbackFunction}
  10356. * @since 4.1.0
  10357. * @product highcharts highstock gantt
  10358. */
  10359. getTimezoneOffset: void 0,
  10360. /**
  10361. * Requires [moment.js](https://momentjs.com/). If the timezone option
  10362. * is specified, it creates a default
  10363. * [getTimezoneOffset](#time.getTimezoneOffset) function that looks
  10364. * up the specified timezone in moment.js. If moment.js is not included,
  10365. * this throws a Highcharts error in the console, but does not crash the
  10366. * chart.
  10367. *
  10368. * @see [getTimezoneOffset](#time.getTimezoneOffset)
  10369. *
  10370. * @sample {highcharts|highstock} highcharts/time/timezone/
  10371. * Europe/Oslo
  10372. *
  10373. * @type {string}
  10374. * @since 5.0.7
  10375. * @product highcharts highstock gantt
  10376. */
  10377. timezone: void 0,
  10378. /**
  10379. * The timezone offset in minutes. Positive values are west, negative
  10380. * values are east of UTC, as in the ECMAScript
  10381. * [getTimezoneOffset](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
  10382. * method. Use this to display UTC based data in a predefined time zone.
  10383. *
  10384. * @see [time.getTimezoneOffset](#time.getTimezoneOffset)
  10385. *
  10386. * @sample {highcharts|highstock} highcharts/time/timezoneoffset/
  10387. * Timezone offset
  10388. *
  10389. * @since 3.0.8
  10390. * @product highcharts highstock gantt
  10391. */
  10392. timezoneOffset: 0,
  10393. /**
  10394. * Whether to use UTC time for axis scaling, tickmark placement and
  10395. * time display in `Highcharts.dateFormat`. Advantages of using UTC
  10396. * is that the time displays equally regardless of the user agent's
  10397. * time zone settings. Local time can be used when the data is loaded
  10398. * in real time or when correct Daylight Saving Time transitions are
  10399. * required.
  10400. *
  10401. * @sample {highcharts} highcharts/time/useutc-true/
  10402. * True by default
  10403. * @sample {highcharts} highcharts/time/useutc-false/
  10404. * False
  10405. */
  10406. useUTC: true
  10407. },
  10408. /**
  10409. * General options for the chart.
  10410. */
  10411. chart: {
  10412. /**
  10413. * Default `mapData` for all series. If set to a string, it functions
  10414. * as an index into the `Highcharts.maps` array. Otherwise it is
  10415. * interpreted as map data.
  10416. *
  10417. * @see [mapData](#series.map.mapData)
  10418. *
  10419. * @sample maps/demo/geojson
  10420. * Loading geoJSON data
  10421. * @sample maps/chart/topojson
  10422. * Loading topoJSON converted to geoJSON
  10423. *
  10424. * @type {string|Array<*>|Highcharts.GeoJSON}
  10425. * @since 5.0.0
  10426. * @product highmaps
  10427. * @apioption chart.map
  10428. */
  10429. /**
  10430. * Set lat/lon transformation definitions for the chart. If not defined,
  10431. * these are extracted from the map data.
  10432. *
  10433. * @type {*}
  10434. * @since 5.0.0
  10435. * @product highmaps
  10436. * @apioption chart.mapTransforms
  10437. */
  10438. /**
  10439. * When using multiple axis, the ticks of two or more opposite axes
  10440. * will automatically be aligned by adding ticks to the axis or axes
  10441. * with the least ticks, as if `tickAmount` were specified.
  10442. *
  10443. * This can be prevented by setting `alignTicks` to false. If the grid
  10444. * lines look messy, it's a good idea to hide them for the secondary
  10445. * axis by setting `gridLineWidth` to 0.
  10446. *
  10447. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  10448. * then the `alignTicks ` will be disabled for the Axis.
  10449. *
  10450. * Disabled for logarithmic axes.
  10451. *
  10452. * @sample {highcharts} highcharts/chart/alignticks-true/
  10453. * True by default
  10454. * @sample {highcharts} highcharts/chart/alignticks-false/
  10455. * False
  10456. * @sample {highstock} stock/chart/alignticks-true/
  10457. * True by default
  10458. * @sample {highstock} stock/chart/alignticks-false/
  10459. * False
  10460. *
  10461. * @type {boolean}
  10462. * @default true
  10463. * @product highcharts highstock gantt
  10464. * @apioption chart.alignTicks
  10465. */
  10466. /**
  10467. * Set the overall animation for all chart updating. Animation can be
  10468. * disabled throughout the chart by setting it to false here. It can
  10469. * be overridden for each individual API method as a function parameter.
  10470. * The only animation not affected by this option is the initial series
  10471. * animation, see [plotOptions.series.animation](
  10472. * #plotOptions.series.animation).
  10473. *
  10474. * The animation can either be set as a boolean or a configuration
  10475. * object. If `true`, it will use the 'swing' jQuery easing and a
  10476. * duration of 500 ms. If used as a configuration object, the following
  10477. * properties are supported:
  10478. *
  10479. * - **duration**: The duration of the animation in milliseconds.
  10480. *
  10481. * - **easing**: A string reference to an easing function set on the
  10482. * `Math` object. See
  10483. * [the easing demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-animation-easing/).
  10484. *
  10485. * When zooming on a series with less than 100 points, the chart redraw
  10486. * will be done with animation, but in case of more data points, it is
  10487. * necessary to set this option to ensure animation on zoom.
  10488. *
  10489. * @sample {highcharts} highcharts/chart/animation-none/
  10490. * Updating with no animation
  10491. * @sample {highcharts} highcharts/chart/animation-duration/
  10492. * With a longer duration
  10493. * @sample {highcharts} highcharts/chart/animation-easing/
  10494. * With a jQuery UI easing
  10495. * @sample {highmaps} maps/chart/animation-none/
  10496. * Updating with no animation
  10497. * @sample {highmaps} maps/chart/animation-duration/
  10498. * With a longer duration
  10499. *
  10500. * @type {boolean|Highcharts.AnimationOptionsObject}
  10501. * @default undefined
  10502. * @apioption chart.animation
  10503. */
  10504. /**
  10505. * A CSS class name to apply to the charts container `div`, allowing
  10506. * unique CSS styling for each chart.
  10507. *
  10508. * @type {string}
  10509. * @apioption chart.className
  10510. */
  10511. /**
  10512. * Event listeners for the chart.
  10513. *
  10514. * @apioption chart.events
  10515. */
  10516. /**
  10517. * Fires when a series is added to the chart after load time, using the
  10518. * `addSeries` method. One parameter, `event`, is passed to the
  10519. * function, containing common event information. Through
  10520. * `event.options` you can access the series options that were passed to
  10521. * the `addSeries` method. Returning false prevents the series from
  10522. * being added.
  10523. *
  10524. * @sample {highcharts} highcharts/chart/events-addseries/
  10525. * Alert on add series
  10526. * @sample {highstock} stock/chart/events-addseries/
  10527. * Alert on add series
  10528. *
  10529. * @type {Highcharts.ChartAddSeriesCallbackFunction}
  10530. * @since 1.2.0
  10531. * @context Highcharts.Chart
  10532. * @apioption chart.events.addSeries
  10533. */
  10534. /**
  10535. * Fires when clicking on the plot background. One parameter, `event`,
  10536. * is passed to the function, containing common event information.
  10537. *
  10538. * Information on the clicked spot can be found through `event.xAxis`
  10539. * and `event.yAxis`, which are arrays containing the axes of each
  10540. * dimension and each axis' value at the clicked spot. The primary axes
  10541. * are `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  10542. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  10543. *
  10544. * ```js
  10545. * click: function(e) {
  10546. * console.log(
  10547. * Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', e.xAxis[0].value),
  10548. * e.yAxis[0].value
  10549. * )
  10550. * }
  10551. * ```
  10552. *
  10553. * @sample {highcharts} highcharts/chart/events-click/
  10554. * Alert coordinates on click
  10555. * @sample {highcharts} highcharts/chart/events-container/
  10556. * Alternatively, attach event to container
  10557. * @sample {highstock} stock/chart/events-click/
  10558. * Alert coordinates on click
  10559. * @sample {highstock} highcharts/chart/events-container/
  10560. * Alternatively, attach event to container
  10561. * @sample {highmaps} maps/chart/events-click/
  10562. * Record coordinates on click
  10563. * @sample {highmaps} highcharts/chart/events-container/
  10564. * Alternatively, attach event to container
  10565. *
  10566. * @type {Highcharts.ChartClickCallbackFunction}
  10567. * @since 1.2.0
  10568. * @context Highcharts.Chart
  10569. * @apioption chart.events.click
  10570. */
  10571. /**
  10572. * Fires when the chart is finished loading. Since v4.2.2, it also waits
  10573. * for images to be loaded, for example from point markers. One
  10574. * parameter, `event`, is passed to the function, containing common
  10575. * event information.
  10576. *
  10577. * There is also a second parameter to the chart constructor where a
  10578. * callback function can be passed to be executed on chart.load.
  10579. *
  10580. * @sample {highcharts} highcharts/chart/events-load/
  10581. * Alert on chart load
  10582. * @sample {highstock} stock/chart/events-load/
  10583. * Alert on chart load
  10584. * @sample {highmaps} maps/chart/events-load/
  10585. * Add series on chart load
  10586. *
  10587. * @type {Highcharts.ChartLoadCallbackFunction}
  10588. * @context Highcharts.Chart
  10589. * @apioption chart.events.load
  10590. */
  10591. /**
  10592. * Fires when the chart is redrawn, either after a call to
  10593. * `chart.redraw()` or after an axis, series or point is modified with
  10594. * the `redraw` option set to `true`. One parameter, `event`, is passed
  10595. * to the function, containing common event information.
  10596. *
  10597. * @sample {highcharts} highcharts/chart/events-redraw/
  10598. * Alert on chart redraw
  10599. * @sample {highstock} stock/chart/events-redraw/
  10600. * Alert on chart redraw when adding a series or moving the
  10601. * zoomed range
  10602. * @sample {highmaps} maps/chart/events-redraw/
  10603. * Set subtitle on chart redraw
  10604. *
  10605. * @type {Highcharts.ChartRedrawCallbackFunction}
  10606. * @since 1.2.0
  10607. * @context Highcharts.Chart
  10608. * @apioption chart.events.redraw
  10609. */
  10610. /**
  10611. * Fires after initial load of the chart (directly after the `load`
  10612. * event), and after each redraw (directly after the `redraw` event).
  10613. *
  10614. * @type {Highcharts.ChartRenderCallbackFunction}
  10615. * @since 5.0.7
  10616. * @context Highcharts.Chart
  10617. * @apioption chart.events.render
  10618. */
  10619. /**
  10620. * Fires when an area of the chart has been selected. Selection is
  10621. * enabled by setting the chart's zoomType. One parameter, `event`, is
  10622. * passed to the function, containing common event information. The
  10623. * default action for the selection event is to zoom the chart to the
  10624. * selected area. It can be prevented by calling
  10625. * `event.preventDefault()` or return false.
  10626. *
  10627. * Information on the selected area can be found through `event.xAxis`
  10628. * and `event.yAxis`, which are arrays containing the axes of each
  10629. * dimension and each axis' min and max values. The primary axes are
  10630. * `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  10631. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  10632. *
  10633. * ```js
  10634. * selection: function(event) {
  10635. * // log the min and max of the primary, datetime x-axis
  10636. * console.log(
  10637. * Highcharts.dateFormat(
  10638. * '%Y-%m-%d %H:%M:%S',
  10639. * event.xAxis[0].min
  10640. * ),
  10641. * Highcharts.dateFormat(
  10642. * '%Y-%m-%d %H:%M:%S',
  10643. * event.xAxis[0].max
  10644. * )
  10645. * );
  10646. * // log the min and max of the y axis
  10647. * console.log(event.yAxis[0].min, event.yAxis[0].max);
  10648. * }
  10649. * ```
  10650. *
  10651. * @sample {highcharts} highcharts/chart/events-selection/
  10652. * Report on selection and reset
  10653. * @sample {highcharts} highcharts/chart/events-selection-points/
  10654. * Select a range of points through a drag selection
  10655. * @sample {highstock} stock/chart/events-selection/
  10656. * Report on selection and reset
  10657. * @sample {highstock} highcharts/chart/events-selection-points/
  10658. * Select a range of points through a drag selection
  10659. * (Highcharts)
  10660. *
  10661. * @type {Highcharts.ChartSelectionCallbackFunction}
  10662. * @apioption chart.events.selection
  10663. */
  10664. /**
  10665. * The margin between the outer edge of the chart and the plot area.
  10666. * The numbers in the array designate top, right, bottom and left
  10667. * respectively. Use the options `marginTop`, `marginRight`,
  10668. * `marginBottom` and `marginLeft` for shorthand setting of one option.
  10669. *
  10670. * By default there is no margin. The actual space is dynamically
  10671. * calculated from the offset of axis labels, axis title, title,
  10672. * subtitle and legend in addition to the `spacingTop`, `spacingRight`,
  10673. * `spacingBottom` and `spacingLeft` options.
  10674. *
  10675. * @sample {highcharts} highcharts/chart/margins-zero/
  10676. * Zero margins
  10677. * @sample {highstock} stock/chart/margin-zero/
  10678. * Zero margins
  10679. *
  10680. * @type {number|Array<number>}
  10681. * @apioption chart.margin
  10682. */
  10683. /**
  10684. * The margin between the bottom outer edge of the chart and the plot
  10685. * area. Use this to set a fixed pixel value for the margin as opposed
  10686. * to the default dynamic margin. See also `spacingBottom`.
  10687. *
  10688. * @sample {highcharts} highcharts/chart/marginbottom/
  10689. * 100px bottom margin
  10690. * @sample {highstock} stock/chart/marginbottom/
  10691. * 100px bottom margin
  10692. * @sample {highmaps} maps/chart/margin/
  10693. * 100px margins
  10694. *
  10695. * @type {number}
  10696. * @since 2.0
  10697. * @apioption chart.marginBottom
  10698. */
  10699. /**
  10700. * The margin between the left outer edge of the chart and the plot
  10701. * area. Use this to set a fixed pixel value for the margin as opposed
  10702. * to the default dynamic margin. See also `spacingLeft`.
  10703. *
  10704. * @sample {highcharts} highcharts/chart/marginleft/
  10705. * 150px left margin
  10706. * @sample {highstock} stock/chart/marginleft/
  10707. * 150px left margin
  10708. * @sample {highmaps} maps/chart/margin/
  10709. * 100px margins
  10710. *
  10711. * @type {number}
  10712. * @since 2.0
  10713. * @apioption chart.marginLeft
  10714. */
  10715. /**
  10716. * The margin between the right outer edge of the chart and the plot
  10717. * area. Use this to set a fixed pixel value for the margin as opposed
  10718. * to the default dynamic margin. See also `spacingRight`.
  10719. *
  10720. * @sample {highcharts} highcharts/chart/marginright/
  10721. * 100px right margin
  10722. * @sample {highstock} stock/chart/marginright/
  10723. * 100px right margin
  10724. * @sample {highmaps} maps/chart/margin/
  10725. * 100px margins
  10726. *
  10727. * @type {number}
  10728. * @since 2.0
  10729. * @apioption chart.marginRight
  10730. */
  10731. /**
  10732. * The margin between the top outer edge of the chart and the plot area.
  10733. * Use this to set a fixed pixel value for the margin as opposed to
  10734. * the default dynamic margin. See also `spacingTop`.
  10735. *
  10736. * @sample {highcharts} highcharts/chart/margintop/ 100px top margin
  10737. * @sample {highstock} stock/chart/margintop/
  10738. * 100px top margin
  10739. * @sample {highmaps} maps/chart/margin/
  10740. * 100px margins
  10741. *
  10742. * @type {number}
  10743. * @since 2.0
  10744. * @apioption chart.marginTop
  10745. */
  10746. /**
  10747. * Callback function to override the default function that formats all
  10748. * the numbers in the chart. Returns a string with the formatted number.
  10749. *
  10750. * @sample highcharts/members/highcharts-numberformat
  10751. * Arabic digits in Highcharts
  10752. * @type {Highcharts.NumberFormatterCallbackFunction}
  10753. * @since 8.0.0
  10754. * @apioption chart.numberFormatter
  10755. */
  10756. /**
  10757. * Allows setting a key to switch between zooming and panning. Can be
  10758. * one of `alt`, `ctrl`, `meta` (the command key on Mac and Windows
  10759. * key on Windows) or `shift`. The keys are mapped directly to the key
  10760. * properties of the click event argument (`event.altKey`,
  10761. * `event.ctrlKey`, `event.metaKey` and `event.shiftKey`).
  10762. *
  10763. * @type {string}
  10764. * @since 4.0.3
  10765. * @product highcharts gantt
  10766. * @validvalue ["alt", "ctrl", "meta", "shift"]
  10767. * @apioption chart.panKey
  10768. */
  10769. /**
  10770. * Allow panning in a chart. Best used with [panKey](#chart.panKey)
  10771. * to combine zooming and panning.
  10772. *
  10773. * On touch devices, when the [tooltip.followTouchMove](
  10774. * #tooltip.followTouchMove) option is `true` (default), panning
  10775. * requires two fingers. To allow panning with one finger, set
  10776. * `followTouchMove` to `false`.
  10777. *
  10778. * @sample {highcharts} highcharts/chart/pankey/ Zooming and panning
  10779. * @sample {highstock} stock/chart/panning/ Zooming and xy panning
  10780. *
  10781. * @product highcharts highstock gantt
  10782. * @apioption chart.panning
  10783. */
  10784. /**
  10785. * Enable or disable chart panning.
  10786. *
  10787. * @type {boolean}
  10788. * @default {highcharts} false
  10789. * @default {highstock} true
  10790. * @apioption chart.panning.enabled
  10791. */
  10792. /**
  10793. * Decides in what dimensions the user can pan the chart. Can be
  10794. * one of `x`, `y`, or `xy`.
  10795. *
  10796. * @sample {highcharts} highcharts/chart/panning-type
  10797. * Zooming and xy panning
  10798. *
  10799. * @type {string}
  10800. * @validvalue ["x", "y", "xy"]
  10801. * @default x
  10802. * @apioption chart.panning.type
  10803. */
  10804. /**
  10805. * Equivalent to [zoomType](#chart.zoomType), but for multitouch
  10806. * gestures only. By default, the `pinchType` is the same as the
  10807. * `zoomType` setting. However, pinching can be enabled separately in
  10808. * some cases, for example in stock charts where a mouse drag pans the
  10809. * chart, while pinching is enabled. When [tooltip.followTouchMove](
  10810. * #tooltip.followTouchMove) is true, pinchType only applies to
  10811. * two-finger touches.
  10812. *
  10813. * @type {string}
  10814. * @default {highcharts} undefined
  10815. * @default {highstock} x
  10816. * @since 3.0
  10817. * @product highcharts highstock gantt
  10818. * @validvalue ["x", "y", "xy"]
  10819. * @apioption chart.pinchType
  10820. */
  10821. /**
  10822. * Whether to apply styled mode. When in styled mode, no presentational
  10823. * attributes or CSS are applied to the chart SVG. Instead, CSS rules
  10824. * are required to style the chart. The default style sheet is
  10825. * available from `https://code.highcharts.com/css/highcharts.css`.
  10826. *
  10827. * @type {boolean}
  10828. * @default false
  10829. * @since 7.0
  10830. * @apioption chart.styledMode
  10831. */
  10832. styledMode: false,
  10833. /**
  10834. * The corner radius of the outer chart border.
  10835. *
  10836. * @sample {highcharts} highcharts/chart/borderradius/
  10837. * 20px radius
  10838. * @sample {highstock} stock/chart/border/
  10839. * 10px radius
  10840. * @sample {highmaps} maps/chart/border/
  10841. * Border options
  10842. *
  10843. */
  10844. borderRadius: 0,
  10845. /**
  10846. * In styled mode, this sets how many colors the class names
  10847. * should rotate between. With ten colors, series (or points) are
  10848. * given class names like `highcharts-color-0`, `highcharts-color-0`
  10849. * [...] `highcharts-color-9`. The equivalent in non-styled mode
  10850. * is to set colors using the [colors](#colors) setting.
  10851. *
  10852. * @since 5.0.0
  10853. */
  10854. colorCount: 10,
  10855. /**
  10856. * Alias of `type`.
  10857. *
  10858. * @sample {highcharts} highcharts/chart/defaultseriestype/
  10859. * Bar
  10860. *
  10861. * @deprecated
  10862. *
  10863. * @product highcharts
  10864. */
  10865. defaultSeriesType: 'line',
  10866. /**
  10867. * If true, the axes will scale to the remaining visible series once
  10868. * one series is hidden. If false, hiding and showing a series will
  10869. * not affect the axes or the other series. For stacks, once one series
  10870. * within the stack is hidden, the rest of the stack will close in
  10871. * around it even if the axis is not affected.
  10872. *
  10873. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true/
  10874. * True by default
  10875. * @sample {highcharts} highcharts/chart/ignorehiddenseries-false/
  10876. * False
  10877. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true-stacked/
  10878. * True with stack
  10879. * @sample {highstock} stock/chart/ignorehiddenseries-true/
  10880. * True by default
  10881. * @sample {highstock} stock/chart/ignorehiddenseries-false/
  10882. * False
  10883. *
  10884. * @since 1.2.0
  10885. * @product highcharts highstock gantt
  10886. */
  10887. ignoreHiddenSeries: true,
  10888. /**
  10889. * Whether to invert the axes so that the x axis is vertical and y axis
  10890. * is horizontal. When `true`, the x axis is [reversed](#xAxis.reversed)
  10891. * by default.
  10892. *
  10893. * @productdesc {highcharts}
  10894. * If a bar series is present in the chart, it will be inverted
  10895. * automatically. Inverting the chart doesn't have an effect if there
  10896. * are no cartesian series in the chart, or if the chart is
  10897. * [polar](#chart.polar).
  10898. *
  10899. * @sample {highcharts} highcharts/chart/inverted/
  10900. * Inverted line
  10901. * @sample {highstock} stock/navigator/inverted/
  10902. * Inverted stock chart
  10903. *
  10904. * @type {boolean}
  10905. * @default false
  10906. * @product highcharts highstock gantt
  10907. * @apioption chart.inverted
  10908. */
  10909. /**
  10910. * The distance between the outer edge of the chart and the content,
  10911. * like title or legend, or axis title and labels if present. The
  10912. * numbers in the array designate top, right, bottom and left
  10913. * respectively. Use the options spacingTop, spacingRight, spacingBottom
  10914. * and spacingLeft options for shorthand setting of one option.
  10915. *
  10916. * @type {Array<number>}
  10917. * @see [chart.margin](#chart.margin)
  10918. * @default [10, 10, 15, 10]
  10919. * @since 3.0.6
  10920. */
  10921. spacing: [10, 10, 15, 10],
  10922. /**
  10923. * The button that appears after a selection zoom, allowing the user
  10924. * to reset zoom.
  10925. */
  10926. resetZoomButton: {
  10927. /**
  10928. * What frame the button placement should be related to. Can be
  10929. * either `plotBox` or `spacingBox`.
  10930. *
  10931. * @sample {highcharts} highcharts/chart/resetzoombutton-relativeto/
  10932. * Relative to the chart
  10933. * @sample {highstock} highcharts/chart/resetzoombutton-relativeto/
  10934. * Relative to the chart
  10935. *
  10936. * @type {Highcharts.ButtonRelativeToValue}
  10937. * @default plot
  10938. * @since 2.2
  10939. * @apioption chart.resetZoomButton.relativeTo
  10940. */
  10941. /**
  10942. * A collection of attributes for the button. The object takes SVG
  10943. * attributes like `fill`, `stroke`, `stroke-width` or `r`, the
  10944. * border radius. The theme also supports `style`, a collection of
  10945. * CSS properties for the text. Equivalent attributes for the hover
  10946. * state are given in `theme.states.hover`.
  10947. *
  10948. * @sample {highcharts} highcharts/chart/resetzoombutton-theme/
  10949. * Theming the button
  10950. * @sample {highstock} highcharts/chart/resetzoombutton-theme/
  10951. * Theming the button
  10952. *
  10953. * @type {Highcharts.SVGAttributes}
  10954. * @since 2.2
  10955. */
  10956. theme: {
  10957. /** @internal */
  10958. zIndex: 6
  10959. },
  10960. /**
  10961. * The position of the button.
  10962. *
  10963. * @sample {highcharts} highcharts/chart/resetzoombutton-position/
  10964. * Above the plot area
  10965. * @sample {highstock} highcharts/chart/resetzoombutton-position/
  10966. * Above the plot area
  10967. * @sample {highmaps} highcharts/chart/resetzoombutton-position/
  10968. * Above the plot area
  10969. *
  10970. * @type {Highcharts.AlignObject}
  10971. * @since 2.2
  10972. */
  10973. position: {
  10974. /**
  10975. * The horizontal alignment of the button.
  10976. */
  10977. align: 'right',
  10978. /**
  10979. * The horizontal offset of the button.
  10980. */
  10981. x: -10,
  10982. /**
  10983. * The vertical alignment of the button.
  10984. *
  10985. * @type {Highcharts.VerticalAlignValue}
  10986. * @default top
  10987. * @apioption chart.resetZoomButton.position.verticalAlign
  10988. */
  10989. /**
  10990. * The vertical offset of the button.
  10991. */
  10992. y: 10
  10993. }
  10994. },
  10995. /**
  10996. * The pixel width of the plot area border.
  10997. *
  10998. * @sample {highcharts} highcharts/chart/plotborderwidth/
  10999. * 1px border
  11000. * @sample {highstock} stock/chart/plotborder/
  11001. * 2px border
  11002. * @sample {highmaps} maps/chart/plotborder/
  11003. * Plot border options
  11004. *
  11005. * @type {number}
  11006. * @default 0
  11007. * @apioption chart.plotBorderWidth
  11008. */
  11009. /**
  11010. * Whether to apply a drop shadow to the plot area. Requires that
  11011. * plotBackgroundColor be set. The shadow can be an object configuration
  11012. * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
  11013. *
  11014. * @sample {highcharts} highcharts/chart/plotshadow/
  11015. * Plot shadow
  11016. * @sample {highstock} stock/chart/plotshadow/
  11017. * Plot shadow
  11018. * @sample {highmaps} maps/chart/plotborder/
  11019. * Plot border options
  11020. *
  11021. * @type {boolean|Highcharts.CSSObject}
  11022. * @default false
  11023. * @apioption chart.plotShadow
  11024. */
  11025. /**
  11026. * When true, cartesian charts like line, spline, area and column are
  11027. * transformed into the polar coordinate system. This produces _polar
  11028. * charts_, also known as _radar charts_.
  11029. *
  11030. * @sample {highcharts} highcharts/demo/polar/
  11031. * Polar chart
  11032. * @sample {highcharts} highcharts/demo/polar-wind-rose/
  11033. * Wind rose, stacked polar column chart
  11034. * @sample {highcharts} highcharts/demo/polar-spider/
  11035. * Spider web chart
  11036. * @sample {highcharts} highcharts/parallel-coordinates/polar/
  11037. * Star plot, multivariate data in a polar chart
  11038. *
  11039. * @type {boolean}
  11040. * @default false
  11041. * @since 2.3.0
  11042. * @product highcharts
  11043. * @requires highcharts-more
  11044. * @apioption chart.polar
  11045. */
  11046. /**
  11047. * Whether to reflow the chart to fit the width of the container div
  11048. * on resizing the window.
  11049. *
  11050. * @sample {highcharts} highcharts/chart/reflow-true/
  11051. * True by default
  11052. * @sample {highcharts} highcharts/chart/reflow-false/
  11053. * False
  11054. * @sample {highstock} stock/chart/reflow-true/
  11055. * True by default
  11056. * @sample {highstock} stock/chart/reflow-false/
  11057. * False
  11058. * @sample {highmaps} maps/chart/reflow-true/
  11059. * True by default
  11060. * @sample {highmaps} maps/chart/reflow-false/
  11061. * False
  11062. *
  11063. * @type {boolean}
  11064. * @default true
  11065. * @since 2.1
  11066. * @apioption chart.reflow
  11067. */
  11068. /**
  11069. * The HTML element where the chart will be rendered. If it is a string,
  11070. * the element by that id is used. The HTML element can also be passed
  11071. * by direct reference, or as the first argument of the chart
  11072. * constructor, in which case the option is not needed.
  11073. *
  11074. * @sample {highcharts} highcharts/chart/reflow-true/
  11075. * String
  11076. * @sample {highcharts} highcharts/chart/renderto-object/
  11077. * Object reference
  11078. * @sample {highcharts} highcharts/chart/renderto-jquery/
  11079. * Object reference through jQuery
  11080. * @sample {highstock} stock/chart/renderto-string/
  11081. * String
  11082. * @sample {highstock} stock/chart/renderto-object/
  11083. * Object reference
  11084. * @sample {highstock} stock/chart/renderto-jquery/
  11085. * Object reference through jQuery
  11086. *
  11087. * @type {string|Highcharts.HTMLDOMElement}
  11088. * @apioption chart.renderTo
  11089. */
  11090. /**
  11091. * The background color of the marker square when selecting (zooming
  11092. * in on) an area of the chart.
  11093. *
  11094. * @see In styled mode, the selection marker fill is set with the
  11095. * `.highcharts-selection-marker` class.
  11096. *
  11097. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11098. * @default rgba(51,92,173,0.25)
  11099. * @since 2.1.7
  11100. * @apioption chart.selectionMarkerFill
  11101. */
  11102. /**
  11103. * Whether to apply a drop shadow to the outer chart area. Requires
  11104. * that backgroundColor be set. The shadow can be an object
  11105. * configuration containing `color`, `offsetX`, `offsetY`, `opacity` and
  11106. * `width`.
  11107. *
  11108. * @sample {highcharts} highcharts/chart/shadow/
  11109. * Shadow
  11110. * @sample {highstock} stock/chart/shadow/
  11111. * Shadow
  11112. * @sample {highmaps} maps/chart/border/
  11113. * Chart border and shadow
  11114. *
  11115. * @type {boolean|Highcharts.CSSObject}
  11116. * @default false
  11117. * @apioption chart.shadow
  11118. */
  11119. /**
  11120. * Whether to show the axes initially. This only applies to empty charts
  11121. * where series are added dynamically, as axes are automatically added
  11122. * to cartesian series.
  11123. *
  11124. * @sample {highcharts} highcharts/chart/showaxes-false/
  11125. * False by default
  11126. * @sample {highcharts} highcharts/chart/showaxes-true/
  11127. * True
  11128. *
  11129. * @type {boolean}
  11130. * @since 1.2.5
  11131. * @product highcharts gantt
  11132. * @apioption chart.showAxes
  11133. */
  11134. /**
  11135. * The space between the bottom edge of the chart and the content (plot
  11136. * area, axis title and labels, title, subtitle or legend in top
  11137. * position).
  11138. *
  11139. * @sample {highcharts} highcharts/chart/spacingbottom/
  11140. * Spacing bottom set to 100
  11141. * @sample {highstock} stock/chart/spacingbottom/
  11142. * Spacing bottom set to 100
  11143. * @sample {highmaps} maps/chart/spacing/
  11144. * Spacing 100 all around
  11145. *
  11146. * @type {number}
  11147. * @default 15
  11148. * @since 2.1
  11149. * @apioption chart.spacingBottom
  11150. */
  11151. /**
  11152. * The space between the left edge of the chart and the content (plot
  11153. * area, axis title and labels, title, subtitle or legend in top
  11154. * position).
  11155. *
  11156. * @sample {highcharts} highcharts/chart/spacingleft/
  11157. * Spacing left set to 100
  11158. * @sample {highstock} stock/chart/spacingleft/
  11159. * Spacing left set to 100
  11160. * @sample {highmaps} maps/chart/spacing/
  11161. * Spacing 100 all around
  11162. *
  11163. * @type {number}
  11164. * @default 10
  11165. * @since 2.1
  11166. * @apioption chart.spacingLeft
  11167. */
  11168. /**
  11169. * The space between the right edge of the chart and the content (plot
  11170. * area, axis title and labels, title, subtitle or legend in top
  11171. * position).
  11172. *
  11173. * @sample {highcharts} highcharts/chart/spacingright-100/
  11174. * Spacing set to 100
  11175. * @sample {highcharts} highcharts/chart/spacingright-legend/
  11176. * Legend in right position with default spacing
  11177. * @sample {highstock} stock/chart/spacingright/
  11178. * Spacing set to 100
  11179. * @sample {highmaps} maps/chart/spacing/
  11180. * Spacing 100 all around
  11181. *
  11182. * @type {number}
  11183. * @default 10
  11184. * @since 2.1
  11185. * @apioption chart.spacingRight
  11186. */
  11187. /**
  11188. * The space between the top edge of the chart and the content (plot
  11189. * area, axis title and labels, title, subtitle or legend in top
  11190. * position).
  11191. *
  11192. * @sample {highcharts} highcharts/chart/spacingtop-100/
  11193. * A top spacing of 100
  11194. * @sample {highcharts} highcharts/chart/spacingtop-10/
  11195. * Floating chart title makes the plot area align to the default
  11196. * spacingTop of 10.
  11197. * @sample {highstock} stock/chart/spacingtop/
  11198. * A top spacing of 100
  11199. * @sample {highmaps} maps/chart/spacing/
  11200. * Spacing 100 all around
  11201. *
  11202. * @type {number}
  11203. * @default 10
  11204. * @since 2.1
  11205. * @apioption chart.spacingTop
  11206. */
  11207. /**
  11208. * Additional CSS styles to apply inline to the container `div`. Note
  11209. * that since the default font styles are applied in the renderer, it
  11210. * is ignorant of the individual chart options and must be set globally.
  11211. *
  11212. * @see In styled mode, general chart styles can be set with the
  11213. * `.highcharts-root` class.
  11214. * @sample {highcharts} highcharts/chart/style-serif-font/
  11215. * Using a serif type font
  11216. * @sample {highcharts} highcharts/css/em/
  11217. * Styled mode with relative font sizes
  11218. * @sample {highstock} stock/chart/style/
  11219. * Using a serif type font
  11220. * @sample {highmaps} maps/chart/style-serif-font/
  11221. * Using a serif type font
  11222. *
  11223. * @type {Highcharts.CSSObject}
  11224. * @default {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}
  11225. * @apioption chart.style
  11226. */
  11227. /**
  11228. * The default series type for the chart. Can be any of the chart types
  11229. * listed under [plotOptions](#plotOptions) and [series](#series) or can
  11230. * be a series provided by an additional module.
  11231. *
  11232. * In TypeScript this option has no effect in sense of typing and
  11233. * instead the `type` option must always be set in the series.
  11234. *
  11235. * @sample {highcharts} highcharts/chart/type-bar/
  11236. * Bar
  11237. * @sample {highstock} stock/chart/type/
  11238. * Areaspline
  11239. * @sample {highmaps} maps/chart/type-mapline/
  11240. * Mapline
  11241. *
  11242. * @type {string}
  11243. * @default {highcharts} line
  11244. * @default {highstock} line
  11245. * @default {highmaps} map
  11246. * @since 2.1.0
  11247. * @apioption chart.type
  11248. */
  11249. /**
  11250. * Decides in what dimensions the user can zoom by dragging the mouse.
  11251. * Can be one of `x`, `y` or `xy`.
  11252. *
  11253. * @see [panKey](#chart.panKey)
  11254. *
  11255. * @sample {highcharts} highcharts/chart/zoomtype-none/
  11256. * None by default
  11257. * @sample {highcharts} highcharts/chart/zoomtype-x/
  11258. * X
  11259. * @sample {highcharts} highcharts/chart/zoomtype-y/
  11260. * Y
  11261. * @sample {highcharts} highcharts/chart/zoomtype-xy/
  11262. * Xy
  11263. * @sample {highstock} stock/demo/basic-line/
  11264. * None by default
  11265. * @sample {highstock} stock/chart/zoomtype-x/
  11266. * X
  11267. * @sample {highstock} stock/chart/zoomtype-y/
  11268. * Y
  11269. * @sample {highstock} stock/chart/zoomtype-xy/
  11270. * Xy
  11271. *
  11272. * @type {string}
  11273. * @product highcharts highstock gantt
  11274. * @validvalue ["x", "y", "xy"]
  11275. * @apioption chart.zoomType
  11276. */
  11277. /**
  11278. * An explicit width for the chart. By default (when `null`) the width
  11279. * is calculated from the offset width of the containing element.
  11280. *
  11281. * @sample {highcharts} highcharts/chart/width/
  11282. * 800px wide
  11283. * @sample {highstock} stock/chart/width/
  11284. * 800px wide
  11285. * @sample {highmaps} maps/chart/size/
  11286. * Chart with explicit size
  11287. *
  11288. * @type {null|number|string}
  11289. */
  11290. width: null,
  11291. /**
  11292. * An explicit height for the chart. If a _number_, the height is
  11293. * given in pixels. If given a _percentage string_ (for example
  11294. * `'56%'`), the height is given as the percentage of the actual chart
  11295. * width. This allows for preserving the aspect ratio across responsive
  11296. * sizes.
  11297. *
  11298. * By default (when `null`) the height is calculated from the offset
  11299. * height of the containing element, or 400 pixels if the containing
  11300. * element's height is 0.
  11301. *
  11302. * @sample {highcharts} highcharts/chart/height/
  11303. * 500px height
  11304. * @sample {highstock} stock/chart/height/
  11305. * 300px height
  11306. * @sample {highmaps} maps/chart/size/
  11307. * Chart with explicit size
  11308. * @sample highcharts/chart/height-percent/
  11309. * Highcharts with percentage height
  11310. *
  11311. * @type {null|number|string}
  11312. */
  11313. height: null,
  11314. /**
  11315. * The color of the outer chart border.
  11316. *
  11317. * @see In styled mode, the stroke is set with the
  11318. * `.highcharts-background` class.
  11319. *
  11320. * @sample {highcharts} highcharts/chart/bordercolor/
  11321. * Brown border
  11322. * @sample {highstock} stock/chart/border/
  11323. * Brown border
  11324. * @sample {highmaps} maps/chart/border/
  11325. * Border options
  11326. *
  11327. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11328. */
  11329. borderColor: '#335cad',
  11330. /**
  11331. * The pixel width of the outer chart border.
  11332. *
  11333. * @see In styled mode, the stroke is set with the
  11334. * `.highcharts-background` class.
  11335. *
  11336. * @sample {highcharts} highcharts/chart/borderwidth/
  11337. * 5px border
  11338. * @sample {highstock} stock/chart/border/
  11339. * 2px border
  11340. * @sample {highmaps} maps/chart/border/
  11341. * Border options
  11342. *
  11343. * @type {number}
  11344. * @default 0
  11345. * @apioption chart.borderWidth
  11346. */
  11347. /**
  11348. * The background color or gradient for the outer chart area.
  11349. *
  11350. * @see In styled mode, the background is set with the
  11351. * `.highcharts-background` class.
  11352. *
  11353. * @sample {highcharts} highcharts/chart/backgroundcolor-color/
  11354. * Color
  11355. * @sample {highcharts} highcharts/chart/backgroundcolor-gradient/
  11356. * Gradient
  11357. * @sample {highstock} stock/chart/backgroundcolor-color/
  11358. * Color
  11359. * @sample {highstock} stock/chart/backgroundcolor-gradient/
  11360. * Gradient
  11361. * @sample {highmaps} maps/chart/backgroundcolor-color/
  11362. * Color
  11363. * @sample {highmaps} maps/chart/backgroundcolor-gradient/
  11364. * Gradient
  11365. *
  11366. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11367. */
  11368. backgroundColor: '#ffffff',
  11369. /**
  11370. * The background color or gradient for the plot area.
  11371. *
  11372. * @see In styled mode, the plot background is set with the
  11373. * `.highcharts-plot-background` class.
  11374. *
  11375. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-color/
  11376. * Color
  11377. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-gradient/
  11378. * Gradient
  11379. * @sample {highstock} stock/chart/plotbackgroundcolor-color/
  11380. * Color
  11381. * @sample {highstock} stock/chart/plotbackgroundcolor-gradient/
  11382. * Gradient
  11383. * @sample {highmaps} maps/chart/plotbackgroundcolor-color/
  11384. * Color
  11385. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  11386. * Gradient
  11387. *
  11388. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11389. * @apioption chart.plotBackgroundColor
  11390. */
  11391. /**
  11392. * The URL for an image to use as the plot background. To set an image
  11393. * as the background for the entire chart, set a CSS background image
  11394. * to the container element. Note that for the image to be applied to
  11395. * exported charts, its URL needs to be accessible by the export server.
  11396. *
  11397. * @see In styled mode, a plot background image can be set with the
  11398. * `.highcharts-plot-background` class and a [custom pattern](
  11399. * https://www.highcharts.com/docs/chart-design-and-style/
  11400. * gradients-shadows-and-patterns).
  11401. *
  11402. * @sample {highcharts} highcharts/chart/plotbackgroundimage/
  11403. * Skies
  11404. * @sample {highstock} stock/chart/plotbackgroundimage/
  11405. * Skies
  11406. *
  11407. * @type {string}
  11408. * @apioption chart.plotBackgroundImage
  11409. */
  11410. /**
  11411. * The color of the inner chart or plot area border.
  11412. *
  11413. * @see In styled mode, a plot border stroke can be set with the
  11414. * `.highcharts-plot-border` class.
  11415. *
  11416. * @sample {highcharts} highcharts/chart/plotbordercolor/
  11417. * Blue border
  11418. * @sample {highstock} stock/chart/plotborder/
  11419. * Blue border
  11420. * @sample {highmaps} maps/chart/plotborder/
  11421. * Plot border options
  11422. *
  11423. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11424. */
  11425. plotBorderColor: '#cccccc'
  11426. },
  11427. /**
  11428. * The chart's main title.
  11429. *
  11430. * @sample {highmaps} maps/title/title/
  11431. * Title options demonstrated
  11432. */
  11433. title: {
  11434. /**
  11435. * When the title is floating, the plot area will not move to make space
  11436. * for it.
  11437. *
  11438. * @sample {highcharts} highcharts/chart/zoomtype-none/
  11439. * False by default
  11440. * @sample {highcharts} highcharts/title/floating/
  11441. * True - title on top of the plot area
  11442. * @sample {highstock} stock/chart/title-floating/
  11443. * True - title on top of the plot area
  11444. *
  11445. * @type {boolean}
  11446. * @default false
  11447. * @since 2.1
  11448. * @apioption title.floating
  11449. */
  11450. /**
  11451. * CSS styles for the title. Use this for font styling, but use `align`,
  11452. * `x` and `y` for text alignment.
  11453. *
  11454. * In styled mode, the title style is given in the `.highcharts-title`
  11455. * class.
  11456. *
  11457. * @sample {highcharts} highcharts/title/style/
  11458. * Custom color and weight
  11459. * @sample {highstock} stock/chart/title-style/
  11460. * Custom color and weight
  11461. * @sample highcharts/css/titles/
  11462. * Styled mode
  11463. *
  11464. * @type {Highcharts.CSSObject}
  11465. * @default {highcharts|highmaps} { "color": "#333333", "fontSize": "18px" }
  11466. * @default {highstock} { "color": "#333333", "fontSize": "16px" }
  11467. * @apioption title.style
  11468. */
  11469. /**
  11470. * Whether to
  11471. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  11472. * to render the text.
  11473. *
  11474. * @type {boolean}
  11475. * @default false
  11476. * @apioption title.useHTML
  11477. */
  11478. /**
  11479. * The vertical alignment of the title. Can be one of `"top"`,
  11480. * `"middle"` and `"bottom"`. When a value is given, the title behaves
  11481. * as if [floating](#title.floating) were `true`.
  11482. *
  11483. * @sample {highcharts} highcharts/title/verticalalign/
  11484. * Chart title in bottom right corner
  11485. * @sample {highstock} stock/chart/title-verticalalign/
  11486. * Chart title in bottom right corner
  11487. *
  11488. * @type {Highcharts.VerticalAlignValue}
  11489. * @since 2.1
  11490. * @apioption title.verticalAlign
  11491. */
  11492. /**
  11493. * The x position of the title relative to the alignment within
  11494. * `chart.spacingLeft` and `chart.spacingRight`.
  11495. *
  11496. * @sample {highcharts} highcharts/title/align/
  11497. * Aligned to the plot area (x = 70px = margin left - spacing
  11498. * left)
  11499. * @sample {highstock} stock/chart/title-align/
  11500. * Aligned to the plot area (x = 50px = margin left - spacing
  11501. * left)
  11502. *
  11503. * @type {number}
  11504. * @default 0
  11505. * @since 2.0
  11506. * @apioption title.x
  11507. */
  11508. /**
  11509. * The y position of the title relative to the alignment within
  11510. * [chart.spacingTop](#chart.spacingTop) and [chart.spacingBottom](
  11511. * #chart.spacingBottom). By default it depends on the font size.
  11512. *
  11513. * @sample {highcharts} highcharts/title/y/
  11514. * Title inside the plot area
  11515. * @sample {highstock} stock/chart/title-verticalalign/
  11516. * Chart title in bottom right corner
  11517. *
  11518. * @type {number}
  11519. * @since 2.0
  11520. * @apioption title.y
  11521. */
  11522. /**
  11523. * The title of the chart. To disable the title, set the `text` to
  11524. * `undefined`.
  11525. *
  11526. * @sample {highcharts} highcharts/title/text/
  11527. * Custom title
  11528. * @sample {highstock} stock/chart/title-text/
  11529. * Custom title
  11530. *
  11531. * @default {highcharts|highmaps} Chart title
  11532. * @default {highstock} undefined
  11533. */
  11534. text: 'Chart title',
  11535. /**
  11536. * The horizontal alignment of the title. Can be one of "left", "center"
  11537. * and "right".
  11538. *
  11539. * @sample {highcharts} highcharts/title/align/
  11540. * Aligned to the plot area (x = 70px = margin left - spacing
  11541. * left)
  11542. * @sample {highstock} stock/chart/title-align/
  11543. * Aligned to the plot area (x = 50px = margin left - spacing
  11544. * left)
  11545. *
  11546. * @type {Highcharts.AlignValue}
  11547. * @since 2.0
  11548. */
  11549. align: 'center',
  11550. /**
  11551. * The margin between the title and the plot area, or if a subtitle
  11552. * is present, the margin between the subtitle and the plot area.
  11553. *
  11554. * @sample {highcharts} highcharts/title/margin-50/
  11555. * A chart title margin of 50
  11556. * @sample {highcharts} highcharts/title/margin-subtitle/
  11557. * The same margin applied with a subtitle
  11558. * @sample {highstock} stock/chart/title-margin/
  11559. * A chart title margin of 50
  11560. *
  11561. * @since 2.1
  11562. */
  11563. margin: 15,
  11564. /**
  11565. * Adjustment made to the title width, normally to reserve space for
  11566. * the exporting burger menu.
  11567. *
  11568. * @sample highcharts/title/widthadjust/
  11569. * Wider menu, greater padding
  11570. *
  11571. * @since 4.2.5
  11572. */
  11573. widthAdjust: -44
  11574. },
  11575. /**
  11576. * The chart's subtitle. This can be used both to display a subtitle below
  11577. * the main title, and to display random text anywhere in the chart. The
  11578. * subtitle can be updated after chart initialization through the
  11579. * `Chart.setTitle` method.
  11580. *
  11581. * @sample {highmaps} maps/title/subtitle/
  11582. * Subtitle options demonstrated
  11583. */
  11584. subtitle: {
  11585. /**
  11586. * When the subtitle is floating, the plot area will not move to make
  11587. * space for it.
  11588. *
  11589. * @sample {highcharts} highcharts/subtitle/floating/
  11590. * Floating title and subtitle
  11591. * @sample {highstock} stock/chart/subtitle-footnote
  11592. * Footnote floating at bottom right of plot area
  11593. *
  11594. * @type {boolean}
  11595. * @default false
  11596. * @since 2.1
  11597. * @apioption subtitle.floating
  11598. */
  11599. /**
  11600. * CSS styles for the title.
  11601. *
  11602. * In styled mode, the subtitle style is given in the
  11603. * `.highcharts-subtitle` class.
  11604. *
  11605. * @sample {highcharts} highcharts/subtitle/style/
  11606. * Custom color and weight
  11607. * @sample {highcharts} highcharts/css/titles/
  11608. * Styled mode
  11609. * @sample {highstock} stock/chart/subtitle-style
  11610. * Custom color and weight
  11611. * @sample {highstock} highcharts/css/titles/
  11612. * Styled mode
  11613. * @sample {highmaps} highcharts/css/titles/
  11614. * Styled mode
  11615. *
  11616. * @type {Highcharts.CSSObject}
  11617. * @default {"color": "#666666"}
  11618. * @apioption subtitle.style
  11619. */
  11620. /**
  11621. * Whether to
  11622. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  11623. * to render the text.
  11624. *
  11625. * @type {boolean}
  11626. * @default false
  11627. * @apioption subtitle.useHTML
  11628. */
  11629. /**
  11630. * The vertical alignment of the title. Can be one of `"top"`,
  11631. * `"middle"` and `"bottom"`. When middle, the subtitle behaves as
  11632. * floating.
  11633. *
  11634. * @sample {highcharts} highcharts/subtitle/verticalalign/
  11635. * Footnote at the bottom right of plot area
  11636. * @sample {highstock} stock/chart/subtitle-footnote
  11637. * Footnote at the bottom right of plot area
  11638. *
  11639. * @type {Highcharts.VerticalAlignValue}
  11640. * @since 2.1
  11641. * @apioption subtitle.verticalAlign
  11642. */
  11643. /**
  11644. * The x position of the subtitle relative to the alignment within
  11645. * `chart.spacingLeft` and `chart.spacingRight`.
  11646. *
  11647. * @sample {highcharts} highcharts/subtitle/align/
  11648. * Footnote at right of plot area
  11649. * @sample {highstock} stock/chart/subtitle-footnote
  11650. * Footnote at the bottom right of plot area
  11651. *
  11652. * @type {number}
  11653. * @default 0
  11654. * @since 2.0
  11655. * @apioption subtitle.x
  11656. */
  11657. /**
  11658. * The y position of the subtitle relative to the alignment within
  11659. * `chart.spacingTop` and `chart.spacingBottom`. By default the subtitle
  11660. * is laid out below the title unless the title is floating.
  11661. *
  11662. * @sample {highcharts} highcharts/subtitle/verticalalign/
  11663. * Footnote at the bottom right of plot area
  11664. * @sample {highstock} stock/chart/subtitle-footnote
  11665. * Footnote at the bottom right of plot area
  11666. *
  11667. * @type {number}
  11668. * @since 2.0
  11669. * @apioption subtitle.y
  11670. */
  11671. /**
  11672. * The subtitle of the chart.
  11673. *
  11674. * @sample {highcharts|highstock} highcharts/subtitle/text/
  11675. * Custom subtitle
  11676. * @sample {highcharts|highstock} highcharts/subtitle/text-formatted/
  11677. * Formatted and linked text.
  11678. */
  11679. text: '',
  11680. /**
  11681. * The horizontal alignment of the subtitle. Can be one of "left",
  11682. * "center" and "right".
  11683. *
  11684. * @sample {highcharts} highcharts/subtitle/align/
  11685. * Footnote at right of plot area
  11686. * @sample {highstock} stock/chart/subtitle-footnote
  11687. * Footnote at bottom right of plot area
  11688. *
  11689. * @type {Highcharts.AlignValue}
  11690. * @since 2.0
  11691. */
  11692. align: 'center',
  11693. /**
  11694. * Adjustment made to the subtitle width, normally to reserve space
  11695. * for the exporting burger menu.
  11696. *
  11697. * @see [title.widthAdjust](#title.widthAdjust)
  11698. *
  11699. * @sample highcharts/title/widthadjust/
  11700. * Wider menu, greater padding
  11701. *
  11702. * @since 4.2.5
  11703. */
  11704. widthAdjust: -44
  11705. },
  11706. /**
  11707. * The chart's caption, which will render below the chart and will be part
  11708. * of exported charts. The caption can be updated after chart initialization
  11709. * through the `Chart.update` or `Chart.caption.update` methods.
  11710. *
  11711. * @sample highcharts/caption/text/
  11712. * A chart with a caption
  11713. * @since 7.2.0
  11714. */
  11715. caption: {
  11716. /**
  11717. * When the caption is floating, the plot area will not move to make
  11718. * space for it.
  11719. *
  11720. * @type {boolean}
  11721. * @default false
  11722. * @apioption caption.floating
  11723. */
  11724. /**
  11725. * The margin between the caption and the plot area.
  11726. */
  11727. margin: 15,
  11728. /**
  11729. * CSS styles for the caption.
  11730. *
  11731. * In styled mode, the caption style is given in the
  11732. * `.highcharts-caption` class.
  11733. *
  11734. * @sample {highcharts} highcharts/css/titles/
  11735. * Styled mode
  11736. *
  11737. * @type {Highcharts.CSSObject}
  11738. * @default {"color": "#666666"}
  11739. * @apioption caption.style
  11740. */
  11741. /**
  11742. * Whether to
  11743. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  11744. * to render the text.
  11745. *
  11746. * @type {boolean}
  11747. * @default false
  11748. * @apioption caption.useHTML
  11749. */
  11750. /**
  11751. * The x position of the caption relative to the alignment within
  11752. * `chart.spacingLeft` and `chart.spacingRight`.
  11753. *
  11754. * @type {number}
  11755. * @default 0
  11756. * @apioption caption.x
  11757. */
  11758. /**
  11759. * The y position of the caption relative to the alignment within
  11760. * `chart.spacingTop` and `chart.spacingBottom`.
  11761. *
  11762. * @type {number}
  11763. * @apioption caption.y
  11764. */
  11765. /**
  11766. * The caption text of the chart.
  11767. *
  11768. * @sample {highcharts} highcharts/caption/text/
  11769. * Custom caption
  11770. */
  11771. text: '',
  11772. /**
  11773. * The horizontal alignment of the caption. Can be one of "left",
  11774. * "center" and "right".
  11775. *
  11776. * @type {Highcharts.AlignValue}
  11777. */
  11778. align: 'left',
  11779. /**
  11780. * The vertical alignment of the caption. Can be one of `"top"`,
  11781. * `"middle"` and `"bottom"`. When middle, the caption behaves as
  11782. * floating.
  11783. *
  11784. * @type {Highcharts.VerticalAlignValue}
  11785. */
  11786. verticalAlign: 'bottom'
  11787. },
  11788. /**
  11789. * The plotOptions is a wrapper object for config objects for each series
  11790. * type. The config objects for each series can also be overridden for
  11791. * each series item as given in the series array.
  11792. *
  11793. * Configuration options for the series are given in three levels. Options
  11794. * for all series in a chart are given in the [plotOptions.series](
  11795. * #plotOptions.series) object. Then options for all series of a specific
  11796. * type are given in the plotOptions of that type, for example
  11797. * `plotOptions.line`. Next, options for one single series are given in
  11798. * [the series array](#series).
  11799. */
  11800. plotOptions: {},
  11801. /**
  11802. * HTML labels that can be positioned anywhere in the chart area.
  11803. *
  11804. * This option is deprecated since v7.1.2. Instead, use
  11805. * [annotations](#annotations) that support labels.
  11806. *
  11807. * @deprecated
  11808. * @product highcharts highstock
  11809. */
  11810. labels: {
  11811. /**
  11812. * An HTML label that can be positioned anywhere in the chart area.
  11813. *
  11814. * @deprecated
  11815. * @type {Array<*>}
  11816. * @apioption labels.items
  11817. */
  11818. /**
  11819. * Inner HTML or text for the label.
  11820. *
  11821. * @deprecated
  11822. * @type {string}
  11823. * @apioption labels.items.html
  11824. */
  11825. /**
  11826. * CSS styles for each label. To position the label, use left and top
  11827. * like this:
  11828. * ```js
  11829. * style: {
  11830. * left: '100px',
  11831. * top: '100px'
  11832. * }
  11833. * ```
  11834. *
  11835. * @deprecated
  11836. * @type {Highcharts.CSSObject}
  11837. * @apioption labels.items.style
  11838. */
  11839. /**
  11840. * Shared CSS styles for all labels.
  11841. *
  11842. * @deprecated
  11843. * @type {Highcharts.CSSObject}
  11844. * @default {"color": "#333333", "position": "absolute"}
  11845. */
  11846. style: {
  11847. /**
  11848. * @ignore-option
  11849. */
  11850. position: 'absolute',
  11851. /**
  11852. * @ignore-option
  11853. */
  11854. color: '#333333'
  11855. }
  11856. },
  11857. /**
  11858. * The legend is a box containing a symbol and name for each series
  11859. * item or point item in the chart. Each series (or points in case
  11860. * of pie charts) is represented by a symbol and its name in the legend.
  11861. *
  11862. * It is possible to override the symbol creator function and create
  11863. * [custom legend symbols](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/studies/legend-custom-symbol/).
  11864. *
  11865. * @productdesc {highmaps}
  11866. * A Highmaps legend by default contains one legend item per series, but if
  11867. * a `colorAxis` is defined, the axis will be displayed in the legend.
  11868. * Either as a gradient, or as multiple legend items for `dataClasses`.
  11869. */
  11870. legend: {
  11871. /**
  11872. * The background color of the legend.
  11873. *
  11874. * @see In styled mode, the legend background fill can be applied with
  11875. * the `.highcharts-legend-box` class.
  11876. *
  11877. * @sample {highcharts} highcharts/legend/backgroundcolor/
  11878. * Yellowish background
  11879. * @sample {highstock} stock/legend/align/
  11880. * Various legend options
  11881. * @sample {highmaps} maps/legend/border-background/
  11882. * Border and background options
  11883. *
  11884. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11885. * @apioption legend.backgroundColor
  11886. */
  11887. /**
  11888. * The width of the drawn border around the legend.
  11889. *
  11890. * @see In styled mode, the legend border stroke width can be applied
  11891. * with the `.highcharts-legend-box` class.
  11892. *
  11893. * @sample {highcharts} highcharts/legend/borderwidth/
  11894. * 2px border width
  11895. * @sample {highstock} stock/legend/align/
  11896. * Various legend options
  11897. * @sample {highmaps} maps/legend/border-background/
  11898. * Border and background options
  11899. *
  11900. * @type {number}
  11901. * @default 0
  11902. * @apioption legend.borderWidth
  11903. */
  11904. /**
  11905. * Enable or disable the legend. There is also a series-specific option,
  11906. * [showInLegend](#plotOptions.series.showInLegend), that can hide the
  11907. * series from the legend. In some series types this is `false` by
  11908. * default, so it must set to `true` in order to show the legend for the
  11909. * series.
  11910. *
  11911. * @sample {highcharts} highcharts/legend/enabled-false/ Legend disabled
  11912. * @sample {highstock} stock/legend/align/ Various legend options
  11913. * @sample {highmaps} maps/legend/enabled-false/ Legend disabled
  11914. *
  11915. * @default {highstock} false
  11916. * @default {highmaps} true
  11917. * @default {gantt} false
  11918. */
  11919. enabled: true,
  11920. /**
  11921. * The horizontal alignment of the legend box within the chart area.
  11922. * Valid values are `left`, `center` and `right`.
  11923. *
  11924. * In the case that the legend is aligned in a corner position, the
  11925. * `layout` option will determine whether to place it above/below
  11926. * or on the side of the plot area.
  11927. *
  11928. * @sample {highcharts} highcharts/legend/align/
  11929. * Legend at the right of the chart
  11930. * @sample {highstock} stock/legend/align/
  11931. * Various legend options
  11932. * @sample {highmaps} maps/legend/alignment/
  11933. * Legend alignment
  11934. *
  11935. * @type {Highcharts.AlignValue}
  11936. * @since 2.0
  11937. */
  11938. align: 'center',
  11939. /**
  11940. * If the [layout](legend.layout) is `horizontal` and the legend items
  11941. * span over two lines or more, whether to align the items into vertical
  11942. * columns. Setting this to `false` makes room for more items, but will
  11943. * look more messy.
  11944. *
  11945. * @since 6.1.0
  11946. */
  11947. alignColumns: true,
  11948. /**
  11949. * When the legend is floating, the plot area ignores it and is allowed
  11950. * to be placed below it.
  11951. *
  11952. * @sample {highcharts} highcharts/legend/floating-false/
  11953. * False by default
  11954. * @sample {highcharts} highcharts/legend/floating-true/
  11955. * True
  11956. * @sample {highmaps} maps/legend/alignment/
  11957. * Floating legend
  11958. *
  11959. * @type {boolean}
  11960. * @default false
  11961. * @since 2.1
  11962. * @apioption legend.floating
  11963. */
  11964. /**
  11965. * The layout of the legend items. Can be one of `horizontal` or
  11966. * `vertical` or `proximate`. When `proximate`, the legend items will be
  11967. * placed as close as possible to the graphs they're representing,
  11968. * except in inverted charts or when the legend position doesn't allow
  11969. * it.
  11970. *
  11971. * @sample {highcharts} highcharts/legend/layout-horizontal/
  11972. * Horizontal by default
  11973. * @sample {highcharts} highcharts/legend/layout-vertical/
  11974. * Vertical
  11975. * @sample highcharts/legend/layout-proximate
  11976. * Labels proximate to the data
  11977. * @sample {highstock} stock/legend/layout-horizontal/
  11978. * Horizontal by default
  11979. * @sample {highmaps} maps/legend/padding-itemmargin/
  11980. * Vertical with data classes
  11981. * @sample {highmaps} maps/legend/layout-vertical/
  11982. * Vertical with color axis gradient
  11983. *
  11984. * @validvalue ["horizontal", "vertical", "proximate"]
  11985. */
  11986. layout: 'horizontal',
  11987. /**
  11988. * In a legend with horizontal layout, the itemDistance defines the
  11989. * pixel distance between each item.
  11990. *
  11991. * @sample {highcharts} highcharts/legend/layout-horizontal/
  11992. * 50px item distance
  11993. * @sample {highstock} highcharts/legend/layout-horizontal/
  11994. * 50px item distance
  11995. *
  11996. * @type {number}
  11997. * @default {highcharts} 20
  11998. * @default {highstock} 20
  11999. * @default {highmaps} 8
  12000. * @since 3.0.3
  12001. * @apioption legend.itemDistance
  12002. */
  12003. /**
  12004. * The pixel bottom margin for each legend item.
  12005. *
  12006. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  12007. * Padding and item margins demonstrated
  12008. * @sample {highmaps} maps/legend/padding-itemmargin/
  12009. * Padding and item margins demonstrated
  12010. *
  12011. * @type {number}
  12012. * @default 0
  12013. * @since 2.2.0
  12014. * @apioption legend.itemMarginBottom
  12015. */
  12016. /**
  12017. * The pixel top margin for each legend item.
  12018. *
  12019. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  12020. * Padding and item margins demonstrated
  12021. * @sample {highmaps} maps/legend/padding-itemmargin/
  12022. * Padding and item margins demonstrated
  12023. *
  12024. * @type {number}
  12025. * @default 0
  12026. * @since 2.2.0
  12027. * @apioption legend.itemMarginTop
  12028. */
  12029. /**
  12030. * The width for each legend item. By default the items are laid out
  12031. * successively. In a [horizontal layout](legend.layout), if the items
  12032. * are laid out across two rows or more, they will be vertically aligned
  12033. * depending on the [legend.alignColumns](legend.alignColumns) option.
  12034. *
  12035. * @sample {highcharts} highcharts/legend/itemwidth-default/
  12036. * Undefined by default
  12037. * @sample {highcharts} highcharts/legend/itemwidth-80/
  12038. * 80 for aligned legend items
  12039. *
  12040. * @type {number}
  12041. * @since 2.0
  12042. * @apioption legend.itemWidth
  12043. */
  12044. /**
  12045. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  12046. * for each legend label. Available variables relates to properties on
  12047. * the series, or the point in case of pies.
  12048. *
  12049. * @type {string}
  12050. * @default {name}
  12051. * @since 1.3
  12052. * @apioption legend.labelFormat
  12053. */
  12054. /* eslint-disable valid-jsdoc */
  12055. /**
  12056. * Callback function to format each of the series' labels. The `this`
  12057. * keyword refers to the series object, or the point object in case of
  12058. * pie charts. By default the series or point name is printed.
  12059. *
  12060. * @productdesc {highmaps}
  12061. * In Highmaps the context can also be a data class in case of a
  12062. * `colorAxis`.
  12063. *
  12064. * @sample {highcharts} highcharts/legend/labelformatter/
  12065. * Add text
  12066. * @sample {highmaps} maps/legend/labelformatter/
  12067. * Data classes with label formatter
  12068. *
  12069. * @type {Highcharts.FormatterCallbackFunction<Point|Series>}
  12070. */
  12071. labelFormatter: function () {
  12072. /** eslint-enable valid-jsdoc */
  12073. return this.name;
  12074. },
  12075. /**
  12076. * Line height for the legend items. Deprecated as of 2.1\. Instead,
  12077. * the line height for each item can be set using
  12078. * `itemStyle.lineHeight`, and the padding between items using
  12079. * `itemMarginTop` and `itemMarginBottom`.
  12080. *
  12081. * @sample {highcharts} highcharts/legend/lineheight/
  12082. * Setting padding
  12083. *
  12084. * @deprecated
  12085. *
  12086. * @type {number}
  12087. * @default 16
  12088. * @since 2.0
  12089. * @product highcharts gantt
  12090. * @apioption legend.lineHeight
  12091. */
  12092. /**
  12093. * If the plot area sized is calculated automatically and the legend is
  12094. * not floating, the legend margin is the space between the legend and
  12095. * the axis labels or plot area.
  12096. *
  12097. * @sample {highcharts} highcharts/legend/margin-default/
  12098. * 12 pixels by default
  12099. * @sample {highcharts} highcharts/legend/margin-30/
  12100. * 30 pixels
  12101. *
  12102. * @type {number}
  12103. * @default 12
  12104. * @since 2.1
  12105. * @apioption legend.margin
  12106. */
  12107. /**
  12108. * Maximum pixel height for the legend. When the maximum height is
  12109. * extended, navigation will show.
  12110. *
  12111. * @type {number}
  12112. * @since 2.3.0
  12113. * @apioption legend.maxHeight
  12114. */
  12115. /**
  12116. * The color of the drawn border around the legend.
  12117. *
  12118. * @see In styled mode, the legend border stroke can be applied with the
  12119. * `.highcharts-legend-box` class.
  12120. *
  12121. * @sample {highcharts} highcharts/legend/bordercolor/
  12122. * Brown border
  12123. * @sample {highstock} stock/legend/align/
  12124. * Various legend options
  12125. * @sample {highmaps} maps/legend/border-background/
  12126. * Border and background options
  12127. *
  12128. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12129. */
  12130. borderColor: '#999999',
  12131. /**
  12132. * The border corner radius of the legend.
  12133. *
  12134. * @sample {highcharts} highcharts/legend/borderradius-default/
  12135. * Square by default
  12136. * @sample {highcharts} highcharts/legend/borderradius-round/
  12137. * 5px rounded
  12138. * @sample {highmaps} maps/legend/border-background/
  12139. * Border and background options
  12140. */
  12141. borderRadius: 0,
  12142. /**
  12143. * Options for the paging or navigation appearing when the legend is
  12144. * overflown. Navigation works well on screen, but not in static
  12145. * exported images. One way of working around that is to
  12146. * [increase the chart height in
  12147. * export](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/legend/navigation-enabled-false/).
  12148. */
  12149. navigation: {
  12150. /**
  12151. * How to animate the pages when navigating up or down. A value of
  12152. * `true` applies the default navigation given in the
  12153. * `chart.animation` option. Additional options can be given as an
  12154. * object containing values for easing and duration.
  12155. *
  12156. * @sample {highcharts} highcharts/legend/navigation/
  12157. * Legend page navigation demonstrated
  12158. * @sample {highstock} highcharts/legend/navigation/
  12159. * Legend page navigation demonstrated
  12160. *
  12161. * @type {boolean|Highcharts.AnimationOptionsObject}
  12162. * @default true
  12163. * @since 2.2.4
  12164. * @apioption legend.navigation.animation
  12165. */
  12166. /**
  12167. * The pixel size of the up and down arrows in the legend paging
  12168. * navigation.
  12169. *
  12170. * @sample {highcharts} highcharts/legend/navigation/
  12171. * Legend page navigation demonstrated
  12172. * @sample {highstock} highcharts/legend/navigation/
  12173. * Legend page navigation demonstrated
  12174. *
  12175. * @type {number}
  12176. * @default 12
  12177. * @since 2.2.4
  12178. * @apioption legend.navigation.arrowSize
  12179. */
  12180. /**
  12181. * Whether to enable the legend navigation. In most cases, disabling
  12182. * the navigation results in an unwanted overflow.
  12183. *
  12184. * See also the [adapt chart to legend](
  12185. * https://www.highcharts.com/products/plugin-registry/single/8/Adapt-Chart-To-Legend)
  12186. * plugin for a solution to extend the chart height to make room for
  12187. * the legend, optionally in exported charts only.
  12188. *
  12189. * @type {boolean}
  12190. * @default true
  12191. * @since 4.2.4
  12192. * @apioption legend.navigation.enabled
  12193. */
  12194. /**
  12195. * Text styles for the legend page navigation.
  12196. *
  12197. * @see In styled mode, the navigation items are styled with the
  12198. * `.highcharts-legend-navigation` class.
  12199. *
  12200. * @sample {highcharts} highcharts/legend/navigation/
  12201. * Legend page navigation demonstrated
  12202. * @sample {highstock} highcharts/legend/navigation/
  12203. * Legend page navigation demonstrated
  12204. *
  12205. * @type {Highcharts.CSSObject}
  12206. * @since 2.2.4
  12207. * @apioption legend.navigation.style
  12208. */
  12209. /**
  12210. * The color for the active up or down arrow in the legend page
  12211. * navigation.
  12212. *
  12213. * @see In styled mode, the active arrow be styled with the
  12214. * `.highcharts-legend-nav-active` class.
  12215. *
  12216. * @sample {highcharts} highcharts/legend/navigation/
  12217. * Legend page navigation demonstrated
  12218. * @sample {highstock} highcharts/legend/navigation/
  12219. * Legend page navigation demonstrated
  12220. *
  12221. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12222. * @since 2.2.4
  12223. */
  12224. activeColor: '#003399',
  12225. /**
  12226. * The color of the inactive up or down arrow in the legend page
  12227. * navigation. .
  12228. *
  12229. * @see In styled mode, the inactive arrow be styled with the
  12230. * `.highcharts-legend-nav-inactive` class.
  12231. *
  12232. * @sample {highcharts} highcharts/legend/navigation/
  12233. * Legend page navigation demonstrated
  12234. * @sample {highstock} highcharts/legend/navigation/
  12235. * Legend page navigation demonstrated
  12236. *
  12237. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12238. * @since 2.2.4
  12239. */
  12240. inactiveColor: '#cccccc'
  12241. },
  12242. /**
  12243. * The inner padding of the legend box.
  12244. *
  12245. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  12246. * Padding and item margins demonstrated
  12247. * @sample {highmaps} maps/legend/padding-itemmargin/
  12248. * Padding and item margins demonstrated
  12249. *
  12250. * @type {number}
  12251. * @default 8
  12252. * @since 2.2.0
  12253. * @apioption legend.padding
  12254. */
  12255. /**
  12256. * Whether to reverse the order of the legend items compared to the
  12257. * order of the series or points as defined in the configuration object.
  12258. *
  12259. * @see [yAxis.reversedStacks](#yAxis.reversedStacks),
  12260. * [series.legendIndex](#series.legendIndex)
  12261. *
  12262. * @sample {highcharts} highcharts/legend/reversed/
  12263. * Stacked bar with reversed legend
  12264. *
  12265. * @type {boolean}
  12266. * @default false
  12267. * @since 1.2.5
  12268. * @apioption legend.reversed
  12269. */
  12270. /**
  12271. * Whether to show the symbol on the right side of the text rather than
  12272. * the left side. This is common in Arabic and Hebraic.
  12273. *
  12274. * @sample {highcharts} highcharts/legend/rtl/
  12275. * Symbol to the right
  12276. *
  12277. * @type {boolean}
  12278. * @default false
  12279. * @since 2.2
  12280. * @apioption legend.rtl
  12281. */
  12282. /**
  12283. * CSS styles for the legend area. In the 1.x versions the position
  12284. * of the legend area was determined by CSS. In 2.x, the position is
  12285. * determined by properties like `align`, `verticalAlign`, `x` and `y`,
  12286. * but the styles are still parsed for backwards compatibility.
  12287. *
  12288. * @deprecated
  12289. *
  12290. * @type {Highcharts.CSSObject}
  12291. * @product highcharts highstock
  12292. * @apioption legend.style
  12293. */
  12294. /**
  12295. * CSS styles for each legend item. Only a subset of CSS is supported,
  12296. * notably those options related to text. The default `textOverflow`
  12297. * property makes long texts truncate. Set it to `undefined` to wrap
  12298. * text instead. A `width` property can be added to control the text
  12299. * width.
  12300. *
  12301. * @see In styled mode, the legend items can be styled with the
  12302. * `.highcharts-legend-item` class.
  12303. *
  12304. * @sample {highcharts} highcharts/legend/itemstyle/
  12305. * Bold black text
  12306. * @sample {highmaps} maps/legend/itemstyle/
  12307. * Item text styles
  12308. *
  12309. * @type {Highcharts.CSSObject}
  12310. * @default {"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}
  12311. */
  12312. itemStyle: {
  12313. /**
  12314. * @ignore
  12315. */
  12316. color: '#333333',
  12317. /**
  12318. * @ignore
  12319. */
  12320. cursor: 'pointer',
  12321. /**
  12322. * @ignore
  12323. */
  12324. fontSize: '12px',
  12325. /**
  12326. * @ignore
  12327. */
  12328. fontWeight: 'bold',
  12329. /**
  12330. * @ignore
  12331. */
  12332. textOverflow: 'ellipsis'
  12333. },
  12334. /**
  12335. * CSS styles for each legend item in hover mode. Only a subset of
  12336. * CSS is supported, notably those options related to text. Properties
  12337. * are inherited from `style` unless overridden here.
  12338. *
  12339. * @see In styled mode, the hovered legend items can be styled with
  12340. * the `.highcharts-legend-item:hover` pesudo-class.
  12341. *
  12342. * @sample {highcharts} highcharts/legend/itemhoverstyle/
  12343. * Red on hover
  12344. * @sample {highmaps} maps/legend/itemstyle/
  12345. * Item text styles
  12346. *
  12347. * @type {Highcharts.CSSObject}
  12348. * @default {"color": "#000000"}
  12349. */
  12350. itemHoverStyle: {
  12351. /**
  12352. * @ignore
  12353. */
  12354. color: '#000000'
  12355. },
  12356. /**
  12357. * CSS styles for each legend item when the corresponding series or
  12358. * point is hidden. Only a subset of CSS is supported, notably those
  12359. * options related to text. Properties are inherited from `style`
  12360. * unless overridden here.
  12361. *
  12362. * @see In styled mode, the hidden legend items can be styled with
  12363. * the `.highcharts-legend-item-hidden` class.
  12364. *
  12365. * @sample {highcharts} highcharts/legend/itemhiddenstyle/
  12366. * Darker gray color
  12367. *
  12368. * @type {Highcharts.CSSObject}
  12369. * @default {"color": "#cccccc"}
  12370. */
  12371. itemHiddenStyle: {
  12372. /**
  12373. * @ignore
  12374. */
  12375. color: '#cccccc'
  12376. },
  12377. /**
  12378. * Whether to apply a drop shadow to the legend. A `backgroundColor`
  12379. * also needs to be applied for this to take effect. The shadow can be
  12380. * an object configuration containing `color`, `offsetX`, `offsetY`,
  12381. * `opacity` and `width`.
  12382. *
  12383. * @sample {highcharts} highcharts/legend/shadow/
  12384. * White background and drop shadow
  12385. * @sample {highstock} stock/legend/align/
  12386. * Various legend options
  12387. * @sample {highmaps} maps/legend/border-background/
  12388. * Border and background options
  12389. *
  12390. * @type {boolean|Highcharts.CSSObject}
  12391. */
  12392. shadow: false,
  12393. /**
  12394. * Default styling for the checkbox next to a legend item when
  12395. * `showCheckbox` is true.
  12396. *
  12397. * @type {Highcharts.CSSObject}
  12398. * @default {"width": "13px", "height": "13px", "position":"absolute"}
  12399. */
  12400. itemCheckboxStyle: {
  12401. /**
  12402. * @ignore
  12403. */
  12404. position: 'absolute',
  12405. /**
  12406. * @ignore
  12407. */
  12408. width: '13px',
  12409. /**
  12410. * @ignore
  12411. */
  12412. height: '13px'
  12413. },
  12414. // itemWidth: undefined,
  12415. /**
  12416. * When this is true, the legend symbol width will be the same as
  12417. * the symbol height, which in turn defaults to the font size of the
  12418. * legend items.
  12419. *
  12420. * @since 5.0.0
  12421. */
  12422. squareSymbol: true,
  12423. /**
  12424. * The pixel height of the symbol for series types that use a rectangle
  12425. * in the legend. Defaults to the font size of legend items.
  12426. *
  12427. * @productdesc {highmaps}
  12428. * In Highmaps, when the symbol is the gradient of a vertical color
  12429. * axis, the height defaults to 200.
  12430. *
  12431. * @sample {highmaps} maps/legend/layout-vertical-sized/
  12432. * Sized vertical gradient
  12433. * @sample {highmaps} maps/legend/padding-itemmargin/
  12434. * No distance between data classes
  12435. *
  12436. * @type {number}
  12437. * @since 3.0.8
  12438. * @apioption legend.symbolHeight
  12439. */
  12440. /**
  12441. * The border radius of the symbol for series types that use a rectangle
  12442. * in the legend. Defaults to half the `symbolHeight`.
  12443. *
  12444. * @sample {highcharts} highcharts/legend/symbolradius/
  12445. * Round symbols
  12446. * @sample {highstock} highcharts/legend/symbolradius/
  12447. * Round symbols
  12448. * @sample {highmaps} highcharts/legend/symbolradius/
  12449. * Round symbols
  12450. *
  12451. * @type {number}
  12452. * @since 3.0.8
  12453. * @apioption legend.symbolRadius
  12454. */
  12455. /**
  12456. * The pixel width of the legend item symbol. When the `squareSymbol`
  12457. * option is set, this defaults to the `symbolHeight`, otherwise 16.
  12458. *
  12459. * @productdesc {highmaps}
  12460. * In Highmaps, when the symbol is the gradient of a horizontal color
  12461. * axis, the width defaults to 200.
  12462. *
  12463. * @sample {highcharts} highcharts/legend/symbolwidth/
  12464. * Greater symbol width and padding
  12465. * @sample {highmaps} maps/legend/padding-itemmargin/
  12466. * Padding and item margins demonstrated
  12467. * @sample {highmaps} maps/legend/layout-vertical-sized/
  12468. * Sized vertical gradient
  12469. *
  12470. * @type {number}
  12471. * @apioption legend.symbolWidth
  12472. */
  12473. /**
  12474. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  12475. * to render the legend item texts.
  12476. *
  12477. * Prior to 4.1.7, when using HTML, [legend.navigation](
  12478. * #legend.navigation) was disabled.
  12479. *
  12480. * @type {boolean}
  12481. * @default false
  12482. * @apioption legend.useHTML
  12483. */
  12484. /**
  12485. * The width of the legend box. If a number is set, it translates to
  12486. * pixels. Since v7.0.2 it allows setting a percent string of the full
  12487. * chart width, for example `40%`.
  12488. *
  12489. * Defaults to the full chart width from legends below or above the
  12490. * chart, half the chart width for legends to the left and right.
  12491. *
  12492. * @sample {highcharts} highcharts/legend/width/
  12493. * Aligned to the plot area
  12494. * @sample {highcharts} highcharts/legend/width-percent/
  12495. * A percent of the chart width
  12496. *
  12497. * @type {number|string}
  12498. * @since 2.0
  12499. * @apioption legend.width
  12500. */
  12501. /**
  12502. * The pixel padding between the legend item symbol and the legend
  12503. * item text.
  12504. *
  12505. * @sample {highcharts} highcharts/legend/symbolpadding/
  12506. * Greater symbol width and padding
  12507. */
  12508. symbolPadding: 5,
  12509. /**
  12510. * The vertical alignment of the legend box. Can be one of `top`,
  12511. * `middle` or `bottom`. Vertical position can be further determined
  12512. * by the `y` option.
  12513. *
  12514. * In the case that the legend is aligned in a corner position, the
  12515. * `layout` option will determine whether to place it above/below
  12516. * or on the side of the plot area.
  12517. *
  12518. * When the [layout](#legend.layout) option is `proximate`, the
  12519. * `verticalAlign` option doesn't apply.
  12520. *
  12521. * @sample {highcharts} highcharts/legend/verticalalign/
  12522. * Legend 100px from the top of the chart
  12523. * @sample {highstock} stock/legend/align/
  12524. * Various legend options
  12525. * @sample {highmaps} maps/legend/alignment/
  12526. * Legend alignment
  12527. *
  12528. * @type {Highcharts.VerticalAlignValue}
  12529. * @since 2.0
  12530. */
  12531. verticalAlign: 'bottom',
  12532. // width: undefined,
  12533. /**
  12534. * The x offset of the legend relative to its horizontal alignment
  12535. * `align` within chart.spacingLeft and chart.spacingRight. Negative
  12536. * x moves it to the left, positive x moves it to the right.
  12537. *
  12538. * @sample {highcharts} highcharts/legend/width/
  12539. * Aligned to the plot area
  12540. *
  12541. * @since 2.0
  12542. */
  12543. x: 0,
  12544. /**
  12545. * The vertical offset of the legend relative to it's vertical alignment
  12546. * `verticalAlign` within chart.spacingTop and chart.spacingBottom.
  12547. * Negative y moves it up, positive y moves it down.
  12548. *
  12549. * @sample {highcharts} highcharts/legend/verticalalign/
  12550. * Legend 100px from the top of the chart
  12551. * @sample {highstock} stock/legend/align/
  12552. * Various legend options
  12553. * @sample {highmaps} maps/legend/alignment/
  12554. * Legend alignment
  12555. *
  12556. * @since 2.0
  12557. */
  12558. y: 0,
  12559. /**
  12560. * A title to be added on top of the legend.
  12561. *
  12562. * @sample {highcharts} highcharts/legend/title/
  12563. * Legend title
  12564. * @sample {highmaps} maps/legend/alignment/
  12565. * Legend with title
  12566. *
  12567. * @since 3.0
  12568. */
  12569. title: {
  12570. /**
  12571. * A text or HTML string for the title.
  12572. *
  12573. * @type {string}
  12574. * @since 3.0
  12575. * @apioption legend.title.text
  12576. */
  12577. /**
  12578. * Generic CSS styles for the legend title.
  12579. *
  12580. * @see In styled mode, the legend title is styled with the
  12581. * `.highcharts-legend-title` class.
  12582. *
  12583. * @type {Highcharts.CSSObject}
  12584. * @default {"fontWeight": "bold"}
  12585. * @since 3.0
  12586. */
  12587. style: {
  12588. /**
  12589. * @ignore
  12590. */
  12591. fontWeight: 'bold'
  12592. }
  12593. }
  12594. },
  12595. /**
  12596. * The loading options control the appearance of the loading screen
  12597. * that covers the plot area on chart operations. This screen only
  12598. * appears after an explicit call to `chart.showLoading()`. It is a
  12599. * utility for developers to communicate to the end user that something
  12600. * is going on, for example while retrieving new data via an XHR connection.
  12601. * The "Loading..." text itself is not part of this configuration
  12602. * object, but part of the `lang` object.
  12603. */
  12604. loading: {
  12605. /**
  12606. * The duration in milliseconds of the fade out effect.
  12607. *
  12608. * @sample highcharts/loading/hideduration/
  12609. * Fade in and out over a second
  12610. *
  12611. * @type {number}
  12612. * @default 100
  12613. * @since 1.2.0
  12614. * @apioption loading.hideDuration
  12615. */
  12616. /**
  12617. * The duration in milliseconds of the fade in effect.
  12618. *
  12619. * @sample highcharts/loading/hideduration/
  12620. * Fade in and out over a second
  12621. *
  12622. * @type {number}
  12623. * @default 100
  12624. * @since 1.2.0
  12625. * @apioption loading.showDuration
  12626. */
  12627. /**
  12628. * CSS styles for the loading label `span`.
  12629. *
  12630. * @see In styled mode, the loading label is styled with the
  12631. * `.highcharts-loading-inner` class.
  12632. *
  12633. * @sample {highcharts|highmaps} highcharts/loading/labelstyle/
  12634. * Vertically centered
  12635. * @sample {highstock} stock/loading/general/
  12636. * Label styles
  12637. *
  12638. * @type {Highcharts.CSSObject}
  12639. * @default {"fontWeight": "bold", "position": "relative", "top": "45%"}
  12640. * @since 1.2.0
  12641. */
  12642. labelStyle: {
  12643. /**
  12644. * @ignore
  12645. */
  12646. fontWeight: 'bold',
  12647. /**
  12648. * @ignore
  12649. */
  12650. position: 'relative',
  12651. /**
  12652. * @ignore
  12653. */
  12654. top: '45%'
  12655. },
  12656. /**
  12657. * CSS styles for the loading screen that covers the plot area.
  12658. *
  12659. * In styled mode, the loading label is styled with the
  12660. * `.highcharts-loading` class.
  12661. *
  12662. * @sample {highcharts|highmaps} highcharts/loading/style/
  12663. * Gray plot area, white text
  12664. * @sample {highstock} stock/loading/general/
  12665. * Gray plot area, white text
  12666. *
  12667. * @type {Highcharts.CSSObject}
  12668. * @default {"position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center"}
  12669. * @since 1.2.0
  12670. */
  12671. style: {
  12672. /**
  12673. * @ignore
  12674. */
  12675. position: 'absolute',
  12676. /**
  12677. * @ignore
  12678. */
  12679. backgroundColor: '#ffffff',
  12680. /**
  12681. * @ignore
  12682. */
  12683. opacity: 0.5,
  12684. /**
  12685. * @ignore
  12686. */
  12687. textAlign: 'center'
  12688. }
  12689. },
  12690. /**
  12691. * Options for the tooltip that appears when the user hovers over a
  12692. * series or point.
  12693. *
  12694. * @declare Highcharts.TooltipOptions
  12695. */
  12696. tooltip: {
  12697. /**
  12698. * The color of the tooltip border. When `undefined`, the border takes
  12699. * the color of the corresponding series or point.
  12700. *
  12701. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  12702. * Follow series by default
  12703. * @sample {highcharts} highcharts/tooltip/bordercolor-black/
  12704. * Black border
  12705. * @sample {highstock} stock/tooltip/general/
  12706. * Styled tooltip
  12707. * @sample {highmaps} maps/tooltip/background-border/
  12708. * Background and border demo
  12709. *
  12710. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12711. * @apioption tooltip.borderColor
  12712. */
  12713. /**
  12714. * A CSS class name to apply to the tooltip's container div,
  12715. * allowing unique CSS styling for each chart.
  12716. *
  12717. * @type {string}
  12718. * @apioption tooltip.className
  12719. */
  12720. /**
  12721. * Since 4.1, the crosshair definitions are moved to the Axis object
  12722. * in order for a better separation from the tooltip. See
  12723. * [xAxis.crosshair](#xAxis.crosshair).
  12724. *
  12725. * @sample {highcharts} highcharts/tooltip/crosshairs-x/
  12726. * Enable a crosshair for the x value
  12727. *
  12728. * @deprecated
  12729. *
  12730. * @type {*}
  12731. * @default true
  12732. * @apioption tooltip.crosshairs
  12733. */
  12734. /**
  12735. * Distance from point to tooltip in pixels.
  12736. *
  12737. * @type {number}
  12738. * @default 16
  12739. * @apioption tooltip.distance
  12740. */
  12741. /**
  12742. * Whether the tooltip should follow the mouse as it moves across
  12743. * columns, pie slices and other point types with an extent.
  12744. * By default it behaves this way for pie, polygon, map, sankey
  12745. * and wordcloud series by override in the `plotOptions`
  12746. * for those series types.
  12747. *
  12748. * For touch moves to behave the same way, [followTouchMove](
  12749. * #tooltip.followTouchMove) must be `true` also.
  12750. *
  12751. * @type {boolean}
  12752. * @default {highcharts} false
  12753. * @default {highstock} false
  12754. * @default {highmaps} true
  12755. * @since 3.0
  12756. * @apioption tooltip.followPointer
  12757. */
  12758. /**
  12759. * Whether the tooltip should update as the finger moves on a touch
  12760. * device. If this is `true` and [chart.panning](#chart.panning) is
  12761. * set,`followTouchMove` will take over one-finger touches, so the user
  12762. * needs to use two fingers for zooming and panning.
  12763. *
  12764. * Note the difference to [followPointer](#tooltip.followPointer) that
  12765. * only defines the _position_ of the tooltip. If `followPointer` is
  12766. * false in for example a column series, the tooltip will show above or
  12767. * below the column, but as `followTouchMove` is true, the tooltip will
  12768. * jump from column to column as the user swipes across the plot area.
  12769. *
  12770. * @type {boolean}
  12771. * @default {highcharts} true
  12772. * @default {highstock} true
  12773. * @default {highmaps} false
  12774. * @since 3.0.1
  12775. * @apioption tooltip.followTouchMove
  12776. */
  12777. /**
  12778. * Callback function to format the text of the tooltip from scratch. In
  12779. * case of single or [shared](#tooltip.shared) tooltips, a string should
  12780. * be returned. In case of [split](#tooltip.split) tooltips, it should
  12781. * return an array where the first item is the header, and subsequent
  12782. * items are mapped to the points. Return `false` to disable tooltip for
  12783. * a specific point on series.
  12784. *
  12785. * A subset of HTML is supported. Unless `useHTML` is true, the HTML of
  12786. * the tooltip is parsed and converted to SVG, therefore this isn't a
  12787. * complete HTML renderer. The following HTML tags are supported: `b`,
  12788. * `br`, `em`, `i`, `span`, `strong`. Spans can be styled with a `style`
  12789. * attribute, but only text-related CSS, that is shared with SVG, is
  12790. * handled.
  12791. *
  12792. * The available data in the formatter differ a bit depending on whether
  12793. * the tooltip is shared or split, or belongs to a single point. In a
  12794. * shared/split tooltip, all properties except `x`, which is common for
  12795. * all points, are kept in an array, `this.points`.
  12796. *
  12797. * Available data are:
  12798. *
  12799. * - **this.percentage (not shared) /**
  12800. * **this.points[i].percentage (shared)**:
  12801. * Stacked series and pies only. The point's percentage of the total.
  12802. *
  12803. * - **this.point (not shared) / this.points[i].point (shared)**:
  12804. * The point object. The point name, if defined, is available through
  12805. * `this.point.name`.
  12806. *
  12807. * - **this.points**:
  12808. * In a shared tooltip, this is an array containing all other
  12809. * properties for each point.
  12810. *
  12811. * - **this.series (not shared) / this.points[i].series (shared)**:
  12812. * The series object. The series name is available through
  12813. * `this.series.name`.
  12814. *
  12815. * - **this.total (not shared) / this.points[i].total (shared)**:
  12816. * Stacked series only. The total value at this point's x value.
  12817. *
  12818. * - **this.x**:
  12819. * The x value. This property is the same regardless of the tooltip
  12820. * being shared or not.
  12821. *
  12822. * - **this.y (not shared) / this.points[i].y (shared)**:
  12823. * The y value.
  12824. *
  12825. * @sample {highcharts} highcharts/tooltip/formatter-simple/
  12826. * Simple string formatting
  12827. * @sample {highcharts} highcharts/tooltip/formatter-shared/
  12828. * Formatting with shared tooltip
  12829. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  12830. * Formatting with split tooltip
  12831. * @sample highcharts/tooltip/formatter-conditional-default/
  12832. * Extending default formatter
  12833. * @sample {highstock} stock/tooltip/formatter/
  12834. * Formatting with shared tooltip
  12835. * @sample {highmaps} maps/tooltip/formatter/
  12836. * String formatting
  12837. *
  12838. * @type {Highcharts.TooltipFormatterCallbackFunction}
  12839. * @apioption tooltip.formatter
  12840. */
  12841. /**
  12842. * Callback function to format the text of the tooltip for
  12843. * visible null points.
  12844. * Works analogously to [formatter](#tooltip.formatter).
  12845. *
  12846. * @sample highcharts/plotoptions/series-nullformat
  12847. * Format data label and tooltip for null point.
  12848. *
  12849. * @type {Highcharts.TooltipFormatterCallbackFunction}
  12850. * @apioption tooltip.nullFormatter
  12851. */
  12852. /**
  12853. * The number of milliseconds to wait until the tooltip is hidden when
  12854. * mouse out from a point or chart.
  12855. *
  12856. * @type {number}
  12857. * @default 500
  12858. * @since 3.0
  12859. * @apioption tooltip.hideDelay
  12860. */
  12861. /**
  12862. * Whether to allow the tooltip to render outside the chart's SVG
  12863. * element box. By default (`false`), the tooltip is rendered within the
  12864. * chart's SVG element, which results in the tooltip being aligned
  12865. * inside the chart area. For small charts, this may result in clipping
  12866. * or overlapping. When `true`, a separate SVG element is created and
  12867. * overlaid on the page, allowing the tooltip to be aligned inside the
  12868. * page itself.
  12869. *
  12870. * Defaults to `true` if `chart.scrollablePlotArea` is activated,
  12871. * otherwise `false`.
  12872. *
  12873. * @sample highcharts/tooltip/outside
  12874. * Small charts with tooltips outside
  12875. *
  12876. * @type {boolean|undefined}
  12877. * @default undefined
  12878. * @since 6.1.1
  12879. * @apioption tooltip.outside
  12880. */
  12881. /**
  12882. * A callback function for formatting the HTML output for a single point
  12883. * in the tooltip. Like the `pointFormat` string, but with more
  12884. * flexibility.
  12885. *
  12886. * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
  12887. * @since 4.1.0
  12888. * @context Highcharts.Point
  12889. * @apioption tooltip.pointFormatter
  12890. */
  12891. /**
  12892. * A callback function to place the tooltip in a default position. The
  12893. * callback receives three parameters: `labelWidth`, `labelHeight` and
  12894. * `point`, where point contains values for `plotX` and `plotY` telling
  12895. * where the reference point is in the plot area. Add `chart.plotLeft`
  12896. * and `chart.plotTop` to get the full coordinates.
  12897. *
  12898. * Since v7, when [tooltip.split](#tooltip.split) option is enabled,
  12899. * positioner is called for each of the boxes separately, including
  12900. * xAxis header. xAxis header is not a point, instead `point` argument
  12901. * contains info:
  12902. * `{ plotX: Number, plotY: Number, isHeader: Boolean }`
  12903. *
  12904. *
  12905. * The return should be an object containing x and y values, for example
  12906. * `{ x: 100, y: 100 }`.
  12907. *
  12908. * @sample {highcharts} highcharts/tooltip/positioner/
  12909. * A fixed tooltip position
  12910. * @sample {highstock} stock/tooltip/positioner/
  12911. * A fixed tooltip position on top of the chart
  12912. * @sample {highmaps} maps/tooltip/positioner/
  12913. * A fixed tooltip position
  12914. * @sample {highstock} stock/tooltip/split-positioner/
  12915. * Split tooltip with fixed positions
  12916. * @sample {highstock} stock/tooltip/positioner-scrollable-plotarea/
  12917. * Scrollable plot area combined with tooltip positioner
  12918. *
  12919. * @type {Highcharts.TooltipPositionerCallbackFunction}
  12920. * @since 2.2.4
  12921. * @apioption tooltip.positioner
  12922. */
  12923. /**
  12924. * The name of a symbol to use for the border around the tooltip. Can
  12925. * be one of: `"callout"`, `"circle"`, or `"square"`. When
  12926. * [tooltip.split](#tooltip.split)
  12927. * option is enabled, shape is applied to all boxes except header, which
  12928. * is controlled by
  12929. * [tooltip.headerShape](#tooltip.headerShape).
  12930. *
  12931. * Custom callbacks for symbol path generation can also be added to
  12932. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  12933. * [series.marker.symbol](plotOptions.line.marker.symbol).
  12934. *
  12935. * @type {Highcharts.TooltipShapeValue}
  12936. * @default callout
  12937. * @since 4.0
  12938. * @apioption tooltip.shape
  12939. */
  12940. /**
  12941. * The name of a symbol to use for the border around the tooltip
  12942. * header. Applies only when [tooltip.split](#tooltip.split) is
  12943. * enabled.
  12944. *
  12945. * Custom callbacks for symbol path generation can also be added to
  12946. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  12947. * [series.marker.symbol](plotOptions.line.marker.symbol).
  12948. *
  12949. * @see [tooltip.shape](#tooltip.shape)
  12950. *
  12951. * @sample {highstock} stock/tooltip/split-positioner/
  12952. * Different shapes for header and split boxes
  12953. *
  12954. * @type {Highcharts.TooltipShapeValue}
  12955. * @default callout
  12956. * @validvalue ["callout", "square"]
  12957. * @since 7.0
  12958. * @apioption tooltip.headerShape
  12959. */
  12960. /**
  12961. * When the tooltip is shared, the entire plot area will capture mouse
  12962. * movement or touch events. Tooltip texts for series types with ordered
  12963. * data (not pie, scatter, flags etc) will be shown in a single bubble.
  12964. * This is recommended for single series charts and for tablet/mobile
  12965. * optimized charts.
  12966. *
  12967. * See also [tooltip.split](#tooltip.split), that is better suited for
  12968. * charts with many series, especially line-type series. The
  12969. * `tooltip.split` option takes precedence over `tooltip.shared`.
  12970. *
  12971. * @sample {highcharts} highcharts/tooltip/shared-false/
  12972. * False by default
  12973. * @sample {highcharts} highcharts/tooltip/shared-true/
  12974. * True
  12975. * @sample {highcharts} highcharts/tooltip/shared-x-crosshair/
  12976. * True with x axis crosshair
  12977. * @sample {highcharts} highcharts/tooltip/shared-true-mixed-types/
  12978. * True with mixed series types
  12979. *
  12980. * @type {boolean}
  12981. * @default false
  12982. * @since 2.1
  12983. * @product highcharts highstock
  12984. * @apioption tooltip.shared
  12985. */
  12986. /**
  12987. * Split the tooltip into one label per series, with the header close
  12988. * to the axis. This is recommended over [shared](#tooltip.shared)
  12989. * tooltips for charts with multiple line series, generally making them
  12990. * easier to read. This option takes precedence over `tooltip.shared`.
  12991. *
  12992. * @productdesc {highstock} In Highstock, tooltips are split by default
  12993. * since v6.0.0. Stock charts typically contain multi-dimension points
  12994. * and multiple panes, making split tooltips the preferred layout over
  12995. * the previous `shared` tooltip.
  12996. *
  12997. * @sample highcharts/tooltip/split/
  12998. * Split tooltip
  12999. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  13000. * Split tooltip and custom formatter callback
  13001. *
  13002. * @type {boolean}
  13003. * @default {highcharts} false
  13004. * @default {highstock} true
  13005. * @since 5.0.0
  13006. * @product highcharts highstock
  13007. * @apioption tooltip.split
  13008. */
  13009. /**
  13010. * Prevents the tooltip from switching or closing, when touched or
  13011. * pointed.
  13012. *
  13013. * @sample highcharts/tooltip/stickoncontact/
  13014. * Tooltip sticks on pointer contact
  13015. *
  13016. * @type {boolean}
  13017. * @since 8.0.1
  13018. * @apioption tooltip.stickOnContact
  13019. */
  13020. /**
  13021. * Use HTML to render the contents of the tooltip instead of SVG. Using
  13022. * HTML allows advanced formatting like tables and images in the
  13023. * tooltip. It is also recommended for rtl languages as it works around
  13024. * rtl bugs in early Firefox.
  13025. *
  13026. * @sample {highcharts|highstock} highcharts/tooltip/footerformat/
  13027. * A table for value alignment
  13028. * @sample {highcharts|highstock} highcharts/tooltip/fullhtml/
  13029. * Full HTML tooltip
  13030. * @sample {highmaps} maps/tooltip/usehtml/
  13031. * Pure HTML tooltip
  13032. *
  13033. * @type {boolean}
  13034. * @default false
  13035. * @since 2.2
  13036. * @apioption tooltip.useHTML
  13037. */
  13038. /**
  13039. * How many decimals to show in each series' y value. This is
  13040. * overridable in each series' tooltip options object. The default is to
  13041. * preserve all decimals.
  13042. *
  13043. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  13044. * Set decimals, prefix and suffix for the value
  13045. * @sample {highmaps} maps/tooltip/valuedecimals/
  13046. * Set decimals, prefix and suffix for the value
  13047. *
  13048. * @type {number}
  13049. * @since 2.2
  13050. * @apioption tooltip.valueDecimals
  13051. */
  13052. /**
  13053. * A string to prepend to each series' y value. Overridable in each
  13054. * series' tooltip options object.
  13055. *
  13056. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  13057. * Set decimals, prefix and suffix for the value
  13058. * @sample {highmaps} maps/tooltip/valuedecimals/
  13059. * Set decimals, prefix and suffix for the value
  13060. *
  13061. * @type {string}
  13062. * @since 2.2
  13063. * @apioption tooltip.valuePrefix
  13064. */
  13065. /**
  13066. * A string to append to each series' y value. Overridable in each
  13067. * series' tooltip options object.
  13068. *
  13069. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  13070. * Set decimals, prefix and suffix for the value
  13071. * @sample {highmaps} maps/tooltip/valuedecimals/
  13072. * Set decimals, prefix and suffix for the value
  13073. *
  13074. * @type {string}
  13075. * @since 2.2
  13076. * @apioption tooltip.valueSuffix
  13077. */
  13078. /**
  13079. * The format for the date in the tooltip header if the X axis is a
  13080. * datetime axis. The default is a best guess based on the smallest
  13081. * distance between points in the chart.
  13082. *
  13083. * @sample {highcharts} highcharts/tooltip/xdateformat/
  13084. * A different format
  13085. *
  13086. * @type {string}
  13087. * @product highcharts highstock gantt
  13088. * @apioption tooltip.xDateFormat
  13089. */
  13090. /**
  13091. * How many decimals to show for the `point.change` value when the
  13092. * `series.compare` option is set. This is overridable in each series'
  13093. * tooltip options object. The default is to preserve all decimals.
  13094. *
  13095. * @type {number}
  13096. * @since 1.0.1
  13097. * @product highstock
  13098. * @apioption tooltip.changeDecimals
  13099. */
  13100. /**
  13101. * Enable or disable the tooltip.
  13102. *
  13103. * @sample {highcharts} highcharts/tooltip/enabled/
  13104. * Disabled
  13105. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  13106. * Disable tooltip and show values on chart instead
  13107. */
  13108. enabled: true,
  13109. /**
  13110. * Enable or disable animation of the tooltip.
  13111. *
  13112. * @type {boolean}
  13113. * @default true
  13114. * @since 2.3.0
  13115. */
  13116. animation: svg,
  13117. /**
  13118. * The radius of the rounded border corners.
  13119. *
  13120. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13121. * 5px by default
  13122. * @sample {highcharts} highcharts/tooltip/borderradius-0/
  13123. * Square borders
  13124. * @sample {highmaps} maps/tooltip/background-border/
  13125. * Background and border demo
  13126. */
  13127. borderRadius: 3,
  13128. /**
  13129. * For series on a datetime axes, the date format in the tooltip's
  13130. * header will by default be guessed based on the closest data points.
  13131. * This member gives the default string representations used for
  13132. * each unit. For an overview of the replacement codes, see
  13133. * [dateFormat](/class-reference/Highcharts#dateFormat).
  13134. *
  13135. * @see [xAxis.dateTimeLabelFormats](#xAxis.dateTimeLabelFormats)
  13136. *
  13137. * @type {Highcharts.Dictionary<string>}
  13138. * @product highcharts highstock gantt
  13139. */
  13140. dateTimeLabelFormats: {
  13141. /** @internal */
  13142. millisecond: '%A, %b %e, %H:%M:%S.%L',
  13143. /** @internal */
  13144. second: '%A, %b %e, %H:%M:%S',
  13145. /** @internal */
  13146. minute: '%A, %b %e, %H:%M',
  13147. /** @internal */
  13148. hour: '%A, %b %e, %H:%M',
  13149. /** @internal */
  13150. day: '%A, %b %e, %Y',
  13151. /** @internal */
  13152. week: 'Week from %A, %b %e, %Y',
  13153. /** @internal */
  13154. month: '%B %Y',
  13155. /** @internal */
  13156. year: '%Y'
  13157. },
  13158. /**
  13159. * A string to append to the tooltip format.
  13160. *
  13161. * @sample {highcharts} highcharts/tooltip/footerformat/
  13162. * A table for value alignment
  13163. * @sample {highmaps} maps/tooltip/format/
  13164. * Format demo
  13165. *
  13166. * @since 2.2
  13167. */
  13168. footerFormat: '',
  13169. /**
  13170. * Padding inside the tooltip, in pixels.
  13171. *
  13172. * @since 5.0.0
  13173. */
  13174. padding: 8,
  13175. /**
  13176. * Proximity snap for graphs or single points. It defaults to 10 for
  13177. * mouse-powered devices and 25 for touch devices.
  13178. *
  13179. * Note that in most cases the whole plot area captures the mouse
  13180. * movement, and in these cases `tooltip.snap` doesn't make sense. This
  13181. * applies when [stickyTracking](#plotOptions.series.stickyTracking)
  13182. * is `true` (default) and when the tooltip is [shared](#tooltip.shared)
  13183. * or [split](#tooltip.split).
  13184. *
  13185. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13186. * 10 px by default
  13187. * @sample {highcharts} highcharts/tooltip/snap-50/
  13188. * 50 px on graph
  13189. *
  13190. * @type {number}
  13191. * @default 10/25
  13192. * @since 1.2.0
  13193. * @product highcharts highstock
  13194. */
  13195. snap: isTouchDevice ? 25 : 10,
  13196. /**
  13197. * The HTML of the tooltip header line. Variables are enclosed by
  13198. * curly brackets. Available variables are `point.key`, `series.name`,
  13199. * `series.color` and other members from the `point` and `series`
  13200. * objects. The `point.key` variable contains the category name, x
  13201. * value or datetime string depending on the type of axis. For datetime
  13202. * axes, the `point.key` date format can be set using
  13203. * `tooltip.xDateFormat`.
  13204. *
  13205. * @sample {highcharts} highcharts/tooltip/footerformat/
  13206. * An HTML table in the tooltip
  13207. * @sample {highstock} highcharts/tooltip/footerformat/
  13208. * An HTML table in the tooltip
  13209. * @sample {highmaps} maps/tooltip/format/
  13210. * Format demo
  13211. *
  13212. * @type {string}
  13213. * @apioption tooltip.headerFormat
  13214. */
  13215. headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
  13216. /**
  13217. * The HTML of the null point's line in the tooltip. Works analogously
  13218. * to [pointFormat](#tooltip.pointFormat).
  13219. *
  13220. * @sample {highcharts} highcharts/plotoptions/series-nullformat
  13221. * Format data label and tooltip for null point.
  13222. *
  13223. * @type {string}
  13224. * @apioption tooltip.nullFormat
  13225. */
  13226. /**
  13227. * The HTML of the point's line in the tooltip. Variables are enclosed
  13228. * by curly brackets. Available variables are point.x, point.y, series.
  13229. * name and series.color and other properties on the same form.
  13230. * Furthermore, `point.y` can be extended by the `tooltip.valuePrefix`
  13231. * and `tooltip.valueSuffix` variables. This can also be overridden for
  13232. * each series, which makes it a good hook for displaying units.
  13233. *
  13234. * In styled mode, the dot is colored by a class name rather
  13235. * than the point color.
  13236. *
  13237. * @sample {highcharts} highcharts/tooltip/pointformat/
  13238. * A different point format with value suffix
  13239. * @sample {highmaps} maps/tooltip/format/
  13240. * Format demo
  13241. *
  13242. * @type {string}
  13243. * @since 2.2
  13244. * @apioption tooltip.pointFormat
  13245. */
  13246. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
  13247. /**
  13248. * The background color or gradient for the tooltip.
  13249. *
  13250. * In styled mode, the stroke width is set in the
  13251. * `.highcharts-tooltip-box` class.
  13252. *
  13253. * @sample {highcharts} highcharts/tooltip/backgroundcolor-solid/
  13254. * Yellowish background
  13255. * @sample {highcharts} highcharts/tooltip/backgroundcolor-gradient/
  13256. * Gradient
  13257. * @sample {highcharts} highcharts/css/tooltip-border-background/
  13258. * Tooltip in styled mode
  13259. * @sample {highstock} stock/tooltip/general/
  13260. * Custom tooltip
  13261. * @sample {highstock} highcharts/css/tooltip-border-background/
  13262. * Tooltip in styled mode
  13263. * @sample {highmaps} maps/tooltip/background-border/
  13264. * Background and border demo
  13265. * @sample {highmaps} highcharts/css/tooltip-border-background/
  13266. * Tooltip in styled mode
  13267. *
  13268. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  13269. */
  13270. backgroundColor: color('#f7f7f7')
  13271. .setOpacity(0.85).get(),
  13272. /**
  13273. * The pixel width of the tooltip border.
  13274. *
  13275. * In styled mode, the stroke width is set in the
  13276. * `.highcharts-tooltip-box` class.
  13277. *
  13278. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13279. * 2px by default
  13280. * @sample {highcharts} highcharts/tooltip/borderwidth/
  13281. * No border (shadow only)
  13282. * @sample {highcharts} highcharts/css/tooltip-border-background/
  13283. * Tooltip in styled mode
  13284. * @sample {highstock} stock/tooltip/general/
  13285. * Custom tooltip
  13286. * @sample {highstock} highcharts/css/tooltip-border-background/
  13287. * Tooltip in styled mode
  13288. * @sample {highmaps} maps/tooltip/background-border/
  13289. * Background and border demo
  13290. * @sample {highmaps} highcharts/css/tooltip-border-background/
  13291. * Tooltip in styled mode
  13292. */
  13293. borderWidth: 1,
  13294. /**
  13295. * Whether to apply a drop shadow to the tooltip.
  13296. *
  13297. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13298. * True by default
  13299. * @sample {highcharts} highcharts/tooltip/shadow/
  13300. * False
  13301. * @sample {highmaps} maps/tooltip/positioner/
  13302. * Fixed tooltip position, border and shadow disabled
  13303. *
  13304. * @type {boolean|Highcharts.ShadowOptionsObject}
  13305. */
  13306. shadow: true,
  13307. /**
  13308. * CSS styles for the tooltip. The tooltip can also be styled through
  13309. * the CSS class `.highcharts-tooltip`.
  13310. *
  13311. * Note that the default `pointerEvents` style makes the tooltip ignore
  13312. * mouse events, so in order to use clickable tooltips, this value must
  13313. * be set to `auto`.
  13314. *
  13315. * @sample {highcharts} highcharts/tooltip/style/
  13316. * Greater padding, bold text
  13317. *
  13318. * @type {Highcharts.CSSObject}
  13319. */
  13320. style: {
  13321. /** @internal */
  13322. color: '#333333',
  13323. /** @internal */
  13324. cursor: 'default',
  13325. /** @internal */
  13326. fontSize: '12px',
  13327. /** @internal */
  13328. whiteSpace: 'nowrap'
  13329. }
  13330. },
  13331. /**
  13332. * Highchart by default puts a credits label in the lower right corner
  13333. * of the chart. This can be changed using these options.
  13334. */
  13335. credits: {
  13336. /**
  13337. * Credits for map source to be concatenated with conventional credit
  13338. * text. By default this is a format string that collects copyright
  13339. * information from the map if available.
  13340. *
  13341. * @see [mapTextFull](#credits.mapTextFull)
  13342. * @see [text](#credits.text)
  13343. *
  13344. * @type {string}
  13345. * @default \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>
  13346. * @since 4.2.2
  13347. * @product highmaps
  13348. * @apioption credits.mapText
  13349. */
  13350. /**
  13351. * Detailed credits for map source to be displayed on hover of credits
  13352. * text. By default this is a format string that collects copyright
  13353. * information from the map if available.
  13354. *
  13355. * @see [mapText](#credits.mapText)
  13356. * @see [text](#credits.text)
  13357. *
  13358. * @type {string}
  13359. * @default {geojson.copyright}
  13360. * @since 4.2.2
  13361. * @product highmaps
  13362. * @apioption credits.mapTextFull
  13363. */
  13364. /**
  13365. * Whether to show the credits text.
  13366. *
  13367. * @sample {highcharts} highcharts/credits/enabled-false/
  13368. * Credits disabled
  13369. * @sample {highstock} stock/credits/enabled/
  13370. * Credits disabled
  13371. * @sample {highmaps} maps/credits/enabled-false/
  13372. * Credits disabled
  13373. */
  13374. enabled: true,
  13375. /**
  13376. * The URL for the credits label.
  13377. *
  13378. * @sample {highcharts} highcharts/credits/href/
  13379. * Custom URL and text
  13380. * @sample {highmaps} maps/credits/customized/
  13381. * Custom URL and text
  13382. */
  13383. href: 'https://www.highcharts.com?credits',
  13384. /**
  13385. * Position configuration for the credits label.
  13386. *
  13387. * @sample {highcharts} highcharts/credits/position-left/
  13388. * Left aligned
  13389. * @sample {highcharts} highcharts/credits/position-left/
  13390. * Left aligned
  13391. * @sample {highmaps} maps/credits/customized/
  13392. * Left aligned
  13393. * @sample {highmaps} maps/credits/customized/
  13394. * Left aligned
  13395. *
  13396. * @type {Highcharts.AlignObject}
  13397. * @since 2.1
  13398. */
  13399. position: {
  13400. /** @internal */
  13401. align: 'right',
  13402. /** @internal */
  13403. x: -10,
  13404. /** @internal */
  13405. verticalAlign: 'bottom',
  13406. /** @internal */
  13407. y: -5
  13408. },
  13409. /**
  13410. * CSS styles for the credits label.
  13411. *
  13412. * @see In styled mode, credits styles can be set with the
  13413. * `.highcharts-credits` class.
  13414. *
  13415. * @type {Highcharts.CSSObject}
  13416. */
  13417. style: {
  13418. /** @internal */
  13419. cursor: 'pointer',
  13420. /** @internal */
  13421. color: '#999999',
  13422. /** @internal */
  13423. fontSize: '9px'
  13424. },
  13425. /**
  13426. * The text for the credits label.
  13427. *
  13428. * @productdesc {highmaps}
  13429. * If a map is loaded as GeoJSON, the text defaults to
  13430. * `Highcharts @ {map-credits}`. Otherwise, it defaults to
  13431. * `Highcharts.com`.
  13432. *
  13433. * @sample {highcharts} highcharts/credits/href/
  13434. * Custom URL and text
  13435. * @sample {highmaps} maps/credits/customized/
  13436. * Custom URL and text
  13437. */
  13438. text: 'Highcharts.com'
  13439. }
  13440. };
  13441. /* eslint-disable spaced-comment */
  13442. '';
  13443. /**
  13444. * Global `Time` object with default options. Since v6.0.5, time settings can be
  13445. * applied individually for each chart. If no individual settings apply, this
  13446. * `Time` object is shared by all instances.
  13447. *
  13448. * @name Highcharts.time
  13449. * @type {Highcharts.Time}
  13450. */
  13451. H.time = new Time(merge(H.defaultOptions.global, H.defaultOptions.time));
  13452. /**
  13453. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970) into a
  13454. * human readable date string. The format is a subset of the formats for PHP's
  13455. * [strftime](https://www.php.net/manual/en/function.strftime.php) function.
  13456. * Additional formats can be given in the {@link Highcharts.dateFormats} hook.
  13457. *
  13458. * Since v6.0.5, all internal dates are formatted through the
  13459. * {@link Highcharts.Chart#time} instance to respect chart-level time settings.
  13460. * The `Highcharts.dateFormat` function only reflects global time settings set
  13461. * with `setOptions`.
  13462. *
  13463. * Supported format keys:
  13464. * - `%a`: Short weekday, like 'Mon'
  13465. * - `%A`: Long weekday, like 'Monday'
  13466. * - `%d`: Two digit day of the month, 01 to 31
  13467. * - `%e`: Day of the month, 1 through 31
  13468. * - `%w`: Day of the week, 0 through 6
  13469. * - `%b`: Short month, like 'Jan'
  13470. * - `%B`: Long month, like 'January'
  13471. * - `%m`: Two digit month number, 01 through 12
  13472. * - `%y`: Two digits year, like 09 for 2009
  13473. * - `%Y`: Four digits year, like 2009
  13474. * - `%H`: Two digits hours in 24h format, 00 through 23
  13475. * - `%k`: Hours in 24h format, 0 through 23
  13476. * - `%I`: Two digits hours in 12h format, 00 through 11
  13477. * - `%l`: Hours in 12h format, 1 through 12
  13478. * - `%M`: Two digits minutes, 00 through 59
  13479. * - `%p`: Upper case AM or PM
  13480. * - `%P`: Lower case AM or PM
  13481. * - `%S`: Two digits seconds, 00 through 59
  13482. * - `%L`: Milliseconds (naming from Ruby)
  13483. *
  13484. * @function Highcharts.dateFormat
  13485. *
  13486. * @param {string} format
  13487. * The desired format where various time representations are prefixed
  13488. * with `%`.
  13489. *
  13490. * @param {number} timestamp
  13491. * The JavaScript timestamp.
  13492. *
  13493. * @param {boolean} [capitalize=false]
  13494. * Upper case first letter in the return.
  13495. *
  13496. * @return {string}
  13497. * The formatted date.
  13498. */
  13499. H.dateFormat = function (format, timestamp, capitalize) {
  13500. return H.time.dateFormat(format, timestamp, capitalize);
  13501. };
  13502. var optionsModule = {
  13503. dateFormat: H.dateFormat,
  13504. defaultOptions: H.defaultOptions,
  13505. time: H.time
  13506. };
  13507. return optionsModule;
  13508. });
  13509. _registerModule(_modules, 'parts/Axis.js', [_modules['parts/Color.js'], _modules['parts/Globals.js'], _modules['parts/Tick.js'], _modules['parts/Utilities.js'], _modules['parts/Options.js']], function (Color, H, Tick, U, O) {
  13510. /* *
  13511. *
  13512. * (c) 2010-2020 Torstein Honsi
  13513. *
  13514. * License: www.highcharts.com/license
  13515. *
  13516. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  13517. *
  13518. * */
  13519. var addEvent = U.addEvent, animObject = U.animObject, arrayMax = U.arrayMax, arrayMin = U.arrayMin, clamp = U.clamp, correctFloat = U.correctFloat, defined = U.defined, destroyObjectProperties = U.destroyObjectProperties, error = U.error, extend = U.extend, fireEvent = U.fireEvent, format = U.format, getMagnitude = U.getMagnitude, isArray = U.isArray, isFunction = U.isFunction, isNumber = U.isNumber, isString = U.isString, merge = U.merge, normalizeTickInterval = U.normalizeTickInterval, objectEach = U.objectEach, pick = U.pick, relativeLength = U.relativeLength, removeEvent = U.removeEvent, splat = U.splat, syncTimeout = U.syncTimeout;
  13520. /**
  13521. * Options for the path on the Axis to be calculated.
  13522. * @interface Highcharts.AxisPlotLinePathOptionsObject
  13523. */ /**
  13524. * Axis value.
  13525. * @name Highcharts.AxisPlotLinePathOptionsObject#value
  13526. * @type {number|undefined}
  13527. */ /**
  13528. * Line width used for calculation crisp line coordinates. Defaults to 1.
  13529. * @name Highcharts.AxisPlotLinePathOptionsObject#lineWidth
  13530. * @type {number|undefined}
  13531. */ /**
  13532. * If `false`, the function will return null when it falls outside the axis
  13533. * bounds. If `true`, the function will return a path aligned to the plot area
  13534. * sides if it falls outside. If `pass`, it will return a path outside.
  13535. * @name Highcharts.AxisPlotLinePathOptionsObject#force
  13536. * @type {string|boolean|undefined}
  13537. */ /**
  13538. * Used in Highstock. When `true`, plot paths (crosshair, plotLines, gridLines)
  13539. * will be rendered on all axes when defined on the first axis.
  13540. * @name Highcharts.AxisPlotLinePathOptionsObject#acrossPanes
  13541. * @type {boolean|undefined}
  13542. */ /**
  13543. * Use old coordinates (for resizing and rescaling).
  13544. * If not set, defaults to `false`.
  13545. * @name Highcharts.AxisPlotLinePathOptionsObject#old
  13546. * @type {boolean|undefined}
  13547. */ /**
  13548. * If given, return the plot line path of a pixel position on the axis.
  13549. * @name Highcharts.AxisPlotLinePathOptionsObject#translatedValue
  13550. * @type {number|undefined}
  13551. */ /**
  13552. * Used in Polar axes. Reverse the positions for concatenation of polygonal
  13553. * plot bands
  13554. * @name Highcharts.AxisPlotLinePathOptionsObject#reverse
  13555. * @type {boolean|undefined}
  13556. */
  13557. /**
  13558. * Options for crosshairs on axes.
  13559. *
  13560. * @product highstock
  13561. *
  13562. * @typedef {Highcharts.XAxisCrosshairOptions|Highcharts.YAxisCrosshairOptions} Highcharts.AxisCrosshairOptions
  13563. */
  13564. /**
  13565. * @typedef {"navigator"|"pan"|"rangeSelectorButton"|"rangeSelectorInput"|"scrollbar"|"traverseUpButton"|"zoom"} Highcharts.AxisExtremesTriggerValue
  13566. */
  13567. /**
  13568. * @callback Highcharts.AxisEventCallbackFunction
  13569. *
  13570. * @param {Highcharts.Axis} this
  13571. */
  13572. /**
  13573. * @callback Highcharts.AxisLabelsFormatterCallbackFunction
  13574. *
  13575. * @param {Highcharts.AxisLabelsFormatterContextObject<number>} this
  13576. *
  13577. * @param {Highcharts.AxisLabelsFormatterContextObject<string>} that
  13578. *
  13579. * @return {string}
  13580. */
  13581. /**
  13582. * @interface Highcharts.AxisLabelsFormatterContextObject<T>
  13583. */ /**
  13584. * @name Highcharts.AxisLabelsFormatterContextObject<T>#axis
  13585. * @type {Highcharts.Axis}
  13586. */ /**
  13587. * @name Highcharts.AxisLabelsFormatterContextObject<T>#chart
  13588. * @type {Highcharts.Chart}
  13589. */ /**
  13590. * @name Highcharts.AxisLabelsFormatterContextObject<T>#isFirst
  13591. * @type {boolean}
  13592. */ /**
  13593. * @name Highcharts.AxisLabelsFormatterContextObject<T>#isLast
  13594. * @type {boolean}
  13595. */ /**
  13596. * @name Highcharts.AxisLabelsFormatterContextObject<T>#pos
  13597. * @type {number}
  13598. */ /**
  13599. * This can be either a numeric value or a category string.
  13600. * @name Highcharts.AxisLabelsFormatterContextObject<T>#value
  13601. * @type {T}
  13602. */
  13603. /**
  13604. * Options for axes.
  13605. *
  13606. * @typedef {Highcharts.XAxisOptions|Highcharts.YAxisOptions|Highcharts.ZAxisOptions} Highcharts.AxisOptions
  13607. */
  13608. /**
  13609. * @callback Highcharts.AxisPointBreakEventCallbackFunction
  13610. *
  13611. * @param {Highcharts.Axis} this
  13612. *
  13613. * @param {Highcharts.AxisPointBreakEventObject} evt
  13614. */
  13615. /**
  13616. * @interface Highcharts.AxisPointBreakEventObject
  13617. */ /**
  13618. * @name Highcharts.AxisPointBreakEventObject#brk
  13619. * @type {Highcharts.Dictionary<number>}
  13620. */ /**
  13621. * @name Highcharts.AxisPointBreakEventObject#point
  13622. * @type {Highcharts.Point}
  13623. */ /**
  13624. * @name Highcharts.AxisPointBreakEventObject#preventDefault
  13625. * @type {Function}
  13626. */ /**
  13627. * @name Highcharts.AxisPointBreakEventObject#target
  13628. * @type {Highcharts.SVGElement}
  13629. */ /**
  13630. * @name Highcharts.AxisPointBreakEventObject#type
  13631. * @type {"pointBreak"|"pointInBreak"}
  13632. */
  13633. /**
  13634. * @callback Highcharts.AxisSetExtremesEventCallbackFunction
  13635. *
  13636. * @param {Highcharts.Axis} this
  13637. *
  13638. * @param {Highcharts.AxisSetExtremesEventObject} evt
  13639. */
  13640. /**
  13641. * @interface Highcharts.AxisSetExtremesEventObject
  13642. * @extends Highcharts.ExtremesObject
  13643. */ /**
  13644. * @name Highcharts.AxisSetExtremesEventObject#preventDefault
  13645. * @type {Function}
  13646. */ /**
  13647. * @name Highcharts.AxisSetExtremesEventObject#target
  13648. * @type {Highcharts.SVGElement}
  13649. */ /**
  13650. * @name Highcharts.AxisSetExtremesEventObject#trigger
  13651. * @type {Highcharts.AxisExtremesTriggerValue|string}
  13652. */ /**
  13653. * @name Highcharts.AxisSetExtremesEventObject#type
  13654. * @type {"setExtremes"}
  13655. */
  13656. /**
  13657. * @callback Highcharts.AxisTickPositionerCallbackFunction
  13658. *
  13659. * @param {Highcharts.Axis} this
  13660. *
  13661. * @return {Highcharts.AxisTickPositionsArray}
  13662. */
  13663. /**
  13664. * @interface Highcharts.AxisTickPositionsArray
  13665. * @augments Array<number>
  13666. */
  13667. /**
  13668. * @typedef {"high"|"low"|"middle"} Highcharts.AxisTitleAlignValue
  13669. */
  13670. /**
  13671. * @typedef {Highcharts.XAxisTitleOptions|Highcharts.YAxisTitleOptions|Highcharts.ZAxisTitleOptions} Highcharts.AxisTitleOptions
  13672. */
  13673. /**
  13674. * @typedef {"linear"|"logarithmic"|"datetime"|"category"|"treegrid"} Highcharts.AxisTypeValue
  13675. */
  13676. /**
  13677. * The returned object literal from the {@link Highcharts.Axis#getExtremes}
  13678. * function.
  13679. *
  13680. * @interface Highcharts.ExtremesObject
  13681. */ /**
  13682. * The maximum value of the axis' associated series.
  13683. * @name Highcharts.ExtremesObject#dataMax
  13684. * @type {number}
  13685. */ /**
  13686. * The minimum value of the axis' associated series.
  13687. * @name Highcharts.ExtremesObject#dataMin
  13688. * @type {number}
  13689. */ /**
  13690. * The maximum axis value, either automatic or set manually. If the `max` option
  13691. * is not set, `maxPadding` is 0 and `endOnTick` is false, this value will be
  13692. * the same as `dataMax`.
  13693. * @name Highcharts.ExtremesObject#max
  13694. * @type {number}
  13695. */ /**
  13696. * The minimum axis value, either automatic or set manually. If the `min` option
  13697. * is not set, `minPadding` is 0 and `startOnTick` is false, this value will be
  13698. * the same as `dataMin`.
  13699. * @name Highcharts.ExtremesObject#min
  13700. * @type {number}
  13701. */ /**
  13702. * The user defined maximum, either from the `max` option or from a zoom or
  13703. * `setExtremes` action.
  13704. * @name Highcharts.ExtremesObject#userMax
  13705. * @type {number}
  13706. */ /**
  13707. * The user defined minimum, either from the `min` option or from a zoom or
  13708. * `setExtremes` action.
  13709. * @name Highcharts.ExtremesObject#userMin
  13710. * @type {number}
  13711. */
  13712. /**
  13713. * Formatter function for the text of a crosshair label.
  13714. *
  13715. * @callback Highcharts.XAxisCrosshairLabelFormatterCallbackFunction
  13716. *
  13717. * @param {Highcharts.Axis} this
  13718. * Axis context
  13719. *
  13720. * @param {number} value
  13721. * Y value of the data point
  13722. *
  13723. * @return {string}
  13724. */
  13725. var defaultOptions = O.defaultOptions;
  13726. var deg2rad = H.deg2rad;
  13727. /**
  13728. * Create a new axis object. Called internally when instanciating a new chart or
  13729. * adding axes by {@link Highcharts.Chart#addAxis}.
  13730. *
  13731. * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
  13732. * series cartesian chart, there is one X axis and one Y axis.
  13733. *
  13734. * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
  13735. * an array of Axis objects. If there is only one axis, it can be referenced
  13736. * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
  13737. * pattern goes for Y axes.
  13738. *
  13739. * If you need to get the axes from a series object, use the `series.xAxis` and
  13740. * `series.yAxis` properties. These are not arrays, as one series can only be
  13741. * associated to one X and one Y axis.
  13742. *
  13743. * A third way to reference the axis programmatically is by `id`. Add an `id` in
  13744. * the axis configuration options, and get the axis by
  13745. * {@link Highcharts.Chart#get}.
  13746. *
  13747. * Configuration options for the axes are given in options.xAxis and
  13748. * options.yAxis.
  13749. *
  13750. * @class
  13751. * @name Highcharts.Axis
  13752. *
  13753. * @param {Highcharts.Chart} chart
  13754. * The Chart instance to apply the axis on.
  13755. *
  13756. * @param {Highcharts.AxisOptions} userOptions
  13757. * Axis options.
  13758. */
  13759. var Axis = /** @class */ (function () {
  13760. /* *
  13761. *
  13762. * Constructors
  13763. *
  13764. * */
  13765. function Axis(chart, userOptions) {
  13766. this.alternateBands = void 0;
  13767. this.bottom = void 0;
  13768. this.categories = void 0;
  13769. this.chart = void 0;
  13770. this.closestPointRange = void 0;
  13771. this.coll = void 0;
  13772. this.hasNames = void 0;
  13773. this.hasVisibleSeries = void 0;
  13774. this.height = void 0;
  13775. this.isLinked = void 0;
  13776. this.labelEdge = void 0; // @todo
  13777. this.labelFormatter = void 0;
  13778. this.left = void 0;
  13779. this.len = void 0;
  13780. this.max = void 0;
  13781. this.maxLabelLength = void 0;
  13782. this.min = void 0;
  13783. this.minorTickInterval = void 0;
  13784. this.minorTicks = void 0;
  13785. this.minPixelPadding = void 0;
  13786. this.names = void 0;
  13787. this.offset = void 0;
  13788. this.oldMax = void 0;
  13789. this.oldMin = void 0;
  13790. this.options = void 0;
  13791. this.overlap = void 0;
  13792. this.paddedTicks = void 0;
  13793. this.plotLinesAndBands = void 0;
  13794. this.plotLinesAndBandsGroups = void 0;
  13795. this.pointRange = void 0;
  13796. this.pointRangePadding = void 0;
  13797. this.pos = void 0;
  13798. this.positiveValuesOnly = void 0;
  13799. this.right = void 0;
  13800. this.series = void 0;
  13801. this.side = void 0;
  13802. this.tickAmount = void 0;
  13803. this.tickInterval = void 0;
  13804. this.tickmarkOffset = void 0;
  13805. this.tickPositions = void 0;
  13806. this.tickRotCorr = void 0;
  13807. this.ticks = void 0;
  13808. this.top = void 0;
  13809. this.transA = void 0;
  13810. this.transB = void 0;
  13811. this.translationSlope = void 0;
  13812. this.userOptions = void 0;
  13813. this.visible = void 0;
  13814. this.width = void 0;
  13815. this.zoomEnabled = void 0;
  13816. this.init(chart, userOptions);
  13817. }
  13818. /* *
  13819. *
  13820. * Functions
  13821. *
  13822. * */
  13823. /**
  13824. * Overrideable function to initialize the axis.
  13825. *
  13826. * @see {@link Axis}
  13827. *
  13828. * @function Highcharts.Axis#init
  13829. *
  13830. * @param {Highcharts.Chart} chart
  13831. * The Chart instance to apply the axis on.
  13832. *
  13833. * @param {Highcharts.AxisOptions} userOptions
  13834. * Axis options.
  13835. *
  13836. * @fires Highcharts.Axis#event:afterInit
  13837. * @fires Highcharts.Axis#event:init
  13838. */
  13839. Axis.prototype.init = function (chart, userOptions) {
  13840. var isXAxis = userOptions.isX, axis = this;
  13841. /**
  13842. * The Chart that the axis belongs to.
  13843. *
  13844. * @name Highcharts.Axis#chart
  13845. * @type {Highcharts.Chart}
  13846. */
  13847. axis.chart = chart;
  13848. /**
  13849. * Whether the axis is horizontal.
  13850. *
  13851. * @name Highcharts.Axis#horiz
  13852. * @type {boolean|undefined}
  13853. */
  13854. axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;
  13855. /**
  13856. * Whether the axis is the x-axis.
  13857. *
  13858. * @name Highcharts.Axis#isXAxis
  13859. * @type {boolean|undefined}
  13860. */
  13861. axis.isXAxis = isXAxis;
  13862. /**
  13863. * The collection where the axis belongs, for example `xAxis`, `yAxis`
  13864. * or `colorAxis`. Corresponds to properties on Chart, for example
  13865. * {@link Chart.xAxis}.
  13866. *
  13867. * @name Highcharts.Axis#coll
  13868. * @type {string}
  13869. */
  13870. axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
  13871. fireEvent(this, 'init', { userOptions: userOptions });
  13872. axis.opposite = userOptions.opposite; // needed in setOptions
  13873. /**
  13874. * The side on which the axis is rendered. 0 is top, 1 is right, 2
  13875. * is bottom and 3 is left.
  13876. *
  13877. * @name Highcharts.Axis#side
  13878. * @type {number}
  13879. */
  13880. axis.side = userOptions.side || (axis.horiz ?
  13881. (axis.opposite ? 0 : 2) : // top : bottom
  13882. (axis.opposite ? 1 : 3)); // right : left
  13883. /**
  13884. * Current options for the axis after merge of defaults and user's
  13885. * options.
  13886. *
  13887. * @name Highcharts.Axis#options
  13888. * @type {Highcharts.AxisOptions}
  13889. */
  13890. axis.setOptions(userOptions);
  13891. var options = this.options, type = options.type;
  13892. axis.labelFormatter = (options.labels.formatter ||
  13893. // can be overwritten by dynamic format
  13894. axis.defaultLabelFormatter);
  13895. /**
  13896. * User's options for this axis without defaults.
  13897. *
  13898. * @name Highcharts.Axis#userOptions
  13899. * @type {Highcharts.AxisOptions}
  13900. */
  13901. axis.userOptions = userOptions;
  13902. axis.minPixelPadding = 0;
  13903. /**
  13904. * Whether the axis is reversed. Based on the `axis.reversed`,
  13905. * option, but inverted charts have reversed xAxis by default.
  13906. *
  13907. * @name Highcharts.Axis#reversed
  13908. * @type {boolean}
  13909. */
  13910. axis.reversed = options.reversed;
  13911. axis.visible = options.visible !== false;
  13912. axis.zoomEnabled = options.zoomEnabled !== false;
  13913. // Initial categories
  13914. axis.hasNames =
  13915. type === 'category' || options.categories === true;
  13916. /**
  13917. * If categories are present for the axis, names are used instead of
  13918. * numbers for that axis.
  13919. *
  13920. * Since Highcharts 3.0, categories can also be extracted by giving each
  13921. * point a name and setting axis type to `category`. However, if you
  13922. * have multiple series, best practice remains defining the `categories`
  13923. * array.
  13924. *
  13925. * @see [xAxis.categories](/highcharts/xAxis.categories)
  13926. *
  13927. * @name Highcharts.Axis#categories
  13928. * @type {Array<string>}
  13929. * @readonly
  13930. */
  13931. axis.categories = options.categories || axis.hasNames;
  13932. if (!axis.names) { // Preserve on update (#3830)
  13933. axis.names = [];
  13934. axis.names.keys = {};
  13935. }
  13936. // Placeholder for plotlines and plotbands groups
  13937. axis.plotLinesAndBandsGroups = {};
  13938. // Shorthand types
  13939. axis.positiveValuesOnly = !!(axis.logarithmic && !options.allowNegativeLog);
  13940. // Flag, if axis is linked to another axis
  13941. axis.isLinked = defined(options.linkedTo);
  13942. /**
  13943. * List of major ticks mapped by postition on axis.
  13944. *
  13945. * @see {@link Highcharts.Tick}
  13946. *
  13947. * @name Highcharts.Axis#ticks
  13948. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  13949. */
  13950. axis.ticks = {};
  13951. axis.labelEdge = [];
  13952. /**
  13953. * List of minor ticks mapped by position on the axis.
  13954. *
  13955. * @see {@link Highcharts.Tick}
  13956. *
  13957. * @name Highcharts.Axis#minorTicks
  13958. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  13959. */
  13960. axis.minorTicks = {};
  13961. // List of plotLines/Bands
  13962. axis.plotLinesAndBands = [];
  13963. // Alternate bands
  13964. axis.alternateBands = {};
  13965. // Axis metrics
  13966. axis.len = 0;
  13967. axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
  13968. axis.range = options.range;
  13969. axis.offset = options.offset || 0;
  13970. /**
  13971. * The maximum value of the axis. In a logarithmic axis, this is the
  13972. * logarithm of the real value, and the real value can be obtained from
  13973. * {@link Axis#getExtremes}.
  13974. *
  13975. * @name Highcharts.Axis#max
  13976. * @type {number|null}
  13977. */
  13978. axis.max = null;
  13979. /**
  13980. * The minimum value of the axis. In a logarithmic axis, this is the
  13981. * logarithm of the real value, and the real value can be obtained from
  13982. * {@link Axis#getExtremes}.
  13983. *
  13984. * @name Highcharts.Axis#min
  13985. * @type {number|null}
  13986. */
  13987. axis.min = null;
  13988. /**
  13989. * The processed crosshair options.
  13990. *
  13991. * @name Highcharts.Axis#crosshair
  13992. * @type {boolean|Highcharts.AxisCrosshairOptions}
  13993. */
  13994. axis.crosshair = pick(options.crosshair, splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1], false);
  13995. var events = axis.options.events;
  13996. // Register. Don't add it again on Axis.update().
  13997. if (chart.axes.indexOf(axis) === -1) { //
  13998. if (isXAxis) { // #2713
  13999. chart.axes.splice(chart.xAxis.length, 0, axis);
  14000. }
  14001. else {
  14002. chart.axes.push(axis);
  14003. }
  14004. chart[axis.coll].push(axis);
  14005. }
  14006. /**
  14007. * All series associated to the axis.
  14008. *
  14009. * @name Highcharts.Axis#series
  14010. * @type {Array<Highcharts.Series>}
  14011. */
  14012. axis.series = axis.series || []; // populated by Series
  14013. // Reversed axis
  14014. if (chart.inverted &&
  14015. !axis.isZAxis &&
  14016. isXAxis &&
  14017. typeof axis.reversed === 'undefined') {
  14018. axis.reversed = true;
  14019. }
  14020. axis.labelRotation = axis.options.labels.rotation;
  14021. // register event listeners
  14022. objectEach(events, function (event, eventType) {
  14023. if (isFunction(event)) {
  14024. addEvent(axis, eventType, event);
  14025. }
  14026. });
  14027. fireEvent(this, 'afterInit');
  14028. };
  14029. /**
  14030. * Merge and set options.
  14031. *
  14032. * @private
  14033. * @function Highcharts.Axis#setOptions
  14034. *
  14035. * @param {Highcharts.AxisOptions} userOptions
  14036. * Axis options.
  14037. *
  14038. * @fires Highcharts.Axis#event:afterSetOptions
  14039. */
  14040. Axis.prototype.setOptions = function (userOptions) {
  14041. this.options = merge(Axis.defaultOptions, (this.coll === 'yAxis') && Axis.defaultYAxisOptions, [
  14042. Axis.defaultTopAxisOptions,
  14043. Axis.defaultRightAxisOptions,
  14044. Axis.defaultBottomAxisOptions,
  14045. Axis.defaultLeftAxisOptions
  14046. ][this.side], merge(
  14047. // if set in setOptions (#1053):
  14048. defaultOptions[this.coll], userOptions));
  14049. fireEvent(this, 'afterSetOptions', { userOptions: userOptions });
  14050. };
  14051. /**
  14052. * The default label formatter. The context is a special config object for
  14053. * the label. In apps, use the
  14054. * [labels.formatter](https://api.highcharts.com/highcharts/xAxis.labels.formatter)
  14055. * instead, except when a modification is needed.
  14056. *
  14057. * @function Highcharts.Axis#defaultLabelFormatter
  14058. *
  14059. * @param {Highcharts.AxisLabelsFormatterContextObject<number>|Highcharts.AxisLabelsFormatterContextObject<string>} this
  14060. * Formatter context of axis label.
  14061. *
  14062. * @return {string}
  14063. * The formatted label content.
  14064. */
  14065. Axis.prototype.defaultLabelFormatter = function () {
  14066. var axis = this.axis, value = isNumber(this.value) ? this.value : NaN, time = axis.chart.time, categories = axis.categories, dateTimeLabelFormat = this.dateTimeLabelFormat, lang = defaultOptions.lang, numericSymbols = lang.numericSymbols, numSymMagnitude = lang.numericSymbolMagnitude || 1000, i = numericSymbols && numericSymbols.length, multi, ret, formatOption = axis.options.labels.format,
  14067. // make sure the same symbol is added for all labels on a linear
  14068. // axis
  14069. numericSymbolDetector = axis.logarithmic ?
  14070. Math.abs(value) :
  14071. axis.tickInterval;
  14072. var chart = this.chart;
  14073. var numberFormatter = chart.numberFormatter;
  14074. if (formatOption) {
  14075. ret = format(formatOption, this, chart);
  14076. }
  14077. else if (categories) {
  14078. ret = "" + this.value;
  14079. }
  14080. else if (dateTimeLabelFormat) { // datetime axis
  14081. ret = time.dateFormat(dateTimeLabelFormat, value);
  14082. }
  14083. else if (i && numericSymbolDetector >= 1000) {
  14084. // Decide whether we should add a numeric symbol like k (thousands)
  14085. // or M (millions). If we are to enable this in tooltip or other
  14086. // places as well, we can move this logic to the numberFormatter and
  14087. // enable it by a parameter.
  14088. while (i-- && typeof ret === 'undefined') {
  14089. multi = Math.pow(numSymMagnitude, i + 1);
  14090. if (
  14091. // Only accept a numeric symbol when the distance is more
  14092. // than a full unit. So for example if the symbol is k, we
  14093. // don't accept numbers like 0.5k.
  14094. numericSymbolDetector >= multi &&
  14095. // Accept one decimal before the symbol. Accepts 0.5k but
  14096. // not 0.25k. How does this work with the previous?
  14097. (value * 10) % multi === 0 &&
  14098. numericSymbols[i] !== null &&
  14099. value !== 0) { // #5480
  14100. ret = numberFormatter(value / multi, -1) + numericSymbols[i];
  14101. }
  14102. }
  14103. }
  14104. if (typeof ret === 'undefined') {
  14105. if (Math.abs(value) >= 10000) { // add thousands separators
  14106. ret = numberFormatter(value, -1);
  14107. }
  14108. else { // small numbers
  14109. ret = numberFormatter(value, -1, void 0, ''); // #2466
  14110. }
  14111. }
  14112. return ret;
  14113. };
  14114. /**
  14115. * Get the minimum and maximum for the series of each axis. The function
  14116. * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
  14117. *
  14118. * @private
  14119. * @function Highcharts.Axis#getSeriesExtremes
  14120. *
  14121. * @fires Highcharts.Axis#event:afterGetSeriesExtremes
  14122. * @fires Highcharts.Axis#event:getSeriesExtremes
  14123. */
  14124. Axis.prototype.getSeriesExtremes = function () {
  14125. var axis = this, chart = axis.chart, xExtremes;
  14126. fireEvent(this, 'getSeriesExtremes', null, function () {
  14127. axis.hasVisibleSeries = false;
  14128. // Reset properties in case we're redrawing (#3353)
  14129. axis.dataMin = axis.dataMax = axis.threshold = null;
  14130. axis.softThreshold = !axis.isXAxis;
  14131. if (axis.stacking) {
  14132. axis.stacking.buildStacks();
  14133. }
  14134. // loop through this axis' series
  14135. axis.series.forEach(function (series) {
  14136. if (series.visible ||
  14137. !chart.options.chart.ignoreHiddenSeries) {
  14138. var seriesOptions = series.options, xData, threshold = seriesOptions.threshold, seriesDataMin, seriesDataMax;
  14139. axis.hasVisibleSeries = true;
  14140. // Validate threshold in logarithmic axes
  14141. if (axis.positiveValuesOnly && threshold <= 0) {
  14142. threshold = null;
  14143. }
  14144. // Get dataMin and dataMax for X axes
  14145. if (axis.isXAxis) {
  14146. xData = series.xData;
  14147. if (xData.length) {
  14148. xExtremes = series.getXExtremes(xData);
  14149. // If xData contains values which is not numbers,
  14150. // then filter them out. To prevent performance hit,
  14151. // we only do this after we have already found
  14152. // seriesDataMin because in most cases all data is
  14153. // valid. #5234.
  14154. seriesDataMin = xExtremes.min;
  14155. seriesDataMax = xExtremes.max;
  14156. if (!isNumber(seriesDataMin) &&
  14157. // #5010:
  14158. !(seriesDataMin instanceof Date)) {
  14159. xData = xData.filter(isNumber);
  14160. xExtremes = series.getXExtremes(xData);
  14161. // Do it again with valid data
  14162. seriesDataMin = xExtremes.min;
  14163. seriesDataMax = xExtremes.max;
  14164. }
  14165. if (xData.length) {
  14166. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  14167. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  14168. }
  14169. }
  14170. // Get dataMin and dataMax for Y axes, as well as handle
  14171. // stacking and processed data
  14172. }
  14173. else {
  14174. // Get this particular series extremes
  14175. var dataExtremes = series.applyExtremes();
  14176. // Get the dataMin and dataMax so far. If percentage is
  14177. // used, the min and max are always 0 and 100. If
  14178. // seriesDataMin and seriesDataMax is null, then series
  14179. // doesn't have active y data, we continue with nulls
  14180. if (isNumber(dataExtremes.dataMin)) {
  14181. seriesDataMin = dataExtremes.dataMin;
  14182. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  14183. }
  14184. if (isNumber(dataExtremes.dataMax)) {
  14185. seriesDataMax = dataExtremes.dataMax;
  14186. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  14187. }
  14188. // Adjust to threshold
  14189. if (defined(threshold)) {
  14190. axis.threshold = threshold;
  14191. }
  14192. // If any series has a hard threshold, it takes
  14193. // precedence
  14194. if (!seriesOptions.softThreshold ||
  14195. axis.positiveValuesOnly) {
  14196. axis.softThreshold = false;
  14197. }
  14198. }
  14199. }
  14200. });
  14201. });
  14202. fireEvent(this, 'afterGetSeriesExtremes');
  14203. };
  14204. /**
  14205. * Translate from axis value to pixel position on the chart, or back. Use
  14206. * the `toPixels` and `toValue` functions in applications.
  14207. *
  14208. * @private
  14209. * @function Highcharts.Axis#translate
  14210. *
  14211. * @param {number} val
  14212. * TO-DO: parameter description
  14213. *
  14214. * @param {boolean|null} [backwards]
  14215. * TO-DO: parameter description
  14216. *
  14217. * @param {boolean|null} [cvsCoord]
  14218. * TO-DO: parameter description
  14219. *
  14220. * @param {boolean|null} [old]
  14221. * TO-DO: parameter description
  14222. *
  14223. * @param {boolean} [handleLog]
  14224. * TO-DO: parameter description
  14225. *
  14226. * @param {number} [pointPlacement]
  14227. * TO-DO: parameter description
  14228. *
  14229. * @return {number|undefined}
  14230. */
  14231. Axis.prototype.translate = function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
  14232. var axis = this.linkedParent || this, // #1417
  14233. sign = 1, cvsOffset = 0, localA = old ? axis.oldTransA : axis.transA, localMin = old ? axis.oldMin : axis.min, returnValue = 0, minPixelPadding = axis.minPixelPadding, doPostTranslate = (axis.isOrdinal ||
  14234. axis.brokenAxis && axis.brokenAxis.hasBreaks ||
  14235. (axis.logarithmic && handleLog)) && axis.lin2val;
  14236. if (!localA) {
  14237. localA = axis.transA;
  14238. }
  14239. // In vertical axes, the canvas coordinates start from 0 at the top like
  14240. // in SVG.
  14241. if (cvsCoord) {
  14242. sign *= -1; // canvas coordinates inverts the value
  14243. cvsOffset = axis.len;
  14244. }
  14245. // Handle reversed axis
  14246. if (axis.reversed) {
  14247. sign *= -1;
  14248. cvsOffset -= sign * (axis.sector || axis.len);
  14249. }
  14250. // From pixels to value
  14251. if (backwards) { // reverse translation
  14252. val = val * sign + cvsOffset;
  14253. val -= minPixelPadding;
  14254. // from chart pixel to value:
  14255. returnValue = val / localA + localMin;
  14256. if (doPostTranslate) { // log and ordinal axes
  14257. returnValue = axis.lin2val(returnValue);
  14258. }
  14259. // From value to pixels
  14260. }
  14261. else {
  14262. if (doPostTranslate) { // log and ordinal axes
  14263. val = axis.val2lin(val);
  14264. }
  14265. returnValue = isNumber(localMin) ?
  14266. (sign * (val - localMin) * localA +
  14267. cvsOffset +
  14268. (sign * minPixelPadding) +
  14269. (isNumber(pointPlacement) ?
  14270. localA * pointPlacement :
  14271. 0)) :
  14272. void 0;
  14273. }
  14274. return returnValue;
  14275. };
  14276. /**
  14277. * Translate a value in terms of axis units into pixels within the chart.
  14278. *
  14279. * @function Highcharts.Axis#toPixels
  14280. *
  14281. * @param {number} value
  14282. * A value in terms of axis units.
  14283. *
  14284. * @param {boolean} paneCoordinates
  14285. * Whether to return the pixel coordinate relative to the chart or just the
  14286. * axis/pane itself.
  14287. *
  14288. * @return {number}
  14289. * Pixel position of the value on the chart or axis.
  14290. */
  14291. Axis.prototype.toPixels = function (value, paneCoordinates) {
  14292. return this.translate(value, false, !this.horiz, null, true) +
  14293. (paneCoordinates ? 0 : this.pos);
  14294. };
  14295. /**
  14296. * Translate a pixel position along the axis to a value in terms of axis
  14297. * units.
  14298. *
  14299. * @function Highcharts.Axis#toValue
  14300. *
  14301. * @param {number} pixel
  14302. * The pixel value coordinate.
  14303. *
  14304. * @param {boolean} [paneCoordinates=false]
  14305. * Whether the input pixel is relative to the chart or just the axis/pane
  14306. * itself.
  14307. *
  14308. * @return {number}
  14309. * The axis value.
  14310. */
  14311. Axis.prototype.toValue = function (pixel, paneCoordinates) {
  14312. return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
  14313. };
  14314. /**
  14315. * Create the path for a plot line that goes from the given value on
  14316. * this axis, across the plot to the opposite side. Also used internally for
  14317. * grid lines and crosshairs.
  14318. *
  14319. * @function Highcharts.Axis#getPlotLinePath
  14320. *
  14321. * @param {Highcharts.AxisPlotLinePathOptionsObject} options
  14322. * Options for the path.
  14323. *
  14324. * @return {Highcharts.SVGPathArray|null}
  14325. * The SVG path definition for the plot line.
  14326. */
  14327. Axis.prototype.getPlotLinePath = function (options) {
  14328. var axis = this, chart = axis.chart, axisLeft = axis.left, axisTop = axis.top, old = options.old, value = options.value, translatedValue = options.translatedValue, lineWidth = options.lineWidth, force = options.force, x1, y1, x2, y2, cHeight = (old && chart.oldChartHeight) || chart.chartHeight, cWidth = (old && chart.oldChartWidth) || chart.chartWidth, skip, transB = axis.transB, evt;
  14329. // eslint-disable-next-line valid-jsdoc
  14330. /**
  14331. * Check if x is between a and b. If not, either move to a/b
  14332. * or skip, depending on the force parameter.
  14333. * @private
  14334. */
  14335. function between(x, a, b) {
  14336. if (force !== 'pass' && x < a || x > b) {
  14337. if (force) {
  14338. x = clamp(x, a, b);
  14339. }
  14340. else {
  14341. skip = true;
  14342. }
  14343. }
  14344. return x;
  14345. }
  14346. evt = {
  14347. value: value,
  14348. lineWidth: lineWidth,
  14349. old: old,
  14350. force: force,
  14351. acrossPanes: options.acrossPanes,
  14352. translatedValue: translatedValue
  14353. };
  14354. fireEvent(this, 'getPlotLinePath', evt, function (e) {
  14355. translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
  14356. // Keep the translated value within sane bounds, and avoid Infinity
  14357. // to fail the isNumber test (#7709).
  14358. translatedValue = clamp(translatedValue, -1e5, 1e5);
  14359. x1 = x2 = Math.round(translatedValue + transB);
  14360. y1 = y2 = Math.round(cHeight - translatedValue - transB);
  14361. if (!isNumber(translatedValue)) { // no min or max
  14362. skip = true;
  14363. force = false; // #7175, don't force it when path is invalid
  14364. }
  14365. else if (axis.horiz) {
  14366. y1 = axisTop;
  14367. y2 = cHeight - axis.bottom;
  14368. x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
  14369. }
  14370. else {
  14371. x1 = axisLeft;
  14372. x2 = cWidth - axis.right;
  14373. y1 = y2 = between(y1, axisTop, axisTop + axis.height);
  14374. }
  14375. e.path = skip && !force ?
  14376. null :
  14377. chart.renderer.crispLine([['M', x1, y1], ['L', x2, y2]], lineWidth || 1);
  14378. });
  14379. return evt.path;
  14380. };
  14381. /**
  14382. * Internal function to et the tick positions of a linear axis to round
  14383. * values like whole tens or every five.
  14384. *
  14385. * @function Highcharts.Axis#getLinearTickPositions
  14386. *
  14387. * @param {number} tickInterval
  14388. * The normalized tick interval.
  14389. *
  14390. * @param {number} min
  14391. * Axis minimum.
  14392. *
  14393. * @param {number} max
  14394. * Axis maximum.
  14395. *
  14396. * @return {Array<number>}
  14397. * An array of axis values where ticks should be placed.
  14398. */
  14399. Axis.prototype.getLinearTickPositions = function (tickInterval, min, max) {
  14400. var pos, lastPos, roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval), roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval), tickPositions = [], precision;
  14401. // When the precision is higher than what we filter out in
  14402. // correctFloat, skip it (#6183).
  14403. if (correctFloat(roundedMin + tickInterval) === roundedMin) {
  14404. precision = 20;
  14405. }
  14406. // For single points, add a tick regardless of the relative position
  14407. // (#2662, #6274)
  14408. if (this.single) {
  14409. return [min];
  14410. }
  14411. // Populate the intermediate values
  14412. pos = roundedMin;
  14413. while (pos <= roundedMax) {
  14414. // Place the tick on the rounded value
  14415. tickPositions.push(pos);
  14416. // Always add the raw tickInterval, not the corrected one.
  14417. pos = correctFloat(pos + tickInterval, precision);
  14418. // If the interval is not big enough in the current min - max range
  14419. // to actually increase the loop variable, we need to break out to
  14420. // prevent endless loop. Issue #619
  14421. if (pos === lastPos) {
  14422. break;
  14423. }
  14424. // Record the last value
  14425. lastPos = pos;
  14426. }
  14427. return tickPositions;
  14428. };
  14429. /**
  14430. * Resolve the new minorTicks/minorTickInterval options into the legacy
  14431. * loosely typed minorTickInterval option.
  14432. *
  14433. * @function Highcharts.Axis#getMinorTickInterval
  14434. *
  14435. * @return {number|"auto"|null}
  14436. */
  14437. Axis.prototype.getMinorTickInterval = function () {
  14438. var options = this.options;
  14439. if (options.minorTicks === true) {
  14440. return pick(options.minorTickInterval, 'auto');
  14441. }
  14442. if (options.minorTicks === false) {
  14443. return null;
  14444. }
  14445. return options.minorTickInterval;
  14446. };
  14447. /**
  14448. * Internal function to return the minor tick positions. For logarithmic
  14449. * axes, the same logic as for major ticks is reused.
  14450. *
  14451. * @function Highcharts.Axis#getMinorTickPositions
  14452. *
  14453. * @return {Array<number>}
  14454. * An array of axis values where ticks should be placed.
  14455. */
  14456. Axis.prototype.getMinorTickPositions = function () {
  14457. var axis = this, options = axis.options, tickPositions = axis.tickPositions, minorTickInterval = axis.minorTickInterval, minorTickPositions = [], pos, pointRangePadding = axis.pointRangePadding || 0, min = axis.min - pointRangePadding, // #1498
  14458. max = axis.max + pointRangePadding, // #1498
  14459. range = max - min;
  14460. // If minor ticks get too dense, they are hard to read, and may cause
  14461. // long running script. So we don't draw them.
  14462. if (range && range / minorTickInterval < axis.len / 3) { // #3875
  14463. var logarithmic_1 = axis.logarithmic;
  14464. if (logarithmic_1) {
  14465. // For each interval in the major ticks, compute the minor ticks
  14466. // separately.
  14467. this.paddedTicks.forEach(function (_pos, i, paddedTicks) {
  14468. if (i) {
  14469. minorTickPositions.push.apply(minorTickPositions, logarithmic_1.getLogTickPositions(minorTickInterval, paddedTicks[i - 1], paddedTicks[i], true));
  14470. }
  14471. });
  14472. }
  14473. else if (axis.dateTime &&
  14474. this.getMinorTickInterval() === 'auto') { // #1314
  14475. minorTickPositions = minorTickPositions.concat(axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(minorTickInterval), min, max, options.startOfWeek));
  14476. }
  14477. else {
  14478. for (pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval) {
  14479. // Very, very, tight grid lines (#5771)
  14480. if (pos === minorTickPositions[0]) {
  14481. break;
  14482. }
  14483. minorTickPositions.push(pos);
  14484. }
  14485. }
  14486. }
  14487. if (minorTickPositions.length !== 0) {
  14488. axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
  14489. }
  14490. return minorTickPositions;
  14491. };
  14492. /**
  14493. * Adjust the min and max for the minimum range. Keep in mind that the
  14494. * series data is not yet processed, so we don't have information on data
  14495. * cropping and grouping, or updated `axis.pointRange` or
  14496. * `series.pointRange`. The data can't be processed until we have finally
  14497. * established min and max.
  14498. *
  14499. * @private
  14500. * @function Highcharts.Axis#adjustForMinRange
  14501. */
  14502. Axis.prototype.adjustForMinRange = function () {
  14503. var axis = this, options = axis.options, min = axis.min, max = axis.max, log = axis.logarithmic, zoomOffset, spaceAvailable, closestDataRange, i, distance, xData, loopLength, minArgs, maxArgs, minRange;
  14504. // Set the automatic minimum range based on the closest point distance
  14505. if (axis.isXAxis &&
  14506. typeof axis.minRange === 'undefined' &&
  14507. !log) {
  14508. if (defined(options.min) || defined(options.max)) {
  14509. axis.minRange = null; // don't do this again
  14510. }
  14511. else {
  14512. // Find the closest distance between raw data points, as opposed
  14513. // to closestPointRange that applies to processed points
  14514. // (cropped and grouped)
  14515. axis.series.forEach(function (series) {
  14516. xData = series.xData;
  14517. loopLength = series.xIncrement ? 1 : xData.length - 1;
  14518. for (i = loopLength; i > 0; i--) {
  14519. distance = xData[i] - xData[i - 1];
  14520. if (typeof closestDataRange === 'undefined' ||
  14521. distance < closestDataRange) {
  14522. closestDataRange = distance;
  14523. }
  14524. }
  14525. });
  14526. axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
  14527. }
  14528. }
  14529. // if minRange is exceeded, adjust
  14530. if (max - min < axis.minRange) {
  14531. spaceAvailable =
  14532. axis.dataMax - axis.dataMin >=
  14533. axis.minRange;
  14534. minRange = axis.minRange;
  14535. zoomOffset = (minRange - max + min) / 2;
  14536. // if min and max options have been set, don't go beyond it
  14537. minArgs = [
  14538. min - zoomOffset,
  14539. pick(options.min, min - zoomOffset)
  14540. ];
  14541. // If space is available, stay within the data range
  14542. if (spaceAvailable) {
  14543. minArgs[2] = axis.logarithmic ?
  14544. axis.logarithmic.log2lin(axis.dataMin) :
  14545. axis.dataMin;
  14546. }
  14547. min = arrayMax(minArgs);
  14548. maxArgs = [
  14549. min + minRange,
  14550. pick(options.max, min + minRange)
  14551. ];
  14552. // If space is availabe, stay within the data range
  14553. if (spaceAvailable) {
  14554. maxArgs[2] = log ?
  14555. log.log2lin(axis.dataMax) :
  14556. axis.dataMax;
  14557. }
  14558. max = arrayMin(maxArgs);
  14559. // now if the max is adjusted, adjust the min back
  14560. if (max - min < minRange) {
  14561. minArgs[0] = max - minRange;
  14562. minArgs[1] = pick(options.min, max - minRange);
  14563. min = arrayMax(minArgs);
  14564. }
  14565. }
  14566. // Record modified extremes
  14567. axis.min = min;
  14568. axis.max = max;
  14569. };
  14570. // eslint-disable-next-line valid-jsdoc
  14571. /**
  14572. * Find the closestPointRange across all series.
  14573. *
  14574. * @private
  14575. * @function Highcharts.Axis#getClosest
  14576. */
  14577. Axis.prototype.getClosest = function () {
  14578. var ret;
  14579. if (this.categories) {
  14580. ret = 1;
  14581. }
  14582. else {
  14583. this.series.forEach(function (series) {
  14584. var seriesClosest = series.closestPointRange, visible = series.visible ||
  14585. !series.chart.options.chart.ignoreHiddenSeries;
  14586. if (!series.noSharedTooltip &&
  14587. defined(seriesClosest) &&
  14588. visible) {
  14589. ret = defined(ret) ?
  14590. Math.min(ret, seriesClosest) :
  14591. seriesClosest;
  14592. }
  14593. });
  14594. }
  14595. return ret;
  14596. };
  14597. /**
  14598. * When a point name is given and no x, search for the name in the existing
  14599. * categories, or if categories aren't provided, search names or create a
  14600. * new category (#2522).
  14601. * @private
  14602. * @function Highcharts.Axis#nameToX
  14603. *
  14604. * @param {Highcharts.Point} point
  14605. * The point to inspect.
  14606. *
  14607. * @return {number}
  14608. * The X value that the point is given.
  14609. */
  14610. Axis.prototype.nameToX = function (point) {
  14611. var explicitCategories = isArray(this.categories), names = explicitCategories ? this.categories : this.names, nameX = point.options.x, x;
  14612. point.series.requireSorting = false;
  14613. if (!defined(nameX)) {
  14614. nameX = this.options.uniqueNames === false ?
  14615. point.series.autoIncrement() :
  14616. (explicitCategories ?
  14617. names.indexOf(point.name) :
  14618. pick(names.keys[point.name], -1));
  14619. }
  14620. if (nameX === -1) { // Not found in currenct categories
  14621. if (!explicitCategories) {
  14622. x = names.length;
  14623. }
  14624. }
  14625. else {
  14626. x = nameX;
  14627. }
  14628. // Write the last point's name to the names array
  14629. if (typeof x !== 'undefined') {
  14630. this.names[x] = point.name;
  14631. // Backwards mapping is much faster than array searching (#7725)
  14632. this.names.keys[point.name] = x;
  14633. }
  14634. return x;
  14635. };
  14636. /**
  14637. * When changes have been done to series data, update the axis.names.
  14638. *
  14639. * @private
  14640. * @function Highcharts.Axis#updateNames
  14641. */
  14642. Axis.prototype.updateNames = function () {
  14643. var axis = this, names = this.names, i = names.length;
  14644. if (i > 0) {
  14645. Object.keys(names.keys).forEach(function (key) {
  14646. delete (names.keys)[key];
  14647. });
  14648. names.length = 0;
  14649. this.minRange = this.userMinRange; // Reset
  14650. (this.series || []).forEach(function (series) {
  14651. // Reset incrementer (#5928)
  14652. series.xIncrement = null;
  14653. // When adding a series, points are not yet generated
  14654. if (!series.points || series.isDirtyData) {
  14655. // When we're updating the series with data that is longer
  14656. // than it was, and cropThreshold is passed, we need to make
  14657. // sure that the axis.max is increased _before_ running the
  14658. // premature processData. Otherwise this early iteration of
  14659. // processData will crop the points to axis.max, and the
  14660. // names array will be too short (#5857).
  14661. axis.max = Math.max(axis.max, series.xData.length - 1);
  14662. series.processData();
  14663. series.generatePoints();
  14664. }
  14665. series.data.forEach(function (point, i) {
  14666. var x;
  14667. if (point &&
  14668. point.options &&
  14669. typeof point.name !== 'undefined' // #9562
  14670. ) {
  14671. x = axis.nameToX(point);
  14672. if (typeof x !== 'undefined' && x !== point.x) {
  14673. point.x = x;
  14674. series.xData[i] = x;
  14675. }
  14676. }
  14677. });
  14678. });
  14679. }
  14680. };
  14681. /**
  14682. * Update translation information.
  14683. *
  14684. * @private
  14685. * @function Highcharts.Axis#setAxisTranslation
  14686. *
  14687. * @param {boolean} [saveOld]
  14688. * TO-DO: parameter description
  14689. *
  14690. * @fires Highcharts.Axis#event:afterSetAxisTranslation
  14691. */
  14692. Axis.prototype.setAxisTranslation = function (saveOld) {
  14693. var axis = this, range = axis.max - axis.min, pointRange = axis.axisPointRange || 0, closestPointRange, minPointOffset = 0, pointRangePadding = 0, linkedParent = axis.linkedParent, ordinalCorrection, hasCategories = !!axis.categories, transA = axis.transA, isXAxis = axis.isXAxis;
  14694. // Adjust translation for padding. Y axis with categories need to go
  14695. // through the same (#1784).
  14696. if (isXAxis || hasCategories || pointRange) {
  14697. // Get the closest points
  14698. closestPointRange = axis.getClosest();
  14699. if (linkedParent) {
  14700. minPointOffset = linkedParent.minPointOffset;
  14701. pointRangePadding = linkedParent.pointRangePadding;
  14702. }
  14703. else {
  14704. axis.series.forEach(function (series) {
  14705. var seriesPointRange = hasCategories ?
  14706. 1 :
  14707. (isXAxis ?
  14708. pick(series.options.pointRange, closestPointRange, 0) :
  14709. (axis.axisPointRange || 0)), // #2806
  14710. pointPlacement = series.options.pointPlacement;
  14711. pointRange = Math.max(pointRange, seriesPointRange);
  14712. if (!axis.single || hasCategories) {
  14713. // TODO: series should internally set x- and y-
  14714. // pointPlacement to simplify this logic.
  14715. var isPointPlacementAxis = series.is('xrange') ? !isXAxis : isXAxis;
  14716. // minPointOffset is the value padding to the left of
  14717. // the axis in order to make room for points with a
  14718. // pointRange, typically columns. When the
  14719. // pointPlacement option is 'between' or 'on', this
  14720. // padding does not apply.
  14721. minPointOffset = Math.max(minPointOffset, isPointPlacementAxis && isString(pointPlacement) ?
  14722. 0 :
  14723. seriesPointRange / 2);
  14724. // Determine the total padding needed to the length of
  14725. // the axis to make room for the pointRange. If the
  14726. // series' pointPlacement is 'on', no padding is added.
  14727. pointRangePadding = Math.max(pointRangePadding, isPointPlacementAxis && pointPlacement === 'on' ?
  14728. 0 :
  14729. seriesPointRange);
  14730. }
  14731. });
  14732. }
  14733. // Record minPointOffset and pointRangePadding
  14734. ordinalCorrection = axis.ordinal && axis.ordinal.slope && closestPointRange ?
  14735. axis.ordinal.slope / closestPointRange :
  14736. 1; // #988, #1853
  14737. axis.minPointOffset = minPointOffset =
  14738. minPointOffset * ordinalCorrection;
  14739. axis.pointRangePadding =
  14740. pointRangePadding = pointRangePadding * ordinalCorrection;
  14741. // pointRange means the width reserved for each point, like in a
  14742. // column chart
  14743. axis.pointRange = Math.min(pointRange, axis.single && hasCategories ? 1 : range);
  14744. // closestPointRange means the closest distance between points. In
  14745. // columns it is mostly equal to pointRange, but in lines pointRange
  14746. // is 0 while closestPointRange is some other value
  14747. if (isXAxis) {
  14748. axis.closestPointRange = closestPointRange;
  14749. }
  14750. }
  14751. // Secondary values
  14752. if (saveOld) {
  14753. axis.oldTransA = transA;
  14754. }
  14755. axis.translationSlope = axis.transA = transA =
  14756. axis.staticScale ||
  14757. axis.len / ((range + pointRangePadding) || 1);
  14758. // Translation addend
  14759. axis.transB = axis.horiz ? axis.left : axis.bottom;
  14760. axis.minPixelPadding = transA * minPointOffset;
  14761. fireEvent(this, 'afterSetAxisTranslation');
  14762. };
  14763. /**
  14764. * @private
  14765. * @function Highcharts.Axis#minFromRange
  14766. *
  14767. * @return {number}
  14768. */
  14769. Axis.prototype.minFromRange = function () {
  14770. var axis = this;
  14771. return axis.max - axis.range;
  14772. };
  14773. /**
  14774. * Set the tick positions to round values and optionally extend the extremes
  14775. * to the nearest tick.
  14776. *
  14777. * @private
  14778. * @function Highcharts.Axis#setTickInterval
  14779. *
  14780. * @param {boolean} secondPass
  14781. * TO-DO: parameter description
  14782. *
  14783. * @fires Highcharts.Axis#event:foundExtremes
  14784. */
  14785. Axis.prototype.setTickInterval = function (secondPass) {
  14786. var axis = this, chart = axis.chart, log = axis.logarithmic, options = axis.options, isXAxis = axis.isXAxis, isLinked = axis.isLinked, maxPadding = options.maxPadding, minPadding = options.minPadding, length, linkedParentExtremes, tickIntervalOption = options.tickInterval, minTickInterval, tickPixelIntervalOption = options.tickPixelInterval, categories = axis.categories, threshold = isNumber(axis.threshold) ? axis.threshold : null, softThreshold = axis.softThreshold, thresholdMin, thresholdMax, hardMin, hardMax;
  14787. if (!axis.dateTime && !categories && !isLinked) {
  14788. this.getTickAmount();
  14789. }
  14790. // Min or max set either by zooming/setExtremes or initial options
  14791. hardMin = pick(axis.userMin, options.min);
  14792. hardMax = pick(axis.userMax, options.max);
  14793. // Linked axis gets the extremes from the parent axis
  14794. if (isLinked) {
  14795. axis.linkedParent = chart[axis.coll][options.linkedTo];
  14796. linkedParentExtremes = axis.linkedParent.getExtremes();
  14797. axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
  14798. axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
  14799. if (options.type !== axis.linkedParent.options.type) {
  14800. // Can't link axes of different type
  14801. error(11, 1, chart);
  14802. }
  14803. // Initial min and max from the extreme data values
  14804. }
  14805. else {
  14806. // Adjust to hard threshold
  14807. if (!softThreshold && defined(threshold)) {
  14808. if (axis.dataMin >= threshold) {
  14809. thresholdMin = threshold;
  14810. minPadding = 0;
  14811. }
  14812. else if (axis.dataMax <= threshold) {
  14813. thresholdMax = threshold;
  14814. maxPadding = 0;
  14815. }
  14816. }
  14817. axis.min = pick(hardMin, thresholdMin, axis.dataMin);
  14818. axis.max = pick(hardMax, thresholdMax, axis.dataMax);
  14819. }
  14820. if (log) {
  14821. if (axis.positiveValuesOnly &&
  14822. !secondPass &&
  14823. Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978
  14824. // Can't plot negative values on log axis
  14825. error(10, 1, chart);
  14826. }
  14827. // The correctFloat cures #934, float errors on full tens. But it
  14828. // was too aggressive for #4360 because of conversion back to lin,
  14829. // therefore use precision 15.
  14830. axis.min = correctFloat(log.log2lin(axis.min), 16);
  14831. axis.max = correctFloat(log.log2lin(axis.max), 16);
  14832. }
  14833. // handle zoomed range
  14834. if (axis.range && defined(axis.max)) {
  14835. // #618, #6773:
  14836. axis.userMin = axis.min = hardMin =
  14837. Math.max(axis.dataMin, axis.minFromRange());
  14838. axis.userMax = hardMax = axis.max;
  14839. axis.range = null; // don't use it when running setExtremes
  14840. }
  14841. // Hook for Highstock Scroller. Consider combining with beforePadding.
  14842. fireEvent(axis, 'foundExtremes');
  14843. // Hook for adjusting this.min and this.max. Used by bubble series.
  14844. if (axis.beforePadding) {
  14845. axis.beforePadding();
  14846. }
  14847. // adjust min and max for the minimum range
  14848. axis.adjustForMinRange();
  14849. // Pad the values to get clear of the chart's edges. To avoid
  14850. // tickInterval taking the padding into account, we do this after
  14851. // computing tick interval (#1337).
  14852. if (!categories &&
  14853. !axis.axisPointRange &&
  14854. !(axis.stacking && axis.stacking.usePercentage) &&
  14855. !isLinked &&
  14856. defined(axis.min) &&
  14857. defined(axis.max)) {
  14858. length = axis.max - axis.min;
  14859. if (length) {
  14860. if (!defined(hardMin) && minPadding) {
  14861. axis.min -= length * minPadding;
  14862. }
  14863. if (!defined(hardMax) && maxPadding) {
  14864. axis.max += length * maxPadding;
  14865. }
  14866. }
  14867. }
  14868. // Handle options for floor, ceiling, softMin and softMax (#6359)
  14869. if (!isNumber(axis.userMin)) {
  14870. if (isNumber(options.softMin) && options.softMin < axis.min) {
  14871. axis.min = hardMin = options.softMin; // #6894
  14872. }
  14873. if (isNumber(options.floor)) {
  14874. axis.min = Math.max(axis.min, options.floor);
  14875. }
  14876. }
  14877. if (!isNumber(axis.userMax)) {
  14878. if (isNumber(options.softMax) && options.softMax > axis.max) {
  14879. axis.max = hardMax = options.softMax; // #6894
  14880. }
  14881. if (isNumber(options.ceiling)) {
  14882. axis.max = Math.min(axis.max, options.ceiling);
  14883. }
  14884. }
  14885. // When the threshold is soft, adjust the extreme value only if the data
  14886. // extreme and the padded extreme land on either side of the threshold.
  14887. // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
  14888. // for -1 because of the default minPadding and startOnTick options.
  14889. // This is prevented by the softThreshold option.
  14890. if (softThreshold && defined(axis.dataMin)) {
  14891. threshold = threshold || 0;
  14892. if (!defined(hardMin) &&
  14893. axis.min < threshold &&
  14894. axis.dataMin >= threshold) {
  14895. axis.min = axis.options.minRange ?
  14896. Math.min(threshold, axis.max -
  14897. axis.minRange) :
  14898. threshold;
  14899. }
  14900. else if (!defined(hardMax) &&
  14901. axis.max > threshold &&
  14902. axis.dataMax <= threshold) {
  14903. axis.max = axis.options.minRange ?
  14904. Math.max(threshold, axis.min +
  14905. axis.minRange) :
  14906. threshold;
  14907. }
  14908. }
  14909. // get tickInterval
  14910. if (axis.min === axis.max ||
  14911. typeof axis.min === 'undefined' ||
  14912. typeof axis.max === 'undefined') {
  14913. axis.tickInterval = 1;
  14914. }
  14915. else if (isLinked &&
  14916. !tickIntervalOption &&
  14917. tickPixelIntervalOption ===
  14918. axis.linkedParent.options.tickPixelInterval) {
  14919. axis.tickInterval = tickIntervalOption =
  14920. axis.linkedParent.tickInterval;
  14921. }
  14922. else {
  14923. axis.tickInterval = pick(tickIntervalOption, this.tickAmount ?
  14924. ((axis.max - axis.min) /
  14925. Math.max(this.tickAmount - 1, 1)) :
  14926. void 0,
  14927. // For categoried axis, 1 is default, for linear axis use
  14928. // tickPix
  14929. categories ?
  14930. 1 :
  14931. // don't let it be more than the data range
  14932. (axis.max - axis.min) *
  14933. tickPixelIntervalOption /
  14934. Math.max(axis.len, tickPixelIntervalOption));
  14935. }
  14936. // Now we're finished detecting min and max, crop and group series data.
  14937. // This is in turn needed in order to find tick positions in ordinal
  14938. // axes.
  14939. if (isXAxis && !secondPass) {
  14940. axis.series.forEach(function (series) {
  14941. series.processData(axis.min !== axis.oldMin || axis.max !== axis.oldMax);
  14942. });
  14943. }
  14944. // set the translation factor used in translate function
  14945. axis.setAxisTranslation(true);
  14946. // hook for ordinal axes and radial axes
  14947. fireEvent(this, 'initialAxisTranslation');
  14948. // In column-like charts, don't cramp in more ticks than there are
  14949. // points (#1943, #4184)
  14950. if (axis.pointRange && !tickIntervalOption) {
  14951. axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
  14952. }
  14953. // Before normalizing the tick interval, handle minimum tick interval.
  14954. // This applies only if tickInterval is not defined.
  14955. minTickInterval = pick(options.minTickInterval,
  14956. // In datetime axes, don't go below the data interval, except when
  14957. // there are scatter-like series involved (#13369).
  14958. axis.dateTime &&
  14959. !axis.series.some(function (s) { return s.noSharedTooltip; }) ?
  14960. axis.closestPointRange : 0);
  14961. if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
  14962. axis.tickInterval = minTickInterval;
  14963. }
  14964. // for linear axes, get magnitude and normalize the interval
  14965. if (!axis.dateTime && !axis.logarithmic && !tickIntervalOption) {
  14966. axis.tickInterval = normalizeTickInterval(axis.tickInterval, void 0, getMagnitude(axis.tickInterval), pick(options.allowDecimals,
  14967. // If the tick interval is greather than 0.5, avoid
  14968. // decimals, as linear axes are often used to render
  14969. // discrete values. #3363. If a tick amount is set, allow
  14970. // decimals by default, as it increases the chances for a
  14971. // good fit.
  14972. axis.tickInterval < 0.5 || this.tickAmount !== void 0), !!this.tickAmount);
  14973. }
  14974. // Prevent ticks from getting so close that we can't draw the labels
  14975. if (!this.tickAmount) {
  14976. axis.tickInterval = axis.unsquish();
  14977. }
  14978. this.setTickPositions();
  14979. };
  14980. /**
  14981. * Now we have computed the normalized tickInterval, get the tick positions
  14982. *
  14983. * @function Highcharts.Axis#setTickPositions
  14984. *
  14985. * @fires Highcharts.Axis#event:afterSetTickPositions
  14986. */
  14987. Axis.prototype.setTickPositions = function () {
  14988. var axis = this, options = this.options, tickPositions, tickPositionsOption = options.tickPositions, minorTickIntervalOption = this.getMinorTickInterval(), tickPositioner = options.tickPositioner, hasVerticalPanning = this.hasVerticalPanning(), isColorAxis = this.coll === 'colorAxis', startOnTick = (isColorAxis || !hasVerticalPanning) && options.startOnTick, endOnTick = (isColorAxis || !hasVerticalPanning) && options.endOnTick;
  14989. // Set the tickmarkOffset
  14990. this.tickmarkOffset = (this.categories &&
  14991. options.tickmarkPlacement === 'between' &&
  14992. this.tickInterval === 1) ? 0.5 : 0; // #3202
  14993. // get minorTickInterval
  14994. this.minorTickInterval =
  14995. minorTickIntervalOption === 'auto' &&
  14996. this.tickInterval ?
  14997. this.tickInterval / 5 :
  14998. minorTickIntervalOption;
  14999. // When there is only one point, or all points have the same value on
  15000. // this axis, then min and max are equal and tickPositions.length is 0
  15001. // or 1. In this case, add some padding in order to center the point,
  15002. // but leave it with one tick. #1337.
  15003. this.single =
  15004. this.min === this.max &&
  15005. defined(this.min) &&
  15006. !this.tickAmount &&
  15007. (
  15008. // Data is on integer (#6563)
  15009. parseInt(this.min, 10) === this.min ||
  15010. // Between integers and decimals are not allowed (#6274)
  15011. options.allowDecimals !== false);
  15012. /**
  15013. * Contains the current positions that are laid out on the axis. The
  15014. * positions are numbers in terms of axis values. In a category axis
  15015. * they are integers, in a datetime axis they are also integers, but
  15016. * designating milliseconds.
  15017. *
  15018. * This property is read only - for modifying the tick positions, use
  15019. * the `tickPositioner` callback or [axis.tickPositions(
  15020. * https://api.highcharts.com/highcharts/xAxis.tickPositions) option
  15021. * instead.
  15022. *
  15023. * @name Highcharts.Axis#tickPositions
  15024. * @type {Highcharts.AxisTickPositionsArray|undefined}
  15025. */
  15026. this.tickPositions =
  15027. // Find the tick positions. Work on a copy (#1565)
  15028. tickPositions =
  15029. (tickPositionsOption && tickPositionsOption.slice());
  15030. if (!tickPositions) {
  15031. // Too many ticks (#6405). Create a friendly warning and provide two
  15032. // ticks so at least we can show the data series.
  15033. if ((!axis.ordinal || !axis.ordinal.positions) &&
  15034. ((this.max - this.min) /
  15035. this.tickInterval >
  15036. Math.max(2 * this.len, 200))) {
  15037. tickPositions = [this.min, this.max];
  15038. error(19, false, this.chart);
  15039. }
  15040. else if (axis.dateTime) {
  15041. tickPositions = axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(this.tickInterval, options.units), this.min, this.max, options.startOfWeek, axis.ordinal && axis.ordinal.positions, this.closestPointRange, true);
  15042. }
  15043. else if (axis.logarithmic) {
  15044. tickPositions = axis.logarithmic.getLogTickPositions(this.tickInterval, this.min, this.max);
  15045. }
  15046. else {
  15047. tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
  15048. }
  15049. // Too dense ticks, keep only the first and last (#4477)
  15050. if (tickPositions.length > this.len) {
  15051. tickPositions = [tickPositions[0], tickPositions.pop()];
  15052. // Reduce doubled value (#7339)
  15053. if (tickPositions[0] === tickPositions[1]) {
  15054. tickPositions.length = 1;
  15055. }
  15056. }
  15057. this.tickPositions = tickPositions;
  15058. // Run the tick positioner callback, that allows modifying auto tick
  15059. // positions.
  15060. if (tickPositioner) {
  15061. tickPositioner = tickPositioner.apply(axis, [this.min, this.max]);
  15062. if (tickPositioner) {
  15063. this.tickPositions = tickPositions = tickPositioner;
  15064. }
  15065. }
  15066. }
  15067. // Reset min/max or remove extremes based on start/end on tick
  15068. this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
  15069. this.trimTicks(tickPositions, startOnTick, endOnTick);
  15070. if (!this.isLinked) {
  15071. // Substract half a unit (#2619, #2846, #2515, #3390),
  15072. // but not in case of multiple ticks (#6897)
  15073. if (this.single &&
  15074. tickPositions.length < 2 &&
  15075. !this.categories &&
  15076. !this.series.some(function (s) {
  15077. return (s.is('heatmap') && s.options.pointPlacement === 'between');
  15078. })) {
  15079. this.min -= 0.5;
  15080. this.max += 0.5;
  15081. }
  15082. if (!tickPositionsOption && !tickPositioner) {
  15083. this.adjustTickAmount();
  15084. }
  15085. }
  15086. fireEvent(this, 'afterSetTickPositions');
  15087. };
  15088. /**
  15089. * Handle startOnTick and endOnTick by either adapting to padding min/max or
  15090. * rounded min/max. Also handle single data points.
  15091. *
  15092. * @private
  15093. * @function Highcharts.Axis#trimTicks
  15094. *
  15095. * @param {Array<number>} tickPositions
  15096. * TO-DO: parameter description
  15097. *
  15098. * @param {boolean} [startOnTick]
  15099. * TO-DO: parameter description
  15100. *
  15101. * @param {boolean} [endOnTick]
  15102. * TO-DO: parameter description
  15103. */
  15104. Axis.prototype.trimTicks = function (tickPositions, startOnTick, endOnTick) {
  15105. var roundedMin = tickPositions[0], roundedMax = tickPositions[tickPositions.length - 1], minPointOffset = (!this.isOrdinal && this.minPointOffset) || 0; // (#12716)
  15106. fireEvent(this, 'trimTicks');
  15107. if (!this.isLinked) {
  15108. if (startOnTick && roundedMin !== -Infinity) { // #6502
  15109. this.min = roundedMin;
  15110. }
  15111. else {
  15112. while (this.min - minPointOffset > tickPositions[0]) {
  15113. tickPositions.shift();
  15114. }
  15115. }
  15116. if (endOnTick) {
  15117. this.max = roundedMax;
  15118. }
  15119. else {
  15120. while (this.max + minPointOffset <
  15121. tickPositions[tickPositions.length - 1]) {
  15122. tickPositions.pop();
  15123. }
  15124. }
  15125. // If no tick are left, set one tick in the middle (#3195)
  15126. if (tickPositions.length === 0 &&
  15127. defined(roundedMin) &&
  15128. !this.options.tickPositions) {
  15129. tickPositions.push((roundedMax + roundedMin) / 2);
  15130. }
  15131. }
  15132. };
  15133. /**
  15134. * Check if there are multiple axes in the same pane.
  15135. *
  15136. * @private
  15137. * @function Highcharts.Axis#alignToOthers
  15138. *
  15139. * @return {boolean|undefined}
  15140. * True if there are other axes.
  15141. */
  15142. Axis.prototype.alignToOthers = function () {
  15143. var axis = this, others = // Whether there is another axis to pair with this one
  15144. {}, hasOther, options = axis.options;
  15145. if (
  15146. // Only if alignTicks is true
  15147. this.chart.options.chart.alignTicks !== false &&
  15148. options.alignTicks !== false &&
  15149. // Disabled when startOnTick or endOnTick are false (#7604)
  15150. options.startOnTick !== false &&
  15151. options.endOnTick !== false &&
  15152. // Don't try to align ticks on a log axis, they are not evenly
  15153. // spaced (#6021)
  15154. !axis.logarithmic) {
  15155. this.chart[this.coll].forEach(function (axis) {
  15156. var otherOptions = axis.options, horiz = axis.horiz, key = [
  15157. horiz ? otherOptions.left : otherOptions.top,
  15158. otherOptions.width,
  15159. otherOptions.height,
  15160. otherOptions.pane
  15161. ].join(',');
  15162. if (axis.series.length) { // #4442
  15163. if (others[key]) {
  15164. hasOther = true; // #4201
  15165. }
  15166. else {
  15167. others[key] = 1;
  15168. }
  15169. }
  15170. });
  15171. }
  15172. return hasOther;
  15173. };
  15174. /**
  15175. * Find the max ticks of either the x and y axis collection, and record it
  15176. * in `this.tickAmount`.
  15177. *
  15178. * @private
  15179. * @function Highcharts.Axis#getTickAmount
  15180. */
  15181. Axis.prototype.getTickAmount = function () {
  15182. var axis = this, options = this.options, tickAmount = options.tickAmount, tickPixelInterval = options.tickPixelInterval;
  15183. if (!defined(options.tickInterval) &&
  15184. !tickAmount && this.len < tickPixelInterval &&
  15185. !this.isRadial &&
  15186. !axis.logarithmic &&
  15187. options.startOnTick &&
  15188. options.endOnTick) {
  15189. tickAmount = 2;
  15190. }
  15191. if (!tickAmount && this.alignToOthers()) {
  15192. // Add 1 because 4 tick intervals require 5 ticks (including first
  15193. // and last)
  15194. tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
  15195. }
  15196. // For tick amounts of 2 and 3, compute five ticks and remove the
  15197. // intermediate ones. This prevents the axis from adding ticks that are
  15198. // too far away from the data extremes.
  15199. if (tickAmount < 4) {
  15200. this.finalTickAmt = tickAmount;
  15201. tickAmount = 5;
  15202. }
  15203. this.tickAmount = tickAmount;
  15204. };
  15205. /**
  15206. * When using multiple axes, adjust the number of ticks to match the highest
  15207. * number of ticks in that group.
  15208. *
  15209. * @private
  15210. * @function Highcharts.Axis#adjustTickAmount
  15211. */
  15212. Axis.prototype.adjustTickAmount = function () {
  15213. var axis = this, axisOptions = axis.options, tickInterval = axis.tickInterval, tickPositions = axis.tickPositions, tickAmount = axis.tickAmount, finalTickAmt = axis.finalTickAmt, currentTickAmount = tickPositions && tickPositions.length, threshold = pick(axis.threshold, axis.softThreshold ? 0 : null), min, len, i;
  15214. if (axis.hasData()) {
  15215. if (currentTickAmount < tickAmount) {
  15216. min = axis.min;
  15217. while (tickPositions.length < tickAmount) {
  15218. // Extend evenly for both sides unless we're on the
  15219. // threshold (#3965)
  15220. if (tickPositions.length % 2 ||
  15221. min === threshold) {
  15222. // to the end
  15223. tickPositions.push(correctFloat(tickPositions[tickPositions.length - 1] +
  15224. tickInterval));
  15225. }
  15226. else {
  15227. // to the start
  15228. tickPositions.unshift(correctFloat(tickPositions[0] - tickInterval));
  15229. }
  15230. }
  15231. axis.transA *= (currentTickAmount - 1) / (tickAmount - 1);
  15232. // Do not crop when ticks are not extremes (#9841)
  15233. axis.min = axisOptions.startOnTick ?
  15234. tickPositions[0] :
  15235. Math.min(axis.min, tickPositions[0]);
  15236. axis.max = axisOptions.endOnTick ?
  15237. tickPositions[tickPositions.length - 1] :
  15238. Math.max(axis.max, tickPositions[tickPositions.length - 1]);
  15239. // We have too many ticks, run second pass to try to reduce ticks
  15240. }
  15241. else if (currentTickAmount > tickAmount) {
  15242. axis.tickInterval *= 2;
  15243. axis.setTickPositions();
  15244. }
  15245. // The finalTickAmt property is set in getTickAmount
  15246. if (defined(finalTickAmt)) {
  15247. i = len = tickPositions.length;
  15248. while (i--) {
  15249. if (
  15250. // Remove every other tick
  15251. (finalTickAmt === 3 && i % 2 === 1) ||
  15252. // Remove all but first and last
  15253. (finalTickAmt <= 2 && i > 0 && i < len - 1)) {
  15254. tickPositions.splice(i, 1);
  15255. }
  15256. }
  15257. axis.finalTickAmt = void 0;
  15258. }
  15259. }
  15260. };
  15261. /**
  15262. * Set the scale based on data min and max, user set min and max or options.
  15263. *
  15264. * @private
  15265. * @function Highcharts.Axis#setScale
  15266. *
  15267. * @fires Highcharts.Axis#event:afterSetScale
  15268. */
  15269. Axis.prototype.setScale = function () {
  15270. var axis = this, isDirtyAxisLength, isDirtyData = false, isXAxisDirty = false;
  15271. axis.series.forEach(function (series) {
  15272. var _a;
  15273. isDirtyData = isDirtyData || series.isDirtyData || series.isDirty;
  15274. // When x axis is dirty, we need new data extremes for y as
  15275. // well:
  15276. isXAxisDirty = isXAxisDirty || ((_a = series.xAxis) === null || _a === void 0 ? void 0 : _a.isDirty) || false;
  15277. });
  15278. axis.oldMin = axis.min;
  15279. axis.oldMax = axis.max;
  15280. axis.oldAxisLength = axis.len;
  15281. // set the new axisLength
  15282. axis.setAxisSize();
  15283. isDirtyAxisLength = axis.len !== axis.oldAxisLength;
  15284. // do we really need to go through all this?
  15285. if (isDirtyAxisLength ||
  15286. isDirtyData ||
  15287. isXAxisDirty ||
  15288. axis.isLinked ||
  15289. axis.forceRedraw ||
  15290. axis.userMin !== axis.oldUserMin ||
  15291. axis.userMax !== axis.oldUserMax ||
  15292. axis.alignToOthers()) {
  15293. if (axis.stacking) {
  15294. axis.stacking.resetStacks();
  15295. }
  15296. axis.forceRedraw = false;
  15297. // get data extremes if needed
  15298. axis.getSeriesExtremes();
  15299. // get fixed positions based on tickInterval
  15300. axis.setTickInterval();
  15301. // record old values to decide whether a rescale is necessary later
  15302. // on (#540)
  15303. axis.oldUserMin = axis.userMin;
  15304. axis.oldUserMax = axis.userMax;
  15305. // Mark as dirty if it is not already set to dirty and extremes have
  15306. // changed. #595.
  15307. if (!axis.isDirty) {
  15308. axis.isDirty =
  15309. isDirtyAxisLength ||
  15310. axis.min !== axis.oldMin ||
  15311. axis.max !== axis.oldMax;
  15312. }
  15313. }
  15314. else if (axis.stacking) {
  15315. axis.stacking.cleanStacks();
  15316. }
  15317. // Recalculate panning state object, when the data
  15318. // has changed. It is required when vertical panning is enabled.
  15319. if (isDirtyData && axis.panningState) {
  15320. axis.panningState.isDirty = true;
  15321. }
  15322. fireEvent(this, 'afterSetScale');
  15323. };
  15324. /**
  15325. * Set the minimum and maximum of the axes after render time. If the
  15326. * `startOnTick` and `endOnTick` options are true, the minimum and maximum
  15327. * values are rounded off to the nearest tick. To prevent this, these
  15328. * options can be set to false before calling setExtremes. Also, setExtremes
  15329. * will not allow a range lower than the `minRange` option, which by default
  15330. * is the range of five points.
  15331. *
  15332. * @sample highcharts/members/axis-setextremes/
  15333. * Set extremes from a button
  15334. * @sample highcharts/members/axis-setextremes-datetime/
  15335. * Set extremes on a datetime axis
  15336. * @sample highcharts/members/axis-setextremes-off-ticks/
  15337. * Set extremes off ticks
  15338. * @sample stock/members/axis-setextremes/
  15339. * Set extremes in Highstock
  15340. * @sample maps/members/axis-setextremes/
  15341. * Set extremes in Highmaps
  15342. *
  15343. * @function Highcharts.Axis#setExtremes
  15344. *
  15345. * @param {number} [newMin]
  15346. * The new minimum value.
  15347. *
  15348. * @param {number} [newMax]
  15349. * The new maximum value.
  15350. *
  15351. * @param {boolean} [redraw=true]
  15352. * Whether to redraw the chart or wait for an explicit call to
  15353. * {@link Highcharts.Chart#redraw}
  15354. *
  15355. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=true]
  15356. * Enable or modify animations.
  15357. *
  15358. * @param {*} [eventArguments]
  15359. * Arguments to be accessed in event handler.
  15360. *
  15361. * @fires Highcharts.Axis#event:setExtremes
  15362. */
  15363. Axis.prototype.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  15364. var axis = this, chart = axis.chart;
  15365. redraw = pick(redraw, true); // defaults to true
  15366. axis.series.forEach(function (serie) {
  15367. delete serie.kdTree;
  15368. });
  15369. // Extend the arguments with min and max
  15370. eventArguments = extend(eventArguments, {
  15371. min: newMin,
  15372. max: newMax
  15373. });
  15374. // Fire the event
  15375. fireEvent(axis, 'setExtremes', eventArguments, function () {
  15376. axis.userMin = newMin;
  15377. axis.userMax = newMax;
  15378. axis.eventArgs = eventArguments;
  15379. if (redraw) {
  15380. chart.redraw(animation);
  15381. }
  15382. });
  15383. };
  15384. /**
  15385. * Overridable method for zooming chart. Pulled out in a separate method to
  15386. * allow overriding in stock charts.
  15387. * @private
  15388. * @function Highcharts.Axis#zoom
  15389. *
  15390. * @param {number} newMin
  15391. * TO-DO: parameter description
  15392. *
  15393. * @param {number} newMax
  15394. * TO-DO: parameter description
  15395. *
  15396. * @return {boolean}
  15397. */
  15398. Axis.prototype.zoom = function (newMin, newMax) {
  15399. var axis = this, dataMin = this.dataMin, dataMax = this.dataMax, options = this.options, min = Math.min(dataMin, pick(options.min, dataMin)), max = Math.max(dataMax, pick(options.max, dataMax)), evt = {
  15400. newMin: newMin,
  15401. newMax: newMax
  15402. };
  15403. fireEvent(this, 'zoom', evt, function (e) {
  15404. // Use e.newMin and e.newMax - event handlers may have altered them
  15405. var newMin = e.newMin, newMax = e.newMax;
  15406. if (newMin !== axis.min || newMax !== axis.max) { // #5790
  15407. // Prevent pinch zooming out of range. Check for defined is for
  15408. // #1946. #1734.
  15409. if (!axis.allowZoomOutside) {
  15410. // #6014, sometimes newMax will be smaller than min (or
  15411. // newMin will be larger than max).
  15412. if (defined(dataMin)) {
  15413. if (newMin < min) {
  15414. newMin = min;
  15415. }
  15416. if (newMin > max) {
  15417. newMin = max;
  15418. }
  15419. }
  15420. if (defined(dataMax)) {
  15421. if (newMax < min) {
  15422. newMax = min;
  15423. }
  15424. if (newMax > max) {
  15425. newMax = max;
  15426. }
  15427. }
  15428. }
  15429. // In full view, displaying the reset zoom button is not
  15430. // required
  15431. axis.displayBtn = (typeof newMin !== 'undefined' ||
  15432. typeof newMax !== 'undefined');
  15433. // Do it
  15434. axis.setExtremes(newMin, newMax, false, void 0, { trigger: 'zoom' });
  15435. }
  15436. e.zoomed = true;
  15437. });
  15438. return evt.zoomed;
  15439. };
  15440. /**
  15441. * Update the axis metrics.
  15442. *
  15443. * @private
  15444. * @function Highcharts.Axis#setAxisSize
  15445. */
  15446. Axis.prototype.setAxisSize = function () {
  15447. var chart = this.chart, options = this.options,
  15448. // [top, right, bottom, left]
  15449. offsets = options.offsets || [0, 0, 0, 0], horiz = this.horiz,
  15450. // Check for percentage based input values. Rounding fixes problems
  15451. // with column overflow and plot line filtering (#4898, #4899)
  15452. width = this.width = Math.round(relativeLength(pick(options.width, chart.plotWidth - offsets[3] + offsets[1]), chart.plotWidth)), height = this.height = Math.round(relativeLength(pick(options.height, chart.plotHeight - offsets[0] + offsets[2]), chart.plotHeight)), top = this.top = Math.round(relativeLength(pick(options.top, chart.plotTop + offsets[0]), chart.plotHeight, chart.plotTop)), left = this.left = Math.round(relativeLength(pick(options.left, chart.plotLeft + offsets[3]), chart.plotWidth, chart.plotLeft));
  15453. // Expose basic values to use in Series object and navigator
  15454. this.bottom = chart.chartHeight - height - top;
  15455. this.right = chart.chartWidth - width - left;
  15456. // Direction agnostic properties
  15457. this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
  15458. this.pos = horiz ? left : top; // distance from SVG origin
  15459. };
  15460. /**
  15461. * Get the current extremes for the axis.
  15462. *
  15463. * @sample highcharts/members/axis-getextremes/
  15464. * Report extremes by click on a button
  15465. * @sample maps/members/axis-getextremes/
  15466. * Get extremes in Highmaps
  15467. *
  15468. * @function Highcharts.Axis#getExtremes
  15469. *
  15470. * @return {Highcharts.ExtremesObject}
  15471. * An object containing extremes information.
  15472. */
  15473. Axis.prototype.getExtremes = function () {
  15474. var axis = this;
  15475. var log = axis.logarithmic;
  15476. return {
  15477. min: log ?
  15478. correctFloat(log.lin2log(axis.min)) :
  15479. axis.min,
  15480. max: log ?
  15481. correctFloat(log.lin2log(axis.max)) :
  15482. axis.max,
  15483. dataMin: axis.dataMin,
  15484. dataMax: axis.dataMax,
  15485. userMin: axis.userMin,
  15486. userMax: axis.userMax
  15487. };
  15488. };
  15489. /**
  15490. * Get the zero plane either based on zero or on the min or max value.
  15491. * Used in bar and area plots.
  15492. *
  15493. * @function Highcharts.Axis#getThreshold
  15494. *
  15495. * @param {number} threshold
  15496. * The threshold in axis values.
  15497. *
  15498. * @return {number|undefined}
  15499. * The translated threshold position in terms of pixels, and corrected to
  15500. * stay within the axis bounds.
  15501. */
  15502. Axis.prototype.getThreshold = function (threshold) {
  15503. var axis = this, log = axis.logarithmic, realMin = log ? log.lin2log(axis.min) : axis.min, realMax = log ? log.lin2log(axis.max) : axis.max;
  15504. if (threshold === null || threshold === -Infinity) {
  15505. threshold = realMin;
  15506. }
  15507. else if (threshold === Infinity) {
  15508. threshold = realMax;
  15509. }
  15510. else if (realMin > threshold) {
  15511. threshold = realMin;
  15512. }
  15513. else if (realMax < threshold) {
  15514. threshold = realMax;
  15515. }
  15516. return axis.translate(threshold, 0, 1, 0, 1);
  15517. };
  15518. /**
  15519. * Compute auto alignment for the axis label based on which side the axis is
  15520. * on and the given rotation for the label.
  15521. *
  15522. * @private
  15523. * @function Highcharts.Axis#autoLabelAlign
  15524. *
  15525. * @param {number} rotation
  15526. * The rotation in degrees as set by either the `rotation` or `autoRotation`
  15527. * options.
  15528. *
  15529. * @return {Highcharts.AlignValue}
  15530. * Can be `"center"`, `"left"` or `"right"`.
  15531. */
  15532. Axis.prototype.autoLabelAlign = function (rotation) {
  15533. var angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360, evt = { align: 'center' };
  15534. fireEvent(this, 'autoLabelAlign', evt, function (e) {
  15535. if (angle > 15 && angle < 165) {
  15536. e.align = 'right';
  15537. }
  15538. else if (angle > 195 && angle < 345) {
  15539. e.align = 'left';
  15540. }
  15541. });
  15542. return evt.align;
  15543. };
  15544. /**
  15545. * Get the tick length and width for the axis based on axis options.
  15546. * @private
  15547. * @function Highcharts.Axis#tickSize
  15548. *
  15549. * @param {string} [prefix]
  15550. * 'tick' or 'minorTick'
  15551. *
  15552. * @return {Array<number,number>|undefined}
  15553. * An array of tickLength and tickWidth
  15554. */
  15555. Axis.prototype.tickSize = function (prefix) {
  15556. var options = this.options, tickLength = options[prefix === 'tick' ? 'tickLength' : 'minorTickLength'], tickWidth = pick(options[prefix === 'tick' ? 'tickWidth' : 'minorTickWidth'],
  15557. // Default to 1 on linear and datetime X axes
  15558. prefix === 'tick' && this.isXAxis && !this.categories ? 1 : 0), e, tickSize;
  15559. if (tickWidth && tickLength) {
  15560. // Negate the length
  15561. if (options[prefix + 'Position'] === 'inside') {
  15562. tickLength = -tickLength;
  15563. }
  15564. tickSize = [tickLength, tickWidth];
  15565. }
  15566. e = { tickSize: tickSize };
  15567. fireEvent(this, 'afterTickSize', e);
  15568. return e.tickSize;
  15569. };
  15570. /**
  15571. * Return the size of the labels.
  15572. *
  15573. * @private
  15574. * @function Highcharts.Axis#labelMetrics
  15575. *
  15576. * @return {Highcharts.FontMetricsObject}
  15577. */
  15578. Axis.prototype.labelMetrics = function () {
  15579. var index = this.tickPositions && this.tickPositions[0] || 0;
  15580. return this.chart.renderer.fontMetrics(this.options.labels.style &&
  15581. this.options.labels.style.fontSize, this.ticks[index] && this.ticks[index].label);
  15582. };
  15583. /**
  15584. * Prevent the ticks from getting so close we can't draw the labels. On a
  15585. * horizontal axis, this is handled by rotating the labels, removing ticks
  15586. * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
  15587. *
  15588. * @private
  15589. * @function Highcharts.Axis#unsquish
  15590. *
  15591. * @return {number}
  15592. */
  15593. Axis.prototype.unsquish = function () {
  15594. var labelOptions = this.options.labels, horiz = this.horiz, tickInterval = this.tickInterval, newTickInterval = tickInterval, slotSize = this.len / (((this.categories ? 1 : 0) +
  15595. this.max -
  15596. this.min) /
  15597. tickInterval), rotation, rotationOption = labelOptions.rotation, labelMetrics = this.labelMetrics(), step, bestScore = Number.MAX_VALUE, autoRotation, range = this.max - this.min,
  15598. // Return the multiple of tickInterval that is needed to avoid
  15599. // collision
  15600. getStep = function (spaceNeeded) {
  15601. var step = spaceNeeded / (slotSize || 1);
  15602. step = step > 1 ? Math.ceil(step) : 1;
  15603. // Guard for very small or negative angles (#9835)
  15604. if (step * tickInterval > range &&
  15605. spaceNeeded !== Infinity &&
  15606. slotSize !== Infinity &&
  15607. range) {
  15608. step = Math.ceil(range / tickInterval);
  15609. }
  15610. return correctFloat(step * tickInterval);
  15611. };
  15612. if (horiz) {
  15613. autoRotation = !labelOptions.staggerLines &&
  15614. !labelOptions.step &&
  15615. ( // #3971
  15616. defined(rotationOption) ?
  15617. [rotationOption] :
  15618. slotSize < pick(labelOptions.autoRotationLimit, 80) && labelOptions.autoRotation);
  15619. if (autoRotation) {
  15620. // Loop over the given autoRotation options, and determine
  15621. // which gives the best score. The best score is that with
  15622. // the lowest number of steps and a rotation closest
  15623. // to horizontal.
  15624. autoRotation.forEach(function (rot) {
  15625. var score;
  15626. if (rot === rotationOption ||
  15627. (rot && rot >= -90 && rot <= 90)) { // #3891
  15628. step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
  15629. score = step + Math.abs(rot / 360);
  15630. if (score < bestScore) {
  15631. bestScore = score;
  15632. rotation = rot;
  15633. newTickInterval = step;
  15634. }
  15635. }
  15636. });
  15637. }
  15638. }
  15639. else if (!labelOptions.step) { // #4411
  15640. newTickInterval = getStep(labelMetrics.h);
  15641. }
  15642. this.autoRotation = autoRotation;
  15643. this.labelRotation = pick(rotation, rotationOption);
  15644. return newTickInterval;
  15645. };
  15646. /**
  15647. * Get the general slot width for labels/categories on this axis. This may
  15648. * change between the pre-render (from Axis.getOffset) and the final tick
  15649. * rendering and placement.
  15650. *
  15651. * @private
  15652. * @function Highcharts.Axis#getSlotWidth
  15653. *
  15654. * @param {Highcharts.Tick} [tick] Optionally, calculate the slot width
  15655. * basing on tick label. It is used in highcharts-3d module, where the slots
  15656. * has different widths depending on perspective angles.
  15657. *
  15658. * @return {number}
  15659. * The pixel width allocated to each axis label.
  15660. */
  15661. Axis.prototype.getSlotWidth = function (tick) {
  15662. var _a;
  15663. // #5086, #1580, #1931
  15664. var chart = this.chart, horiz = this.horiz, labelOptions = this.options.labels, slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1), marginLeft = chart.margin[3];
  15665. // Used by grid axis
  15666. if (tick && isNumber(tick.slotWidth)) { // #13221, can be 0
  15667. return tick.slotWidth;
  15668. }
  15669. if (horiz &&
  15670. labelOptions &&
  15671. (labelOptions.step || 0) < 2) {
  15672. if (labelOptions.rotation) { // #4415
  15673. return 0;
  15674. }
  15675. return ((this.staggerLines || 1) * this.len) / slotCount;
  15676. }
  15677. if (!horiz) {
  15678. // #7028
  15679. var cssWidth = (_a = labelOptions === null || labelOptions === void 0 ? void 0 : labelOptions.style) === null || _a === void 0 ? void 0 : _a.width;
  15680. if (cssWidth !== void 0) {
  15681. return parseInt(cssWidth, 10);
  15682. }
  15683. if (marginLeft) {
  15684. return marginLeft - chart.spacing[3];
  15685. }
  15686. }
  15687. // Last resort, a fraction of the available size
  15688. return chart.chartWidth * 0.33;
  15689. };
  15690. /**
  15691. * Render the axis labels and determine whether ellipsis or rotation need to
  15692. * be applied.
  15693. *
  15694. * @private
  15695. * @function Highcharts.Axis#renderUnsquish
  15696. */
  15697. Axis.prototype.renderUnsquish = function () {
  15698. var chart = this.chart, renderer = chart.renderer, tickPositions = this.tickPositions, ticks = this.ticks, labelOptions = this.options.labels, labelStyleOptions = (labelOptions && labelOptions.style || {}), horiz = this.horiz, slotWidth = this.getSlotWidth(), innerWidth = Math.max(1, Math.round(slotWidth - 2 * (labelOptions.padding || 5))), attr = {}, labelMetrics = this.labelMetrics(), textOverflowOption = (labelOptions.style &&
  15699. labelOptions.style.textOverflow), commonWidth, commonTextOverflow, maxLabelLength = 0, label, i, pos;
  15700. // Set rotation option unless it is "auto", like in gauges
  15701. if (!isString(labelOptions.rotation)) {
  15702. // #4443:
  15703. attr.rotation = labelOptions.rotation || 0;
  15704. }
  15705. // Get the longest label length
  15706. tickPositions.forEach(function (tick) {
  15707. tick = ticks[tick];
  15708. // Replace label - sorting animation
  15709. if (tick.movedLabel) {
  15710. tick.replaceMovedLabel();
  15711. }
  15712. if (tick &&
  15713. tick.label &&
  15714. tick.label.textPxLength > maxLabelLength) {
  15715. maxLabelLength = tick.label.textPxLength;
  15716. }
  15717. });
  15718. this.maxLabelLength = maxLabelLength;
  15719. // Handle auto rotation on horizontal axis
  15720. if (this.autoRotation) {
  15721. // Apply rotation only if the label is too wide for the slot, and
  15722. // the label is wider than its height.
  15723. if (maxLabelLength > innerWidth &&
  15724. maxLabelLength > labelMetrics.h) {
  15725. attr.rotation = this.labelRotation;
  15726. }
  15727. else {
  15728. this.labelRotation = 0;
  15729. }
  15730. // Handle word-wrap or ellipsis on vertical axis
  15731. }
  15732. else if (slotWidth) {
  15733. // For word-wrap or ellipsis
  15734. commonWidth = innerWidth;
  15735. if (!textOverflowOption) {
  15736. commonTextOverflow = 'clip';
  15737. // On vertical axis, only allow word wrap if there is room
  15738. // for more lines.
  15739. i = tickPositions.length;
  15740. while (!horiz && i--) {
  15741. pos = tickPositions[i];
  15742. label = ticks[pos].label;
  15743. if (label) {
  15744. // Reset ellipsis in order to get the correct
  15745. // bounding box (#4070)
  15746. if (label.styles &&
  15747. label.styles.textOverflow === 'ellipsis') {
  15748. label.css({ textOverflow: 'clip' });
  15749. // Set the correct width in order to read
  15750. // the bounding box height (#4678, #5034)
  15751. }
  15752. else if (label.textPxLength > slotWidth) {
  15753. label.css({ width: slotWidth + 'px' });
  15754. }
  15755. if (label.getBBox().height > (this.len / tickPositions.length -
  15756. (labelMetrics.h - labelMetrics.f))) {
  15757. label.specificTextOverflow = 'ellipsis';
  15758. }
  15759. }
  15760. }
  15761. }
  15762. }
  15763. // Add ellipsis if the label length is significantly longer than ideal
  15764. if (attr.rotation) {
  15765. commonWidth = (maxLabelLength > chart.chartHeight * 0.5 ?
  15766. chart.chartHeight * 0.33 :
  15767. maxLabelLength);
  15768. if (!textOverflowOption) {
  15769. commonTextOverflow = 'ellipsis';
  15770. }
  15771. }
  15772. // Set the explicit or automatic label alignment
  15773. this.labelAlign = labelOptions.align ||
  15774. this.autoLabelAlign(this.labelRotation);
  15775. if (this.labelAlign) {
  15776. attr.align = this.labelAlign;
  15777. }
  15778. // Apply general and specific CSS
  15779. tickPositions.forEach(function (pos) {
  15780. var tick = ticks[pos], label = tick && tick.label, widthOption = labelStyleOptions.width, css = {};
  15781. if (label) {
  15782. // This needs to go before the CSS in old IE (#4502)
  15783. label.attr(attr);
  15784. if (tick.shortenLabel) {
  15785. tick.shortenLabel();
  15786. }
  15787. else if (commonWidth &&
  15788. !widthOption &&
  15789. // Setting width in this case messes with the bounding box
  15790. // (#7975)
  15791. labelStyleOptions.whiteSpace !== 'nowrap' &&
  15792. (
  15793. // Speed optimizing, #7656
  15794. commonWidth < label.textPxLength ||
  15795. // Resetting CSS, #4928
  15796. label.element.tagName === 'SPAN')) {
  15797. css.width = commonWidth + 'px';
  15798. if (!textOverflowOption) {
  15799. css.textOverflow = (label.specificTextOverflow ||
  15800. commonTextOverflow);
  15801. }
  15802. label.css(css);
  15803. // Reset previously shortened label (#8210)
  15804. }
  15805. else if (label.styles &&
  15806. label.styles.width &&
  15807. !css.width &&
  15808. !widthOption) {
  15809. label.css({ width: null });
  15810. }
  15811. delete label.specificTextOverflow;
  15812. tick.rotation = attr.rotation;
  15813. }
  15814. }, this);
  15815. // Note: Why is this not part of getLabelPosition?
  15816. this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
  15817. };
  15818. /**
  15819. * Return true if the axis has associated data.
  15820. *
  15821. * @function Highcharts.Axis#hasData
  15822. *
  15823. * @return {boolean}
  15824. * True if the axis has associated visible series and those series have
  15825. * either valid data points or explicit `min` and `max` settings.
  15826. */
  15827. Axis.prototype.hasData = function () {
  15828. return this.series.some(function (s) {
  15829. return s.hasData();
  15830. }) ||
  15831. (this.options.showEmpty &&
  15832. defined(this.min) &&
  15833. defined(this.max));
  15834. };
  15835. /**
  15836. * Adds the title defined in axis.options.title.
  15837. *
  15838. * @function Highcharts.Axis#addTitle
  15839. *
  15840. * @param {boolean} [display]
  15841. * Whether or not to display the title.
  15842. */
  15843. Axis.prototype.addTitle = function (display) {
  15844. var axis = this, renderer = axis.chart.renderer, horiz = axis.horiz, opposite = axis.opposite, options = axis.options, axisTitleOptions = options.title, textAlign, styledMode = axis.chart.styledMode;
  15845. if (!axis.axisTitle) {
  15846. textAlign = axisTitleOptions.textAlign;
  15847. if (!textAlign) {
  15848. textAlign = (horiz ? {
  15849. low: 'left',
  15850. middle: 'center',
  15851. high: 'right'
  15852. } : {
  15853. low: opposite ? 'right' : 'left',
  15854. middle: 'center',
  15855. high: opposite ? 'left' : 'right'
  15856. })[axisTitleOptions.align];
  15857. }
  15858. axis.axisTitle = renderer
  15859. .text(axisTitleOptions.text, 0, 0, axisTitleOptions.useHTML)
  15860. .attr({
  15861. zIndex: 7,
  15862. rotation: axisTitleOptions.rotation || 0,
  15863. align: textAlign
  15864. })
  15865. .addClass('highcharts-axis-title');
  15866. // #7814, don't mutate style option
  15867. if (!styledMode) {
  15868. axis.axisTitle.css(merge(axisTitleOptions.style));
  15869. }
  15870. axis.axisTitle.add(axis.axisGroup);
  15871. axis.axisTitle.isNew = true;
  15872. }
  15873. // Max width defaults to the length of the axis
  15874. if (!styledMode &&
  15875. !axisTitleOptions.style.width &&
  15876. !axis.isRadial) {
  15877. axis.axisTitle.css({
  15878. width: axis.len + 'px'
  15879. });
  15880. }
  15881. // hide or show the title depending on whether showEmpty is set
  15882. axis.axisTitle[display ? 'show' : 'hide'](display);
  15883. };
  15884. /**
  15885. * Generates a tick for initial positioning.
  15886. *
  15887. * @private
  15888. * @function Highcharts.Axis#generateTick
  15889. *
  15890. * @param {number} pos
  15891. * The tick position in axis values.
  15892. *
  15893. * @param {number} [i]
  15894. * The index of the tick in {@link Axis.tickPositions}.
  15895. */
  15896. Axis.prototype.generateTick = function (pos) {
  15897. var axis = this;
  15898. var ticks = axis.ticks;
  15899. if (!ticks[pos]) {
  15900. ticks[pos] = new Tick(axis, pos);
  15901. }
  15902. else {
  15903. ticks[pos].addLabel(); // update labels depending on tick interval
  15904. }
  15905. };
  15906. /**
  15907. * Render the tick labels to a preliminary position to get their sizes
  15908. *
  15909. * @private
  15910. * @function Highcharts.Axis#getOffset
  15911. *
  15912. * @fires Highcharts.Axis#event:afterGetOffset
  15913. */
  15914. Axis.prototype.getOffset = function () {
  15915. var axis = this, chart = axis.chart, renderer = chart.renderer, options = axis.options, tickPositions = axis.tickPositions, ticks = axis.ticks, horiz = axis.horiz, side = axis.side, invertedSide = chart.inverted &&
  15916. !axis.isZAxis ? [1, 0, 3, 2][side] : side, hasData, showAxis, titleOffset = 0, titleOffsetOption, titleMargin = 0, axisTitleOptions = options.title, labelOptions = options.labels, labelOffset = 0, // reset
  15917. labelOffsetPadded, axisOffset = chart.axisOffset, clipOffset = chart.clipOffset, clip, directionFactor = [-1, 1, 1, -1][side], className = options.className, axisParent = axis.axisParent, // Used in color axis
  15918. lineHeightCorrection;
  15919. // For reuse in Axis.render
  15920. hasData = axis.hasData();
  15921. axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);
  15922. // Set/reset staggerLines
  15923. axis.staggerLines = axis.horiz && labelOptions.staggerLines;
  15924. // Create the axisGroup and gridGroup elements on first iteration
  15925. if (!axis.axisGroup) {
  15926. axis.gridGroup = renderer.g('grid')
  15927. .attr({ zIndex: options.gridZIndex || 1 })
  15928. .addClass('highcharts-' + this.coll.toLowerCase() + '-grid ' +
  15929. (className || ''))
  15930. .add(axisParent);
  15931. axis.axisGroup = renderer.g('axis')
  15932. .attr({ zIndex: options.zIndex || 2 })
  15933. .addClass('highcharts-' + this.coll.toLowerCase() + ' ' +
  15934. (className || ''))
  15935. .add(axisParent);
  15936. axis.labelGroup = renderer.g('axis-labels')
  15937. .attr({ zIndex: labelOptions.zIndex || 7 })
  15938. .addClass('highcharts-' + axis.coll.toLowerCase() + '-labels ' +
  15939. (className || ''))
  15940. .add(axisParent);
  15941. }
  15942. if (hasData || axis.isLinked) {
  15943. // Generate ticks
  15944. tickPositions.forEach(function (pos, i) {
  15945. // i is not used here, but may be used in overrides
  15946. axis.generateTick(pos, i);
  15947. });
  15948. axis.renderUnsquish();
  15949. // Left side must be align: right and right side must
  15950. // have align: left for labels
  15951. axis.reserveSpaceDefault = (side === 0 ||
  15952. side === 2 ||
  15953. { 1: 'left', 3: 'right' }[side] === axis.labelAlign);
  15954. if (pick(labelOptions.reserveSpace, axis.labelAlign === 'center' ? true : null, axis.reserveSpaceDefault)) {
  15955. tickPositions.forEach(function (pos) {
  15956. // get the highest offset
  15957. labelOffset = Math.max(ticks[pos].getLabelSize(), labelOffset);
  15958. });
  15959. }
  15960. if (axis.staggerLines) {
  15961. labelOffset *= axis.staggerLines;
  15962. }
  15963. axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
  15964. }
  15965. else { // doesn't have data
  15966. objectEach(ticks, function (tick, n) {
  15967. tick.destroy();
  15968. delete ticks[n];
  15969. });
  15970. }
  15971. if (axisTitleOptions &&
  15972. axisTitleOptions.text &&
  15973. axisTitleOptions.enabled !== false) {
  15974. axis.addTitle(showAxis);
  15975. if (showAxis && axisTitleOptions.reserveSpace !== false) {
  15976. axis.titleOffset = titleOffset =
  15977. axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
  15978. titleOffsetOption = axisTitleOptions.offset;
  15979. titleMargin = defined(titleOffsetOption) ?
  15980. 0 :
  15981. pick(axisTitleOptions.margin, horiz ? 5 : 10);
  15982. }
  15983. }
  15984. // Render the axis line
  15985. axis.renderLine();
  15986. // handle automatic or user set offset
  15987. axis.offset = directionFactor * pick(options.offset, axisOffset[side] ? axisOffset[side] + (options.margin || 0) : 0);
  15988. axis.tickRotCorr = axis.tickRotCorr || { x: 0, y: 0 }; // polar
  15989. if (side === 0) {
  15990. lineHeightCorrection = -axis.labelMetrics().h;
  15991. }
  15992. else if (side === 2) {
  15993. lineHeightCorrection = axis.tickRotCorr.y;
  15994. }
  15995. else {
  15996. lineHeightCorrection = 0;
  15997. }
  15998. // Find the padded label offset
  15999. labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
  16000. if (labelOffset) {
  16001. labelOffsetPadded -= lineHeightCorrection;
  16002. labelOffsetPadded += directionFactor * (horiz ?
  16003. pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) :
  16004. labelOptions.x);
  16005. }
  16006. axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
  16007. if (axis.getMaxLabelDimensions) {
  16008. axis.maxLabelDimensions = axis.getMaxLabelDimensions(ticks, tickPositions);
  16009. }
  16010. // Due to GridAxis.tickSize, tickSize should be calculated after ticks
  16011. // has rendered.
  16012. var tickSize = this.tickSize('tick');
  16013. axisOffset[side] = Math.max(axisOffset[side], axis.axisTitleMargin + titleOffset +
  16014. directionFactor * axis.offset, labelOffsetPadded, // #3027
  16015. tickPositions && tickPositions.length && tickSize ?
  16016. tickSize[0] + directionFactor * axis.offset :
  16017. 0 // #4866
  16018. );
  16019. // Decide the clipping needed to keep the graph inside
  16020. // the plot area and axis lines
  16021. clip = options.offset ?
  16022. 0 :
  16023. // #4308, #4371:
  16024. Math.floor(axis.axisLine.strokeWidth() / 2) * 2;
  16025. clipOffset[invertedSide] =
  16026. Math.max(clipOffset[invertedSide], clip);
  16027. fireEvent(this, 'afterGetOffset');
  16028. };
  16029. /**
  16030. * Internal function to get the path for the axis line. Extended for polar
  16031. * charts.
  16032. *
  16033. * @function Highcharts.Axis#getLinePath
  16034. *
  16035. * @param {number} lineWidth
  16036. * The line width in pixels.
  16037. *
  16038. * @return {Highcharts.SVGPathArray}
  16039. * The SVG path definition in array form.
  16040. */
  16041. Axis.prototype.getLinePath = function (lineWidth) {
  16042. var chart = this.chart, opposite = this.opposite, offset = this.offset, horiz = this.horiz, lineLeft = this.left + (opposite ? this.width : 0) + offset, lineTop = chart.chartHeight - this.bottom -
  16043. (opposite ? this.height : 0) + offset;
  16044. if (opposite) {
  16045. lineWidth *= -1; // crispify the other way - #1480, #1687
  16046. }
  16047. return chart.renderer
  16048. .crispLine([
  16049. [
  16050. 'M',
  16051. horiz ?
  16052. this.left :
  16053. lineLeft,
  16054. horiz ?
  16055. lineTop :
  16056. this.top
  16057. ],
  16058. [
  16059. 'L',
  16060. horiz ?
  16061. chart.chartWidth - this.right :
  16062. lineLeft,
  16063. horiz ?
  16064. lineTop :
  16065. chart.chartHeight - this.bottom
  16066. ]
  16067. ], lineWidth);
  16068. };
  16069. /**
  16070. * Render the axis line. Called internally when rendering and redrawing the
  16071. * axis.
  16072. *
  16073. * @function Highcharts.Axis#renderLine
  16074. */
  16075. Axis.prototype.renderLine = function () {
  16076. if (!this.axisLine) {
  16077. this.axisLine = this.chart.renderer.path()
  16078. .addClass('highcharts-axis-line')
  16079. .add(this.axisGroup);
  16080. if (!this.chart.styledMode) {
  16081. this.axisLine.attr({
  16082. stroke: this.options.lineColor,
  16083. 'stroke-width': this.options.lineWidth,
  16084. zIndex: 7
  16085. });
  16086. }
  16087. }
  16088. };
  16089. /**
  16090. * Position the axis title.
  16091. *
  16092. * @private
  16093. * @function Highcharts.Axis#getTitlePosition
  16094. *
  16095. * @return {Highcharts.PositionObject}
  16096. * X and Y positions for the title.
  16097. */
  16098. Axis.prototype.getTitlePosition = function () {
  16099. // compute anchor points for each of the title align options
  16100. var horiz = this.horiz, axisLeft = this.left, axisTop = this.top, axisLength = this.len, axisTitleOptions = this.options.title, margin = horiz ? axisLeft : axisTop, opposite = this.opposite, offset = this.offset, xOption = axisTitleOptions.x || 0, yOption = axisTitleOptions.y || 0, axisTitle = this.axisTitle, fontMetrics = this.chart.renderer.fontMetrics(axisTitleOptions.style &&
  16101. axisTitleOptions.style.fontSize, axisTitle),
  16102. // The part of a multiline text that is below the baseline of the
  16103. // first line. Subtract 1 to preserve pixel-perfectness from the
  16104. // old behaviour (v5.0.12), where only one line was allowed.
  16105. textHeightOvershoot = Math.max(axisTitle.getBBox(null, 0).height - fontMetrics.h - 1, 0),
  16106. // the position in the length direction of the axis
  16107. alongAxis = {
  16108. low: margin + (horiz ? 0 : axisLength),
  16109. middle: margin + axisLength / 2,
  16110. high: margin + (horiz ? axisLength : 0)
  16111. }[axisTitleOptions.align],
  16112. // the position in the perpendicular direction of the axis
  16113. offAxis = (horiz ? axisTop + this.height : axisLeft) +
  16114. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  16115. (opposite ? -1 : 1) * // so does opposite axes
  16116. this.axisTitleMargin +
  16117. [
  16118. -textHeightOvershoot,
  16119. textHeightOvershoot,
  16120. fontMetrics.f,
  16121. -textHeightOvershoot // left
  16122. ][this.side], titlePosition = {
  16123. x: horiz ?
  16124. alongAxis + xOption :
  16125. offAxis + (opposite ? this.width : 0) + offset + xOption,
  16126. y: horiz ?
  16127. offAxis + yOption - (opposite ? this.height : 0) + offset :
  16128. alongAxis + yOption
  16129. };
  16130. fireEvent(this, 'afterGetTitlePosition', { titlePosition: titlePosition });
  16131. return titlePosition;
  16132. };
  16133. /**
  16134. * Render a minor tick into the given position. If a minor tick already
  16135. * exists in this position, move it.
  16136. *
  16137. * @function Highcharts.Axis#renderMinorTick
  16138. *
  16139. * @param {number} pos
  16140. * The position in axis values.
  16141. */
  16142. Axis.prototype.renderMinorTick = function (pos) {
  16143. var axis = this;
  16144. var slideInTicks = axis.chart.hasRendered && isNumber(axis.oldMin);
  16145. var minorTicks = axis.minorTicks;
  16146. if (!minorTicks[pos]) {
  16147. minorTicks[pos] = new Tick(axis, pos, 'minor');
  16148. }
  16149. // Render new ticks in old position
  16150. if (slideInTicks && minorTicks[pos].isNew) {
  16151. minorTicks[pos].render(null, true);
  16152. }
  16153. minorTicks[pos].render(null, false, 1);
  16154. };
  16155. /**
  16156. * Render a major tick into the given position. If a tick already exists
  16157. * in this position, move it.
  16158. *
  16159. * @function Highcharts.Axis#renderTick
  16160. *
  16161. * @param {number} pos
  16162. * The position in axis values.
  16163. *
  16164. * @param {number} i
  16165. * The tick index.
  16166. */
  16167. Axis.prototype.renderTick = function (pos, i) {
  16168. var axis = this;
  16169. var isLinked = axis.isLinked;
  16170. var ticks = axis.ticks;
  16171. var slideInTicks = axis.chart.hasRendered && isNumber(axis.oldMin);
  16172. // Linked axes need an extra check to find out if
  16173. if (!isLinked ||
  16174. (pos >= axis.min && pos <= axis.max)) {
  16175. if (!ticks[pos]) {
  16176. ticks[pos] = new Tick(axis, pos);
  16177. }
  16178. // NOTE this seems like overkill. Could be handled in tick.render by
  16179. // setting old position in attr, then set new position in animate.
  16180. // render new ticks in old position
  16181. if (slideInTicks && ticks[pos].isNew) {
  16182. // Start with negative opacity so that it is visible from
  16183. // halfway into the animation
  16184. ticks[pos].render(i, true, -1);
  16185. }
  16186. ticks[pos].render(i);
  16187. }
  16188. };
  16189. /**
  16190. * Render the axis.
  16191. *
  16192. * @private
  16193. * @function Highcharts.Axis#render
  16194. *
  16195. * @fires Highcharts.Axis#event:afterRender
  16196. */
  16197. Axis.prototype.render = function () {
  16198. var axis = this, chart = axis.chart, log = axis.logarithmic, renderer = chart.renderer, options = axis.options, isLinked = axis.isLinked, tickPositions = axis.tickPositions, axisTitle = axis.axisTitle, ticks = axis.ticks, minorTicks = axis.minorTicks, alternateBands = axis.alternateBands, stackLabelOptions = options.stackLabels, alternateGridColor = options.alternateGridColor, tickmarkOffset = axis.tickmarkOffset, axisLine = axis.axisLine, showAxis = axis.showAxis, animation = animObject(renderer.globalAnimation), from, to;
  16199. // Reset
  16200. axis.labelEdge.length = 0;
  16201. axis.overlap = false;
  16202. // Mark all elements inActive before we go over and mark the active ones
  16203. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  16204. objectEach(coll, function (tick) {
  16205. tick.isActive = false;
  16206. });
  16207. });
  16208. // If the series has data draw the ticks. Else only the line and title
  16209. if (axis.hasData() || isLinked) {
  16210. // minor ticks
  16211. if (axis.minorTickInterval && !axis.categories) {
  16212. axis.getMinorTickPositions().forEach(function (pos) {
  16213. axis.renderMinorTick(pos);
  16214. });
  16215. }
  16216. // Major ticks. Pull out the first item and render it last so that
  16217. // we can get the position of the neighbour label. #808.
  16218. if (tickPositions.length) { // #1300
  16219. tickPositions.forEach(function (pos, i) {
  16220. axis.renderTick(pos, i);
  16221. });
  16222. // In a categorized axis, the tick marks are displayed
  16223. // between labels. So we need to add a tick mark and
  16224. // grid line at the left edge of the X axis.
  16225. if (tickmarkOffset && (axis.min === 0 || axis.single)) {
  16226. if (!ticks[-1]) {
  16227. ticks[-1] = new Tick(axis, -1, null, true);
  16228. }
  16229. ticks[-1].render(-1);
  16230. }
  16231. }
  16232. // alternate grid color
  16233. if (alternateGridColor) {
  16234. tickPositions.forEach(function (pos, i) {
  16235. to = typeof tickPositions[i + 1] !== 'undefined' ?
  16236. tickPositions[i + 1] + tickmarkOffset :
  16237. axis.max - tickmarkOffset;
  16238. if (i % 2 === 0 &&
  16239. pos < axis.max &&
  16240. to <= axis.max + (chart.polar ?
  16241. -tickmarkOffset :
  16242. tickmarkOffset)) { // #2248, #4660
  16243. if (!alternateBands[pos]) {
  16244. // Should be imported from PlotLineOrBand.js, but
  16245. // the dependency cycle with axis is a problem
  16246. alternateBands[pos] = new H.PlotLineOrBand(axis);
  16247. }
  16248. from = pos + tickmarkOffset; // #949
  16249. alternateBands[pos].options = {
  16250. from: log ? log.lin2log(from) : from,
  16251. to: log ? log.lin2log(to) : to,
  16252. color: alternateGridColor,
  16253. className: 'highcharts-alternate-grid'
  16254. };
  16255. alternateBands[pos].render();
  16256. alternateBands[pos].isActive = true;
  16257. }
  16258. });
  16259. }
  16260. // custom plot lines and bands
  16261. if (!axis._addedPlotLB) { // only first time
  16262. (options.plotLines || [])
  16263. .concat(options.plotBands || [])
  16264. .forEach(function (plotLineOptions) {
  16265. axis.addPlotBandOrLine(plotLineOptions);
  16266. });
  16267. axis._addedPlotLB = true;
  16268. }
  16269. } // end if hasData
  16270. // Remove inactive ticks
  16271. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  16272. var i, forDestruction = [], delay = animation.duration, destroyInactiveItems = function () {
  16273. i = forDestruction.length;
  16274. while (i--) {
  16275. // When resizing rapidly, the same items
  16276. // may be destroyed in different timeouts,
  16277. // or the may be reactivated
  16278. if (coll[forDestruction[i]] &&
  16279. !coll[forDestruction[i]].isActive) {
  16280. coll[forDestruction[i]].destroy();
  16281. delete coll[forDestruction[i]];
  16282. }
  16283. }
  16284. };
  16285. objectEach(coll, function (tick, pos) {
  16286. if (!tick.isActive) {
  16287. // Render to zero opacity
  16288. tick.render(pos, false, 0);
  16289. tick.isActive = false;
  16290. forDestruction.push(pos);
  16291. }
  16292. });
  16293. // When the objects are finished fading out, destroy them
  16294. syncTimeout(destroyInactiveItems, coll === alternateBands ||
  16295. !chart.hasRendered ||
  16296. !delay ?
  16297. 0 :
  16298. delay);
  16299. });
  16300. // Set the axis line path
  16301. if (axisLine) {
  16302. axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
  16303. d: this.getLinePath(axisLine.strokeWidth())
  16304. });
  16305. axisLine.isPlaced = true;
  16306. // Show or hide the line depending on options.showEmpty
  16307. axisLine[showAxis ? 'show' : 'hide'](showAxis);
  16308. }
  16309. if (axisTitle && showAxis) {
  16310. var titleXy = axis.getTitlePosition();
  16311. if (isNumber(titleXy.y)) {
  16312. axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
  16313. axisTitle.isNew = false;
  16314. }
  16315. else {
  16316. axisTitle.attr('y', -9999);
  16317. axisTitle.isNew = true;
  16318. }
  16319. }
  16320. // Stacked totals:
  16321. if (stackLabelOptions && stackLabelOptions.enabled && axis.stacking) {
  16322. axis.stacking.renderStackTotals();
  16323. }
  16324. // End stacked totals
  16325. axis.isDirty = false;
  16326. fireEvent(this, 'afterRender');
  16327. };
  16328. /**
  16329. * Redraw the axis to reflect changes in the data or axis extremes. Called
  16330. * internally from Highcharts.Chart#redraw.
  16331. *
  16332. * @private
  16333. * @function Highcharts.Axis#redraw
  16334. */
  16335. Axis.prototype.redraw = function () {
  16336. if (this.visible) {
  16337. // render the axis
  16338. this.render();
  16339. // move plot lines and bands
  16340. this.plotLinesAndBands.forEach(function (plotLine) {
  16341. plotLine.render();
  16342. });
  16343. }
  16344. // mark associated series as dirty and ready for redraw
  16345. this.series.forEach(function (series) {
  16346. series.isDirty = true;
  16347. });
  16348. };
  16349. /**
  16350. * Returns an array of axis properties, that should be untouched during
  16351. * reinitialization.
  16352. *
  16353. * @private
  16354. * @function Highcharts.Axis#getKeepProps
  16355. *
  16356. * @return {Array<string>}
  16357. */
  16358. Axis.prototype.getKeepProps = function () {
  16359. return (this.keepProps || Axis.keepProps);
  16360. };
  16361. /**
  16362. * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
  16363. * to fully remove the axis.
  16364. *
  16365. * @private
  16366. * @function Highcharts.Axis#destroy
  16367. *
  16368. * @param {boolean} [keepEvents]
  16369. * Whether to preserve events, used internally in Axis.update.
  16370. */
  16371. Axis.prototype.destroy = function (keepEvents) {
  16372. var axis = this, plotLinesAndBands = axis.plotLinesAndBands, plotGroup, i;
  16373. fireEvent(this, 'destroy', { keepEvents: keepEvents });
  16374. // Remove the events
  16375. if (!keepEvents) {
  16376. removeEvent(axis);
  16377. }
  16378. // Destroy collections
  16379. [axis.ticks, axis.minorTicks, axis.alternateBands].forEach(function (coll) {
  16380. destroyObjectProperties(coll);
  16381. });
  16382. if (plotLinesAndBands) {
  16383. i = plotLinesAndBands.length;
  16384. while (i--) { // #1975
  16385. plotLinesAndBands[i].destroy();
  16386. }
  16387. }
  16388. // Destroy elements
  16389. ['axisLine', 'axisTitle', 'axisGroup',
  16390. 'gridGroup', 'labelGroup', 'cross', 'scrollbar'].forEach(function (prop) {
  16391. if (axis[prop]) {
  16392. axis[prop] = axis[prop].destroy();
  16393. }
  16394. });
  16395. // Destroy each generated group for plotlines and plotbands
  16396. for (plotGroup in axis.plotLinesAndBandsGroups) { // eslint-disable-line guard-for-in
  16397. axis.plotLinesAndBandsGroups[plotGroup] =
  16398. axis.plotLinesAndBandsGroups[plotGroup].destroy();
  16399. }
  16400. // Delete all properties and fall back to the prototype.
  16401. objectEach(axis, function (val, key) {
  16402. if (axis.getKeepProps().indexOf(key) === -1) {
  16403. delete axis[key];
  16404. }
  16405. });
  16406. };
  16407. /**
  16408. * Internal function to draw a crosshair.
  16409. *
  16410. * @function Highcharts.Axis#drawCrosshair
  16411. *
  16412. * @param {Highcharts.PointerEventObject} [e]
  16413. * The event arguments from the modified pointer event, extended with
  16414. * `chartX` and `chartY`
  16415. *
  16416. * @param {Highcharts.Point} [point]
  16417. * The Point object if the crosshair snaps to points.
  16418. *
  16419. * @fires Highcharts.Axis#event:afterDrawCrosshair
  16420. * @fires Highcharts.Axis#event:drawCrosshair
  16421. */
  16422. Axis.prototype.drawCrosshair = function (e, point) {
  16423. var path, options = this.crosshair, snap = pick(options.snap, true), pos, categorized, graphic = this.cross, crossOptions, chart = this.chart;
  16424. fireEvent(this, 'drawCrosshair', { e: e, point: point });
  16425. // Use last available event when updating non-snapped crosshairs without
  16426. // mouse interaction (#5287)
  16427. if (!e) {
  16428. e = this.cross && this.cross.e;
  16429. }
  16430. if (
  16431. // Disabled in options
  16432. !this.crosshair ||
  16433. // Snap
  16434. ((defined(point) || !snap) === false)) {
  16435. this.hideCrosshair();
  16436. }
  16437. else {
  16438. // Get the path
  16439. if (!snap) {
  16440. pos = e &&
  16441. (this.horiz ?
  16442. e.chartX - this.pos :
  16443. this.len - e.chartY + this.pos);
  16444. }
  16445. else if (defined(point)) {
  16446. // #3834
  16447. pos = pick(this.coll !== 'colorAxis' ?
  16448. point.crosshairPos : // 3D axis extension
  16449. null, this.isXAxis ?
  16450. point.plotX :
  16451. this.len - point.plotY);
  16452. }
  16453. if (defined(pos)) {
  16454. crossOptions = {
  16455. // value, only used on radial
  16456. value: point && (this.isXAxis ?
  16457. point.x :
  16458. pick(point.stackY, point.y)),
  16459. translatedValue: pos
  16460. };
  16461. if (chart.polar) {
  16462. // Additional information required for crosshairs in
  16463. // polar chart
  16464. extend(crossOptions, {
  16465. isCrosshair: true,
  16466. chartX: e && e.chartX,
  16467. chartY: e && e.chartY,
  16468. point: point
  16469. });
  16470. }
  16471. path = this.getPlotLinePath(crossOptions) ||
  16472. null; // #3189
  16473. }
  16474. if (!defined(path)) {
  16475. this.hideCrosshair();
  16476. return;
  16477. }
  16478. categorized = this.categories && !this.isRadial;
  16479. // Draw the cross
  16480. if (!graphic) {
  16481. this.cross = graphic = chart.renderer
  16482. .path()
  16483. .addClass('highcharts-crosshair highcharts-crosshair-' +
  16484. (categorized ? 'category ' : 'thin ') +
  16485. options.className)
  16486. .attr({
  16487. zIndex: pick(options.zIndex, 2)
  16488. })
  16489. .add();
  16490. // Presentational attributes
  16491. if (!chart.styledMode) {
  16492. graphic.attr({
  16493. stroke: options.color ||
  16494. (categorized ?
  16495. Color
  16496. .parse('#ccd6eb')
  16497. .setOpacity(0.25)
  16498. .get() :
  16499. '#cccccc'),
  16500. 'stroke-width': pick(options.width, 1)
  16501. }).css({
  16502. 'pointer-events': 'none'
  16503. });
  16504. if (options.dashStyle) {
  16505. graphic.attr({
  16506. dashstyle: options.dashStyle
  16507. });
  16508. }
  16509. }
  16510. }
  16511. graphic.show().attr({
  16512. d: path
  16513. });
  16514. if (categorized && !options.width) {
  16515. graphic.attr({
  16516. 'stroke-width': this.transA
  16517. });
  16518. }
  16519. this.cross.e = e;
  16520. }
  16521. fireEvent(this, 'afterDrawCrosshair', { e: e, point: point });
  16522. };
  16523. /**
  16524. * Hide the crosshair if visible.
  16525. *
  16526. * @function Highcharts.Axis#hideCrosshair
  16527. */
  16528. Axis.prototype.hideCrosshair = function () {
  16529. if (this.cross) {
  16530. this.cross.hide();
  16531. }
  16532. fireEvent(this, 'afterHideCrosshair');
  16533. };
  16534. /**
  16535. * Check whether the chart has vertical panning ('y' or 'xy' type).
  16536. *
  16537. * @private
  16538. * @function Highcharts.Axis#hasVerticalPanning
  16539. * @return {boolean}
  16540. *
  16541. */
  16542. Axis.prototype.hasVerticalPanning = function () {
  16543. var _a, _b;
  16544. 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) || '');
  16545. };
  16546. /* *
  16547. *
  16548. * Static Properties
  16549. *
  16550. * */
  16551. /**
  16552. * The X axis or category axis. Normally this is the horizontal axis,
  16553. * though if the chart is inverted this is the vertical axis. In case of
  16554. * multiple axes, the xAxis node is an array of configuration objects.
  16555. *
  16556. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  16557. * access to the axis.
  16558. *
  16559. * @productdesc {highmaps}
  16560. * In Highmaps, the axis is hidden, but it is used behind the scenes to
  16561. * control features like zooming and panning. Zooming is in effect the same
  16562. * as setting the extremes of one of the exes.
  16563. *
  16564. * @type {*|Array<*>}
  16565. * @optionparent xAxis
  16566. *
  16567. * @private
  16568. */
  16569. Axis.defaultOptions = {
  16570. /**
  16571. * When using multiple axis, the ticks of two or more opposite axes
  16572. * will automatically be aligned by adding ticks to the axis or axes
  16573. * with the least ticks, as if `tickAmount` were specified.
  16574. *
  16575. * This can be prevented by setting `alignTicks` to false. If the grid
  16576. * lines look messy, it's a good idea to hide them for the secondary
  16577. * axis by setting `gridLineWidth` to 0.
  16578. *
  16579. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  16580. * then the `alignTicks ` will be disabled for the Axis.
  16581. *
  16582. * Disabled for logarithmic axes.
  16583. *
  16584. * @type {boolean}
  16585. * @default true
  16586. * @product highcharts highstock gantt
  16587. * @apioption xAxis.alignTicks
  16588. */
  16589. /**
  16590. * Whether to allow decimals in this axis' ticks. When counting
  16591. * integers, like persons or hits on a web page, decimals should
  16592. * be avoided in the labels.
  16593. *
  16594. * @see [minTickInterval](#xAxis.minTickInterval)
  16595. *
  16596. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-true/
  16597. * True by default
  16598. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-false/
  16599. * False
  16600. *
  16601. * @type {boolean}
  16602. * @default true
  16603. * @since 2.0
  16604. * @apioption xAxis.allowDecimals
  16605. */
  16606. /**
  16607. * When using an alternate grid color, a band is painted across the
  16608. * plot area between every other grid line.
  16609. *
  16610. * @sample {highcharts} highcharts/yaxis/alternategridcolor/
  16611. * Alternate grid color on the Y axis
  16612. * @sample {highstock} stock/xaxis/alternategridcolor/
  16613. * Alternate grid color on the Y axis
  16614. *
  16615. * @type {Highcharts.ColorType}
  16616. * @apioption xAxis.alternateGridColor
  16617. */
  16618. /**
  16619. * An array defining breaks in the axis, the sections defined will be
  16620. * left out and all the points shifted closer to each other.
  16621. *
  16622. * @productdesc {highcharts}
  16623. * Requires that the broken-axis.js module is loaded.
  16624. *
  16625. * @sample {highcharts} highcharts/axisbreak/break-simple/
  16626. * Simple break
  16627. * @sample {highcharts|highstock} highcharts/axisbreak/break-visualized/
  16628. * Advanced with callback
  16629. * @sample {highstock} stock/demo/intraday-breaks/
  16630. * Break on nights and weekends
  16631. *
  16632. * @type {Array<*>}
  16633. * @since 4.1.0
  16634. * @product highcharts highstock gantt
  16635. * @apioption xAxis.breaks
  16636. */
  16637. /**
  16638. * A number indicating how much space should be left between the start
  16639. * and the end of the break. The break size is given in axis units,
  16640. * so for instance on a `datetime` axis, a break size of 3600000 would
  16641. * indicate the equivalent of an hour.
  16642. *
  16643. * @type {number}
  16644. * @default 0
  16645. * @since 4.1.0
  16646. * @product highcharts highstock gantt
  16647. * @apioption xAxis.breaks.breakSize
  16648. */
  16649. /**
  16650. * The point where the break starts.
  16651. *
  16652. * @type {number}
  16653. * @since 4.1.0
  16654. * @product highcharts highstock gantt
  16655. * @apioption xAxis.breaks.from
  16656. */
  16657. /**
  16658. * Defines an interval after which the break appears again. By default
  16659. * the breaks do not repeat.
  16660. *
  16661. * @type {number}
  16662. * @default 0
  16663. * @since 4.1.0
  16664. * @product highcharts highstock gantt
  16665. * @apioption xAxis.breaks.repeat
  16666. */
  16667. /**
  16668. * The point where the break ends.
  16669. *
  16670. * @type {number}
  16671. * @since 4.1.0
  16672. * @product highcharts highstock gantt
  16673. * @apioption xAxis.breaks.to
  16674. */
  16675. /**
  16676. * If categories are present for the xAxis, names are used instead of
  16677. * numbers for that axis.
  16678. *
  16679. * Since Highcharts 3.0, categories can also
  16680. * be extracted by giving each point a [name](#series.data) and setting
  16681. * axis [type](#xAxis.type) to `category`. However, if you have multiple
  16682. * series, best practice remains defining the `categories` array.
  16683. *
  16684. * Example: `categories: ['Apples', 'Bananas', 'Oranges']`
  16685. *
  16686. * @sample {highcharts} highcharts/demo/line-labels/
  16687. * With
  16688. * @sample {highcharts} highcharts/xaxis/categories/
  16689. * Without
  16690. *
  16691. * @type {Array<string>}
  16692. * @product highcharts gantt
  16693. * @apioption xAxis.categories
  16694. */
  16695. /**
  16696. * The highest allowed value for automatically computed axis extremes.
  16697. *
  16698. * @see [floor](#xAxis.floor)
  16699. *
  16700. * @sample {highcharts|highstock} highcharts/yaxis/floor-ceiling/
  16701. * Floor and ceiling
  16702. *
  16703. * @type {number}
  16704. * @since 4.0
  16705. * @product highcharts highstock gantt
  16706. * @apioption xAxis.ceiling
  16707. */
  16708. /**
  16709. * A class name that opens for styling the axis by CSS, especially in
  16710. * Highcharts styled mode. The class name is applied to group elements
  16711. * for the grid, axis elements and labels.
  16712. *
  16713. * @sample {highcharts|highstock|highmaps} highcharts/css/axis/
  16714. * Multiple axes with separate styling
  16715. *
  16716. * @type {string}
  16717. * @since 5.0.0
  16718. * @apioption xAxis.className
  16719. */
  16720. /**
  16721. * Configure a crosshair that follows either the mouse pointer or the
  16722. * hovered point.
  16723. *
  16724. * In styled mode, the crosshairs are styled in the
  16725. * `.highcharts-crosshair`, `.highcharts-crosshair-thin` or
  16726. * `.highcharts-xaxis-category` classes.
  16727. *
  16728. * @productdesc {highstock}
  16729. * In Highstock, by default, the crosshair is enabled on the X axis and
  16730. * disabled on the Y axis.
  16731. *
  16732. * @sample {highcharts} highcharts/xaxis/crosshair-both/
  16733. * Crosshair on both axes
  16734. * @sample {highstock} stock/xaxis/crosshairs-xy/
  16735. * Crosshair on both axes
  16736. * @sample {highmaps} highcharts/xaxis/crosshair-both/
  16737. * Crosshair on both axes
  16738. *
  16739. * @declare Highcharts.AxisCrosshairOptions
  16740. * @type {boolean|*}
  16741. * @default false
  16742. * @since 4.1
  16743. * @apioption xAxis.crosshair
  16744. */
  16745. /**
  16746. * A class name for the crosshair, especially as a hook for styling.
  16747. *
  16748. * @type {string}
  16749. * @since 5.0.0
  16750. * @apioption xAxis.crosshair.className
  16751. */
  16752. /**
  16753. * The color of the crosshair. Defaults to `#cccccc` for numeric and
  16754. * datetime axes, and `rgba(204,214,235,0.25)` for category axes, where
  16755. * the crosshair by default highlights the whole category.
  16756. *
  16757. * @sample {highcharts|highstock|highmaps} highcharts/xaxis/crosshair-customized/
  16758. * Customized crosshairs
  16759. *
  16760. * @type {Highcharts.ColorType}
  16761. * @default #cccccc
  16762. * @since 4.1
  16763. * @apioption xAxis.crosshair.color
  16764. */
  16765. /**
  16766. * The dash style for the crosshair. See
  16767. * [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  16768. * for possible values.
  16769. *
  16770. * @sample {highcharts|highmaps} highcharts/xaxis/crosshair-dotted/
  16771. * Dotted crosshair
  16772. * @sample {highstock} stock/xaxis/crosshair-dashed/
  16773. * Dashed X axis crosshair
  16774. *
  16775. * @type {Highcharts.DashStyleValue}
  16776. * @default Solid
  16777. * @since 4.1
  16778. * @apioption xAxis.crosshair.dashStyle
  16779. */
  16780. /**
  16781. * A label on the axis next to the crosshair.
  16782. *
  16783. * In styled mode, the label is styled with the
  16784. * `.highcharts-crosshair-label` class.
  16785. *
  16786. * @sample {highstock} stock/xaxis/crosshair-label/
  16787. * Crosshair labels
  16788. * @sample {highstock} highcharts/css/crosshair-label/
  16789. * Style mode
  16790. *
  16791. * @declare Highcharts.AxisCrosshairLabelOptions
  16792. * @since 2.1
  16793. * @product highstock
  16794. * @apioption xAxis.crosshair.label
  16795. */
  16796. /**
  16797. * Alignment of the label compared to the axis. Defaults to `"left"` for
  16798. * right-side axes, `"right"` for left-side axes and `"center"` for
  16799. * horizontal axes.
  16800. *
  16801. * @type {Highcharts.AlignValue}
  16802. * @since 2.1
  16803. * @product highstock
  16804. * @apioption xAxis.crosshair.label.align
  16805. */
  16806. /**
  16807. * The background color for the label. Defaults to the related series
  16808. * color, or `#666666` if that is not available.
  16809. *
  16810. * @type {Highcharts.ColorType}
  16811. * @since 2.1
  16812. * @product highstock
  16813. * @apioption xAxis.crosshair.label.backgroundColor
  16814. */
  16815. /**
  16816. * The border color for the crosshair label
  16817. *
  16818. * @type {Highcharts.ColorType}
  16819. * @since 2.1
  16820. * @product highstock
  16821. * @apioption xAxis.crosshair.label.borderColor
  16822. */
  16823. /**
  16824. * The border corner radius of the crosshair label.
  16825. *
  16826. * @type {number}
  16827. * @default 3
  16828. * @since 2.1.10
  16829. * @product highstock
  16830. * @apioption xAxis.crosshair.label.borderRadius
  16831. */
  16832. /**
  16833. * The border width for the crosshair label.
  16834. *
  16835. * @type {number}
  16836. * @default 0
  16837. * @since 2.1
  16838. * @product highstock
  16839. * @apioption xAxis.crosshair.label.borderWidth
  16840. */
  16841. /**
  16842. * Flag to enable crosshair's label.
  16843. *
  16844. * @sample {highstock} stock/xaxis/crosshairs-xy/
  16845. * Enabled label for yAxis' crosshair
  16846. *
  16847. * @type {boolean}
  16848. * @default false
  16849. * @since 2.1
  16850. * @product highstock
  16851. * @apioption xAxis.crosshair.label.enabled
  16852. */
  16853. /**
  16854. * A format string for the crosshair label. Defaults to `{value}` for
  16855. * numeric axes and `{value:%b %d, %Y}` for datetime axes.
  16856. *
  16857. * @type {string}
  16858. * @since 2.1
  16859. * @product highstock
  16860. * @apioption xAxis.crosshair.label.format
  16861. */
  16862. /**
  16863. * Formatter function for the label text.
  16864. *
  16865. * @type {Highcharts.XAxisCrosshairLabelFormatterCallbackFunction}
  16866. * @since 2.1
  16867. * @product highstock
  16868. * @apioption xAxis.crosshair.label.formatter
  16869. */
  16870. /**
  16871. * Padding inside the crosshair label.
  16872. *
  16873. * @type {number}
  16874. * @default 8
  16875. * @since 2.1
  16876. * @product highstock
  16877. * @apioption xAxis.crosshair.label.padding
  16878. */
  16879. /**
  16880. * The shape to use for the label box.
  16881. *
  16882. * @type {string}
  16883. * @default callout
  16884. * @since 2.1
  16885. * @product highstock
  16886. * @apioption xAxis.crosshair.label.shape
  16887. */
  16888. /**
  16889. * Text styles for the crosshair label.
  16890. *
  16891. * @type {Highcharts.CSSObject}
  16892. * @default {"color": "white", "fontWeight": "normal", "fontSize": "11px", "textAlign": "center"}
  16893. * @since 2.1
  16894. * @product highstock
  16895. * @apioption xAxis.crosshair.label.style
  16896. */
  16897. /**
  16898. * Whether the crosshair should snap to the point or follow the pointer
  16899. * independent of points.
  16900. *
  16901. * @sample {highcharts|highstock} highcharts/xaxis/crosshair-snap-false/
  16902. * True by default
  16903. * @sample {highmaps} maps/demo/latlon-advanced/
  16904. * Snap is false
  16905. *
  16906. * @type {boolean}
  16907. * @default true
  16908. * @since 4.1
  16909. * @apioption xAxis.crosshair.snap
  16910. */
  16911. /**
  16912. * The pixel width of the crosshair. Defaults to 1 for numeric or
  16913. * datetime axes, and for one category width for category axes.
  16914. *
  16915. * @sample {highcharts} highcharts/xaxis/crosshair-customized/
  16916. * Customized crosshairs
  16917. * @sample {highstock} highcharts/xaxis/crosshair-customized/
  16918. * Customized crosshairs
  16919. * @sample {highmaps} highcharts/xaxis/crosshair-customized/
  16920. * Customized crosshairs
  16921. *
  16922. * @type {number}
  16923. * @default 1
  16924. * @since 4.1
  16925. * @apioption xAxis.crosshair.width
  16926. */
  16927. /**
  16928. * The Z index of the crosshair. Higher Z indices allow drawing the
  16929. * crosshair on top of the series or behind the grid lines.
  16930. *
  16931. * @type {number}
  16932. * @default 2
  16933. * @since 4.1
  16934. * @apioption xAxis.crosshair.zIndex
  16935. */
  16936. /**
  16937. * Whether to zoom axis. If `chart.zoomType` is set, the option allows
  16938. * to disable zooming on an individual axis.
  16939. *
  16940. * @sample {highcharts} highcharts/xaxis/zoomenabled/
  16941. * Zoom enabled is false
  16942. *
  16943. *
  16944. * @type {boolean}
  16945. * @default enabled
  16946. * @apioption xAxis.zoomEnabled
  16947. */
  16948. /**
  16949. * For a datetime axis, the scale will automatically adjust to the
  16950. * appropriate unit. This member gives the default string
  16951. * representations used for each unit. For intermediate values,
  16952. * different units may be used, for example the `day` unit can be used
  16953. * on midnight and `hour` unit be used for intermediate values on the
  16954. * same axis. For an overview of the replacement codes, see
  16955. * [dateFormat](/class-reference/Highcharts#dateFormat).
  16956. *
  16957. * Defaults to:
  16958. * ```js
  16959. * {
  16960. * millisecond: '%H:%M:%S.%L',
  16961. * second: '%H:%M:%S',
  16962. * minute: '%H:%M',
  16963. * hour: '%H:%M',
  16964. * day: '%e. %b',
  16965. * week: '%e. %b',
  16966. * month: '%b \'%y',
  16967. * year: '%Y'
  16968. * }
  16969. * ```
  16970. *
  16971. * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
  16972. * Different day format on X axis
  16973. * @sample {highstock} stock/xaxis/datetimelabelformats/
  16974. * More information in x axis labels
  16975. *
  16976. * @declare Highcharts.AxisDateTimeLabelFormatsOptions
  16977. * @product highcharts highstock gantt
  16978. */
  16979. dateTimeLabelFormats: {
  16980. /**
  16981. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  16982. * @type {string|*}
  16983. */
  16984. millisecond: {
  16985. main: '%H:%M:%S.%L',
  16986. range: false
  16987. },
  16988. /**
  16989. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  16990. * @type {string|*}
  16991. */
  16992. second: {
  16993. main: '%H:%M:%S',
  16994. range: false
  16995. },
  16996. /**
  16997. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  16998. * @type {string|*}
  16999. */
  17000. minute: {
  17001. main: '%H:%M',
  17002. range: false
  17003. },
  17004. /**
  17005. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17006. * @type {string|*}
  17007. */
  17008. hour: {
  17009. main: '%H:%M',
  17010. range: false
  17011. },
  17012. /**
  17013. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17014. * @type {string|*}
  17015. */
  17016. day: {
  17017. main: '%e. %b'
  17018. },
  17019. /**
  17020. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17021. * @type {string|*}
  17022. */
  17023. week: {
  17024. main: '%e. %b'
  17025. },
  17026. /**
  17027. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17028. * @type {string|*}
  17029. */
  17030. month: {
  17031. main: '%b \'%y'
  17032. },
  17033. /**
  17034. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17035. * @type {string|*}
  17036. */
  17037. year: {
  17038. main: '%Y'
  17039. }
  17040. },
  17041. /**
  17042. * Whether to force the axis to end on a tick. Use this option with
  17043. * the `maxPadding` option to control the axis end.
  17044. *
  17045. * @productdesc {highstock}
  17046. * In Highstock, `endOnTick` is always `false` when the navigator
  17047. * is enabled, to prevent jumpy scrolling.
  17048. *
  17049. * @sample {highcharts} highcharts/chart/reflow-true/
  17050. * True by default
  17051. * @sample {highcharts} highcharts/yaxis/endontick/
  17052. * False
  17053. * @sample {highstock} stock/demo/basic-line/
  17054. * True by default
  17055. * @sample {highstock} stock/xaxis/endontick/
  17056. * False
  17057. *
  17058. * @since 1.2.0
  17059. */
  17060. endOnTick: false,
  17061. /**
  17062. * Event handlers for the axis.
  17063. *
  17064. * @type {*}
  17065. * @apioption xAxis.events
  17066. */
  17067. /**
  17068. * An event fired after the breaks have rendered.
  17069. *
  17070. * @see [breaks](#xAxis.breaks)
  17071. *
  17072. * @sample {highcharts} highcharts/axisbreak/break-event/
  17073. * AfterBreak Event
  17074. *
  17075. * @type {Highcharts.AxisEventCallbackFunction}
  17076. * @since 4.1.0
  17077. * @product highcharts gantt
  17078. * @apioption xAxis.events.afterBreaks
  17079. */
  17080. /**
  17081. * As opposed to the `setExtremes` event, this event fires after the
  17082. * final min and max values are computed and corrected for `minRange`.
  17083. *
  17084. * Fires when the minimum and maximum is set for the axis, either by
  17085. * calling the `.setExtremes()` method or by selecting an area in the
  17086. * chart. One parameter, `event`, is passed to the function, containing
  17087. * common event information.
  17088. *
  17089. * The new user set minimum and maximum values can be found by
  17090. * `event.min` and `event.max`. These reflect the axis minimum and
  17091. * maximum in axis values. The actual data extremes are found in
  17092. * `event.dataMin` and `event.dataMax`.
  17093. *
  17094. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  17095. * @since 2.3
  17096. * @context Highcharts.Axis
  17097. * @apioption xAxis.events.afterSetExtremes
  17098. */
  17099. /**
  17100. * An event fired when a break from this axis occurs on a point.
  17101. *
  17102. * @see [breaks](#xAxis.breaks)
  17103. *
  17104. * @sample {highcharts} highcharts/axisbreak/break-visualized/
  17105. * Visualization of a Break
  17106. *
  17107. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  17108. * @since 4.1.0
  17109. * @product highcharts gantt
  17110. * @context Highcharts.Axis
  17111. * @apioption xAxis.events.pointBreak
  17112. */
  17113. /**
  17114. * An event fired when a point falls inside a break from this axis.
  17115. *
  17116. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  17117. * @product highcharts highstock gantt
  17118. * @context Highcharts.Axis
  17119. * @apioption xAxis.events.pointInBreak
  17120. */
  17121. /**
  17122. * Fires when the minimum and maximum is set for the axis, either by
  17123. * calling the `.setExtremes()` method or by selecting an area in the
  17124. * chart. One parameter, `event`, is passed to the function,
  17125. * containing common event information.
  17126. *
  17127. * The new user set minimum and maximum values can be found by
  17128. * `event.min` and `event.max`. These reflect the axis minimum and
  17129. * maximum in data values. When an axis is zoomed all the way out from
  17130. * the "Reset zoom" button, `event.min` and `event.max` are null, and
  17131. * the new extremes are set based on `this.dataMin` and `this.dataMax`.
  17132. *
  17133. * @sample {highstock} stock/xaxis/events-setextremes/
  17134. * Log new extremes on x axis
  17135. *
  17136. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  17137. * @since 1.2.0
  17138. * @context Highcharts.Axis
  17139. * @apioption xAxis.events.setExtremes
  17140. */
  17141. /**
  17142. * The lowest allowed value for automatically computed axis extremes.
  17143. *
  17144. * @see [ceiling](#yAxis.ceiling)
  17145. *
  17146. * @sample {highcharts} highcharts/yaxis/floor-ceiling/
  17147. * Floor and ceiling
  17148. * @sample {highstock} stock/demo/lazy-loading/
  17149. * Prevent negative stock price on Y axis
  17150. *
  17151. * @type {number}
  17152. * @since 4.0
  17153. * @product highcharts highstock gantt
  17154. * @apioption xAxis.floor
  17155. */
  17156. /**
  17157. * The dash or dot style of the grid lines. For possible values, see
  17158. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  17159. *
  17160. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  17161. * Long dashes
  17162. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  17163. * Long dashes
  17164. *
  17165. * @type {Highcharts.DashStyleValue}
  17166. * @default Solid
  17167. * @since 1.2
  17168. * @apioption xAxis.gridLineDashStyle
  17169. */
  17170. /**
  17171. * The Z index of the grid lines.
  17172. *
  17173. * @sample {highcharts|highstock} highcharts/xaxis/gridzindex/
  17174. * A Z index of 4 renders the grid above the graph
  17175. *
  17176. * @type {number}
  17177. * @default 1
  17178. * @product highcharts highstock gantt
  17179. * @apioption xAxis.gridZIndex
  17180. */
  17181. /**
  17182. * An id for the axis. This can be used after render time to get
  17183. * a pointer to the axis object through `chart.get()`.
  17184. *
  17185. * @sample {highcharts} highcharts/xaxis/id/
  17186. * Get the object
  17187. * @sample {highstock} stock/xaxis/id/
  17188. * Get the object
  17189. *
  17190. * @type {string}
  17191. * @since 1.2.0
  17192. * @apioption xAxis.id
  17193. */
  17194. /**
  17195. * The axis labels show the number or category for each tick.
  17196. *
  17197. * Since v8.0.0: Labels are animated in categorized x-axis with
  17198. * updating data if `tickInterval` and `step` is set to 1.
  17199. *
  17200. * @productdesc {highmaps}
  17201. * X and Y axis labels are by default disabled in Highmaps, but the
  17202. * functionality is inherited from Highcharts and used on `colorAxis`,
  17203. * and can be enabled on X and Y axes too.
  17204. */
  17205. labels: {
  17206. /**
  17207. * What part of the string the given position is anchored to.
  17208. * If `left`, the left side of the string is at the axis position.
  17209. * Can be one of `"left"`, `"center"` or `"right"`. Defaults to
  17210. * an intelligent guess based on which side of the chart the axis
  17211. * is on and the rotation of the label.
  17212. *
  17213. * @see [reserveSpace](#xAxis.labels.reserveSpace)
  17214. *
  17215. * @sample {highcharts} highcharts/xaxis/labels-align-left/
  17216. * Left
  17217. * @sample {highcharts} highcharts/xaxis/labels-align-right/
  17218. * Right
  17219. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  17220. * Left-aligned labels on a vertical category axis
  17221. *
  17222. * @type {Highcharts.AlignValue}
  17223. * @apioption xAxis.labels.align
  17224. */
  17225. /**
  17226. * For horizontal axes, the allowed degrees of label rotation
  17227. * to prevent overlapping labels. If there is enough space,
  17228. * labels are not rotated. As the chart gets narrower, it
  17229. * will start rotating the labels -45 degrees, then remove
  17230. * every second label and try again with rotations 0 and -45 etc.
  17231. * Set it to `false` to disable rotation, which will
  17232. * cause the labels to word-wrap if possible.
  17233. *
  17234. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-default/
  17235. * Default auto rotation of 0 or -45
  17236. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-0-90/
  17237. * Custom graded auto rotation
  17238. *
  17239. * @type {Array<number>|false}
  17240. * @default [-45]
  17241. * @since 4.1.0
  17242. * @product highcharts highstock gantt
  17243. * @apioption xAxis.labels.autoRotation
  17244. */
  17245. /**
  17246. * When each category width is more than this many pixels, we don't
  17247. * apply auto rotation. Instead, we lay out the axis label with word
  17248. * wrap. A lower limit makes sense when the label contains multiple
  17249. * short words that don't extend the available horizontal space for
  17250. * each label.
  17251. *
  17252. * @sample {highcharts} highcharts/xaxis/labels-autorotationlimit/
  17253. * Lower limit
  17254. *
  17255. * @type {number}
  17256. * @default 80
  17257. * @since 4.1.5
  17258. * @product highcharts gantt
  17259. * @apioption xAxis.labels.autoRotationLimit
  17260. */
  17261. /**
  17262. * Polar charts only. The label's pixel distance from the perimeter
  17263. * of the plot area.
  17264. *
  17265. * @type {number}
  17266. * @default 15
  17267. * @product highcharts gantt
  17268. * @apioption xAxis.labels.distance
  17269. */
  17270. /**
  17271. * Enable or disable the axis labels.
  17272. *
  17273. * @sample {highcharts} highcharts/xaxis/labels-enabled/
  17274. * X axis labels disabled
  17275. * @sample {highstock} stock/xaxis/labels-enabled/
  17276. * X axis labels disabled
  17277. *
  17278. * @default {highcharts|highstock|gantt} true
  17279. * @default {highmaps} false
  17280. */
  17281. enabled: true,
  17282. /**
  17283. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  17284. * for the axis label.
  17285. *
  17286. * @sample {highcharts|highstock} highcharts/yaxis/labels-format/
  17287. * Add units to Y axis label
  17288. *
  17289. * @type {string}
  17290. * @default {value}
  17291. * @since 3.0
  17292. * @apioption xAxis.labels.format
  17293. */
  17294. /**
  17295. * Callback JavaScript function to format the label. The value
  17296. * is given by `this.value`. Additional properties for `this` are
  17297. * `axis`, `chart`, `isFirst` and `isLast`. The value of the default
  17298. * label formatter can be retrieved by calling
  17299. * `this.axis.defaultLabelFormatter.call(this)` within the function.
  17300. *
  17301. * Defaults to:
  17302. * ```js
  17303. * function() {
  17304. * return this.value;
  17305. * }
  17306. * ```
  17307. *
  17308. * @sample {highcharts} highcharts/xaxis/labels-formatter-linked/
  17309. * Linked category names
  17310. * @sample {highcharts} highcharts/xaxis/labels-formatter-extended/
  17311. * Modified numeric labels
  17312. * @sample {highstock} stock/xaxis/labels-formatter/
  17313. * Added units on Y axis
  17314. *
  17315. * @type {Highcharts.AxisLabelsFormatterCallbackFunction}
  17316. * @apioption xAxis.labels.formatter
  17317. */
  17318. /**
  17319. * The number of pixels to indent the labels per level in a treegrid
  17320. * axis.
  17321. *
  17322. * @sample gantt/treegrid-axis/demo
  17323. * Indentation 10px by default.
  17324. * @sample gantt/treegrid-axis/indentation-0px
  17325. * Indentation set to 0px.
  17326. *
  17327. * @product gantt
  17328. */
  17329. indentation: 10,
  17330. /**
  17331. * Horizontal axis only. When `staggerLines` is not set,
  17332. * `maxStaggerLines` defines how many lines the axis is allowed to
  17333. * add to automatically avoid overlapping X labels. Set to `1` to
  17334. * disable overlap detection.
  17335. *
  17336. * @deprecated
  17337. * @type {number}
  17338. * @default 5
  17339. * @since 1.3.3
  17340. * @apioption xAxis.labels.maxStaggerLines
  17341. */
  17342. /**
  17343. * How to handle overflowing labels on horizontal axis. If set to
  17344. * `"allow"`, it will not be aligned at all. By default it
  17345. * `"justify"` labels inside the chart area. If there is room to
  17346. * move it, it will be aligned to the edge, else it will be removed.
  17347. *
  17348. * @type {string}
  17349. * @default justify
  17350. * @since 2.2.5
  17351. * @validvalue ["allow", "justify"]
  17352. * @apioption xAxis.labels.overflow
  17353. */
  17354. /**
  17355. * The pixel padding for axis labels, to ensure white space between
  17356. * them.
  17357. *
  17358. * @type {number}
  17359. * @default 5
  17360. * @product highcharts gantt
  17361. * @apioption xAxis.labels.padding
  17362. */
  17363. /**
  17364. * Whether to reserve space for the labels. By default, space is
  17365. * reserved for the labels in these cases:
  17366. *
  17367. * * On all horizontal axes.
  17368. * * On vertical axes if `label.align` is `right` on a left-side
  17369. * axis or `left` on a right-side axis.
  17370. * * On vertical axes if `label.align` is `center`.
  17371. *
  17372. * This can be turned off when for example the labels are rendered
  17373. * inside the plot area instead of outside.
  17374. *
  17375. * @see [labels.align](#xAxis.labels.align)
  17376. *
  17377. * @sample {highcharts} highcharts/xaxis/labels-reservespace/
  17378. * No reserved space, labels inside plot
  17379. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  17380. * Left-aligned labels on a vertical category axis
  17381. *
  17382. * @type {boolean}
  17383. * @since 4.1.10
  17384. * @product highcharts gantt
  17385. * @apioption xAxis.labels.reserveSpace
  17386. */
  17387. /**
  17388. * Rotation of the labels in degrees.
  17389. *
  17390. * @sample {highcharts} highcharts/xaxis/labels-rotation/
  17391. * X axis labels rotated 90°
  17392. *
  17393. * @type {number}
  17394. * @default 0
  17395. * @apioption xAxis.labels.rotation
  17396. */
  17397. /**
  17398. * Horizontal axes only. The number of lines to spread the labels
  17399. * over to make room or tighter labels.
  17400. *
  17401. * @sample {highcharts} highcharts/xaxis/labels-staggerlines/
  17402. * Show labels over two lines
  17403. * @sample {highstock} stock/xaxis/labels-staggerlines/
  17404. * Show labels over two lines
  17405. *
  17406. * @type {number}
  17407. * @since 2.1
  17408. * @apioption xAxis.labels.staggerLines
  17409. */
  17410. /**
  17411. * To show only every _n_'th label on the axis, set the step to _n_.
  17412. * Setting the step to 2 shows every other label.
  17413. *
  17414. * By default, the step is calculated automatically to avoid
  17415. * overlap. To prevent this, set it to 1\. This usually only
  17416. * happens on a category axis, and is often a sign that you have
  17417. * chosen the wrong axis type.
  17418. *
  17419. * Read more at
  17420. * [Axis docs](https://www.highcharts.com/docs/chart-concepts/axes)
  17421. * => What axis should I use?
  17422. *
  17423. * @sample {highcharts} highcharts/xaxis/labels-step/
  17424. * Showing only every other axis label on a categorized
  17425. * x-axis
  17426. * @sample {highcharts} highcharts/xaxis/labels-step-auto/
  17427. * Auto steps on a category axis
  17428. *
  17429. * @type {number}
  17430. * @since 2.1
  17431. * @apioption xAxis.labels.step
  17432. */
  17433. /**
  17434. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  17435. * to render the labels.
  17436. *
  17437. * @type {boolean}
  17438. * @default false
  17439. * @apioption xAxis.labels.useHTML
  17440. */
  17441. /**
  17442. * The x position offset of the label relative to the tick position
  17443. * on the axis.
  17444. *
  17445. * @sample {highcharts} highcharts/xaxis/labels-x/
  17446. * Y axis labels placed on grid lines
  17447. */
  17448. x: 0,
  17449. /**
  17450. * The y position offset of the label relative to the tick position
  17451. * on the axis. The default makes it adapt to the font size on
  17452. * bottom axis.
  17453. *
  17454. * @sample {highcharts} highcharts/xaxis/labels-x/
  17455. * Y axis labels placed on grid lines
  17456. *
  17457. * @type {number}
  17458. * @apioption xAxis.labels.y
  17459. */
  17460. /**
  17461. * The Z index for the axis labels.
  17462. *
  17463. * @type {number}
  17464. * @default 7
  17465. * @apioption xAxis.labels.zIndex
  17466. */
  17467. /**
  17468. * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
  17469. * wrapping of category labels. Use `textOverflow: 'none'` to
  17470. * prevent ellipsis (dots).
  17471. *
  17472. * In styled mode, the labels are styled with the
  17473. * `.highcharts-axis-labels` class.
  17474. *
  17475. * @sample {highcharts} highcharts/xaxis/labels-style/
  17476. * Red X axis labels
  17477. *
  17478. * @type {Highcharts.CSSObject}
  17479. */
  17480. style: {
  17481. /** @internal */
  17482. color: '#666666',
  17483. /** @internal */
  17484. cursor: 'default',
  17485. /** @internal */
  17486. fontSize: '11px'
  17487. }
  17488. },
  17489. /**
  17490. * The left position as the horizontal axis. If it's a number, it is
  17491. * interpreted as pixel position relative to the chart.
  17492. *
  17493. * Since Highcharts v5.0.13: If it's a percentage string, it is
  17494. * interpreted as percentages of the plot width, offset from plot area
  17495. * left.
  17496. *
  17497. * @type {number|string}
  17498. * @product highcharts highstock
  17499. * @apioption xAxis.left
  17500. */
  17501. /**
  17502. * The top position as the vertical axis. If it's a number, it is
  17503. * interpreted as pixel position relative to the chart.
  17504. *
  17505. * Since Highcharts 2: If it's a percentage string, it is interpreted
  17506. * as percentages of the plot height, offset from plot area top.
  17507. *
  17508. * @type {number|string}
  17509. * @product highcharts highstock
  17510. * @apioption xAxis.top
  17511. */
  17512. /**
  17513. * Index of another axis that this axis is linked to. When an axis is
  17514. * linked to a master axis, it will take the same extremes as
  17515. * the master, but as assigned by min or max or by setExtremes.
  17516. * It can be used to show additional info, or to ease reading the
  17517. * chart by duplicating the scales.
  17518. *
  17519. * @sample {highcharts} highcharts/xaxis/linkedto/
  17520. * Different string formats of the same date
  17521. * @sample {highcharts} highcharts/yaxis/linkedto/
  17522. * Y values on both sides
  17523. *
  17524. * @type {number}
  17525. * @since 2.0.2
  17526. * @product highcharts highstock gantt
  17527. * @apioption xAxis.linkedTo
  17528. */
  17529. /**
  17530. * The maximum value of the axis. If `null`, the max value is
  17531. * automatically calculated.
  17532. *
  17533. * If the [endOnTick](#yAxis.endOnTick) option is true, the `max` value
  17534. * might be rounded up.
  17535. *
  17536. * If a [tickAmount](#yAxis.tickAmount) is set, the axis may be extended
  17537. * beyond the set max in order to reach the given number of ticks. The
  17538. * same may happen in a chart with multiple axes, determined by [chart.
  17539. * alignTicks](#chart), where a `tickAmount` is applied internally.
  17540. *
  17541. * @sample {highcharts} highcharts/yaxis/max-200/
  17542. * Y axis max of 200
  17543. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  17544. * Y axis max on logarithmic axis
  17545. * @sample {highstock} stock/xaxis/min-max/
  17546. * Fixed min and max on X axis
  17547. * @sample {highmaps} maps/axis/min-max/
  17548. * Pre-zoomed to a specific area
  17549. *
  17550. * @type {number|null}
  17551. * @apioption xAxis.max
  17552. */
  17553. /**
  17554. * Padding of the max value relative to the length of the axis. A
  17555. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  17556. * when you don't want the highest data value to appear on the edge
  17557. * of the plot area. When the axis' `max` option is set or a max extreme
  17558. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  17559. *
  17560. * @sample {highcharts} highcharts/yaxis/maxpadding/
  17561. * Max padding of 0.25 on y axis
  17562. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  17563. * Greater min- and maxPadding
  17564. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  17565. * Add some padding
  17566. *
  17567. * @default {highcharts} 0.01
  17568. * @default {highstock|highmaps} 0
  17569. * @since 1.2.0
  17570. */
  17571. maxPadding: 0.01,
  17572. /**
  17573. * Deprecated. Use `minRange` instead.
  17574. *
  17575. * @deprecated
  17576. * @type {number}
  17577. * @product highcharts highstock
  17578. * @apioption xAxis.maxZoom
  17579. */
  17580. /**
  17581. * The minimum value of the axis. If `null` the min value is
  17582. * automatically calculated.
  17583. *
  17584. * If the [startOnTick](#yAxis.startOnTick) option is true (default),
  17585. * the `min` value might be rounded down.
  17586. *
  17587. * The automatically calculated minimum value is also affected by
  17588. * [floor](#yAxis.floor), [softMin](#yAxis.softMin),
  17589. * [minPadding](#yAxis.minPadding), [minRange](#yAxis.minRange)
  17590. * as well as [series.threshold](#plotOptions.series.threshold)
  17591. * and [series.softThreshold](#plotOptions.series.softThreshold).
  17592. *
  17593. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  17594. * -50 with startOnTick to false
  17595. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  17596. * -50 with startOnTick true by default
  17597. * @sample {highstock} stock/xaxis/min-max/
  17598. * Set min and max on X axis
  17599. * @sample {highmaps} maps/axis/min-max/
  17600. * Pre-zoomed to a specific area
  17601. *
  17602. * @type {number|null}
  17603. * @apioption xAxis.min
  17604. */
  17605. /**
  17606. * The dash or dot style of the minor grid lines. For possible values,
  17607. * see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  17608. *
  17609. * @sample {highcharts} highcharts/yaxis/minorgridlinedashstyle/
  17610. * Long dashes on minor grid lines
  17611. * @sample {highstock} stock/xaxis/minorgridlinedashstyle/
  17612. * Long dashes on minor grid lines
  17613. *
  17614. * @type {Highcharts.DashStyleValue}
  17615. * @default Solid
  17616. * @since 1.2
  17617. * @apioption xAxis.minorGridLineDashStyle
  17618. */
  17619. /**
  17620. * Specific tick interval in axis units for the minor ticks. On a linear
  17621. * axis, if `"auto"`, the minor tick interval is calculated as a fifth
  17622. * of the tickInterval. If `null` or `undefined`, minor ticks are not
  17623. * shown.
  17624. *
  17625. * On logarithmic axes, the unit is the power of the value. For example,
  17626. * setting the minorTickInterval to 1 puts one tick on each of 0.1, 1,
  17627. * 10, 100 etc. Setting the minorTickInterval to 0.1 produces 9 ticks
  17628. * between 1 and 10, 10 and 100 etc.
  17629. *
  17630. * If user settings dictate minor ticks to become too dense, they don't
  17631. * make sense, and will be ignored to prevent performance problems.
  17632. *
  17633. * @sample {highcharts} highcharts/yaxis/minortickinterval-null/
  17634. * Null by default
  17635. * @sample {highcharts} highcharts/yaxis/minortickinterval-5/
  17636. * 5 units
  17637. * @sample {highcharts} highcharts/yaxis/minortickinterval-log-auto/
  17638. * "auto"
  17639. * @sample {highcharts} highcharts/yaxis/minortickinterval-log/
  17640. * 0.1
  17641. * @sample {highstock} stock/demo/basic-line/
  17642. * Null by default
  17643. * @sample {highstock} stock/xaxis/minortickinterval-auto/
  17644. * "auto"
  17645. *
  17646. * @type {number|string|null}
  17647. * @apioption xAxis.minorTickInterval
  17648. */
  17649. /**
  17650. * The pixel length of the minor tick marks.
  17651. *
  17652. * @sample {highcharts} highcharts/yaxis/minorticklength/
  17653. * 10px on Y axis
  17654. * @sample {highstock} stock/xaxis/minorticks/
  17655. * 10px on Y axis
  17656. */
  17657. minorTickLength: 2,
  17658. /**
  17659. * The position of the minor tick marks relative to the axis line.
  17660. * Can be one of `inside` and `outside`.
  17661. *
  17662. * @sample {highcharts} highcharts/yaxis/minortickposition-outside/
  17663. * Outside by default
  17664. * @sample {highcharts} highcharts/yaxis/minortickposition-inside/
  17665. * Inside
  17666. * @sample {highstock} stock/xaxis/minorticks/
  17667. * Inside
  17668. *
  17669. * @validvalue ["inside", "outside"]
  17670. */
  17671. minorTickPosition: 'outside',
  17672. /**
  17673. * Enable or disable minor ticks. Unless
  17674. * [minorTickInterval](#xAxis.minorTickInterval) is set, the tick
  17675. * interval is calculated as a fifth of the `tickInterval`.
  17676. *
  17677. * On a logarithmic axis, minor ticks are laid out based on a best
  17678. * guess, attempting to enter approximately 5 minor ticks between
  17679. * each major tick.
  17680. *
  17681. * Prior to v6.0.0, ticks were unabled in auto layout by setting
  17682. * `minorTickInterval` to `"auto"`.
  17683. *
  17684. * @productdesc {highcharts}
  17685. * On axes using [categories](#xAxis.categories), minor ticks are not
  17686. * supported.
  17687. *
  17688. * @sample {highcharts} highcharts/yaxis/minorticks-true/
  17689. * Enabled on linear Y axis
  17690. *
  17691. * @type {boolean}
  17692. * @default false
  17693. * @since 6.0.0
  17694. * @apioption xAxis.minorTicks
  17695. */
  17696. /**
  17697. * The pixel width of the minor tick mark.
  17698. *
  17699. * @sample {highcharts} highcharts/yaxis/minortickwidth/
  17700. * 3px width
  17701. * @sample {highstock} stock/xaxis/minorticks/
  17702. * 1px width
  17703. *
  17704. * @type {number}
  17705. * @default 0
  17706. * @apioption xAxis.minorTickWidth
  17707. */
  17708. /**
  17709. * Padding of the min value relative to the length of the axis. A
  17710. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  17711. * when you don't want the lowest data value to appear on the edge
  17712. * of the plot area. When the axis' `min` option is set or a min extreme
  17713. * is set using `axis.setExtremes()`, the minPadding will be ignored.
  17714. *
  17715. * @sample {highcharts} highcharts/yaxis/minpadding/
  17716. * Min padding of 0.2
  17717. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  17718. * Greater min- and maxPadding
  17719. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  17720. * Add some padding
  17721. *
  17722. * @default {highcharts} 0.01
  17723. * @default {highstock|highmaps} 0
  17724. * @since 1.2.0
  17725. * @product highcharts highstock gantt
  17726. */
  17727. minPadding: 0.01,
  17728. /**
  17729. * The minimum range to display on this axis. The entire axis will not
  17730. * be allowed to span over a smaller interval than this. For example,
  17731. * for a datetime axis the main unit is milliseconds. If minRange is
  17732. * set to 3600000, you can't zoom in more than to one hour.
  17733. *
  17734. * The default minRange for the x axis is five times the smallest
  17735. * interval between any of the data points.
  17736. *
  17737. * On a logarithmic axis, the unit for the minimum range is the power.
  17738. * So a minRange of 1 means that the axis can be zoomed to 10-100,
  17739. * 100-1000, 1000-10000 etc.
  17740. *
  17741. * **Note**: The `minPadding`, `maxPadding`, `startOnTick` and
  17742. * `endOnTick` settings also affect how the extremes of the axis
  17743. * are computed.
  17744. *
  17745. * @sample {highcharts} highcharts/xaxis/minrange/
  17746. * Minimum range of 5
  17747. * @sample {highstock} stock/xaxis/minrange/
  17748. * Max zoom of 6 months overrides user selections
  17749. * @sample {highmaps} maps/axis/minrange/
  17750. * Minimum range of 1000
  17751. *
  17752. * @type {number}
  17753. * @apioption xAxis.minRange
  17754. */
  17755. /**
  17756. * The minimum tick interval allowed in axis values. For example on
  17757. * zooming in on an axis with daily data, this can be used to prevent
  17758. * the axis from showing hours. Defaults to the closest distance between
  17759. * two points on the axis.
  17760. *
  17761. * @type {number}
  17762. * @since 2.3.0
  17763. * @apioption xAxis.minTickInterval
  17764. */
  17765. /**
  17766. * The distance in pixels from the plot area to the axis line.
  17767. * A positive offset moves the axis with it's line, labels and ticks
  17768. * away from the plot area. This is typically used when two or more
  17769. * axes are displayed on the same side of the plot. With multiple
  17770. * axes the offset is dynamically adjusted to avoid collision, this
  17771. * can be overridden by setting offset explicitly.
  17772. *
  17773. * @sample {highcharts} highcharts/yaxis/offset/
  17774. * Y axis offset of 70
  17775. * @sample {highcharts} highcharts/yaxis/offset-centered/
  17776. * Axes positioned in the center of the plot
  17777. * @sample {highstock} stock/xaxis/offset/
  17778. * Y axis offset by 70 px
  17779. *
  17780. * @type {number}
  17781. * @default 0
  17782. * @apioption xAxis.offset
  17783. */
  17784. /**
  17785. * Whether to display the axis on the opposite side of the normal. The
  17786. * normal is on the left side for vertical axes and bottom for
  17787. * horizontal, so the opposite sides will be right and top respectively.
  17788. * This is typically used with dual or multiple axes.
  17789. *
  17790. * @sample {highcharts} highcharts/yaxis/opposite/
  17791. * Secondary Y axis opposite
  17792. * @sample {highstock} stock/xaxis/opposite/
  17793. * Y axis on left side
  17794. *
  17795. * @type {boolean}
  17796. * @default false
  17797. * @apioption xAxis.opposite
  17798. */
  17799. /**
  17800. * In an ordinal axis, the points are equally spaced in the chart
  17801. * regardless of the actual time or x distance between them. This means
  17802. * that missing data periods (e.g. nights or weekends for a stock chart)
  17803. * will not take up space in the chart.
  17804. * Having `ordinal: false` will show any gaps created by the `gapSize`
  17805. * setting proportionate to their duration.
  17806. *
  17807. * In stock charts the X axis is ordinal by default, unless
  17808. * the boost module is used and at least one of the series' data length
  17809. * exceeds the [boostThreshold](#series.line.boostThreshold).
  17810. *
  17811. * @sample {highstock} stock/xaxis/ordinal-true/
  17812. * True by default
  17813. * @sample {highstock} stock/xaxis/ordinal-false/
  17814. * False
  17815. *
  17816. * @type {boolean}
  17817. * @default true
  17818. * @since 1.1
  17819. * @product highstock
  17820. * @apioption xAxis.ordinal
  17821. */
  17822. /**
  17823. * Additional range on the right side of the xAxis. Works similar to
  17824. * `xAxis.maxPadding`, but value is set in milliseconds. Can be set for
  17825. * both main `xAxis` and the navigator's `xAxis`.
  17826. *
  17827. * @sample {highstock} stock/xaxis/overscroll/
  17828. * One minute overscroll with live data
  17829. *
  17830. * @type {number}
  17831. * @default 0
  17832. * @since 6.0.0
  17833. * @product highstock
  17834. * @apioption xAxis.overscroll
  17835. */
  17836. /**
  17837. * Refers to the index in the [panes](#panes) array. Used for circular
  17838. * gauges and polar charts. When the option is not set then first pane
  17839. * will be used.
  17840. *
  17841. * @sample highcharts/demo/gauge-vu-meter
  17842. * Two gauges with different center
  17843. *
  17844. * @type {number}
  17845. * @product highcharts
  17846. * @apioption xAxis.pane
  17847. */
  17848. /**
  17849. * The zoomed range to display when only defining one or none of `min`
  17850. * or `max`. For example, to show the latest month, a range of one month
  17851. * can be set.
  17852. *
  17853. * @sample {highstock} stock/xaxis/range/
  17854. * Setting a zoomed range when the rangeSelector is disabled
  17855. *
  17856. * @type {number}
  17857. * @product highstock
  17858. * @apioption xAxis.range
  17859. */
  17860. /**
  17861. * Whether to reverse the axis so that the highest number is closest
  17862. * to the origin. If the chart is inverted, the x axis is reversed by
  17863. * default.
  17864. *
  17865. * @sample {highcharts} highcharts/yaxis/reversed/
  17866. * Reversed Y axis
  17867. * @sample {highstock} stock/xaxis/reversed/
  17868. * Reversed Y axis
  17869. *
  17870. * @type {boolean}
  17871. * @default false
  17872. * @apioption xAxis.reversed
  17873. */
  17874. // reversed: false,
  17875. /**
  17876. * This option determines how stacks should be ordered within a group.
  17877. * For example reversed xAxis also reverses stacks, so first series
  17878. * comes last in a group. To keep order like for non-reversed xAxis
  17879. * enable this option.
  17880. *
  17881. * @sample {highcharts} highcharts/xaxis/reversedstacks/
  17882. * Reversed stacks comparison
  17883. * @sample {highstock} highcharts/xaxis/reversedstacks/
  17884. * Reversed stacks comparison
  17885. *
  17886. * @type {boolean}
  17887. * @default false
  17888. * @since 6.1.1
  17889. * @product highcharts highstock
  17890. * @apioption xAxis.reversedStacks
  17891. */
  17892. /**
  17893. * An optional scrollbar to display on the X axis in response to
  17894. * limiting the minimum and maximum of the axis values.
  17895. *
  17896. * In styled mode, all the presentational options for the scrollbar are
  17897. * replaced by the classes `.highcharts-scrollbar-thumb`,
  17898. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  17899. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  17900. *
  17901. * @sample {highstock} stock/yaxis/heatmap-scrollbars/
  17902. * Heatmap with both scrollbars
  17903. *
  17904. * @extends scrollbar
  17905. * @since 4.2.6
  17906. * @product highstock
  17907. * @apioption xAxis.scrollbar
  17908. */
  17909. /**
  17910. * Whether to show the axis line and title when the axis has no data.
  17911. *
  17912. * @sample {highcharts} highcharts/yaxis/showempty/
  17913. * When clicking the legend to hide series, one axis preserves
  17914. * line and title, the other doesn't
  17915. * @sample {highstock} highcharts/yaxis/showempty/
  17916. * When clicking the legend to hide series, one axis preserves
  17917. * line and title, the other doesn't
  17918. *
  17919. * @since 1.1
  17920. */
  17921. showEmpty: true,
  17922. /**
  17923. * Whether to show the first tick label.
  17924. *
  17925. * @sample {highcharts} highcharts/xaxis/showfirstlabel-false/
  17926. * Set to false on X axis
  17927. * @sample {highstock} stock/xaxis/showfirstlabel/
  17928. * Labels below plot lines on Y axis
  17929. *
  17930. * @type {boolean}
  17931. * @default true
  17932. * @apioption xAxis.showFirstLabel
  17933. */
  17934. /**
  17935. * Whether to show the last tick label. Defaults to `true` on cartesian
  17936. * charts, and `false` on polar charts.
  17937. *
  17938. * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
  17939. * Set to true on X axis
  17940. * @sample {highstock} stock/xaxis/showfirstlabel/
  17941. * Labels below plot lines on Y axis
  17942. *
  17943. * @type {boolean}
  17944. * @default true
  17945. * @product highcharts highstock gantt
  17946. * @apioption xAxis.showLastLabel
  17947. */
  17948. /**
  17949. * A soft maximum for the axis. If the series data maximum is less than
  17950. * this, the axis will stay at this maximum, but if the series data
  17951. * maximum is higher, the axis will flex to show all data.
  17952. *
  17953. * @sample highcharts/yaxis/softmin-softmax/
  17954. * Soft min and max
  17955. *
  17956. * @type {number}
  17957. * @since 5.0.1
  17958. * @product highcharts highstock gantt
  17959. * @apioption xAxis.softMax
  17960. */
  17961. /**
  17962. * A soft minimum for the axis. If the series data minimum is greater
  17963. * than this, the axis will stay at this minimum, but if the series
  17964. * data minimum is lower, the axis will flex to show all data.
  17965. *
  17966. * @sample highcharts/yaxis/softmin-softmax/
  17967. * Soft min and max
  17968. *
  17969. * @type {number}
  17970. * @since 5.0.1
  17971. * @product highcharts highstock gantt
  17972. * @apioption xAxis.softMin
  17973. */
  17974. /**
  17975. * For datetime axes, this decides where to put the tick between weeks.
  17976. * 0 = Sunday, 1 = Monday.
  17977. *
  17978. * @sample {highcharts} highcharts/xaxis/startofweek-monday/
  17979. * Monday by default
  17980. * @sample {highcharts} highcharts/xaxis/startofweek-sunday/
  17981. * Sunday
  17982. * @sample {highstock} stock/xaxis/startofweek-1
  17983. * Monday by default
  17984. * @sample {highstock} stock/xaxis/startofweek-0
  17985. * Sunday
  17986. *
  17987. * @product highcharts highstock gantt
  17988. */
  17989. startOfWeek: 1,
  17990. /**
  17991. * Whether to force the axis to start on a tick. Use this option with
  17992. * the `minPadding` option to control the axis start.
  17993. *
  17994. * @productdesc {highstock}
  17995. * In Highstock, `startOnTick` is always `false` when the navigator
  17996. * is enabled, to prevent jumpy scrolling.
  17997. *
  17998. * @sample {highcharts} highcharts/xaxis/startontick-false/
  17999. * False by default
  18000. * @sample {highcharts} highcharts/xaxis/startontick-true/
  18001. * True
  18002. *
  18003. * @since 1.2.0
  18004. */
  18005. startOnTick: false,
  18006. /**
  18007. * The amount of ticks to draw on the axis. This opens up for aligning
  18008. * the ticks of multiple charts or panes within a chart. This option
  18009. * overrides the `tickPixelInterval` option.
  18010. *
  18011. * This option only has an effect on linear axes. Datetime, logarithmic
  18012. * or category axes are not affected.
  18013. *
  18014. * @sample {highcharts} highcharts/yaxis/tickamount/
  18015. * 8 ticks on Y axis
  18016. * @sample {highstock} highcharts/yaxis/tickamount/
  18017. * 8 ticks on Y axis
  18018. *
  18019. * @type {number}
  18020. * @since 4.1.0
  18021. * @product highcharts highstock gantt
  18022. * @apioption xAxis.tickAmount
  18023. */
  18024. /**
  18025. * The interval of the tick marks in axis units. When `undefined`, the
  18026. * tick interval is computed to approximately follow the
  18027. * [tickPixelInterval](#xAxis.tickPixelInterval) on linear and datetime
  18028. * axes. On categorized axes, a `undefined` tickInterval will default to
  18029. * 1, one category. Note that datetime axes are based on milliseconds,
  18030. * so for example an interval of one day is expressed as
  18031. * `24 * 3600 * 1000`.
  18032. *
  18033. * On logarithmic axes, the tickInterval is based on powers, so a
  18034. * tickInterval of 1 means one tick on each of 0.1, 1, 10, 100 etc. A
  18035. * tickInterval of 2 means a tick of 0.1, 10, 1000 etc. A tickInterval
  18036. * of 0.2 puts a tick on 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20,
  18037. * 40 etc.
  18038. *
  18039. *
  18040. * If the tickInterval is too dense for labels to be drawn, Highcharts
  18041. * may remove ticks.
  18042. *
  18043. * If the chart has multiple axes, the [alignTicks](#chart.alignTicks)
  18044. * option may interfere with the `tickInterval` setting.
  18045. *
  18046. * @see [tickPixelInterval](#xAxis.tickPixelInterval)
  18047. * @see [tickPositions](#xAxis.tickPositions)
  18048. * @see [tickPositioner](#xAxis.tickPositioner)
  18049. *
  18050. * @sample {highcharts} highcharts/xaxis/tickinterval-5/
  18051. * Tick interval of 5 on a linear axis
  18052. * @sample {highstock} stock/xaxis/tickinterval/
  18053. * Tick interval of 0.01 on Y axis
  18054. *
  18055. * @type {number}
  18056. * @apioption xAxis.tickInterval
  18057. */
  18058. /**
  18059. * The pixel length of the main tick marks.
  18060. *
  18061. * @sample {highcharts} highcharts/xaxis/ticklength/
  18062. * 20 px tick length on the X axis
  18063. * @sample {highstock} stock/xaxis/ticks/
  18064. * Formatted ticks on X axis
  18065. */
  18066. tickLength: 10,
  18067. /**
  18068. * If tickInterval is `null` this option sets the approximate pixel
  18069. * interval of the tick marks. Not applicable to categorized axis.
  18070. *
  18071. * The tick interval is also influenced by the [minTickInterval](
  18072. * #xAxis.minTickInterval) option, that, by default prevents ticks from
  18073. * being denser than the data points.
  18074. *
  18075. * @see [tickInterval](#xAxis.tickInterval)
  18076. * @see [tickPositioner](#xAxis.tickPositioner)
  18077. * @see [tickPositions](#xAxis.tickPositions)
  18078. *
  18079. * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
  18080. * 50 px on X axis
  18081. * @sample {highstock} stock/xaxis/tickpixelinterval/
  18082. * 200 px on X axis
  18083. */
  18084. tickPixelInterval: 100,
  18085. /**
  18086. * For categorized axes only. If `on` the tick mark is placed in the
  18087. * center of the category, if `between` the tick mark is placed between
  18088. * categories. The default is `between` if the `tickInterval` is 1, else
  18089. * `on`.
  18090. *
  18091. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
  18092. * "between" by default
  18093. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
  18094. * "on"
  18095. *
  18096. * @product highcharts gantt
  18097. * @validvalue ["on", "between"]
  18098. */
  18099. tickmarkPlacement: 'between',
  18100. /**
  18101. * The position of the major tick marks relative to the axis line.
  18102. * Can be one of `inside` and `outside`.
  18103. *
  18104. * @sample {highcharts} highcharts/xaxis/tickposition-outside/
  18105. * "outside" by default
  18106. * @sample {highcharts} highcharts/xaxis/tickposition-inside/
  18107. * "inside"
  18108. * @sample {highstock} stock/xaxis/ticks/
  18109. * Formatted ticks on X axis
  18110. *
  18111. * @validvalue ["inside", "outside"]
  18112. */
  18113. tickPosition: 'outside',
  18114. /**
  18115. * A callback function returning array defining where the ticks are
  18116. * laid out on the axis. This overrides the default behaviour of
  18117. * [tickPixelInterval](#xAxis.tickPixelInterval) and [tickInterval](
  18118. * #xAxis.tickInterval). The automatic tick positions are accessible
  18119. * through `this.tickPositions` and can be modified by the callback.
  18120. *
  18121. * @see [tickPositions](#xAxis.tickPositions)
  18122. *
  18123. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  18124. * Demo of tickPositions and tickPositioner
  18125. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  18126. * Demo of tickPositions and tickPositioner
  18127. *
  18128. * @type {Highcharts.AxisTickPositionerCallbackFunction}
  18129. * @apioption xAxis.tickPositioner
  18130. */
  18131. /**
  18132. * An array defining where the ticks are laid out on the axis. This
  18133. * overrides the default behaviour of [tickPixelInterval](
  18134. * #xAxis.tickPixelInterval) and [tickInterval](#xAxis.tickInterval).
  18135. *
  18136. * @see [tickPositioner](#xAxis.tickPositioner)
  18137. *
  18138. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  18139. * Demo of tickPositions and tickPositioner
  18140. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  18141. * Demo of tickPositions and tickPositioner
  18142. *
  18143. * @type {Array<number>}
  18144. * @apioption xAxis.tickPositions
  18145. */
  18146. /**
  18147. * The pixel width of the major tick marks. Defaults to 0 on category
  18148. * axes, otherwise 1.
  18149. *
  18150. * In styled mode, the stroke width is given in the `.highcharts-tick`
  18151. * class, but in order for the element to be generated on category axes,
  18152. * the option must be explicitly set to 1.
  18153. *
  18154. * @sample {highcharts} highcharts/xaxis/tickwidth/
  18155. * 10 px width
  18156. * @sample {highcharts} highcharts/css/axis-grid/
  18157. * Styled mode
  18158. * @sample {highstock} stock/xaxis/ticks/
  18159. * Formatted ticks on X axis
  18160. * @sample {highstock} highcharts/css/axis-grid/
  18161. * Styled mode
  18162. *
  18163. * @type {undefined|number}
  18164. * @default {highstock} 1
  18165. * @default {highmaps} 0
  18166. * @apioption xAxis.tickWidth
  18167. */
  18168. /**
  18169. * The axis title, showing next to the axis line.
  18170. *
  18171. * @productdesc {highmaps}
  18172. * In Highmaps, the axis is hidden by default, but adding an axis title
  18173. * is still possible. X axis and Y axis titles will appear at the bottom
  18174. * and left by default.
  18175. */
  18176. title: {
  18177. /**
  18178. * Deprecated. Set the `text` to `null` to disable the title.
  18179. *
  18180. * @deprecated
  18181. * @type {boolean}
  18182. * @product highcharts
  18183. * @apioption xAxis.title.enabled
  18184. */
  18185. /**
  18186. * The pixel distance between the axis labels or line and the title.
  18187. * Defaults to 0 for horizontal axes, 10 for vertical
  18188. *
  18189. * @sample {highcharts} highcharts/xaxis/title-margin/
  18190. * Y axis title margin of 60
  18191. *
  18192. * @type {number}
  18193. * @apioption xAxis.title.margin
  18194. */
  18195. /**
  18196. * The distance of the axis title from the axis line. By default,
  18197. * this distance is computed from the offset width of the labels,
  18198. * the labels' distance from the axis and the title's margin.
  18199. * However when the offset option is set, it overrides all this.
  18200. *
  18201. * @sample {highcharts} highcharts/yaxis/title-offset/
  18202. * Place the axis title on top of the axis
  18203. * @sample {highstock} highcharts/yaxis/title-offset/
  18204. * Place the axis title on top of the Y axis
  18205. *
  18206. * @type {number}
  18207. * @since 2.2.0
  18208. * @apioption xAxis.title.offset
  18209. */
  18210. /**
  18211. * Whether to reserve space for the title when laying out the axis.
  18212. *
  18213. * @type {boolean}
  18214. * @default true
  18215. * @since 5.0.11
  18216. * @product highcharts highstock gantt
  18217. * @apioption xAxis.title.reserveSpace
  18218. */
  18219. /**
  18220. * The rotation of the text in degrees. 0 is horizontal, 270 is
  18221. * vertical reading from bottom to top.
  18222. *
  18223. * @sample {highcharts} highcharts/yaxis/title-offset/
  18224. * Horizontal
  18225. *
  18226. * @type {number}
  18227. * @default 0
  18228. * @apioption xAxis.title.rotation
  18229. */
  18230. /**
  18231. * The actual text of the axis title. It can contain basic HTML tags
  18232. * like `b`, `i` and `span` with style.
  18233. *
  18234. * @sample {highcharts} highcharts/xaxis/title-text/
  18235. * Custom HTML
  18236. * @sample {highstock} stock/xaxis/title-text/
  18237. * Titles for both axes
  18238. *
  18239. * @type {string|null}
  18240. * @apioption xAxis.title.text
  18241. */
  18242. /**
  18243. * Alignment of the text, can be `"left"`, `"right"` or `"center"`.
  18244. * Default alignment depends on the
  18245. * [title.align](xAxis.title.align):
  18246. *
  18247. * Horizontal axes:
  18248. * - for `align` = `"low"`, `textAlign` is set to `left`
  18249. * - for `align` = `"middle"`, `textAlign` is set to `center`
  18250. * - for `align` = `"high"`, `textAlign` is set to `right`
  18251. *
  18252. * Vertical axes:
  18253. * - for `align` = `"low"` and `opposite` = `true`, `textAlign` is
  18254. * set to `right`
  18255. * - for `align` = `"low"` and `opposite` = `false`, `textAlign` is
  18256. * set to `left`
  18257. * - for `align` = `"middle"`, `textAlign` is set to `center`
  18258. * - for `align` = `"high"` and `opposite` = `true` `textAlign` is
  18259. * set to `left`
  18260. * - for `align` = `"high"` and `opposite` = `false` `textAlign` is
  18261. * set to `right`
  18262. *
  18263. * @type {Highcharts.AlignValue}
  18264. * @apioption xAxis.title.textAlign
  18265. */
  18266. /**
  18267. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  18268. * to render the axis title.
  18269. *
  18270. * @type {boolean}
  18271. * @default false
  18272. * @product highcharts highstock gantt
  18273. * @apioption xAxis.title.useHTML
  18274. */
  18275. /**
  18276. * Horizontal pixel offset of the title position.
  18277. *
  18278. * @type {number}
  18279. * @default 0
  18280. * @since 4.1.6
  18281. * @product highcharts highstock gantt
  18282. * @apioption xAxis.title.x
  18283. */
  18284. /**
  18285. * Vertical pixel offset of the title position.
  18286. *
  18287. * @type {number}
  18288. * @product highcharts highstock gantt
  18289. * @apioption xAxis.title.y
  18290. */
  18291. /**
  18292. * Alignment of the title relative to the axis values. Possible
  18293. * values are "low", "middle" or "high".
  18294. *
  18295. * @sample {highcharts} highcharts/xaxis/title-align-low/
  18296. * "low"
  18297. * @sample {highcharts} highcharts/xaxis/title-align-center/
  18298. * "middle" by default
  18299. * @sample {highcharts} highcharts/xaxis/title-align-high/
  18300. * "high"
  18301. * @sample {highcharts} highcharts/yaxis/title-offset/
  18302. * Place the Y axis title on top of the axis
  18303. * @sample {highstock} stock/xaxis/title-align/
  18304. * Aligned to "high" value
  18305. *
  18306. * @type {Highcharts.AxisTitleAlignValue}
  18307. */
  18308. align: 'middle',
  18309. /**
  18310. * CSS styles for the title. If the title text is longer than the
  18311. * axis length, it will wrap to multiple lines by default. This can
  18312. * be customized by setting `textOverflow: 'ellipsis'`, by
  18313. * setting a specific `width` or by setting `whiteSpace: 'nowrap'`.
  18314. *
  18315. * In styled mode, the stroke width is given in the
  18316. * `.highcharts-axis-title` class.
  18317. *
  18318. * @sample {highcharts} highcharts/xaxis/title-style/
  18319. * Red
  18320. * @sample {highcharts} highcharts/css/axis/
  18321. * Styled mode
  18322. *
  18323. * @type {Highcharts.CSSObject}
  18324. */
  18325. style: {
  18326. /** @internal */
  18327. color: '#666666'
  18328. }
  18329. },
  18330. /**
  18331. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
  18332. * or `category`. In a datetime axis, the numbers are given in
  18333. * milliseconds, and tick marks are placed on appropriate values like
  18334. * full hours or days. In a category axis, the
  18335. * [point names](#series.line.data.name) of the chart's series are used
  18336. * for categories, if not a [categories](#xAxis.categories) array is
  18337. * defined.
  18338. *
  18339. * @sample {highcharts} highcharts/xaxis/type-linear/
  18340. * Linear
  18341. * @sample {highcharts} highcharts/yaxis/type-log/
  18342. * Logarithmic
  18343. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  18344. * Logarithmic with minor grid lines
  18345. * @sample {highcharts} highcharts/xaxis/type-log-both/
  18346. * Logarithmic on two axes
  18347. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  18348. * Logarithmic with extension to emulate negative values
  18349. *
  18350. * @type {Highcharts.AxisTypeValue}
  18351. * @product highcharts gantt
  18352. */
  18353. type: 'linear',
  18354. /**
  18355. * If there are multiple axes on the same side of the chart, the pixel
  18356. * margin between the axes. Defaults to 0 on vertical axes, 15 on
  18357. * horizontal axes.
  18358. *
  18359. * @type {number}
  18360. * @since 7.0.3
  18361. * @apioption xAxis.margin
  18362. */
  18363. /**
  18364. * Applies only when the axis `type` is `category`. When `uniqueNames`
  18365. * is true, points are placed on the X axis according to their names.
  18366. * If the same point name is repeated in the same or another series,
  18367. * the point is placed on the same X position as other points of the
  18368. * same name. When `uniqueNames` is false, the points are laid out in
  18369. * increasing X positions regardless of their names, and the X axis
  18370. * category will take the name of the last point in each position.
  18371. *
  18372. * @sample {highcharts} highcharts/xaxis/uniquenames-true/
  18373. * True by default
  18374. * @sample {highcharts} highcharts/xaxis/uniquenames-false/
  18375. * False
  18376. *
  18377. * @type {boolean}
  18378. * @default true
  18379. * @since 4.2.7
  18380. * @product highcharts gantt
  18381. * @apioption xAxis.uniqueNames
  18382. */
  18383. /**
  18384. * Datetime axis only. An array determining what time intervals the
  18385. * ticks are allowed to fall on. Each array item is an array where the
  18386. * first value is the time unit and the second value another array of
  18387. * allowed multiples.
  18388. *
  18389. * Defaults to:
  18390. * ```js
  18391. * units: [[
  18392. * 'millisecond', // unit name
  18393. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  18394. * ], [
  18395. * 'second',
  18396. * [1, 2, 5, 10, 15, 30]
  18397. * ], [
  18398. * 'minute',
  18399. * [1, 2, 5, 10, 15, 30]
  18400. * ], [
  18401. * 'hour',
  18402. * [1, 2, 3, 4, 6, 8, 12]
  18403. * ], [
  18404. * 'day',
  18405. * [1]
  18406. * ], [
  18407. * 'week',
  18408. * [1]
  18409. * ], [
  18410. * 'month',
  18411. * [1, 3, 6]
  18412. * ], [
  18413. * 'year',
  18414. * null
  18415. * ]]
  18416. * ```
  18417. *
  18418. * @type {Array<Array<string,(Array<number>|null)>>}
  18419. * @product highcharts highstock gantt
  18420. * @apioption xAxis.units
  18421. */
  18422. /**
  18423. * Whether axis, including axis title, line, ticks and labels, should
  18424. * be visible.
  18425. *
  18426. * @type {boolean}
  18427. * @default true
  18428. * @since 4.1.9
  18429. * @product highcharts highstock gantt
  18430. * @apioption xAxis.visible
  18431. */
  18432. /**
  18433. * Color of the minor, secondary grid lines.
  18434. *
  18435. * In styled mode, the stroke width is given in the
  18436. * `.highcharts-minor-grid-line` class.
  18437. *
  18438. * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
  18439. * Bright grey lines from Y axis
  18440. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  18441. * Styled mode
  18442. * @sample {highstock} stock/xaxis/minorgridlinecolor/
  18443. * Bright grey lines from Y axis
  18444. *
  18445. * @type {Highcharts.ColorType}
  18446. * @default #f2f2f2
  18447. */
  18448. minorGridLineColor: '#f2f2f2',
  18449. /**
  18450. * Width of the minor, secondary grid lines.
  18451. *
  18452. * In styled mode, the stroke width is given in the
  18453. * `.highcharts-grid-line` class.
  18454. *
  18455. * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
  18456. * 2px lines from Y axis
  18457. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  18458. * Styled mode
  18459. * @sample {highstock} stock/xaxis/minorgridlinewidth/
  18460. * 2px lines from Y axis
  18461. */
  18462. minorGridLineWidth: 1,
  18463. /**
  18464. * Color for the minor tick marks.
  18465. *
  18466. * @sample {highcharts} highcharts/yaxis/minortickcolor/
  18467. * Black tick marks on Y axis
  18468. * @sample {highstock} stock/xaxis/minorticks/
  18469. * Black tick marks on Y axis
  18470. *
  18471. * @type {Highcharts.ColorType}
  18472. * @default #999999
  18473. */
  18474. minorTickColor: '#999999',
  18475. /**
  18476. * The color of the line marking the axis itself.
  18477. *
  18478. * In styled mode, the line stroke is given in the
  18479. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  18480. *
  18481. * @productdesc {highmaps}
  18482. * In Highmaps, the axis line is hidden by default, because the axis is
  18483. * not visible by default.
  18484. *
  18485. * @sample {highcharts} highcharts/yaxis/linecolor/
  18486. * A red line on Y axis
  18487. * @sample {highcharts|highstock} highcharts/css/axis/
  18488. * Axes in styled mode
  18489. * @sample {highstock} stock/xaxis/linecolor/
  18490. * A red line on X axis
  18491. *
  18492. * @type {Highcharts.ColorType}
  18493. * @default #ccd6eb
  18494. */
  18495. lineColor: '#ccd6eb',
  18496. /**
  18497. * The width of the line marking the axis itself.
  18498. *
  18499. * In styled mode, the stroke width is given in the
  18500. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  18501. *
  18502. * @sample {highcharts} highcharts/yaxis/linecolor/
  18503. * A 1px line on Y axis
  18504. * @sample {highcharts|highstock} highcharts/css/axis/
  18505. * Axes in styled mode
  18506. * @sample {highstock} stock/xaxis/linewidth/
  18507. * A 2px line on X axis
  18508. *
  18509. * @default {highcharts|highstock} 1
  18510. * @default {highmaps} 0
  18511. */
  18512. lineWidth: 1,
  18513. /**
  18514. * Color of the grid lines extending the ticks across the plot area.
  18515. *
  18516. * In styled mode, the stroke is given in the `.highcharts-grid-line`
  18517. * class.
  18518. *
  18519. * @productdesc {highmaps}
  18520. * In Highmaps, the grid lines are hidden by default.
  18521. *
  18522. * @sample {highcharts} highcharts/yaxis/gridlinecolor/
  18523. * Green lines
  18524. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  18525. * Styled mode
  18526. * @sample {highstock} stock/xaxis/gridlinecolor/
  18527. * Green lines
  18528. *
  18529. * @type {Highcharts.ColorType}
  18530. * @default #e6e6e6
  18531. */
  18532. gridLineColor: '#e6e6e6',
  18533. // gridLineDashStyle: 'solid',
  18534. /**
  18535. * The width of the grid lines extending the ticks across the plot area.
  18536. *
  18537. * In styled mode, the stroke width is given in the
  18538. * `.highcharts-grid-line` class.
  18539. *
  18540. * @sample {highcharts} highcharts/yaxis/gridlinewidth/
  18541. * 2px lines
  18542. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  18543. * Styled mode
  18544. * @sample {highstock} stock/xaxis/gridlinewidth/
  18545. * 2px lines
  18546. *
  18547. * @type {number}
  18548. * @default 0
  18549. * @apioption xAxis.gridLineWidth
  18550. */
  18551. // gridLineWidth: 0,
  18552. /**
  18553. * The height as the vertical axis. If it's a number, it is
  18554. * interpreted as pixels.
  18555. *
  18556. * Since Highcharts 2: If it's a percentage string, it is interpreted
  18557. * as percentages of the total plot height.
  18558. *
  18559. * @type {number|string}
  18560. * @product highcharts highstock
  18561. * @apioption xAxis.height
  18562. */
  18563. /**
  18564. * The width as the horizontal axis. If it's a number, it is interpreted
  18565. * as pixels.
  18566. *
  18567. * Since Highcharts v5.0.13: If it's a percentage string, it is
  18568. * interpreted as percentages of the total plot width.
  18569. *
  18570. * @type {number|string}
  18571. * @product highcharts highstock
  18572. * @apioption xAxis.width
  18573. */
  18574. /**
  18575. * Color for the main tick marks.
  18576. *
  18577. * In styled mode, the stroke is given in the `.highcharts-tick`
  18578. * class.
  18579. *
  18580. * @sample {highcharts} highcharts/xaxis/tickcolor/
  18581. * Red ticks on X axis
  18582. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  18583. * Styled mode
  18584. * @sample {highstock} stock/xaxis/ticks/
  18585. * Formatted ticks on X axis
  18586. *
  18587. * @type {Highcharts.ColorType}
  18588. * @default #ccd6eb
  18589. */
  18590. tickColor: '#ccd6eb'
  18591. // tickWidth: 1
  18592. };
  18593. /**
  18594. * The Y axis or value axis. Normally this is the vertical axis,
  18595. * though if the chart is inverted this is the horizontal axis.
  18596. * In case of multiple axes, the yAxis node is an array of
  18597. * configuration objects.
  18598. *
  18599. * See [the Axis object](/class-reference/Highcharts.Axis) for programmatic
  18600. * access to the axis.
  18601. *
  18602. * @type {*|Array<*>}
  18603. * @extends xAxis
  18604. * @excluding currentDateIndicator,ordinal,overscroll
  18605. * @optionparent yAxis
  18606. *
  18607. * @private
  18608. */
  18609. Axis.defaultYAxisOptions = {
  18610. /**
  18611. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`,
  18612. * `category` or `treegrid`. Defaults to `treegrid` for Gantt charts,
  18613. * `linear` for other chart types.
  18614. *
  18615. * In a datetime axis, the numbers are given in milliseconds, and tick
  18616. * marks are placed on appropriate values, like full hours or days. In a
  18617. * category or treegrid axis, the [point names](#series.line.data.name)
  18618. * of the chart's series are used for categories, if a
  18619. * [categories](#xAxis.categories) array is not defined.
  18620. *
  18621. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  18622. * Logarithmic with minor grid lines
  18623. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  18624. * Logarithmic with extension to emulate negative values
  18625. * @sample {gantt} gantt/treegrid-axis/demo
  18626. * Treegrid axis
  18627. *
  18628. * @type {Highcharts.AxisTypeValue}
  18629. * @default {highcharts} linear
  18630. * @default {gantt} treegrid
  18631. * @product highcharts gantt
  18632. * @apioption yAxis.type
  18633. */
  18634. /**
  18635. * The height of the Y axis. If it's a number, it is interpreted as
  18636. * pixels.
  18637. *
  18638. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  18639. * percentages of the total plot height.
  18640. *
  18641. * @see [yAxis.top](#yAxis.top)
  18642. *
  18643. * @sample {highstock} stock/demo/candlestick-and-volume/
  18644. * Percentage height panes
  18645. *
  18646. * @type {number|string}
  18647. * @product highcharts highstock
  18648. * @apioption yAxis.height
  18649. */
  18650. /**
  18651. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  18652. * to represent the maximum value of the Y axis.
  18653. *
  18654. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  18655. * Min and max colors
  18656. *
  18657. * @type {Highcharts.ColorType}
  18658. * @default #003399
  18659. * @since 4.0
  18660. * @product highcharts
  18661. * @apioption yAxis.maxColor
  18662. */
  18663. /**
  18664. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  18665. * to represent the minimum value of the Y axis.
  18666. *
  18667. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  18668. * Min and max color
  18669. *
  18670. * @type {Highcharts.ColorType}
  18671. * @default #e6ebf5
  18672. * @since 4.0
  18673. * @product highcharts
  18674. * @apioption yAxis.minColor
  18675. */
  18676. /**
  18677. * Whether to reverse the axis so that the highest number is closest
  18678. * to the origin.
  18679. *
  18680. * @sample {highcharts} highcharts/yaxis/reversed/
  18681. * Reversed Y axis
  18682. * @sample {highstock} stock/xaxis/reversed/
  18683. * Reversed Y axis
  18684. *
  18685. * @type {boolean}
  18686. * @default {highcharts} false
  18687. * @default {highstock} false
  18688. * @default {highmaps} true
  18689. * @default {gantt} true
  18690. * @apioption yAxis.reversed
  18691. */
  18692. /**
  18693. * If `true`, the first series in a stack will be drawn on top in a
  18694. * positive, non-reversed Y axis. If `false`, the first series is in
  18695. * the base of the stack.
  18696. *
  18697. * @sample {highcharts} highcharts/yaxis/reversedstacks-false/
  18698. * Non-reversed stacks
  18699. * @sample {highstock} highcharts/yaxis/reversedstacks-false/
  18700. * Non-reversed stacks
  18701. *
  18702. * @type {boolean}
  18703. * @default true
  18704. * @since 3.0.10
  18705. * @product highcharts highstock
  18706. * @apioption yAxis.reversedStacks
  18707. */
  18708. /**
  18709. * Solid gauge series only. Color stops for the solid gauge. Use this
  18710. * in cases where a linear gradient between a `minColor` and `maxColor`
  18711. * is not sufficient. The stops is an array of tuples, where the first
  18712. * item is a float between 0 and 1 assigning the relative position in
  18713. * the gradient, and the second item is the color.
  18714. *
  18715. * For solid gauges, the Y axis also inherits the concept of
  18716. * [data classes](https://api.highcharts.com/highmaps#colorAxis.dataClasses)
  18717. * from the Highmaps color axis.
  18718. *
  18719. * @see [minColor](#yAxis.minColor)
  18720. * @see [maxColor](#yAxis.maxColor)
  18721. *
  18722. * @sample {highcharts} highcharts/demo/gauge-solid/
  18723. * True by default
  18724. *
  18725. * @type {Array<Highcharts.GradientColorStopObject>}
  18726. * @since 4.0
  18727. * @product highcharts
  18728. * @apioption yAxis.stops
  18729. */
  18730. /**
  18731. * The pixel width of the major tick marks.
  18732. *
  18733. * @sample {highcharts} highcharts/xaxis/tickwidth/ 10 px width
  18734. * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
  18735. *
  18736. * @type {number}
  18737. * @default 0
  18738. * @product highcharts highstock gantt
  18739. * @apioption yAxis.tickWidth
  18740. */
  18741. /**
  18742. * Angular gauges and solid gauges only.
  18743. * The label's pixel distance from the perimeter of the plot area.
  18744. *
  18745. * Since v7.1.2: If it's a percentage string, it is interpreted the
  18746. * same as [series.radius](#plotOptions.gauge.radius), so label can be
  18747. * aligned under the gauge's shape.
  18748. *
  18749. * @sample {highcharts} highcharts/yaxis/labels-distance/
  18750. * Labels centered under the arc
  18751. *
  18752. * @type {number|string}
  18753. * @default -25
  18754. * @product highcharts
  18755. * @apioption yAxis.labels.distance
  18756. */
  18757. /**
  18758. * The y position offset of the label relative to the tick position
  18759. * on the axis.
  18760. *
  18761. * @sample {highcharts} highcharts/xaxis/labels-x/
  18762. * Y axis labels placed on grid lines
  18763. *
  18764. * @type {number}
  18765. * @default {highcharts} 3
  18766. * @default {highstock} -2
  18767. * @default {highmaps} 3
  18768. * @apioption yAxis.labels.y
  18769. */
  18770. /**
  18771. * Whether to force the axis to end on a tick. Use this option with
  18772. * the `maxPadding` option to control the axis end.
  18773. *
  18774. * This option is always disabled, when panning type is
  18775. * either `y` or `xy`.
  18776. *
  18777. * @see [type](#chart.panning.type)
  18778. *
  18779. *
  18780. * @sample {highcharts} highcharts/chart/reflow-true/
  18781. * True by default
  18782. * @sample {highcharts} highcharts/yaxis/endontick/
  18783. * False
  18784. * @sample {highstock} stock/demo/basic-line/
  18785. * True by default
  18786. * @sample {highstock} stock/xaxis/endontick/
  18787. * False for Y axis
  18788. *
  18789. * @since 1.2.0
  18790. */
  18791. endOnTick: true,
  18792. /**
  18793. * Padding of the max value relative to the length of the axis. A
  18794. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  18795. * when you don't want the highest data value to appear on the edge
  18796. * of the plot area. When the axis' `max` option is set or a max extreme
  18797. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  18798. *
  18799. * Also the `softThreshold` option takes precedence over `maxPadding`,
  18800. * so if the data is tangent to the threshold, `maxPadding` may not
  18801. * apply unless `softThreshold` is set to false.
  18802. *
  18803. * @sample {highcharts} highcharts/yaxis/maxpadding-02/
  18804. * Max padding of 0.2
  18805. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  18806. * Greater min- and maxPadding
  18807. *
  18808. * @since 1.2.0
  18809. * @product highcharts highstock gantt
  18810. */
  18811. maxPadding: 0.05,
  18812. /**
  18813. * Padding of the min value relative to the length of the axis. A
  18814. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  18815. * when you don't want the lowest data value to appear on the edge
  18816. * of the plot area. When the axis' `min` option is set or a max extreme
  18817. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  18818. *
  18819. * Also the `softThreshold` option takes precedence over `minPadding`,
  18820. * so if the data is tangent to the threshold, `minPadding` may not
  18821. * apply unless `softThreshold` is set to false.
  18822. *
  18823. * @sample {highcharts} highcharts/yaxis/minpadding/
  18824. * Min padding of 0.2
  18825. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  18826. * Greater min- and maxPadding
  18827. *
  18828. * @since 1.2.0
  18829. * @product highcharts highstock gantt
  18830. */
  18831. minPadding: 0.05,
  18832. /**
  18833. * @productdesc {highstock}
  18834. * In Highstock 1.x, the Y axis was placed on the left side by default.
  18835. *
  18836. * @sample {highcharts} highcharts/yaxis/opposite/
  18837. * Secondary Y axis opposite
  18838. * @sample {highstock} stock/xaxis/opposite/
  18839. * Y axis on left side
  18840. *
  18841. * @type {boolean}
  18842. * @default {highstock} true
  18843. * @default {highcharts} false
  18844. * @product highstock highcharts gantt
  18845. * @apioption yAxis.opposite
  18846. */
  18847. /**
  18848. * @see [tickInterval](#xAxis.tickInterval)
  18849. * @see [tickPositioner](#xAxis.tickPositioner)
  18850. * @see [tickPositions](#xAxis.tickPositions)
  18851. */
  18852. tickPixelInterval: 72,
  18853. showLastLabel: true,
  18854. /**
  18855. * @extends xAxis.labels
  18856. */
  18857. labels: {
  18858. /**
  18859. * What part of the string the given position is anchored to. Can
  18860. * be one of `"left"`, `"center"` or `"right"`. The exact position
  18861. * also depends on the `labels.x` setting.
  18862. *
  18863. * Angular gauges and solid gauges defaults to `"center"`.
  18864. * Solid gauges with two labels have additional option `"auto"`
  18865. * for automatic horizontal and vertical alignment.
  18866. *
  18867. * @see [yAxis.labels.distance](#yAxis.labels.distance)
  18868. *
  18869. * @sample {highcharts} highcharts/yaxis/labels-align-left/
  18870. * Left
  18871. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  18872. * Solid gauge labels auto aligned
  18873. *
  18874. * @type {Highcharts.AlignValue}
  18875. * @default {highcharts|highmaps} right
  18876. * @default {highstock} left
  18877. * @apioption yAxis.labels.align
  18878. */
  18879. /**
  18880. * The x position offset of the label relative to the tick position
  18881. * on the axis. Defaults to -15 for left axis, 15 for right axis.
  18882. *
  18883. * @sample {highcharts} highcharts/xaxis/labels-x/
  18884. * Y axis labels placed on grid lines
  18885. */
  18886. x: -8
  18887. },
  18888. /**
  18889. * @productdesc {highmaps}
  18890. * In Highmaps, the axis line is hidden by default, because the axis is
  18891. * not visible by default.
  18892. *
  18893. * @type {Highcharts.ColorType}
  18894. * @apioption yAxis.lineColor
  18895. */
  18896. /**
  18897. * @sample {highcharts} highcharts/yaxis/max-200/
  18898. * Y axis max of 200
  18899. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  18900. * Y axis max on logarithmic axis
  18901. * @sample {highstock} stock/yaxis/min-max/
  18902. * Fixed min and max on Y axis
  18903. * @sample {highmaps} maps/axis/min-max/
  18904. * Pre-zoomed to a specific area
  18905. *
  18906. * @apioption yAxis.max
  18907. */
  18908. /**
  18909. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  18910. * -50 with startOnTick to false
  18911. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  18912. * -50 with startOnTick true by default
  18913. * @sample {highstock} stock/yaxis/min-max/
  18914. * Fixed min and max on Y axis
  18915. * @sample {highmaps} maps/axis/min-max/
  18916. * Pre-zoomed to a specific area
  18917. *
  18918. * @apioption yAxis.min
  18919. */
  18920. /**
  18921. * An optional scrollbar to display on the Y axis in response to
  18922. * limiting the minimum an maximum of the axis values.
  18923. *
  18924. * In styled mode, all the presentational options for the scrollbar
  18925. * are replaced by the classes `.highcharts-scrollbar-thumb`,
  18926. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  18927. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  18928. *
  18929. * @sample {highstock} stock/yaxis/scrollbar/
  18930. * Scrollbar on the Y axis
  18931. *
  18932. * @extends scrollbar
  18933. * @since 4.2.6
  18934. * @product highstock
  18935. * @excluding height
  18936. * @apioption yAxis.scrollbar
  18937. */
  18938. /**
  18939. * Enable the scrollbar on the Y axis.
  18940. *
  18941. * @sample {highstock} stock/yaxis/scrollbar/
  18942. * Enabled on Y axis
  18943. *
  18944. * @type {boolean}
  18945. * @default false
  18946. * @since 4.2.6
  18947. * @product highstock
  18948. * @apioption yAxis.scrollbar.enabled
  18949. */
  18950. /**
  18951. * Pixel margin between the scrollbar and the axis elements.
  18952. *
  18953. * @type {number}
  18954. * @default 10
  18955. * @since 4.2.6
  18956. * @product highstock
  18957. * @apioption yAxis.scrollbar.margin
  18958. */
  18959. /**
  18960. * Whether to show the scrollbar when it is fully zoomed out at max
  18961. * range. Setting it to `false` on the Y axis makes the scrollbar stay
  18962. * hidden until the user zooms in, like common in browsers.
  18963. *
  18964. * @type {boolean}
  18965. * @default true
  18966. * @since 4.2.6
  18967. * @product highstock
  18968. * @apioption yAxis.scrollbar.showFull
  18969. */
  18970. /**
  18971. * The width of a vertical scrollbar or height of a horizontal
  18972. * scrollbar. Defaults to 20 on touch devices.
  18973. *
  18974. * @type {number}
  18975. * @default 14
  18976. * @since 4.2.6
  18977. * @product highstock
  18978. * @apioption yAxis.scrollbar.size
  18979. */
  18980. /**
  18981. * Z index of the scrollbar elements.
  18982. *
  18983. * @type {number}
  18984. * @default 3
  18985. * @since 4.2.6
  18986. * @product highstock
  18987. * @apioption yAxis.scrollbar.zIndex
  18988. */
  18989. /**
  18990. * A soft maximum for the axis. If the series data maximum is less
  18991. * than this, the axis will stay at this maximum, but if the series
  18992. * data maximum is higher, the axis will flex to show all data.
  18993. *
  18994. * **Note**: The [series.softThreshold](
  18995. * #plotOptions.series.softThreshold) option takes precedence over this
  18996. * option.
  18997. *
  18998. * @sample highcharts/yaxis/softmin-softmax/
  18999. * Soft min and max
  19000. *
  19001. * @type {number}
  19002. * @since 5.0.1
  19003. * @product highcharts highstock gantt
  19004. * @apioption yAxis.softMax
  19005. */
  19006. /**
  19007. * A soft minimum for the axis. If the series data minimum is greater
  19008. * than this, the axis will stay at this minimum, but if the series
  19009. * data minimum is lower, the axis will flex to show all data.
  19010. *
  19011. * **Note**: The [series.softThreshold](
  19012. * #plotOptions.series.softThreshold) option takes precedence over this
  19013. * option.
  19014. *
  19015. * @sample highcharts/yaxis/softmin-softmax/
  19016. * Soft min and max
  19017. *
  19018. * @type {number}
  19019. * @since 5.0.1
  19020. * @product highcharts highstock gantt
  19021. * @apioption yAxis.softMin
  19022. */
  19023. /**
  19024. * Defines the horizontal alignment of the stack total label. Can be one
  19025. * of `"left"`, `"center"` or `"right"`. The default value is calculated
  19026. * at runtime and depends on orientation and whether the stack is
  19027. * positive or negative.
  19028. *
  19029. * @sample {highcharts} highcharts/yaxis/stacklabels-align-left/
  19030. * Aligned to the left
  19031. * @sample {highcharts} highcharts/yaxis/stacklabels-align-center/
  19032. * Aligned in center
  19033. * @sample {highcharts} highcharts/yaxis/stacklabels-align-right/
  19034. * Aligned to the right
  19035. *
  19036. * @type {Highcharts.AlignValue}
  19037. * @since 2.1.5
  19038. * @product highcharts
  19039. * @apioption yAxis.stackLabels.align
  19040. */
  19041. /**
  19042. * A format string for the data label. Available variables are the same
  19043. * as for `formatter`.
  19044. *
  19045. * @type {string}
  19046. * @default {total}
  19047. * @since 3.0.2
  19048. * @product highcharts highstock
  19049. * @apioption yAxis.stackLabels.format
  19050. */
  19051. /**
  19052. * Rotation of the labels in degrees.
  19053. *
  19054. * @sample {highcharts} highcharts/yaxis/stacklabels-rotation/
  19055. * Labels rotated 45°
  19056. *
  19057. * @type {number}
  19058. * @default 0
  19059. * @since 2.1.5
  19060. * @product highcharts
  19061. * @apioption yAxis.stackLabels.rotation
  19062. */
  19063. /**
  19064. * The text alignment for the label. While `align` determines where the
  19065. * texts anchor point is placed with regards to the stack, `textAlign`
  19066. * determines how the text is aligned against its anchor point. Possible
  19067. * values are `"left"`, `"center"` and `"right"`. The default value is
  19068. * calculated at runtime and depends on orientation and whether the
  19069. * stack is positive or negative.
  19070. *
  19071. * @sample {highcharts} highcharts/yaxis/stacklabels-textalign-left/
  19072. * Label in center position but text-aligned left
  19073. *
  19074. * @type {Highcharts.AlignValue}
  19075. * @since 2.1.5
  19076. * @product highcharts
  19077. * @apioption yAxis.stackLabels.textAlign
  19078. */
  19079. /**
  19080. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  19081. * to render the labels.
  19082. *
  19083. * @type {boolean}
  19084. * @default false
  19085. * @since 3.0
  19086. * @product highcharts highstock
  19087. * @apioption yAxis.stackLabels.useHTML
  19088. */
  19089. /**
  19090. * Defines the vertical alignment of the stack total label. Can be one
  19091. * of `"top"`, `"middle"` or `"bottom"`. The default value is calculated
  19092. * at runtime and depends on orientation and whether the stack is
  19093. * positive or negative.
  19094. *
  19095. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-top/
  19096. * Vertically aligned top
  19097. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-middle/
  19098. * Vertically aligned middle
  19099. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-bottom/
  19100. * Vertically aligned bottom
  19101. *
  19102. * @type {Highcharts.VerticalAlignValue}
  19103. * @since 2.1.5
  19104. * @product highcharts
  19105. * @apioption yAxis.stackLabels.verticalAlign
  19106. */
  19107. /**
  19108. * The x position offset of the label relative to the left of the
  19109. * stacked bar. The default value is calculated at runtime and depends
  19110. * on orientation and whether the stack is positive or negative.
  19111. *
  19112. * @sample {highcharts} highcharts/yaxis/stacklabels-x/
  19113. * Stack total labels with x offset
  19114. *
  19115. * @type {number}
  19116. * @since 2.1.5
  19117. * @product highcharts
  19118. * @apioption yAxis.stackLabels.x
  19119. */
  19120. /**
  19121. * The y position offset of the label relative to the tick position
  19122. * on the axis. The default value is calculated at runtime and depends
  19123. * on orientation and whether the stack is positive or negative.
  19124. *
  19125. * @sample {highcharts} highcharts/yaxis/stacklabels-y/
  19126. * Stack total labels with y offset
  19127. *
  19128. * @type {number}
  19129. * @since 2.1.5
  19130. * @product highcharts
  19131. * @apioption yAxis.stackLabels.y
  19132. */
  19133. /**
  19134. * Whether to force the axis to start on a tick. Use this option with
  19135. * the `maxPadding` option to control the axis start.
  19136. *
  19137. * This option is always disabled, when panning type is
  19138. * either `y` or `xy`.
  19139. *
  19140. * @see [type](#chart.panning.type)
  19141. *
  19142. * @sample {highcharts} highcharts/xaxis/startontick-false/
  19143. * False by default
  19144. * @sample {highcharts} highcharts/xaxis/startontick-true/
  19145. * True
  19146. * @sample {highstock} stock/xaxis/endontick/
  19147. * False for Y axis
  19148. *
  19149. * @since 1.2.0
  19150. * @product highcharts highstock gantt
  19151. */
  19152. startOnTick: true,
  19153. title: {
  19154. /**
  19155. * The pixel distance between the axis labels and the title.
  19156. * Positive values are outside the axis line, negative are inside.
  19157. *
  19158. * @sample {highcharts} highcharts/xaxis/title-margin/
  19159. * Y axis title margin of 60
  19160. *
  19161. * @type {number}
  19162. * @default 40
  19163. * @apioption yAxis.title.margin
  19164. */
  19165. /**
  19166. * The rotation of the text in degrees. 0 is horizontal, 270 is
  19167. * vertical reading from bottom to top.
  19168. *
  19169. * @sample {highcharts} highcharts/yaxis/title-offset/
  19170. * Horizontal
  19171. */
  19172. rotation: 270,
  19173. /**
  19174. * The actual text of the axis title. Horizontal texts can contain
  19175. * HTML, but rotated texts are painted using vector techniques and
  19176. * must be clean text. The Y axis title is disabled by setting the
  19177. * `text` option to `undefined`.
  19178. *
  19179. * @sample {highcharts} highcharts/xaxis/title-text/
  19180. * Custom HTML
  19181. *
  19182. * @type {string|null}
  19183. * @default {highcharts} Values
  19184. * @default {highstock} undefined
  19185. * @product highcharts highstock gantt
  19186. */
  19187. text: 'Values'
  19188. },
  19189. /**
  19190. * The top position of the Y axis. If it's a number, it is interpreted
  19191. * as pixel position relative to the chart.
  19192. *
  19193. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  19194. * percentages of the plot height, offset from plot area top.
  19195. *
  19196. * @see [yAxis.height](#yAxis.height)
  19197. *
  19198. * @sample {highstock} stock/demo/candlestick-and-volume/
  19199. * Percentage height panes
  19200. *
  19201. * @type {number|string}
  19202. * @product highcharts highstock
  19203. * @apioption yAxis.top
  19204. */
  19205. /**
  19206. * The stack labels show the total value for each bar in a stacked
  19207. * column or bar chart. The label will be placed on top of positive
  19208. * columns and below negative columns. In case of an inverted column
  19209. * chart or a bar chart the label is placed to the right of positive
  19210. * bars and to the left of negative bars.
  19211. *
  19212. * @product highcharts
  19213. */
  19214. stackLabels: {
  19215. /**
  19216. * Allow the stack labels to overlap.
  19217. *
  19218. * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
  19219. * Default false
  19220. *
  19221. * @since 5.0.13
  19222. * @product highcharts
  19223. */
  19224. allowOverlap: false,
  19225. /**
  19226. * The background color or gradient for the stack label.
  19227. *
  19228. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  19229. * Stack labels box options
  19230. * @type {Highcharts.ColorType}
  19231. * @since 8.1.0
  19232. * @apioption yAxis.stackLabels.backgroundColor
  19233. */
  19234. /**
  19235. * The border color for the stack label. Defaults to `undefined`.
  19236. *
  19237. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  19238. * Stack labels box options
  19239. * @type {Highcharts.ColorType}
  19240. * @since 8.1.0
  19241. * @apioption yAxis.stackLabels.borderColor
  19242. */
  19243. /**
  19244. * The border radius in pixels for the stack label.
  19245. *
  19246. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  19247. * Stack labels box options
  19248. * @type {number}
  19249. * @default 0
  19250. * @since 8.1.0
  19251. * @apioption yAxis.stackLabels.borderRadius
  19252. */
  19253. /**
  19254. * The border width in pixels for the stack label.
  19255. *
  19256. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  19257. * Stack labels box options
  19258. * @type {number}
  19259. * @default 0
  19260. * @since 8.1.0
  19261. * @apioption yAxis.stackLabels.borderWidth
  19262. */
  19263. /**
  19264. * Enable or disable the stack total labels.
  19265. *
  19266. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
  19267. * Enabled stack total labels
  19268. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled-waterfall/
  19269. * Enabled stack labels in waterfall chart
  19270. *
  19271. * @since 2.1.5
  19272. * @product highcharts
  19273. */
  19274. enabled: false,
  19275. /**
  19276. * Whether to hide stack labels that are outside the plot area.
  19277. * By default, the stack label is moved
  19278. * inside the plot area according to the
  19279. * [overflow](/highcharts/#yAxis/stackLabels/overflow)
  19280. * option.
  19281. *
  19282. * @type {boolean}
  19283. * @since 7.1.3
  19284. */
  19285. crop: true,
  19286. /**
  19287. * How to handle stack total labels that flow outside the plot area.
  19288. * The default is set to `"justify"`,
  19289. * which aligns them inside the plot area.
  19290. * For columns and bars, this means it will be moved inside the bar.
  19291. * To display stack labels outside the plot area,
  19292. * set `crop` to `false` and `overflow` to `"allow"`.
  19293. *
  19294. * @sample highcharts/yaxis/stacklabels-overflow/
  19295. * Stack labels flows outside the plot area.
  19296. *
  19297. * @type {Highcharts.DataLabelsOverflowValue}
  19298. * @since 7.1.3
  19299. */
  19300. overflow: 'justify',
  19301. /* eslint-disable valid-jsdoc */
  19302. /**
  19303. * Callback JavaScript function to format the label. The value is
  19304. * given by `this.total`.
  19305. *
  19306. * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
  19307. * Added units to stack total value
  19308. *
  19309. * @type {Highcharts.FormatterCallbackFunction<Highcharts.StackItemObject>}
  19310. * @since 2.1.5
  19311. * @product highcharts
  19312. */
  19313. formatter: function () {
  19314. var numberFormatter = this.axis.chart.numberFormatter;
  19315. /* eslint-enable valid-jsdoc */
  19316. return numberFormatter(this.total, -1);
  19317. },
  19318. /**
  19319. * CSS styles for the label.
  19320. *
  19321. * In styled mode, the styles are set in the
  19322. * `.highcharts-stack-label` class.
  19323. *
  19324. * @sample {highcharts} highcharts/yaxis/stacklabels-style/
  19325. * Red stack total labels
  19326. *
  19327. * @type {Highcharts.CSSObject}
  19328. * @since 2.1.5
  19329. * @product highcharts
  19330. */
  19331. style: {
  19332. /** @internal */
  19333. color: '#000000',
  19334. /** @internal */
  19335. fontSize: '11px',
  19336. /** @internal */
  19337. fontWeight: 'bold',
  19338. /** @internal */
  19339. textOutline: '1px contrast'
  19340. }
  19341. },
  19342. gridLineWidth: 1,
  19343. lineWidth: 0
  19344. // tickWidth: 0
  19345. };
  19346. /**
  19347. * The Z axis or depth axis for 3D plots.
  19348. *
  19349. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  19350. * access to the axis.
  19351. *
  19352. * @sample {highcharts} highcharts/3d/scatter-zaxis-categories/
  19353. * Z-Axis with Categories
  19354. * @sample {highcharts} highcharts/3d/scatter-zaxis-grid/
  19355. * Z-Axis with styling
  19356. *
  19357. * @type {*|Array<*>}
  19358. * @extends xAxis
  19359. * @since 5.0.0
  19360. * @product highcharts
  19361. * @excluding breaks, crosshair, height, left, lineColor, lineWidth,
  19362. * nameToX, showEmpty, top, width
  19363. * @apioption zAxis
  19364. *
  19365. * @private
  19366. */
  19367. // This variable extends the defaultOptions for left axes.
  19368. Axis.defaultLeftAxisOptions = {
  19369. labels: {
  19370. x: -15
  19371. },
  19372. title: {
  19373. rotation: 270
  19374. }
  19375. };
  19376. // This variable extends the defaultOptions for right axes.
  19377. Axis.defaultRightAxisOptions = {
  19378. labels: {
  19379. x: 15
  19380. },
  19381. title: {
  19382. rotation: 90
  19383. }
  19384. };
  19385. // This variable extends the defaultOptions for bottom axes.
  19386. Axis.defaultBottomAxisOptions = {
  19387. labels: {
  19388. autoRotation: [-45],
  19389. x: 0
  19390. // overflow: undefined,
  19391. // staggerLines: null
  19392. },
  19393. margin: 15,
  19394. title: {
  19395. rotation: 0
  19396. }
  19397. };
  19398. // This variable extends the defaultOptions for top axes.
  19399. Axis.defaultTopAxisOptions = {
  19400. labels: {
  19401. autoRotation: [-45],
  19402. x: 0
  19403. // overflow: undefined
  19404. // staggerLines: null
  19405. },
  19406. margin: 15,
  19407. title: {
  19408. rotation: 0
  19409. }
  19410. };
  19411. // Properties to survive after destroy, needed for Axis.update (#4317,
  19412. // #5773, #5881).
  19413. Axis.keepProps = ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'];
  19414. return Axis;
  19415. }());
  19416. H.Axis = Axis;
  19417. return H.Axis;
  19418. });
  19419. _registerModule(_modules, 'parts/DateTimeAxis.js', [_modules['parts/Axis.js'], _modules['parts/Utilities.js']], function (Axis, U) {
  19420. /* *
  19421. *
  19422. * (c) 2010-2020 Torstein Honsi
  19423. *
  19424. * License: www.highcharts.com/license
  19425. *
  19426. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  19427. *
  19428. * */
  19429. var addEvent = U.addEvent, getMagnitude = U.getMagnitude, normalizeTickInterval = U.normalizeTickInterval, timeUnits = U.timeUnits;
  19430. /* eslint-disable valid-jsdoc */
  19431. var DateTimeAxisAdditions = /** @class */ (function () {
  19432. /* *
  19433. *
  19434. * Constructors
  19435. *
  19436. * */
  19437. function DateTimeAxisAdditions(axis) {
  19438. this.axis = axis;
  19439. }
  19440. /* *
  19441. *
  19442. * Functions
  19443. *
  19444. * */
  19445. /**
  19446. * Get a normalized tick interval for dates. Returns a configuration object
  19447. * with unit range (interval), count and name. Used to prepare data for
  19448. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  19449. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  19450. * logic was extracted in order to prevent it for running over again for
  19451. * each segment having the same interval. #662, #697.
  19452. * @private
  19453. */
  19454. /**
  19455. * Get a normalized tick interval for dates. Returns a configuration object
  19456. * with unit range (interval), count and name. Used to prepare data for
  19457. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  19458. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  19459. * logic was extracted in order to prevent it for running over again for
  19460. * each segment having the same interval. #662, #697.
  19461. * @private
  19462. */
  19463. DateTimeAxisAdditions.prototype.normalizeTimeTickInterval = function (tickInterval, unitsOption) {
  19464. var units = unitsOption || [[
  19465. 'millisecond',
  19466. [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  19467. ], [
  19468. 'second',
  19469. [1, 2, 5, 10, 15, 30]
  19470. ], [
  19471. 'minute',
  19472. [1, 2, 5, 10, 15, 30]
  19473. ], [
  19474. 'hour',
  19475. [1, 2, 3, 4, 6, 8, 12]
  19476. ], [
  19477. 'day',
  19478. [1, 2]
  19479. ], [
  19480. 'week',
  19481. [1, 2]
  19482. ], [
  19483. 'month',
  19484. [1, 2, 3, 4, 6]
  19485. ], [
  19486. 'year',
  19487. null
  19488. ]], unit = units[units.length - 1], // default unit is years
  19489. interval = timeUnits[unit[0]], multiples = unit[1], count, i;
  19490. // loop through the units to find the one that best fits the
  19491. // tickInterval
  19492. for (i = 0; i < units.length; i++) {
  19493. unit = units[i];
  19494. interval = timeUnits[unit[0]];
  19495. multiples = unit[1];
  19496. if (units[i + 1]) {
  19497. // lessThan is in the middle between the highest multiple and
  19498. // the next unit.
  19499. var lessThan = (interval *
  19500. multiples[multiples.length - 1] +
  19501. timeUnits[units[i + 1][0]]) / 2;
  19502. // break and keep the current unit
  19503. if (tickInterval <= lessThan) {
  19504. break;
  19505. }
  19506. }
  19507. }
  19508. // prevent 2.5 years intervals, though 25, 250 etc. are allowed
  19509. if (interval === timeUnits.year && tickInterval < 5 * interval) {
  19510. multiples = [1, 2, 5];
  19511. }
  19512. // get the count
  19513. count = normalizeTickInterval(tickInterval / interval, multiples, unit[0] === 'year' ? // #1913, #2360
  19514. Math.max(getMagnitude(tickInterval / interval), 1) :
  19515. 1);
  19516. return {
  19517. unitRange: interval,
  19518. count: count,
  19519. unitName: unit[0]
  19520. };
  19521. };
  19522. return DateTimeAxisAdditions;
  19523. }());
  19524. /**
  19525. * Date and time support for axes.
  19526. *
  19527. * @private
  19528. * @class
  19529. */
  19530. var DateTimeAxis = /** @class */ (function () {
  19531. function DateTimeAxis() {
  19532. }
  19533. /* *
  19534. *
  19535. * Static Functions
  19536. *
  19537. * */
  19538. /**
  19539. * Extends axis class with date and time support.
  19540. * @private
  19541. */
  19542. DateTimeAxis.compose = function (AxisClass) {
  19543. AxisClass.keepProps.push('dateTime');
  19544. var axisProto = AxisClass.prototype;
  19545. /**
  19546. * Set the tick positions to a time unit that makes sense, for example
  19547. * on the first of each month or on every Monday. Return an array with
  19548. * the time positions. Used in datetime axes as well as for grouping
  19549. * data on a datetime axis.
  19550. *
  19551. * @private
  19552. * @function Highcharts.Axis#getTimeTicks
  19553. *
  19554. * @param {Highcharts.TimeNormalizeObject} normalizedInterval
  19555. * The interval in axis values (ms) and thecount.
  19556. *
  19557. * @param {number} min
  19558. * The minimum in axis values.
  19559. *
  19560. * @param {number} max
  19561. * The maximum in axis values.
  19562. *
  19563. * @param {number} startOfWeek
  19564. *
  19565. * @return {Highcharts.AxisTickPositionsArray}
  19566. */
  19567. axisProto.getTimeTicks = function () {
  19568. return this.chart.time.getTimeTicks.apply(this.chart.time, arguments);
  19569. };
  19570. /* eslint-disable no-invalid-this */
  19571. addEvent(AxisClass, 'init', function (e) {
  19572. var axis = this;
  19573. var options = e.userOptions;
  19574. if (options.type !== 'datetime') {
  19575. axis.dateTime = void 0;
  19576. return;
  19577. }
  19578. if (!axis.dateTime) {
  19579. axis.dateTime = new DateTimeAxisAdditions(axis);
  19580. }
  19581. });
  19582. /* eslint-enable no-invalid-this */
  19583. };
  19584. /* *
  19585. *
  19586. * Static Properties
  19587. *
  19588. * */
  19589. DateTimeAxis.AdditionsClass = DateTimeAxisAdditions;
  19590. return DateTimeAxis;
  19591. }());
  19592. DateTimeAxis.compose(Axis);
  19593. return DateTimeAxis;
  19594. });
  19595. _registerModule(_modules, 'parts/LogarithmicAxis.js', [_modules['parts/Axis.js'], _modules['parts/Utilities.js']], function (Axis, U) {
  19596. /* *
  19597. *
  19598. * (c) 2010-2020 Torstein Honsi
  19599. *
  19600. * License: www.highcharts.com/license
  19601. *
  19602. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  19603. *
  19604. * */
  19605. var addEvent = U.addEvent, getMagnitude = U.getMagnitude, normalizeTickInterval = U.normalizeTickInterval, pick = U.pick;
  19606. /* eslint-disable valid-jsdoc */
  19607. /**
  19608. * Provides logarithmic support for axes.
  19609. *
  19610. * @private
  19611. * @class
  19612. */
  19613. var LogarithmicAxisAdditions = /** @class */ (function () {
  19614. /* *
  19615. *
  19616. * Constructors
  19617. *
  19618. * */
  19619. function LogarithmicAxisAdditions(axis) {
  19620. this.axis = axis;
  19621. }
  19622. /* *
  19623. *
  19624. * Functions
  19625. *
  19626. * */
  19627. /**
  19628. * Set the tick positions of a logarithmic axis.
  19629. */
  19630. LogarithmicAxisAdditions.prototype.getLogTickPositions = function (interval, min, max, minor) {
  19631. var log = this;
  19632. var axis = log.axis;
  19633. var axisLength = axis.len;
  19634. var options = axis.options;
  19635. // Since we use this method for both major and minor ticks,
  19636. // use a local variable and return the result
  19637. var positions = [];
  19638. // Reset
  19639. if (!minor) {
  19640. log.minorAutoInterval = void 0;
  19641. }
  19642. // First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
  19643. if (interval >= 0.5) {
  19644. interval = Math.round(interval);
  19645. positions = axis.getLinearTickPositions(interval, min, max);
  19646. // Second case: We need intermediary ticks. For example
  19647. // 1, 2, 4, 6, 8, 10, 20, 40 etc.
  19648. }
  19649. else if (interval >= 0.08) {
  19650. var roundedMin = Math.floor(min), intermediate, i, j, len, pos, lastPos, break2;
  19651. if (interval > 0.3) {
  19652. intermediate = [1, 2, 4];
  19653. // 0.2 equals five minor ticks per 1, 10, 100 etc
  19654. }
  19655. else if (interval > 0.15) {
  19656. intermediate = [1, 2, 4, 6, 8];
  19657. }
  19658. else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
  19659. intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  19660. }
  19661. for (i = roundedMin; i < max + 1 && !break2; i++) {
  19662. len = intermediate.length;
  19663. for (j = 0; j < len && !break2; j++) {
  19664. pos = log.log2lin(log.lin2log(i) * intermediate[j]);
  19665. // #1670, lastPos is #3113
  19666. if (pos > min &&
  19667. (!minor || lastPos <= max) &&
  19668. typeof lastPos !== 'undefined') {
  19669. positions.push(lastPos);
  19670. }
  19671. if (lastPos > max) {
  19672. break2 = true;
  19673. }
  19674. lastPos = pos;
  19675. }
  19676. }
  19677. // Third case: We are so deep in between whole logarithmic values that
  19678. // we might as well handle the tick positions like a linear axis. For
  19679. // example 1.01, 1.02, 1.03, 1.04.
  19680. }
  19681. else {
  19682. var realMin = log.lin2log(min), realMax = log.lin2log(max), tickIntervalOption = minor ?
  19683. axis.getMinorTickInterval() :
  19684. options.tickInterval, filteredTickIntervalOption = tickIntervalOption === 'auto' ?
  19685. null :
  19686. tickIntervalOption, tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1), totalPixelLength = minor ?
  19687. axisLength / axis.tickPositions.length :
  19688. axisLength;
  19689. interval = pick(filteredTickIntervalOption, log.minorAutoInterval, (realMax - realMin) *
  19690. tickPixelIntervalOption / (totalPixelLength || 1));
  19691. interval = normalizeTickInterval(interval, void 0, getMagnitude(interval));
  19692. positions = axis.getLinearTickPositions(interval, realMin, realMax).map(log.log2lin);
  19693. if (!minor) {
  19694. log.minorAutoInterval = interval / 5;
  19695. }
  19696. }
  19697. // Set the axis-level tickInterval variable
  19698. if (!minor) {
  19699. axis.tickInterval = interval;
  19700. }
  19701. return positions;
  19702. };
  19703. LogarithmicAxisAdditions.prototype.lin2log = function (num) {
  19704. return Math.pow(10, num);
  19705. };
  19706. LogarithmicAxisAdditions.prototype.log2lin = function (num) {
  19707. return Math.log(num) / Math.LN10;
  19708. };
  19709. return LogarithmicAxisAdditions;
  19710. }());
  19711. var LogarithmicAxis = /** @class */ (function () {
  19712. function LogarithmicAxis() {
  19713. }
  19714. /**
  19715. * Provides logarithmic support for axes.
  19716. *
  19717. * @private
  19718. */
  19719. LogarithmicAxis.compose = function (AxisClass) {
  19720. AxisClass.keepProps.push('logarithmic');
  19721. // HC <= 8 backwards compatibility, allow wrapping
  19722. // Axis.prototype.lin2log and log2lin
  19723. // @todo Remove this in next major
  19724. var axisProto = AxisClass.prototype;
  19725. var logAxisProto = LogarithmicAxisAdditions.prototype;
  19726. axisProto.log2lin = logAxisProto.log2lin;
  19727. axisProto.lin2log = logAxisProto.lin2log;
  19728. /* eslint-disable no-invalid-this */
  19729. addEvent(AxisClass, 'init', function (e) {
  19730. var axis = this;
  19731. var options = e.userOptions;
  19732. var logarithmic = axis.logarithmic;
  19733. if (options.type !== 'logarithmic') {
  19734. axis.logarithmic = void 0;
  19735. }
  19736. else {
  19737. if (!logarithmic) {
  19738. logarithmic = axis.logarithmic = new LogarithmicAxisAdditions(axis);
  19739. }
  19740. // HC <= 8 backwards compatibility, allow wrapping
  19741. // Axis.prototype.lin2log and log2lin
  19742. // @todo Remove this in next major
  19743. if (axis.log2lin !== logarithmic.log2lin) {
  19744. logarithmic.log2lin = axis.log2lin.bind(axis);
  19745. }
  19746. if (axis.lin2log !== logarithmic.lin2log) {
  19747. logarithmic.lin2log = axis.lin2log.bind(axis);
  19748. }
  19749. }
  19750. });
  19751. addEvent(AxisClass, 'afterInit', function () {
  19752. var axis = this;
  19753. var log = axis.logarithmic;
  19754. // extend logarithmic axis
  19755. if (log) {
  19756. axis.lin2val = function (num) {
  19757. return log.lin2log(num);
  19758. };
  19759. axis.val2lin = function (num) {
  19760. return log.log2lin(num);
  19761. };
  19762. }
  19763. });
  19764. };
  19765. return LogarithmicAxis;
  19766. }());
  19767. LogarithmicAxis.compose(Axis); // @todo move to factory functions
  19768. return LogarithmicAxis;
  19769. });
  19770. _registerModule(_modules, 'parts/PlotLineOrBand.js', [_modules['parts/Axis.js'], _modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (Axis, H, U) {
  19771. /* *
  19772. *
  19773. * (c) 2010-2020 Torstein Honsi
  19774. *
  19775. * License: www.highcharts.com/license
  19776. *
  19777. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  19778. *
  19779. * */
  19780. /**
  19781. * Options for plot bands on axes.
  19782. *
  19783. * @typedef {Highcharts.XAxisPlotBandsOptions|Highcharts.YAxisPlotBandsOptions|Highcharts.ZAxisPlotBandsOptions} Highcharts.AxisPlotBandsOptions
  19784. */
  19785. /**
  19786. * Options for plot band labels on axes.
  19787. *
  19788. * @typedef {Highcharts.XAxisPlotBandsLabelOptions|Highcharts.YAxisPlotBandsLabelOptions|Highcharts.ZAxisPlotBandsLabelOptions} Highcharts.AxisPlotBandsLabelOptions
  19789. */
  19790. /**
  19791. * Options for plot lines on axes.
  19792. *
  19793. * @typedef {Highcharts.XAxisPlotLinesOptions|Highcharts.YAxisPlotLinesOptions|Highcharts.ZAxisPlotLinesOptions} Highcharts.AxisPlotLinesOptions
  19794. */
  19795. /**
  19796. * Options for plot line labels on axes.
  19797. *
  19798. * @typedef {Highcharts.XAxisPlotLinesLabelOptions|Highcharts.YAxisPlotLinesLabelOptions|Highcharts.ZAxisPlotLinesLabelOptions} Highcharts.AxisPlotLinesLabelOptions
  19799. */
  19800. var arrayMax = U.arrayMax, arrayMin = U.arrayMin, defined = U.defined, destroyObjectProperties = U.destroyObjectProperties, erase = U.erase, extend = U.extend, fireEvent = U.fireEvent, merge = U.merge, objectEach = U.objectEach, pick = U.pick;
  19801. /* eslint-disable no-invalid-this, valid-jsdoc */
  19802. /**
  19803. * The object wrapper for plot lines and plot bands
  19804. *
  19805. * @class
  19806. * @name Highcharts.PlotLineOrBand
  19807. *
  19808. * @param {Highcharts.Axis} axis
  19809. *
  19810. * @param {Highcharts.AxisPlotLinesOptions|Highcharts.AxisPlotBandsOptions} [options]
  19811. */
  19812. var PlotLineOrBand = /** @class */ (function () {
  19813. function PlotLineOrBand(axis, options) {
  19814. this.axis = axis;
  19815. if (options) {
  19816. this.options = options;
  19817. this.id = options.id;
  19818. }
  19819. }
  19820. /**
  19821. * Render the plot line or plot band. If it is already existing,
  19822. * move it.
  19823. *
  19824. * @private
  19825. * @function Highcharts.PlotLineOrBand#render
  19826. * @return {Highcharts.PlotLineOrBand|undefined}
  19827. */
  19828. PlotLineOrBand.prototype.render = function () {
  19829. H.fireEvent(this, 'render');
  19830. var plotLine = this, axis = plotLine.axis, horiz = axis.horiz, log = axis.logarithmic, options = plotLine.options, optionsLabel = options.label, label = plotLine.label, to = options.to, from = options.from, value = options.value, isBand = defined(from) && defined(to), isLine = defined(value), svgElem = plotLine.svgElem, isNew = !svgElem, path = [], color = options.color, zIndex = pick(options.zIndex, 0), events = options.events, attribs = {
  19831. 'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') +
  19832. (options.className || '')
  19833. }, groupAttribs = {}, renderer = axis.chart.renderer, groupName = isBand ? 'bands' : 'lines', group;
  19834. // logarithmic conversion
  19835. if (log) {
  19836. from = log.log2lin(from);
  19837. to = log.log2lin(to);
  19838. value = log.log2lin(value);
  19839. }
  19840. // Set the presentational attributes
  19841. if (!axis.chart.styledMode) {
  19842. if (isLine) {
  19843. attribs.stroke = color || '#999999';
  19844. attribs['stroke-width'] = pick(options.width, 1);
  19845. if (options.dashStyle) {
  19846. attribs.dashstyle =
  19847. options.dashStyle;
  19848. }
  19849. }
  19850. else if (isBand) { // plot band
  19851. attribs.fill = color || '#e6ebf5';
  19852. if (options.borderWidth) {
  19853. attribs.stroke = options.borderColor;
  19854. attribs['stroke-width'] = options.borderWidth;
  19855. }
  19856. }
  19857. }
  19858. // Grouping and zIndex
  19859. groupAttribs.zIndex = zIndex;
  19860. groupName += '-' + zIndex;
  19861. group = axis.plotLinesAndBandsGroups[groupName];
  19862. if (!group) {
  19863. axis.plotLinesAndBandsGroups[groupName] = group =
  19864. renderer.g('plot-' + groupName)
  19865. .attr(groupAttribs).add();
  19866. }
  19867. // Create the path
  19868. if (isNew) {
  19869. /**
  19870. * SVG element of the plot line or band.
  19871. *
  19872. * @name Highcharts.PlotLineOrBand#svgElement
  19873. * @type {Highcharts.SVGElement}
  19874. */
  19875. plotLine.svgElem = svgElem = renderer
  19876. .path()
  19877. .attr(attribs)
  19878. .add(group);
  19879. }
  19880. // Set the path or return
  19881. if (isLine) {
  19882. path = axis.getPlotLinePath({
  19883. value: value,
  19884. lineWidth: svgElem.strokeWidth(),
  19885. acrossPanes: options.acrossPanes
  19886. });
  19887. }
  19888. else if (isBand) { // plot band
  19889. path = axis.getPlotBandPath(from, to, options);
  19890. }
  19891. else {
  19892. return;
  19893. }
  19894. // common for lines and bands
  19895. // Add events only if they were not added before.
  19896. if (!plotLine.eventsAdded && events) {
  19897. objectEach(events, function (event, eventType) {
  19898. svgElem.on(eventType, function (e) {
  19899. events[eventType].apply(plotLine, [e]);
  19900. });
  19901. });
  19902. plotLine.eventsAdded = true;
  19903. }
  19904. if ((isNew || !svgElem.d) && path && path.length) {
  19905. svgElem.attr({ d: path });
  19906. }
  19907. else if (svgElem) {
  19908. if (path) {
  19909. svgElem.show(true);
  19910. svgElem.animate({ d: path });
  19911. }
  19912. else if (svgElem.d) {
  19913. svgElem.hide();
  19914. if (label) {
  19915. plotLine.label = label = label.destroy();
  19916. }
  19917. }
  19918. }
  19919. // the plot band/line label
  19920. if (optionsLabel &&
  19921. (defined(optionsLabel.text) || defined(optionsLabel.formatter)) &&
  19922. path &&
  19923. path.length &&
  19924. axis.width > 0 &&
  19925. axis.height > 0 &&
  19926. !path.isFlat) {
  19927. // apply defaults
  19928. optionsLabel = merge({
  19929. align: horiz && isBand && 'center',
  19930. x: horiz ? !isBand && 4 : 10,
  19931. verticalAlign: !horiz && isBand && 'middle',
  19932. y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
  19933. rotation: horiz && !isBand && 90
  19934. }, optionsLabel);
  19935. this.renderLabel(optionsLabel, path, isBand, zIndex);
  19936. }
  19937. else if (label) { // move out of sight
  19938. label.hide();
  19939. }
  19940. // chainable
  19941. return plotLine;
  19942. };
  19943. /**
  19944. * Render and align label for plot line or band.
  19945. *
  19946. * @private
  19947. * @function Highcharts.PlotLineOrBand#renderLabel
  19948. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  19949. * @param {Highcharts.SVGPathArray} path
  19950. * @param {boolean} [isBand]
  19951. * @param {number} [zIndex]
  19952. * @return {void}
  19953. */
  19954. PlotLineOrBand.prototype.renderLabel = function (optionsLabel, path, isBand, zIndex) {
  19955. var plotLine = this, label = plotLine.label, renderer = plotLine.axis.chart.renderer, attribs, xBounds, yBounds, x, y, labelText;
  19956. // add the SVG element
  19957. if (!label) {
  19958. attribs = {
  19959. align: optionsLabel.textAlign || optionsLabel.align,
  19960. rotation: optionsLabel.rotation,
  19961. 'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') +
  19962. '-label ' + (optionsLabel.className || '')
  19963. };
  19964. attribs.zIndex = zIndex;
  19965. labelText = this.getLabelText(optionsLabel);
  19966. /**
  19967. * SVG element of the label.
  19968. *
  19969. * @name Highcharts.PlotLineOrBand#label
  19970. * @type {Highcharts.SVGElement}
  19971. */
  19972. plotLine.label = label = renderer
  19973. .text(labelText, 0, 0, optionsLabel.useHTML)
  19974. .attr(attribs)
  19975. .add();
  19976. if (!this.axis.chart.styledMode) {
  19977. label.css(optionsLabel.style);
  19978. }
  19979. }
  19980. // get the bounding box and align the label
  19981. // #3000 changed to better handle choice between plotband or plotline
  19982. xBounds = path.xBounds ||
  19983. [path[0][1], path[1][1], (isBand ? path[2][1] : path[0][1])];
  19984. yBounds = path.yBounds ||
  19985. [path[0][2], path[1][2], (isBand ? path[2][2] : path[0][2])];
  19986. x = arrayMin(xBounds);
  19987. y = arrayMin(yBounds);
  19988. label.align(optionsLabel, false, {
  19989. x: x,
  19990. y: y,
  19991. width: arrayMax(xBounds) - x,
  19992. height: arrayMax(yBounds) - y
  19993. });
  19994. label.show(true);
  19995. };
  19996. /**
  19997. * Get label's text content.
  19998. *
  19999. * @private
  20000. * @function Highcharts.PlotLineOrBand#getLabelText
  20001. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  20002. * @return {string}
  20003. */
  20004. PlotLineOrBand.prototype.getLabelText = function (optionsLabel) {
  20005. return defined(optionsLabel.formatter) ?
  20006. optionsLabel.formatter
  20007. .call(this) :
  20008. optionsLabel.text;
  20009. };
  20010. /**
  20011. * Remove the plot line or band.
  20012. *
  20013. * @function Highcharts.PlotLineOrBand#destroy
  20014. * @return {void}
  20015. */
  20016. PlotLineOrBand.prototype.destroy = function () {
  20017. // remove it from the lookup
  20018. erase(this.axis.plotLinesAndBands, this);
  20019. delete this.axis;
  20020. destroyObjectProperties(this);
  20021. };
  20022. return PlotLineOrBand;
  20023. }());
  20024. /* eslint-enable no-invalid-this, valid-jsdoc */
  20025. // Object with members for extending the Axis prototype
  20026. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  20027. /**
  20028. * An array of colored bands stretching across the plot area marking an
  20029. * interval on the axis.
  20030. *
  20031. * In styled mode, the plot bands are styled by the `.highcharts-plot-band`
  20032. * class in addition to the `className` option.
  20033. *
  20034. * @productdesc {highcharts}
  20035. * In a gauge, a plot band on the Y axis (value axis) will stretch along the
  20036. * perimeter of the gauge.
  20037. *
  20038. * @type {Array<*>}
  20039. * @product highcharts highstock gantt
  20040. * @apioption xAxis.plotBands
  20041. */
  20042. /**
  20043. * Flag to decide if plotBand should be rendered across all panes.
  20044. *
  20045. * @since 7.1.2
  20046. * @product highstock
  20047. * @type {boolean}
  20048. * @default true
  20049. * @apioption xAxis.plotBands.acrossPanes
  20050. */
  20051. /**
  20052. * Border color for the plot band. Also requires `borderWidth` to be set.
  20053. *
  20054. * @type {Highcharts.ColorString}
  20055. * @apioption xAxis.plotBands.borderColor
  20056. */
  20057. /**
  20058. * Border width for the plot band. Also requires `borderColor` to be set.
  20059. *
  20060. * @type {number}
  20061. * @default 0
  20062. * @apioption xAxis.plotBands.borderWidth
  20063. */
  20064. /**
  20065. * A custom class name, in addition to the default `highcharts-plot-band`,
  20066. * to apply to each individual band.
  20067. *
  20068. * @type {string}
  20069. * @since 5.0.0
  20070. * @apioption xAxis.plotBands.className
  20071. */
  20072. /**
  20073. * The color of the plot band.
  20074. *
  20075. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  20076. * Color band
  20077. * @sample {highstock} stock/xaxis/plotbands/
  20078. * Plot band on Y axis
  20079. *
  20080. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  20081. * @default #e6ebf5
  20082. * @apioption xAxis.plotBands.color
  20083. */
  20084. /**
  20085. * An object defining mouse events for the plot band. Supported properties
  20086. * are `click`, `mouseover`, `mouseout`, `mousemove`.
  20087. *
  20088. * @sample {highcharts} highcharts/xaxis/plotbands-events/
  20089. * Mouse events demonstrated
  20090. *
  20091. * @since 1.2
  20092. * @apioption xAxis.plotBands.events
  20093. */
  20094. /**
  20095. * Click event on a plot band.
  20096. *
  20097. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  20098. * @apioption xAxis.plotBands.events.click
  20099. */
  20100. /**
  20101. * Mouse move event on a plot band.
  20102. *
  20103. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  20104. * @apioption xAxis.plotBands.events.mousemove
  20105. */
  20106. /**
  20107. * Mouse out event on the corner of a plot band.
  20108. *
  20109. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  20110. * @apioption xAxis.plotBands.events.mouseout
  20111. */
  20112. /**
  20113. * Mouse over event on a plot band.
  20114. *
  20115. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  20116. * @apioption xAxis.plotBands.events.mouseover
  20117. */
  20118. /**
  20119. * The start position of the plot band in axis units.
  20120. *
  20121. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  20122. * Datetime axis
  20123. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  20124. * Categorized axis
  20125. * @sample {highstock} stock/xaxis/plotbands/
  20126. * Plot band on Y axis
  20127. *
  20128. * @type {number}
  20129. * @apioption xAxis.plotBands.from
  20130. */
  20131. /**
  20132. * An id used for identifying the plot band in Axis.removePlotBand.
  20133. *
  20134. * @sample {highcharts} highcharts/xaxis/plotbands-id/
  20135. * Remove plot band by id
  20136. * @sample {highstock} highcharts/xaxis/plotbands-id/
  20137. * Remove plot band by id
  20138. *
  20139. * @type {string}
  20140. * @apioption xAxis.plotBands.id
  20141. */
  20142. /**
  20143. * The end position of the plot band in axis units.
  20144. *
  20145. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  20146. * Datetime axis
  20147. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  20148. * Categorized axis
  20149. * @sample {highstock} stock/xaxis/plotbands/
  20150. * Plot band on Y axis
  20151. *
  20152. * @type {number}
  20153. * @apioption xAxis.plotBands.to
  20154. */
  20155. /**
  20156. * The z index of the plot band within the chart, relative to other
  20157. * elements. Using the same z index as another element may give
  20158. * unpredictable results, as the last rendered element will be on top.
  20159. * Values from 0 to 20 make sense.
  20160. *
  20161. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  20162. * Behind plot lines by default
  20163. * @sample {highcharts} highcharts/xaxis/plotbands-zindex/
  20164. * Above plot lines
  20165. * @sample {highcharts} highcharts/xaxis/plotbands-zindex-above-series/
  20166. * Above plot lines and series
  20167. *
  20168. * @type {number}
  20169. * @since 1.2
  20170. * @apioption xAxis.plotBands.zIndex
  20171. */
  20172. /**
  20173. * Text labels for the plot bands
  20174. *
  20175. * @product highcharts highstock gantt
  20176. * @apioption xAxis.plotBands.label
  20177. */
  20178. /**
  20179. * Horizontal alignment of the label. Can be one of "left", "center" or
  20180. * "right".
  20181. *
  20182. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  20183. * Aligned to the right
  20184. * @sample {highstock} stock/xaxis/plotbands-label/
  20185. * Plot band with labels
  20186. *
  20187. * @type {Highcharts.AlignValue}
  20188. * @default center
  20189. * @since 2.1
  20190. * @apioption xAxis.plotBands.label.align
  20191. */
  20192. /**
  20193. * Rotation of the text label in degrees .
  20194. *
  20195. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  20196. * Vertical text
  20197. *
  20198. * @type {number}
  20199. * @default 0
  20200. * @since 2.1
  20201. * @apioption xAxis.plotBands.label.rotation
  20202. */
  20203. /**
  20204. * CSS styles for the text label.
  20205. *
  20206. * In styled mode, the labels are styled by the
  20207. * `.highcharts-plot-band-label` class.
  20208. *
  20209. * @sample {highcharts} highcharts/xaxis/plotbands-label-style/
  20210. * Blue and bold label
  20211. *
  20212. * @type {Highcharts.CSSObject}
  20213. * @since 2.1
  20214. * @apioption xAxis.plotBands.label.style
  20215. */
  20216. /**
  20217. * The string text itself. A subset of HTML is supported.
  20218. *
  20219. * @type {string}
  20220. * @since 2.1
  20221. * @apioption xAxis.plotBands.label.text
  20222. */
  20223. /**
  20224. * The text alignment for the label. While `align` determines where the
  20225. * texts anchor point is placed within the plot band, `textAlign` determines
  20226. * how the text is aligned against its anchor point. Possible values are
  20227. * "left", "center" and "right". Defaults to the same as the `align` option.
  20228. *
  20229. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  20230. * Vertical text in center position but text-aligned left
  20231. *
  20232. * @type {Highcharts.AlignValue}
  20233. * @since 2.1
  20234. * @apioption xAxis.plotBands.label.textAlign
  20235. */
  20236. /**
  20237. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20238. * to render the labels.
  20239. *
  20240. * @type {boolean}
  20241. * @default false
  20242. * @since 3.0.3
  20243. * @apioption xAxis.plotBands.label.useHTML
  20244. */
  20245. /**
  20246. * Vertical alignment of the label relative to the plot band. Can be one of
  20247. * "top", "middle" or "bottom".
  20248. *
  20249. * @sample {highcharts} highcharts/xaxis/plotbands-label-verticalalign/
  20250. * Vertically centered label
  20251. * @sample {highstock} stock/xaxis/plotbands-label/
  20252. * Plot band with labels
  20253. *
  20254. * @type {Highcharts.VerticalAlignValue}
  20255. * @default top
  20256. * @since 2.1
  20257. * @apioption xAxis.plotBands.label.verticalAlign
  20258. */
  20259. /**
  20260. * Horizontal position relative the alignment. Default varies by
  20261. * orientation.
  20262. *
  20263. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  20264. * Aligned 10px from the right edge
  20265. * @sample {highstock} stock/xaxis/plotbands-label/
  20266. * Plot band with labels
  20267. *
  20268. * @type {number}
  20269. * @since 2.1
  20270. * @apioption xAxis.plotBands.label.x
  20271. */
  20272. /**
  20273. * Vertical position of the text baseline relative to the alignment. Default
  20274. * varies by orientation.
  20275. *
  20276. * @sample {highcharts} highcharts/xaxis/plotbands-label-y/
  20277. * Label on x axis
  20278. * @sample {highstock} stock/xaxis/plotbands-label/
  20279. * Plot band with labels
  20280. *
  20281. * @type {number}
  20282. * @since 2.1
  20283. * @apioption xAxis.plotBands.label.y
  20284. */
  20285. /**
  20286. * An array of lines stretching across the plot area, marking a specific
  20287. * value on one of the axes.
  20288. *
  20289. * In styled mode, the plot lines are styled by the
  20290. * `.highcharts-plot-line` class in addition to the `className` option.
  20291. *
  20292. * @type {Array<*>}
  20293. * @product highcharts highstock gantt
  20294. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  20295. * Basic plot line
  20296. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  20297. * Solid gauge plot line
  20298. * @apioption xAxis.plotLines
  20299. */
  20300. /**
  20301. * Flag to decide if plotLine should be rendered across all panes.
  20302. *
  20303. * @sample {highstock} stock/xaxis/plotlines-acrosspanes/
  20304. * Plot lines on different panes
  20305. *
  20306. * @since 7.1.2
  20307. * @product highstock
  20308. * @type {boolean}
  20309. * @default true
  20310. * @apioption xAxis.plotLines.acrossPanes
  20311. */
  20312. /**
  20313. * A custom class name, in addition to the default `highcharts-plot-line`,
  20314. * to apply to each individual line.
  20315. *
  20316. * @type {string}
  20317. * @since 5.0.0
  20318. * @apioption xAxis.plotLines.className
  20319. */
  20320. /**
  20321. * The color of the line.
  20322. *
  20323. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  20324. * A red line from X axis
  20325. * @sample {highstock} stock/xaxis/plotlines/
  20326. * Plot line on Y axis
  20327. *
  20328. * @type {Highcharts.ColorString}
  20329. * @default #999999
  20330. * @apioption xAxis.plotLines.color
  20331. */
  20332. /**
  20333. * The dashing or dot style for the plot line. For possible values see
  20334. * [this overview](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  20335. *
  20336. * @sample {highcharts} highcharts/xaxis/plotlines-dashstyle/
  20337. * Dash and dot pattern
  20338. * @sample {highstock} stock/xaxis/plotlines/
  20339. * Plot line on Y axis
  20340. *
  20341. * @type {Highcharts.DashStyleValue}
  20342. * @default Solid
  20343. * @since 1.2
  20344. * @apioption xAxis.plotLines.dashStyle
  20345. */
  20346. /**
  20347. * An object defining mouse events for the plot line. Supported
  20348. * properties are `click`, `mouseover`, `mouseout`, `mousemove`.
  20349. *
  20350. * @sample {highcharts} highcharts/xaxis/plotlines-events/
  20351. * Mouse events demonstrated
  20352. *
  20353. * @since 1.2
  20354. * @apioption xAxis.plotLines.events
  20355. */
  20356. /**
  20357. * Click event on a plot band.
  20358. *
  20359. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  20360. * @apioption xAxis.plotLines.events.click
  20361. */
  20362. /**
  20363. * Mouse move event on a plot band.
  20364. *
  20365. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  20366. * @apioption xAxis.plotLines.events.mousemove
  20367. */
  20368. /**
  20369. * Mouse out event on the corner of a plot band.
  20370. *
  20371. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  20372. * @apioption xAxis.plotLines.events.mouseout
  20373. */
  20374. /**
  20375. * Mouse over event on a plot band.
  20376. *
  20377. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  20378. * @apioption xAxis.plotLines.events.mouseover
  20379. */
  20380. /**
  20381. * An id used for identifying the plot line in Axis.removePlotLine.
  20382. *
  20383. * @sample {highcharts} highcharts/xaxis/plotlines-id/
  20384. * Remove plot line by id
  20385. *
  20386. * @type {string}
  20387. * @apioption xAxis.plotLines.id
  20388. */
  20389. /**
  20390. * The position of the line in axis units.
  20391. *
  20392. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  20393. * Between two categories on X axis
  20394. * @sample {highstock} stock/xaxis/plotlines/
  20395. * Plot line on Y axis
  20396. *
  20397. * @type {number}
  20398. * @apioption xAxis.plotLines.value
  20399. */
  20400. /**
  20401. * The width or thickness of the plot line.
  20402. *
  20403. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  20404. * 2px wide line from X axis
  20405. * @sample {highstock} stock/xaxis/plotlines/
  20406. * Plot line on Y axis
  20407. *
  20408. * @type {number}
  20409. * @default 2
  20410. * @apioption xAxis.plotLines.width
  20411. */
  20412. /**
  20413. * The z index of the plot line within the chart.
  20414. *
  20415. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-behind/
  20416. * Behind plot lines by default
  20417. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above/
  20418. * Above plot lines
  20419. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above-all/
  20420. * Above plot lines and series
  20421. *
  20422. * @type {number}
  20423. * @since 1.2
  20424. * @apioption xAxis.plotLines.zIndex
  20425. */
  20426. /**
  20427. * Text labels for the plot bands
  20428. *
  20429. * @apioption xAxis.plotLines.label
  20430. */
  20431. /**
  20432. * Horizontal alignment of the label. Can be one of "left", "center" or
  20433. * "right".
  20434. *
  20435. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  20436. * Aligned to the right
  20437. * @sample {highstock} stock/xaxis/plotlines/
  20438. * Plot line on Y axis
  20439. *
  20440. * @type {Highcharts.AlignValue}
  20441. * @default left
  20442. * @since 2.1
  20443. * @apioption xAxis.plotLines.label.align
  20444. */
  20445. /**
  20446. * Callback JavaScript function to format the label. Useful properties like
  20447. * the value of plot line or the range of plot band (`from` & `to`
  20448. * properties) can be found in `this.options` object.
  20449. *
  20450. * @sample {highcharts} highcharts/xaxis/plotlines-plotbands-label-formatter
  20451. * Label formatters for plot line and plot band.
  20452. * @type {Highcharts.FormatterCallbackFunction<Highcharts.PlotLineOrBand>}
  20453. * @apioption xAxis.plotLines.label.formatter
  20454. */
  20455. /**
  20456. * Rotation of the text label in degrees. Defaults to 0 for horizontal plot
  20457. * lines and 90 for vertical lines.
  20458. *
  20459. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  20460. * Slanted text
  20461. *
  20462. * @type {number}
  20463. * @since 2.1
  20464. * @apioption xAxis.plotLines.label.rotation
  20465. */
  20466. /**
  20467. * CSS styles for the text label.
  20468. *
  20469. * In styled mode, the labels are styled by the
  20470. * `.highcharts-plot-line-label` class.
  20471. *
  20472. * @sample {highcharts} highcharts/xaxis/plotlines-label-style/
  20473. * Blue and bold label
  20474. *
  20475. * @type {Highcharts.CSSObject}
  20476. * @since 2.1
  20477. * @apioption xAxis.plotLines.label.style
  20478. */
  20479. /**
  20480. * The text itself. A subset of HTML is supported.
  20481. *
  20482. * @type {string}
  20483. * @since 2.1
  20484. * @apioption xAxis.plotLines.label.text
  20485. */
  20486. /**
  20487. * The text alignment for the label. While `align` determines where the
  20488. * texts anchor point is placed within the plot band, `textAlign` determines
  20489. * how the text is aligned against its anchor point. Possible values are
  20490. * "left", "center" and "right". Defaults to the same as the `align` option.
  20491. *
  20492. * @sample {highcharts} highcharts/xaxis/plotlines-label-textalign/
  20493. * Text label in bottom position
  20494. *
  20495. * @type {Highcharts.AlignValue}
  20496. * @since 2.1
  20497. * @apioption xAxis.plotLines.label.textAlign
  20498. */
  20499. /**
  20500. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20501. * to render the labels.
  20502. *
  20503. * @type {boolean}
  20504. * @default false
  20505. * @since 3.0.3
  20506. * @apioption xAxis.plotLines.label.useHTML
  20507. */
  20508. /**
  20509. * Vertical alignment of the label relative to the plot line. Can be
  20510. * one of "top", "middle" or "bottom".
  20511. *
  20512. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  20513. * Vertically centered label
  20514. *
  20515. * @type {Highcharts.VerticalAlignValue}
  20516. * @default {highcharts} top
  20517. * @default {highstock} top
  20518. * @since 2.1
  20519. * @apioption xAxis.plotLines.label.verticalAlign
  20520. */
  20521. /**
  20522. * Horizontal position relative the alignment. Default varies by
  20523. * orientation.
  20524. *
  20525. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  20526. * Aligned 10px from the right edge
  20527. * @sample {highstock} stock/xaxis/plotlines/
  20528. * Plot line on Y axis
  20529. *
  20530. * @type {number}
  20531. * @since 2.1
  20532. * @apioption xAxis.plotLines.label.x
  20533. */
  20534. /**
  20535. * Vertical position of the text baseline relative to the alignment. Default
  20536. * varies by orientation.
  20537. *
  20538. * @sample {highcharts} highcharts/xaxis/plotlines-label-y/
  20539. * Label below the plot line
  20540. * @sample {highstock} stock/xaxis/plotlines/
  20541. * Plot line on Y axis
  20542. *
  20543. * @type {number}
  20544. * @since 2.1
  20545. * @apioption xAxis.plotLines.label.y
  20546. */
  20547. /**
  20548. *
  20549. * @type {Array<*>}
  20550. * @extends xAxis.plotBands
  20551. * @apioption yAxis.plotBands
  20552. */
  20553. /**
  20554. * In a gauge chart, this option determines the inner radius of the
  20555. * plot band that stretches along the perimeter. It can be given as
  20556. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  20557. * By default, the inner radius is controlled by the [thickness](
  20558. * #yAxis.plotBands.thickness) option.
  20559. *
  20560. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  20561. * Gauge plot band
  20562. *
  20563. * @type {number|string}
  20564. * @since 2.3
  20565. * @product highcharts
  20566. * @apioption yAxis.plotBands.innerRadius
  20567. */
  20568. /**
  20569. * In a gauge chart, this option determines the outer radius of the
  20570. * plot band that stretches along the perimeter. It can be given as
  20571. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  20572. *
  20573. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  20574. * Gauge plot band
  20575. *
  20576. * @type {number|string}
  20577. * @default 100%
  20578. * @since 2.3
  20579. * @product highcharts
  20580. * @apioption yAxis.plotBands.outerRadius
  20581. */
  20582. /**
  20583. * In a gauge chart, this option sets the width of the plot band
  20584. * stretching along the perimeter. It can be given as a percentage
  20585. * string, like `"10%"`, or as a pixel number, like `10`. The default
  20586. * value 10 is the same as the default [tickLength](#yAxis.tickLength),
  20587. * thus making the plot band act as a background for the tick markers.
  20588. *
  20589. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  20590. * Gauge plot band
  20591. *
  20592. * @type {number|string}
  20593. * @default 10
  20594. * @since 2.3
  20595. * @product highcharts
  20596. * @apioption yAxis.plotBands.thickness
  20597. */
  20598. /**
  20599. * @type {Array<*>}
  20600. * @extends xAxis.plotLines
  20601. * @apioption yAxis.plotLines
  20602. */
  20603. /* eslint-disable no-invalid-this, valid-jsdoc */
  20604. /**
  20605. * Internal function to create the SVG path definition for a plot band.
  20606. *
  20607. * @function Highcharts.Axis#getPlotBandPath
  20608. *
  20609. * @param {number} from
  20610. * The axis value to start from.
  20611. *
  20612. * @param {number} to
  20613. * The axis value to end on.
  20614. *
  20615. * @return {Highcharts.SVGPathArray}
  20616. * The SVG path definition in array form.
  20617. */
  20618. getPlotBandPath: function (from, to) {
  20619. var toPath = this.getPlotLinePath({
  20620. value: to,
  20621. force: true,
  20622. acrossPanes: this.options.acrossPanes
  20623. }), path = this.getPlotLinePath({
  20624. value: from,
  20625. force: true,
  20626. acrossPanes: this.options.acrossPanes
  20627. }), result = [], i,
  20628. // #4964 check if chart is inverted or plotband is on yAxis
  20629. horiz = this.horiz, plus = 1, isFlat, outside = (from < this.min && to < this.min) ||
  20630. (from > this.max && to > this.max);
  20631. if (path && toPath) {
  20632. // Flat paths don't need labels (#3836)
  20633. if (outside) {
  20634. isFlat = path.toString() === toPath.toString();
  20635. plus = 0;
  20636. }
  20637. // Go over each subpath - for panes in Highstock
  20638. for (i = 0; i < path.length; i += 2) {
  20639. var pathStart = path[i], pathEnd = path[i + 1], toPathStart = toPath[i], toPathEnd = toPath[i + 1];
  20640. // Type checking all affected path segments. Consider something
  20641. // smarter.
  20642. if ((pathStart[0] === 'M' || pathStart[0] === 'L') &&
  20643. (pathEnd[0] === 'M' || pathEnd[0] === 'L') &&
  20644. (toPathStart[0] === 'M' || toPathStart[0] === 'L') &&
  20645. (toPathEnd[0] === 'M' || toPathEnd[0] === 'L')) {
  20646. // Add 1 pixel when coordinates are the same
  20647. if (horiz && toPathStart[1] === pathStart[1]) {
  20648. toPathStart[1] += plus;
  20649. toPathEnd[1] += plus;
  20650. }
  20651. else if (!horiz && toPathStart[2] === pathStart[2]) {
  20652. toPathStart[2] += plus;
  20653. toPathEnd[2] += plus;
  20654. }
  20655. result.push(['M', pathStart[1], pathStart[2]], ['L', pathEnd[1], pathEnd[2]], ['L', toPathEnd[1], toPathEnd[2]], ['L', toPathStart[1], toPathStart[2]], ['Z']);
  20656. }
  20657. result.isFlat = isFlat;
  20658. }
  20659. }
  20660. else { // outside the axis area
  20661. path = null;
  20662. }
  20663. return result;
  20664. },
  20665. /**
  20666. * Add a plot band after render time.
  20667. *
  20668. * @sample highcharts/members/axis-addplotband/
  20669. * Toggle the plot band from a button
  20670. *
  20671. * @function Highcharts.Axis#addPlotBand
  20672. *
  20673. * @param {Highcharts.AxisPlotBandsOptions} options
  20674. * A configuration object for the plot band, as defined in
  20675. * [xAxis.plotBands](https://api.highcharts.com/highcharts/xAxis.plotBands).
  20676. *
  20677. * @return {Highcharts.PlotLineOrBand|undefined}
  20678. * The added plot band.
  20679. */
  20680. addPlotBand: function (options) {
  20681. return this.addPlotBandOrLine(options, 'plotBands');
  20682. },
  20683. /**
  20684. * Add a plot line after render time.
  20685. *
  20686. * @sample highcharts/members/axis-addplotline/
  20687. * Toggle the plot line from a button
  20688. *
  20689. * @function Highcharts.Axis#addPlotLine
  20690. *
  20691. * @param {Highcharts.AxisPlotLinesOptions} options
  20692. * A configuration object for the plot line, as defined in
  20693. * [xAxis.plotLines](https://api.highcharts.com/highcharts/xAxis.plotLines).
  20694. *
  20695. * @return {Highcharts.PlotLineOrBand|undefined}
  20696. * The added plot line.
  20697. */
  20698. addPlotLine: function (options) {
  20699. return this.addPlotBandOrLine(options, 'plotLines');
  20700. },
  20701. /**
  20702. * Add a plot band or plot line after render time. Called from addPlotBand
  20703. * and addPlotLine internally.
  20704. *
  20705. * @private
  20706. * @function Highcharts.Axis#addPlotBandOrLine
  20707. *
  20708. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  20709. * The plotBand or plotLine configuration object.
  20710. *
  20711. * @param {"plotBands"|"plotLines"} [coll]
  20712. *
  20713. * @return {Highcharts.PlotLineOrBand|undefined}
  20714. */
  20715. addPlotBandOrLine: function (options, coll) {
  20716. var obj = new PlotLineOrBand(this, options).render(), userOptions = this.userOptions;
  20717. if (obj) { // #2189
  20718. // Add it to the user options for exporting and Axis.update
  20719. if (coll) {
  20720. // Workaround Microsoft/TypeScript issue #32693
  20721. var updatedOptions = (userOptions[coll] || []);
  20722. updatedOptions.push(options);
  20723. userOptions[coll] = updatedOptions;
  20724. }
  20725. this.plotLinesAndBands.push(obj);
  20726. this._addedPlotLB = true;
  20727. }
  20728. return obj;
  20729. },
  20730. /**
  20731. * Remove a plot band or plot line from the chart by id. Called internally
  20732. * from `removePlotBand` and `removePlotLine`.
  20733. *
  20734. * @private
  20735. * @function Highcharts.Axis#removePlotBandOrLine
  20736. * @param {string} id
  20737. * @return {void}
  20738. */
  20739. removePlotBandOrLine: function (id) {
  20740. var plotLinesAndBands = this.plotLinesAndBands, options = this.options, userOptions = this.userOptions, i = plotLinesAndBands.length;
  20741. while (i--) {
  20742. if (plotLinesAndBands[i].id === id) {
  20743. plotLinesAndBands[i].destroy();
  20744. }
  20745. }
  20746. ([
  20747. options.plotLines || [],
  20748. userOptions.plotLines || [],
  20749. options.plotBands || [],
  20750. userOptions.plotBands || []
  20751. ]).forEach(function (arr) {
  20752. i = arr.length;
  20753. while (i--) {
  20754. if ((arr[i] || {}).id === id) {
  20755. erase(arr, arr[i]);
  20756. }
  20757. }
  20758. });
  20759. },
  20760. /**
  20761. * Remove a plot band by its id.
  20762. *
  20763. * @sample highcharts/members/axis-removeplotband/
  20764. * Remove plot band by id
  20765. * @sample highcharts/members/axis-addplotband/
  20766. * Toggle the plot band from a button
  20767. *
  20768. * @function Highcharts.Axis#removePlotBand
  20769. *
  20770. * @param {string} id
  20771. * The plot band's `id` as given in the original configuration
  20772. * object or in the `addPlotBand` option.
  20773. *
  20774. * @return {void}
  20775. */
  20776. removePlotBand: function (id) {
  20777. this.removePlotBandOrLine(id);
  20778. },
  20779. /**
  20780. * Remove a plot line by its id.
  20781. *
  20782. * @sample highcharts/xaxis/plotlines-id/
  20783. * Remove plot line by id
  20784. * @sample highcharts/members/axis-addplotline/
  20785. * Toggle the plot line from a button
  20786. *
  20787. * @function Highcharts.Axis#removePlotLine
  20788. *
  20789. * @param {string} id
  20790. * The plot line's `id` as given in the original configuration
  20791. * object or in the `addPlotLine` option.
  20792. */
  20793. removePlotLine: function (id) {
  20794. this.removePlotBandOrLine(id);
  20795. }
  20796. });
  20797. H.PlotLineOrBand = PlotLineOrBand;
  20798. return H.PlotLineOrBand;
  20799. });
  20800. _registerModule(_modules, 'parts/Tooltip.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  20801. /* *
  20802. *
  20803. * (c) 2010-2020 Torstein Honsi
  20804. *
  20805. * License: www.highcharts.com/license
  20806. *
  20807. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  20808. *
  20809. * */
  20810. var doc = H.doc;
  20811. var clamp = U.clamp, css = U.css, defined = U.defined, discardElement = U.discardElement, extend = U.extend, fireEvent = U.fireEvent, format = U.format, isNumber = U.isNumber, isString = U.isString, merge = U.merge, pick = U.pick, splat = U.splat, syncTimeout = U.syncTimeout, timeUnits = U.timeUnits;
  20812. /**
  20813. * Callback function to format the text of the tooltip from scratch.
  20814. *
  20815. * In case of single or shared tooltips, a string should be be returned. In case
  20816. * of splitted tooltips, it should return an array where the first item is the
  20817. * header, and subsequent items are mapped to the points. Return `false` to
  20818. * disable tooltip for a specific point on series.
  20819. *
  20820. * @callback Highcharts.TooltipFormatterCallbackFunction
  20821. *
  20822. * @param {Highcharts.TooltipFormatterContextObject} this
  20823. * Context to format
  20824. *
  20825. * @param {Highcharts.Tooltip} tooltip
  20826. * The tooltip instance
  20827. *
  20828. * @return {false|string|Array<(string|null|undefined)>|null|undefined}
  20829. * Formatted text or false
  20830. */
  20831. /**
  20832. * @interface Highcharts.TooltipFormatterContextObject
  20833. */ /**
  20834. * @name Highcharts.TooltipFormatterContextObject#color
  20835. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  20836. */ /**
  20837. * @name Highcharts.TooltipFormatterContextObject#colorIndex
  20838. * @type {number|undefined}
  20839. */ /**
  20840. * @name Highcharts.TooltipFormatterContextObject#key
  20841. * @type {number}
  20842. */ /**
  20843. * @name Highcharts.TooltipFormatterContextObject#percentage
  20844. * @type {number|undefined}
  20845. */ /**
  20846. * @name Highcharts.TooltipFormatterContextObject#point
  20847. * @type {Highcharts.Point}
  20848. */ /**
  20849. * @name Highcharts.TooltipFormatterContextObject#points
  20850. * @type {Array<Highcharts.TooltipFormatterContextObject>|undefined}
  20851. */ /**
  20852. * @name Highcharts.TooltipFormatterContextObject#series
  20853. * @type {Highcharts.Series}
  20854. */ /**
  20855. * @name Highcharts.TooltipFormatterContextObject#total
  20856. * @type {number|undefined}
  20857. */ /**
  20858. * @name Highcharts.TooltipFormatterContextObject#x
  20859. * @type {number}
  20860. */ /**
  20861. * @name Highcharts.TooltipFormatterContextObject#y
  20862. * @type {number}
  20863. */
  20864. /**
  20865. * A callback function to place the tooltip in a specific position.
  20866. *
  20867. * @callback Highcharts.TooltipPositionerCallbackFunction
  20868. *
  20869. * @param {Highcharts.Tooltip} this
  20870. * Tooltip context of the callback.
  20871. *
  20872. * @param {number} labelWidth
  20873. * Width of the tooltip.
  20874. *
  20875. * @param {number} labelHeight
  20876. * Height of the tooltip.
  20877. *
  20878. * @param {Highcharts.Point|Highcharts.TooltipPositionerPointObject} point
  20879. * Point information for positioning a tooltip.
  20880. *
  20881. * @return {Highcharts.PositionObject}
  20882. * New position for the tooltip.
  20883. */
  20884. /**
  20885. * Point information for positioning a tooltip.
  20886. *
  20887. * @interface Highcharts.TooltipPositionerPointObject
  20888. */ /**
  20889. * If `tooltip.split` option is enabled and positioner is called for each of the
  20890. * boxes separately, this property indicates the call on the xAxis header, which
  20891. * is not a point itself.
  20892. * @name Highcharts.TooltipPositionerPointObject#isHeader
  20893. * @type {boolean}
  20894. */ /**
  20895. * The reference point relative to the plot area. Add chart.plotLeft to get the
  20896. * full coordinates.
  20897. * @name Highcharts.TooltipPositionerPointObject#plotX
  20898. * @type {number}
  20899. */ /**
  20900. * The reference point relative to the plot area. Add chart.plotTop to get the
  20901. * full coordinates.
  20902. * @name Highcharts.TooltipPositionerPointObject#plotY
  20903. * @type {number}
  20904. */
  20905. /**
  20906. * @typedef {"callout"|"circle"|"square"} Highcharts.TooltipShapeValue
  20907. */
  20908. ''; // separates doclets above from variables below
  20909. /* eslint-disable no-invalid-this, valid-jsdoc */
  20910. /**
  20911. * Tooltip of a chart.
  20912. *
  20913. * @class
  20914. * @name Highcharts.Tooltip
  20915. *
  20916. * @param {Highcharts.Chart} chart
  20917. * The chart instance.
  20918. *
  20919. * @param {Highcharts.TooltipOptions} options
  20920. * Tooltip options.
  20921. */
  20922. var Tooltip = /** @class */ (function () {
  20923. /* *
  20924. *
  20925. * Constructors
  20926. *
  20927. * */
  20928. function Tooltip(chart, options) {
  20929. this.container = void 0;
  20930. this.crosshairs = [];
  20931. this.distance = 0;
  20932. this.isHidden = true;
  20933. this.isSticky = false;
  20934. this.now = {};
  20935. this.options = {};
  20936. this.outside = false;
  20937. this.chart = chart;
  20938. this.init(chart, options);
  20939. }
  20940. /* *
  20941. *
  20942. * Functions
  20943. *
  20944. * */
  20945. /**
  20946. * In styled mode, apply the default filter for the tooltip drop-shadow. It
  20947. * needs to have an id specific to the chart, otherwise there will be issues
  20948. * when one tooltip adopts the filter of a different chart, specifically one
  20949. * where the container is hidden.
  20950. *
  20951. * @private
  20952. * @function Highcharts.Tooltip#applyFilter
  20953. */
  20954. Tooltip.prototype.applyFilter = function () {
  20955. var chart = this.chart;
  20956. chart.renderer.definition({
  20957. tagName: 'filter',
  20958. id: 'drop-shadow-' + chart.index,
  20959. opacity: 0.5,
  20960. children: [{
  20961. tagName: 'feGaussianBlur',
  20962. 'in': 'SourceAlpha',
  20963. stdDeviation: 1
  20964. }, {
  20965. tagName: 'feOffset',
  20966. dx: 1,
  20967. dy: 1
  20968. }, {
  20969. tagName: 'feComponentTransfer',
  20970. children: [{
  20971. tagName: 'feFuncA',
  20972. type: 'linear',
  20973. slope: 0.3
  20974. }]
  20975. }, {
  20976. tagName: 'feMerge',
  20977. children: [{
  20978. tagName: 'feMergeNode'
  20979. }, {
  20980. tagName: 'feMergeNode',
  20981. 'in': 'SourceGraphic'
  20982. }]
  20983. }]
  20984. });
  20985. chart.renderer.definition({
  20986. tagName: 'style',
  20987. textContent: '.highcharts-tooltip-' + chart.index + '{' +
  20988. 'filter:url(#drop-shadow-' + chart.index + ')' +
  20989. '}'
  20990. });
  20991. };
  20992. /**
  20993. * Build the body (lines) of the tooltip by iterating over the items and
  20994. * returning one entry for each item, abstracting this functionality allows
  20995. * to easily overwrite and extend it.
  20996. *
  20997. * @private
  20998. * @function Highcharts.Tooltip#bodyFormatter
  20999. * @param {Array<(Highcharts.Point|Highcharts.Series)>} items
  21000. * @return {Array<string>}
  21001. */
  21002. Tooltip.prototype.bodyFormatter = function (items) {
  21003. return items.map(function (item) {
  21004. var tooltipOptions = item.series.tooltipOptions;
  21005. return (tooltipOptions[(item.point.formatPrefix || 'point') + 'Formatter'] ||
  21006. item.point.tooltipFormatter).call(item.point, tooltipOptions[(item.point.formatPrefix || 'point') + 'Format'] || '');
  21007. });
  21008. };
  21009. /**
  21010. * Destroy the single tooltips in a split tooltip.
  21011. * If the tooltip is active then it is not destroyed, unless forced to.
  21012. *
  21013. * @private
  21014. * @function Highcharts.Tooltip#cleanSplit
  21015. *
  21016. * @param {boolean} [force]
  21017. * Force destroy all tooltips.
  21018. */
  21019. Tooltip.prototype.cleanSplit = function (force) {
  21020. this.chart.series.forEach(function (series) {
  21021. var tt = series && series.tt;
  21022. if (tt) {
  21023. if (!tt.isActive || force) {
  21024. series.tt = tt.destroy();
  21025. }
  21026. else {
  21027. tt.isActive = false;
  21028. }
  21029. }
  21030. });
  21031. };
  21032. /**
  21033. * In case no user defined formatter is given, this will be used. Note that
  21034. * the context here is an object holding point, series, x, y etc.
  21035. *
  21036. * @function Highcharts.Tooltip#defaultFormatter
  21037. *
  21038. * @param {Highcharts.Tooltip} tooltip
  21039. *
  21040. * @return {Array<string>}
  21041. */
  21042. Tooltip.prototype.defaultFormatter = function (tooltip) {
  21043. var items = this.points || splat(this), s;
  21044. // Build the header
  21045. s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
  21046. // build the values
  21047. s = s.concat(tooltip.bodyFormatter(items));
  21048. // footer
  21049. s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
  21050. return s;
  21051. };
  21052. /**
  21053. * Removes and destroys the tooltip and its elements.
  21054. *
  21055. * @function Highcharts.Tooltip#destroy
  21056. */
  21057. Tooltip.prototype.destroy = function () {
  21058. // Destroy and clear local variables
  21059. if (this.label) {
  21060. this.label = this.label.destroy();
  21061. }
  21062. if (this.split && this.tt) {
  21063. this.cleanSplit(this.chart, true);
  21064. this.tt = this.tt.destroy();
  21065. }
  21066. if (this.renderer) {
  21067. this.renderer = this.renderer.destroy();
  21068. discardElement(this.container);
  21069. }
  21070. U.clearTimeout(this.hideTimer);
  21071. U.clearTimeout(this.tooltipTimeout);
  21072. };
  21073. /**
  21074. * Extendable method to get the anchor position of the tooltip
  21075. * from a point or set of points
  21076. *
  21077. * @private
  21078. * @function Highcharts.Tooltip#getAnchor
  21079. *
  21080. * @param {Highcharts.Point|Array<Highcharts.Point>} points
  21081. *
  21082. * @param {Highcharts.PointerEventObject} [mouseEvent]
  21083. *
  21084. * @return {Array<number>}
  21085. */
  21086. Tooltip.prototype.getAnchor = function (points, mouseEvent) {
  21087. var ret, chart = this.chart, pointer = chart.pointer, inverted = chart.inverted, plotTop = chart.plotTop, plotLeft = chart.plotLeft, plotX = 0, plotY = 0, yAxis, xAxis;
  21088. points = splat(points);
  21089. // When tooltip follows mouse, relate the position to the mouse
  21090. if (this.followPointer && mouseEvent) {
  21091. if (typeof mouseEvent.chartX === 'undefined') {
  21092. mouseEvent = pointer.normalize(mouseEvent);
  21093. }
  21094. ret = [
  21095. mouseEvent.chartX - plotLeft,
  21096. mouseEvent.chartY - plotTop
  21097. ];
  21098. // Some series types use a specificly calculated tooltip position for
  21099. // each point
  21100. }
  21101. else if (points[0].tooltipPos) {
  21102. ret = points[0].tooltipPos;
  21103. // When shared, use the average position
  21104. }
  21105. else {
  21106. points.forEach(function (point) {
  21107. yAxis = point.series.yAxis;
  21108. xAxis = point.series.xAxis;
  21109. plotX += point.plotX +
  21110. (!inverted && xAxis ? xAxis.left - plotLeft : 0);
  21111. plotY += (point.plotLow ?
  21112. (point.plotLow + point.plotHigh) / 2 :
  21113. point.plotY) + (!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
  21114. });
  21115. plotX /= points.length;
  21116. plotY /= points.length;
  21117. ret = [
  21118. inverted ? chart.plotWidth - plotY : plotX,
  21119. this.shared && !inverted && points.length > 1 && mouseEvent ?
  21120. // place shared tooltip next to the mouse (#424)
  21121. mouseEvent.chartY - plotTop :
  21122. inverted ? chart.plotHeight - plotX : plotY
  21123. ];
  21124. }
  21125. return ret.map(Math.round);
  21126. };
  21127. /**
  21128. * Get the optimal date format for a point, based on a range.
  21129. *
  21130. * @private
  21131. * @function Highcharts.Tooltip#getDateFormat
  21132. *
  21133. * @param {number} range
  21134. * The time range
  21135. *
  21136. * @param {number} date
  21137. * The date of the point in question
  21138. *
  21139. * @param {number} startOfWeek
  21140. * An integer representing the first day of the week, where 0 is
  21141. * Sunday.
  21142. *
  21143. * @param {Highcharts.Dictionary<string>} dateTimeLabelFormats
  21144. * A map of time units to formats.
  21145. *
  21146. * @return {string}
  21147. * The optimal date format for a point.
  21148. */
  21149. Tooltip.prototype.getDateFormat = function (range, date, startOfWeek, dateTimeLabelFormats) {
  21150. 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 = {
  21151. millisecond: 15,
  21152. second: 12,
  21153. minute: 9,
  21154. hour: 6,
  21155. day: 3
  21156. }, lastN = 'millisecond'; // for sub-millisecond data, #4223
  21157. for (n in timeUnits) { // eslint-disable-line guard-for-in
  21158. // If the range is exactly one week and we're looking at a
  21159. // Sunday/Monday, go for the week format
  21160. if (range === timeUnits.week &&
  21161. +time.dateFormat('%w', date) === startOfWeek &&
  21162. dateStr.substr(6) === blank.substr(6)) {
  21163. n = 'week';
  21164. break;
  21165. }
  21166. // The first format that is too great for the range
  21167. if (timeUnits[n] > range) {
  21168. n = lastN;
  21169. break;
  21170. }
  21171. // If the point is placed every day at 23:59, we need to show
  21172. // the minutes as well. #2637.
  21173. if (strpos[n] &&
  21174. dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
  21175. break;
  21176. }
  21177. // Weeks are outside the hierarchy, only apply them on
  21178. // Mondays/Sundays like in the first condition
  21179. if (n !== 'week') {
  21180. lastN = n;
  21181. }
  21182. }
  21183. if (n) {
  21184. format = time.resolveDTLFormat(dateTimeLabelFormats[n]).main;
  21185. }
  21186. return format;
  21187. };
  21188. /**
  21189. * Creates the Tooltip label element if it does not exist, then returns it.
  21190. *
  21191. * @function Highcharts.Tooltip#getLabel
  21192. * @return {Highcharts.SVGElement}
  21193. */
  21194. Tooltip.prototype.getLabel = function () {
  21195. var _a, _b;
  21196. var tooltip = this, renderer = this.chart.renderer, styledMode = this.chart.styledMode, options = this.options, className = ('tooltip' + (defined(options.className) ?
  21197. ' ' + options.className :
  21198. '')), pointerEvents = (((_a = options.style) === null || _a === void 0 ? void 0 : _a.pointerEvents) ||
  21199. (!this.followPointer && options.stickOnContact ? 'auto' : 'none')), container, set, onMouseEnter = function () {
  21200. tooltip.inContact = true;
  21201. }, onMouseLeave = function () {
  21202. var series = tooltip.chart.hoverSeries;
  21203. tooltip.inContact = false;
  21204. if (series &&
  21205. series.onMouseOut) {
  21206. series.onMouseOut();
  21207. }
  21208. };
  21209. if (!this.label) {
  21210. if (this.outside) {
  21211. /**
  21212. * Reference to the tooltip's container, when
  21213. * [Highcharts.Tooltip#outside] is set to true, otherwise
  21214. * it's undefined.
  21215. *
  21216. * @name Highcharts.Tooltip#container
  21217. * @type {Highcharts.HTMLDOMElement|undefined}
  21218. */
  21219. this.container = container = H.doc.createElement('div');
  21220. container.className = 'highcharts-tooltip-container';
  21221. css(container, {
  21222. position: 'absolute',
  21223. top: '1px',
  21224. pointerEvents: pointerEvents,
  21225. zIndex: 3
  21226. });
  21227. H.doc.body.appendChild(container);
  21228. /**
  21229. * Reference to the tooltip's renderer, when
  21230. * [Highcharts.Tooltip#outside] is set to true, otherwise
  21231. * it's undefined.
  21232. *
  21233. * @name Highcharts.Tooltip#renderer
  21234. * @type {Highcharts.SVGRenderer|undefined}
  21235. */
  21236. 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);
  21237. }
  21238. // Create the label
  21239. if (this.split) {
  21240. this.label = renderer.g(className);
  21241. }
  21242. else {
  21243. this.label = renderer
  21244. .label('', 0, 0, options.shape || 'callout', null, null, options.useHTML, null, className)
  21245. .attr({
  21246. padding: options.padding,
  21247. r: options.borderRadius
  21248. });
  21249. if (!styledMode) {
  21250. this.label
  21251. .attr({
  21252. fill: options.backgroundColor,
  21253. 'stroke-width': options.borderWidth
  21254. })
  21255. // #2301, #2657
  21256. .css(options.style)
  21257. .css({ pointerEvents: pointerEvents })
  21258. .shadow(options.shadow);
  21259. }
  21260. }
  21261. if (styledMode) {
  21262. // Apply the drop-shadow filter
  21263. this.applyFilter();
  21264. this.label.addClass('highcharts-tooltip-' + this.chart.index);
  21265. }
  21266. // Split tooltip use updateTooltipContainer to position the tooltip
  21267. // container.
  21268. if (tooltip.outside && !tooltip.split) {
  21269. var label_1 = this.label;
  21270. var xSetter_1 = label_1.xSetter, ySetter_1 = label_1.ySetter;
  21271. label_1.xSetter = function (value) {
  21272. xSetter_1.call(label_1, tooltip.distance);
  21273. container.style.left = value + 'px';
  21274. };
  21275. label_1.ySetter = function (value) {
  21276. ySetter_1.call(label_1, tooltip.distance);
  21277. container.style.top = value + 'px';
  21278. };
  21279. }
  21280. this.label
  21281. .on('mouseenter', onMouseEnter)
  21282. .on('mouseleave', onMouseLeave)
  21283. .attr({ zIndex: 8 })
  21284. .add();
  21285. }
  21286. return this.label;
  21287. };
  21288. /**
  21289. * Place the tooltip in a chart without spilling over
  21290. * and not covering the point it self.
  21291. *
  21292. * @private
  21293. * @function Highcharts.Tooltip#getPosition
  21294. *
  21295. * @param {number} boxWidth
  21296. *
  21297. * @param {number} boxHeight
  21298. *
  21299. * @param {Highcharts.Point} point
  21300. *
  21301. * @return {Highcharts.PositionObject}
  21302. */
  21303. Tooltip.prototype.getPosition = function (boxWidth, boxHeight, point) {
  21304. var chart = this.chart, distance = this.distance, ret = {},
  21305. // Don't use h if chart isn't inverted (#7242) ???
  21306. h = (chart.inverted && point.h) || 0, // #4117 ???
  21307. swapped, outside = this.outside, outerWidth = outside ?
  21308. // substract distance to prevent scrollbars
  21309. doc.documentElement.clientWidth - 2 * distance :
  21310. chart.chartWidth, outerHeight = outside ?
  21311. Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight, doc.body.offsetHeight, doc.documentElement.offsetHeight, doc.documentElement.clientHeight) :
  21312. chart.chartHeight, chartPosition = chart.pointer.getChartPosition(), containerScaling = chart.containerScaling, scaleX = function (val) { return ( // eslint-disable-line no-confusing-arrow
  21313. containerScaling ? val * containerScaling.scaleX : val); }, scaleY = function (val) { return ( // eslint-disable-line no-confusing-arrow
  21314. containerScaling ? val * containerScaling.scaleY : val); },
  21315. // Build parameter arrays for firstDimension()/secondDimension()
  21316. buildDimensionArray = function (dim) {
  21317. var isX = dim === 'x';
  21318. return [
  21319. dim,
  21320. isX ? outerWidth : outerHeight,
  21321. isX ? boxWidth : boxHeight
  21322. ].concat(outside ? [
  21323. // If we are using tooltip.outside, we need to scale the
  21324. // position to match scaling of the container in case there
  21325. // is a transform/zoom on the container. #11329
  21326. isX ? scaleX(boxWidth) : scaleY(boxHeight),
  21327. isX ? chartPosition.left - distance +
  21328. scaleX(point.plotX + chart.plotLeft) :
  21329. chartPosition.top - distance +
  21330. scaleY(point.plotY + chart.plotTop),
  21331. 0,
  21332. isX ? outerWidth : outerHeight
  21333. ] : [
  21334. // Not outside, no scaling is needed
  21335. isX ? boxWidth : boxHeight,
  21336. isX ? point.plotX + chart.plotLeft :
  21337. point.plotY + chart.plotTop,
  21338. isX ? chart.plotLeft : chart.plotTop,
  21339. isX ? chart.plotLeft + chart.plotWidth :
  21340. chart.plotTop + chart.plotHeight
  21341. ]);
  21342. }, first = buildDimensionArray('y'), second = buildDimensionArray('x'),
  21343. // The far side is right or bottom
  21344. preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
  21345. /*
  21346. * Handle the preferred dimension. When the preferred dimension is
  21347. * tooltip on top or bottom of the point, it will look for space
  21348. * there.
  21349. *
  21350. * @private
  21351. */
  21352. firstDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  21353. point, min, max) {
  21354. var scaledDist = dim === 'y' ?
  21355. scaleY(distance) : scaleX(distance), scaleDiff = (innerSize - scaledInnerSize) / 2, roomLeft = scaledInnerSize < point - distance, roomRight = point + distance + scaledInnerSize < outerSize, alignedLeft = point - scaledDist - innerSize + scaleDiff, alignedRight = point + scaledDist - scaleDiff;
  21356. if (preferFarSide && roomRight) {
  21357. ret[dim] = alignedRight;
  21358. }
  21359. else if (!preferFarSide && roomLeft) {
  21360. ret[dim] = alignedLeft;
  21361. }
  21362. else if (roomLeft) {
  21363. ret[dim] = Math.min(max - scaledInnerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
  21364. }
  21365. else if (roomRight) {
  21366. ret[dim] = Math.max(min, alignedRight + h + innerSize > outerSize ?
  21367. alignedRight :
  21368. alignedRight + h);
  21369. }
  21370. else {
  21371. return false;
  21372. }
  21373. },
  21374. /*
  21375. * Handle the secondary dimension. If the preferred dimension is
  21376. * tooltip on top or bottom of the point, the second dimension is to
  21377. * align the tooltip above the point, trying to align center but
  21378. * allowing left or right align within the chart box.
  21379. *
  21380. * @private
  21381. */
  21382. secondDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  21383. point) {
  21384. var retVal;
  21385. // Too close to the edge, return false and swap dimensions
  21386. if (point < distance || point > outerSize - distance) {
  21387. retVal = false;
  21388. // Align left/top
  21389. }
  21390. else if (point < innerSize / 2) {
  21391. ret[dim] = 1;
  21392. // Align right/bottom
  21393. }
  21394. else if (point > outerSize - scaledInnerSize / 2) {
  21395. ret[dim] = outerSize - scaledInnerSize - 2;
  21396. // Align center
  21397. }
  21398. else {
  21399. ret[dim] = point - innerSize / 2;
  21400. }
  21401. return retVal;
  21402. },
  21403. /*
  21404. * Swap the dimensions
  21405. */
  21406. swap = function (count) {
  21407. var temp = first;
  21408. first = second;
  21409. second = temp;
  21410. swapped = count;
  21411. }, run = function () {
  21412. if (firstDimension.apply(0, first) !== false) {
  21413. if (secondDimension.apply(0, second) === false &&
  21414. !swapped) {
  21415. swap(true);
  21416. run();
  21417. }
  21418. }
  21419. else if (!swapped) {
  21420. swap(true);
  21421. run();
  21422. }
  21423. else {
  21424. ret.x = ret.y = 0;
  21425. }
  21426. };
  21427. // Under these conditions, prefer the tooltip on the side of the point
  21428. if (chart.inverted || this.len > 1) {
  21429. swap();
  21430. }
  21431. run();
  21432. return ret;
  21433. };
  21434. /**
  21435. * Get the best X date format based on the closest point range on the axis.
  21436. *
  21437. * @private
  21438. * @function Highcharts.Tooltip#getXDateFormat
  21439. *
  21440. * @param {Highcharts.Point} point
  21441. *
  21442. * @param {Highcharts.TooltipOptions} options
  21443. *
  21444. * @param {Highcharts.Axis} xAxis
  21445. *
  21446. * @return {string}
  21447. */
  21448. Tooltip.prototype.getXDateFormat = function (point, options, xAxis) {
  21449. var xDateFormat, dateTimeLabelFormats = options.dateTimeLabelFormats, closestPointRange = xAxis && xAxis.closestPointRange;
  21450. if (closestPointRange) {
  21451. xDateFormat = this.getDateFormat(closestPointRange, point.x, xAxis.options.startOfWeek, dateTimeLabelFormats);
  21452. }
  21453. else {
  21454. xDateFormat = dateTimeLabelFormats.day;
  21455. }
  21456. return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
  21457. };
  21458. /**
  21459. * Hides the tooltip with a fade out animation.
  21460. *
  21461. * @function Highcharts.Tooltip#hide
  21462. *
  21463. * @param {number} [delay]
  21464. * The fade out in milliseconds. If no value is provided the value
  21465. * of the tooltip.hideDelay option is used. A value of 0 disables
  21466. * the fade out animation.
  21467. */
  21468. Tooltip.prototype.hide = function (delay) {
  21469. var tooltip = this;
  21470. // disallow duplicate timers (#1728, #1766)
  21471. U.clearTimeout(this.hideTimer);
  21472. delay = pick(delay, this.options.hideDelay, 500);
  21473. if (!this.isHidden) {
  21474. this.hideTimer = syncTimeout(function () {
  21475. // If there is a delay, do fadeOut with the default duration. If
  21476. // the hideDelay is 0, we assume no animation is wanted, so we
  21477. // pass 0 duration. #12994.
  21478. tooltip.getLabel().fadeOut(delay ? void 0 : delay);
  21479. tooltip.isHidden = true;
  21480. }, delay);
  21481. }
  21482. };
  21483. /**
  21484. * @private
  21485. * @function Highcharts.Tooltip#init
  21486. *
  21487. * @param {Highcharts.Chart} chart
  21488. * The chart instance.
  21489. *
  21490. * @param {Highcharts.TooltipOptions} options
  21491. * Tooltip options.
  21492. */
  21493. Tooltip.prototype.init = function (chart, options) {
  21494. /**
  21495. * Chart of the tooltip.
  21496. *
  21497. * @readonly
  21498. * @name Highcharts.Tooltip#chart
  21499. * @type {Highcharts.Chart}
  21500. */
  21501. this.chart = chart;
  21502. /**
  21503. * Used tooltip options.
  21504. *
  21505. * @readonly
  21506. * @name Highcharts.Tooltip#options
  21507. * @type {Highcharts.TooltipOptions}
  21508. */
  21509. this.options = options;
  21510. /**
  21511. * List of crosshairs.
  21512. *
  21513. * @private
  21514. * @readonly
  21515. * @name Highcharts.Tooltip#crosshairs
  21516. * @type {Array<null>}
  21517. */
  21518. this.crosshairs = [];
  21519. /**
  21520. * Current values of x and y when animating.
  21521. *
  21522. * @private
  21523. * @readonly
  21524. * @name Highcharts.Tooltip#now
  21525. * @type {Highcharts.PositionObject}
  21526. */
  21527. this.now = { x: 0, y: 0 };
  21528. /**
  21529. * Tooltips are initially hidden.
  21530. *
  21531. * @private
  21532. * @readonly
  21533. * @name Highcharts.Tooltip#isHidden
  21534. * @type {boolean}
  21535. */
  21536. this.isHidden = true;
  21537. /**
  21538. * True, if the tooltip is split into one label per series, with the
  21539. * header close to the axis.
  21540. *
  21541. * @readonly
  21542. * @name Highcharts.Tooltip#split
  21543. * @type {boolean|undefined}
  21544. */
  21545. this.split = options.split && !chart.inverted && !chart.polar;
  21546. /**
  21547. * When the tooltip is shared, the entire plot area will capture mouse
  21548. * movement or touch events.
  21549. *
  21550. * @readonly
  21551. * @name Highcharts.Tooltip#shared
  21552. * @type {boolean|undefined}
  21553. */
  21554. this.shared = options.shared || this.split;
  21555. /**
  21556. * Whether to allow the tooltip to render outside the chart's SVG
  21557. * element box. By default (false), the tooltip is rendered within the
  21558. * chart's SVG element, which results in the tooltip being aligned
  21559. * inside the chart area.
  21560. *
  21561. * @readonly
  21562. * @name Highcharts.Tooltip#outside
  21563. * @type {boolean}
  21564. *
  21565. * @todo
  21566. * Split tooltip does not support outside in the first iteration. Should
  21567. * not be too complicated to implement.
  21568. */
  21569. this.outside = pick(options.outside, Boolean(chart.scrollablePixelsX || chart.scrollablePixelsY));
  21570. };
  21571. /**
  21572. * Returns true, if the pointer is in contact with the tooltip tracker.
  21573. */
  21574. Tooltip.prototype.isStickyOnContact = function () {
  21575. return !!(!this.followPointer &&
  21576. this.options.stickOnContact &&
  21577. this.inContact);
  21578. };
  21579. /**
  21580. * Moves the tooltip with a soft animation to a new position.
  21581. *
  21582. * @private
  21583. * @function Highcharts.Tooltip#move
  21584. *
  21585. * @param {number} x
  21586. *
  21587. * @param {number} y
  21588. *
  21589. * @param {number} anchorX
  21590. *
  21591. * @param {number} anchorY
  21592. */
  21593. Tooltip.prototype.move = function (x, y, anchorX, anchorY) {
  21594. var tooltip = this, now = tooltip.now, animate = tooltip.options.animation !== false &&
  21595. !tooltip.isHidden &&
  21596. // When we get close to the target position, abort animation and
  21597. // land on the right place (#3056)
  21598. (Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1), skipAnchor = tooltip.followPointer || tooltip.len > 1;
  21599. // Get intermediate values for animation
  21600. extend(now, {
  21601. x: animate ? (2 * now.x + x) / 3 : x,
  21602. y: animate ? (now.y + y) / 2 : y,
  21603. anchorX: skipAnchor ?
  21604. void 0 :
  21605. animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
  21606. anchorY: skipAnchor ?
  21607. void 0 :
  21608. animate ? (now.anchorY + anchorY) / 2 : anchorY
  21609. });
  21610. // Move to the intermediate value
  21611. tooltip.getLabel().attr(now);
  21612. tooltip.drawTracker();
  21613. // Run on next tick of the mouse tracker
  21614. if (animate) {
  21615. // Never allow two timeouts
  21616. U.clearTimeout(this.tooltipTimeout);
  21617. // Set the fixed interval ticking for the smooth tooltip
  21618. this.tooltipTimeout = setTimeout(function () {
  21619. // The interval function may still be running during destroy,
  21620. // so check that the chart is really there before calling.
  21621. if (tooltip) {
  21622. tooltip.move(x, y, anchorX, anchorY);
  21623. }
  21624. }, 32);
  21625. }
  21626. };
  21627. /**
  21628. * Refresh the tooltip's text and position.
  21629. *
  21630. * @function Highcharts.Tooltip#refresh
  21631. *
  21632. * @param {Highcharts.Point|Array<Highcharts.Point>} pointOrPoints
  21633. * Either a point or an array of points.
  21634. *
  21635. * @param {Highcharts.PointerEventObject} [mouseEvent]
  21636. * Mouse event, that is responsible for the refresh and should be
  21637. * used for the tooltip update.
  21638. */
  21639. Tooltip.prototype.refresh = function (pointOrPoints, mouseEvent) {
  21640. var tooltip = this, chart = this.chart, options = tooltip.options, x, y, point = pointOrPoints, anchor, textConfig = {}, text, pointConfig = [], formatter = options.formatter || tooltip.defaultFormatter, shared = tooltip.shared, currentSeries, styledMode = chart.styledMode;
  21641. if (!options.enabled) {
  21642. return;
  21643. }
  21644. U.clearTimeout(this.hideTimer);
  21645. // get the reference point coordinates (pie charts use tooltipPos)
  21646. tooltip.followPointer = splat(point)[0].series.tooltipOptions
  21647. .followPointer;
  21648. anchor = tooltip.getAnchor(point, mouseEvent);
  21649. x = anchor[0];
  21650. y = anchor[1];
  21651. // shared tooltip, array is sent over
  21652. if (shared &&
  21653. !(point.series &&
  21654. point.series.noSharedTooltip)) {
  21655. chart.pointer.applyInactiveState(point);
  21656. // Now set hover state for the choosen ones:
  21657. point.forEach(function (item) {
  21658. item.setState('hover');
  21659. pointConfig.push(item.getLabelConfig());
  21660. });
  21661. textConfig = {
  21662. x: point[0].category,
  21663. y: point[0].y
  21664. };
  21665. textConfig.points = pointConfig;
  21666. point = point[0];
  21667. // single point tooltip
  21668. }
  21669. else {
  21670. textConfig = point.getLabelConfig();
  21671. }
  21672. this.len = pointConfig.length; // #6128
  21673. text = formatter.call(textConfig, tooltip);
  21674. // register the current series
  21675. currentSeries = point.series;
  21676. this.distance = pick(currentSeries.tooltipOptions.distance, 16);
  21677. // update the inner HTML
  21678. if (text === false) {
  21679. this.hide();
  21680. }
  21681. else {
  21682. // update text
  21683. if (tooltip.split) {
  21684. this.renderSplit(text, splat(pointOrPoints));
  21685. }
  21686. else {
  21687. var label = tooltip.getLabel();
  21688. // Prevent the tooltip from flowing over the chart box (#6659)
  21689. if (!options.style.width || styledMode) {
  21690. label.css({
  21691. width: this.chart.spacingBox.width + 'px'
  21692. });
  21693. }
  21694. label.attr({
  21695. text: text && text.join ?
  21696. text.join('') :
  21697. text
  21698. });
  21699. // Set the stroke color of the box to reflect the point
  21700. label.removeClass(/highcharts-color-[\d]+/g)
  21701. .addClass('highcharts-color-' +
  21702. pick(point.colorIndex, currentSeries.colorIndex));
  21703. if (!styledMode) {
  21704. label.attr({
  21705. stroke: (options.borderColor ||
  21706. point.color ||
  21707. currentSeries.color ||
  21708. '#666666')
  21709. });
  21710. }
  21711. tooltip.updatePosition({
  21712. plotX: x,
  21713. plotY: y,
  21714. negative: point.negative,
  21715. ttBelow: point.ttBelow,
  21716. h: anchor[2] || 0
  21717. });
  21718. }
  21719. // show it
  21720. if (tooltip.isHidden && tooltip.label) {
  21721. tooltip.label.attr({
  21722. opacity: 1
  21723. }).show();
  21724. }
  21725. tooltip.isHidden = false;
  21726. }
  21727. fireEvent(this, 'refresh');
  21728. };
  21729. /**
  21730. * Render the split tooltip. Loops over each point's text and adds
  21731. * a label next to the point, then uses the distribute function to
  21732. * find best non-overlapping positions.
  21733. *
  21734. * @private
  21735. * @function Highcharts.Tooltip#renderSplit
  21736. *
  21737. * @param {string|Array<(boolean|string)>} labels
  21738. *
  21739. * @param {Array<Highcharts.Point>} points
  21740. */
  21741. Tooltip.prototype.renderSplit = function (labels, points) {
  21742. var tooltip = this;
  21743. var chart = tooltip.chart, _a = tooltip.chart, chartWidth = _a.chartWidth, chartHeight = _a.chartHeight, plotHeight = _a.plotHeight, plotLeft = _a.plotLeft, plotTop = _a.plotTop, pointer = _a.pointer, ren = _a.renderer, _b = _a.scrollablePixelsY, scrollablePixelsY = _b === void 0 ? 0 : _b, _c = _a.scrollingContainer, _d = _c === void 0 ? { scrollLeft: 0, scrollTop: 0 } : _c, scrollLeft = _d.scrollLeft, scrollTop = _d.scrollTop, styledMode = _a.styledMode, distance = tooltip.distance, options = tooltip.options, positioner = tooltip.options.positioner;
  21744. // The area which the tooltip should be limited to. Limit to scrollable
  21745. // plot area if enabled, otherwise limit to the chart container.
  21746. var bounds = {
  21747. left: scrollLeft,
  21748. right: scrollLeft + chartWidth,
  21749. top: scrollTop,
  21750. bottom: scrollTop + chartHeight
  21751. };
  21752. var tooltipLabel = tooltip.getLabel();
  21753. var headerTop = Boolean(chart.xAxis[0] && chart.xAxis[0].opposite);
  21754. var distributionBoxTop = plotTop + scrollTop;
  21755. var headerHeight = 0;
  21756. var adjustedPlotHeight = plotHeight - scrollablePixelsY;
  21757. /**
  21758. * Calculates the anchor position for the partial tooltip
  21759. *
  21760. * @private
  21761. * @param {Highcharts.Point} point The point related to the tooltip
  21762. * @return {object} Returns an object with anchorX and anchorY
  21763. */
  21764. function getAnchor(point) {
  21765. var isHeader = point.isHeader, _a = point.plotX, plotX = _a === void 0 ? 0 : _a, _b = point.plotY, plotY = _b === void 0 ? 0 : _b, series = point.series;
  21766. var anchorX;
  21767. var anchorY;
  21768. if (isHeader) {
  21769. // Set anchorX to plotX
  21770. anchorX = plotLeft + plotX;
  21771. // Set anchorY to center of visible plot area.
  21772. anchorY = plotTop + plotHeight / 2;
  21773. }
  21774. else {
  21775. var xAxis = series.xAxis, yAxis = series.yAxis;
  21776. // Set anchorX to plotX. Limit to within xAxis.
  21777. anchorX = xAxis.pos + clamp(plotX, -distance, xAxis.len + distance);
  21778. // Set anchorY, limit to the scrollable plot area
  21779. if (yAxis.pos + plotY >= scrollTop + plotTop &&
  21780. yAxis.pos + plotY <= scrollTop + plotTop + plotHeight - scrollablePixelsY) {
  21781. anchorY = yAxis.pos + plotY;
  21782. }
  21783. }
  21784. // Limit values to plot area
  21785. anchorX = clamp(anchorX, bounds.left - distance, bounds.right + distance);
  21786. return { anchorX: anchorX, anchorY: anchorY };
  21787. }
  21788. /**
  21789. * Calculates the position of the partial tooltip
  21790. *
  21791. * @private
  21792. * @param {number} anchorX The partial tooltip anchor x position
  21793. * @param {number} anchorY The partial tooltip anchor y position
  21794. * @param {boolean} isHeader Whether the partial tooltip is a header
  21795. * @param {number} boxWidth Width of the partial tooltip
  21796. * @return {Highcharts.PositionObject} Returns the partial tooltip x and
  21797. * y position
  21798. */
  21799. function defaultPositioner(anchorX, anchorY, isHeader, boxWidth, alignedLeft) {
  21800. if (alignedLeft === void 0) { alignedLeft = true; }
  21801. var y;
  21802. var x;
  21803. if (isHeader) {
  21804. y = headerTop ? 0 : adjustedPlotHeight;
  21805. x = clamp(anchorX - (boxWidth / 2), bounds.left, bounds.right - boxWidth);
  21806. }
  21807. else {
  21808. y = anchorY - distributionBoxTop;
  21809. x = alignedLeft ?
  21810. anchorX - boxWidth - distance :
  21811. anchorX + distance;
  21812. x = clamp(x, alignedLeft ? x : bounds.left, bounds.right);
  21813. }
  21814. // NOTE: y is relative to distributionBoxTop
  21815. return { x: x, y: y };
  21816. }
  21817. /**
  21818. * Updates the attributes and styling of the partial tooltip. Creates a
  21819. * new partial tooltip if it does not exists.
  21820. *
  21821. * @private
  21822. * @param {Highcharts.SVGElement|undefined} partialTooltip
  21823. * The partial tooltip to update
  21824. * @param {Highcharts.Point} point
  21825. * The point related to the partial tooltip
  21826. * @param {boolean|string} str The text for the partial tooltip
  21827. * @return {Highcharts.SVGElement} Returns the updated partial tooltip
  21828. */
  21829. function updatePartialTooltip(partialTooltip, point, str) {
  21830. var tt = partialTooltip;
  21831. var isHeader = point.isHeader, series = point.series;
  21832. var colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none');
  21833. if (!tt) {
  21834. var attribs = {
  21835. padding: options.padding,
  21836. r: options.borderRadius
  21837. };
  21838. if (!styledMode) {
  21839. attribs.fill = options.backgroundColor;
  21840. attribs['stroke-width'] = options.borderWidth;
  21841. }
  21842. tt = ren
  21843. .label('', 0, 0, (options[isHeader ? 'headerShape' : 'shape']) ||
  21844. 'callout', void 0, void 0, options.useHTML)
  21845. .addClass((isHeader ? 'highcharts-tooltip-header ' : '') +
  21846. 'highcharts-tooltip-box ' +
  21847. colorClass)
  21848. .attr(attribs)
  21849. .add(tooltipLabel);
  21850. }
  21851. tt.isActive = true;
  21852. tt.attr({
  21853. text: str
  21854. });
  21855. if (!styledMode) {
  21856. tt.css(options.style)
  21857. .shadow(options.shadow)
  21858. .attr({
  21859. stroke: (options.borderColor ||
  21860. point.color ||
  21861. series.color ||
  21862. '#333333')
  21863. });
  21864. }
  21865. return tt;
  21866. }
  21867. // Graceful degradation for legacy formatters
  21868. if (isString(labels)) {
  21869. labels = [false, labels];
  21870. }
  21871. // Create the individual labels for header and points, ignore footer
  21872. var boxes = labels.slice(0, points.length + 1).reduce(function (boxes, str, i) {
  21873. if (str !== false && str !== '') {
  21874. var point = (points[i - 1] ||
  21875. {
  21876. // Item 0 is the header. Instead of this, we could also
  21877. // use the crosshair label
  21878. isHeader: true,
  21879. plotX: points[0].plotX,
  21880. plotY: plotHeight,
  21881. series: {}
  21882. });
  21883. var isHeader = point.isHeader;
  21884. // Store the tooltip label referance on the series
  21885. var owner = isHeader ? tooltip : point.series;
  21886. var tt = owner.tt = updatePartialTooltip(owner.tt, point, str);
  21887. // Get X position now, so we can move all to the other side in
  21888. // case of overflow
  21889. var bBox = tt.getBBox();
  21890. var boxWidth = bBox.width + tt.strokeWidth();
  21891. if (isHeader) {
  21892. headerHeight = bBox.height;
  21893. adjustedPlotHeight += headerHeight;
  21894. if (headerTop) {
  21895. distributionBoxTop -= headerHeight;
  21896. }
  21897. }
  21898. var _a = getAnchor(point), anchorX = _a.anchorX, anchorY = _a.anchorY;
  21899. if (typeof anchorY === 'number') {
  21900. var size = bBox.height + 1;
  21901. var boxPosition = (positioner ?
  21902. positioner.call(tooltip, boxWidth, size, point) :
  21903. defaultPositioner(anchorX, anchorY, isHeader, boxWidth));
  21904. boxes.push({
  21905. // 0-align to the top, 1-align to the bottom
  21906. align: positioner ? 0 : void 0,
  21907. anchorX: anchorX,
  21908. anchorY: anchorY,
  21909. boxWidth: boxWidth,
  21910. point: point,
  21911. rank: pick(boxPosition.rank, isHeader ? 1 : 0),
  21912. size: size,
  21913. target: boxPosition.y,
  21914. tt: tt,
  21915. x: boxPosition.x
  21916. });
  21917. }
  21918. else {
  21919. // Hide tooltips which anchorY is outside the visible plot
  21920. // area
  21921. tt.isActive = false;
  21922. }
  21923. }
  21924. return boxes;
  21925. }, []);
  21926. // If overflow left then align all labels to the right
  21927. if (!positioner && boxes.some(function (box) { return box.x < bounds.left; })) {
  21928. boxes = boxes.map(function (box) {
  21929. var _a = defaultPositioner(box.anchorX, box.anchorY, box.point.isHeader, box.boxWidth, false), x = _a.x, y = _a.y;
  21930. return extend(box, {
  21931. target: y,
  21932. x: x
  21933. });
  21934. });
  21935. }
  21936. // Clean previous run (for missing points)
  21937. tooltip.cleanSplit();
  21938. // Distribute and put in place
  21939. H.distribute(boxes, adjustedPlotHeight);
  21940. boxes.forEach(function (box) {
  21941. var anchorX = box.anchorX, anchorY = box.anchorY, pos = box.pos, x = box.x;
  21942. // Put the label in place
  21943. box.tt.attr({
  21944. visibility: typeof pos === 'undefined' ? 'hidden' : 'inherit',
  21945. x: x,
  21946. /* NOTE: y should equal pos to be consistent with !split
  21947. * tooltip, but is currently relative to plotTop. Is left as is
  21948. * to avoid breaking change. Remove distributionBoxTop to make
  21949. * it consistent.
  21950. */
  21951. y: pos + distributionBoxTop,
  21952. anchorX: anchorX,
  21953. anchorY: anchorY
  21954. });
  21955. });
  21956. /* If we have a seperate tooltip container, then update the necessary
  21957. * container properties.
  21958. * Test that tooltip has its own container and renderer before executing
  21959. * the operation.
  21960. */
  21961. var container = tooltip.container, outside = tooltip.outside, renderer = tooltip.renderer;
  21962. if (outside && container && renderer) {
  21963. // Set container size to fit the tooltip
  21964. var _e = tooltipLabel.getBBox(), width = _e.width, height = _e.height, x = _e.x, y = _e.y;
  21965. renderer.setSize(width + x, height + y, false);
  21966. // Position the tooltip container to the chart container
  21967. var chartPosition = pointer.getChartPosition();
  21968. container.style.left = chartPosition.left + 'px';
  21969. container.style.top = chartPosition.top + 'px';
  21970. }
  21971. };
  21972. /**
  21973. * If the `stickOnContact` option is active, this will add a tracker shape.
  21974. *
  21975. * @private
  21976. * @function Highcharts.Tooltip#drawTracker
  21977. */
  21978. Tooltip.prototype.drawTracker = function () {
  21979. var tooltip = this;
  21980. if (tooltip.followPointer ||
  21981. !tooltip.options.stickOnContact) {
  21982. if (tooltip.tracker) {
  21983. tooltip.tracker.destroy();
  21984. }
  21985. return;
  21986. }
  21987. var chart = tooltip.chart;
  21988. var label = tooltip.label;
  21989. var point = chart.hoverPoint;
  21990. if (!label || !point) {
  21991. return;
  21992. }
  21993. var box = {
  21994. x: 0,
  21995. y: 0,
  21996. width: 0,
  21997. height: 0
  21998. };
  21999. // Combine anchor and tooltip
  22000. var anchorPos = this.getAnchor(point);
  22001. var labelBBox = label.getBBox();
  22002. anchorPos[0] += chart.plotLeft - label.translateX;
  22003. anchorPos[1] += chart.plotTop - label.translateY;
  22004. // When the mouse pointer is between the anchor point and the label,
  22005. // the label should stick.
  22006. box.x = Math.min(0, anchorPos[0]);
  22007. box.y = Math.min(0, anchorPos[1]);
  22008. box.width = (anchorPos[0] < 0 ?
  22009. Math.max(Math.abs(anchorPos[0]), (labelBBox.width - anchorPos[0])) :
  22010. Math.max(Math.abs(anchorPos[0]), labelBBox.width));
  22011. box.height = (anchorPos[1] < 0 ?
  22012. Math.max(Math.abs(anchorPos[1]), (labelBBox.height - Math.abs(anchorPos[1]))) :
  22013. Math.max(Math.abs(anchorPos[1]), labelBBox.height));
  22014. if (tooltip.tracker) {
  22015. tooltip.tracker.attr(box);
  22016. }
  22017. else {
  22018. tooltip.tracker = label.renderer
  22019. .rect(box)
  22020. .addClass('highcharts-tracker')
  22021. .add(label);
  22022. if (!chart.styledMode) {
  22023. tooltip.tracker.attr({
  22024. fill: 'rgba(0,0,0,0)'
  22025. });
  22026. }
  22027. }
  22028. };
  22029. /**
  22030. * @private
  22031. */
  22032. Tooltip.prototype.styledModeFormat = function (formatString) {
  22033. return formatString
  22034. .replace('style="font-size: 10px"', 'class="highcharts-header"')
  22035. .replace(/style="color:{(point|series)\.color}"/g, 'class="highcharts-color-{$1.colorIndex}"');
  22036. };
  22037. /**
  22038. * Format the footer/header of the tooltip
  22039. * #3397: abstraction to enable formatting of footer and header
  22040. *
  22041. * @private
  22042. * @function Highcharts.Tooltip#tooltipFooterHeaderFormatter
  22043. * @param {Highcharts.PointLabelObject} labelConfig
  22044. * @param {boolean} [isFooter]
  22045. * @return {string}
  22046. */
  22047. Tooltip.prototype.tooltipFooterHeaderFormatter = function (labelConfig, isFooter) {
  22048. var footOrHead = isFooter ? 'footer' : 'header', series = labelConfig.series, tooltipOptions = series.tooltipOptions, xDateFormat = tooltipOptions.xDateFormat, xAxis = series.xAxis, isDateTime = (xAxis &&
  22049. xAxis.options.type === 'datetime' &&
  22050. isNumber(labelConfig.key)), formatString = tooltipOptions[footOrHead + 'Format'], e = {
  22051. isFooter: isFooter,
  22052. labelConfig: labelConfig
  22053. };
  22054. fireEvent(this, 'headerFormatter', e, function (e) {
  22055. // Guess the best date format based on the closest point distance
  22056. // (#568, #3418)
  22057. if (isDateTime && !xDateFormat) {
  22058. xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
  22059. }
  22060. // Insert the footer date format if any
  22061. if (isDateTime && xDateFormat) {
  22062. ((labelConfig.point && labelConfig.point.tooltipDateKeys) ||
  22063. ['key']).forEach(function (key) {
  22064. formatString = formatString.replace('{point.' + key + '}', '{point.' + key + ':' + xDateFormat + '}');
  22065. });
  22066. }
  22067. // Replace default header style with class name
  22068. if (series.chart.styledMode) {
  22069. formatString = this.styledModeFormat(formatString);
  22070. }
  22071. e.text = format(formatString, {
  22072. point: labelConfig,
  22073. series: series
  22074. }, this.chart);
  22075. });
  22076. return e.text;
  22077. };
  22078. /**
  22079. * Updates the tooltip with the provided tooltip options.
  22080. *
  22081. * @function Highcharts.Tooltip#update
  22082. *
  22083. * @param {Highcharts.TooltipOptions} options
  22084. * The tooltip options to update.
  22085. */
  22086. Tooltip.prototype.update = function (options) {
  22087. this.destroy();
  22088. // Update user options (#6218)
  22089. merge(true, this.chart.options.tooltip.userOptions, options);
  22090. this.init(this.chart, merge(true, this.options, options));
  22091. };
  22092. /**
  22093. * Find the new position and perform the move
  22094. *
  22095. * @private
  22096. * @function Highcharts.Tooltip#updatePosition
  22097. *
  22098. * @param {Highcharts.Point} point
  22099. */
  22100. Tooltip.prototype.updatePosition = function (point) {
  22101. var chart = this.chart, pointer = chart.pointer, label = this.getLabel(), pos, anchorX = point.plotX + chart.plotLeft, anchorY = point.plotY + chart.plotTop, pad;
  22102. // Needed for outside: true (#11688)
  22103. var chartPosition = pointer.getChartPosition();
  22104. pos = (this.options.positioner || this.getPosition).call(this, label.width, label.height, point);
  22105. // Set the renderer size dynamically to prevent document size to change
  22106. if (this.outside) {
  22107. pad = (this.options.borderWidth || 0) + 2 * this.distance;
  22108. this.renderer.setSize(label.width + pad, label.height + pad, false);
  22109. // Anchor and tooltip container need scaling if chart container has
  22110. // scale transform/css zoom. #11329.
  22111. var containerScaling = chart.containerScaling;
  22112. if (containerScaling) {
  22113. css(this.container, {
  22114. transform: "scale(" + containerScaling.scaleX + ", " + containerScaling.scaleY + ")"
  22115. });
  22116. anchorX *= containerScaling.scaleX;
  22117. anchorY *= containerScaling.scaleY;
  22118. }
  22119. anchorX += chartPosition.left - pos.x;
  22120. anchorY += chartPosition.top - pos.y;
  22121. }
  22122. // do the move
  22123. this.move(Math.round(pos.x), Math.round(pos.y || 0), // can be undefined (#3977)
  22124. anchorX, anchorY);
  22125. };
  22126. return Tooltip;
  22127. }());
  22128. H.Tooltip = Tooltip;
  22129. return H.Tooltip;
  22130. });
  22131. _registerModule(_modules, 'parts/Pointer.js', [_modules['parts/Color.js'], _modules['parts/Globals.js'], _modules['parts/Tooltip.js'], _modules['parts/Utilities.js']], function (Color, H, Tooltip, U) {
  22132. /* *
  22133. *
  22134. * (c) 2010-2020 Torstein Honsi
  22135. *
  22136. * License: www.highcharts.com/license
  22137. *
  22138. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  22139. *
  22140. * */
  22141. var color = Color.parse;
  22142. var charts = H.charts, noop = H.noop;
  22143. var addEvent = U.addEvent, attr = U.attr, css = U.css, defined = U.defined, extend = U.extend, find = U.find, fireEvent = U.fireEvent, isNumber = U.isNumber, isObject = U.isObject, objectEach = U.objectEach, offset = U.offset, pick = U.pick, splat = U.splat;
  22144. /**
  22145. * One position in relation to an axis.
  22146. *
  22147. * @interface Highcharts.PointerAxisCoordinateObject
  22148. */ /**
  22149. * Related axis.
  22150. *
  22151. * @name Highcharts.PointerAxisCoordinateObject#axis
  22152. * @type {Highcharts.Axis}
  22153. */ /**
  22154. * Axis value.
  22155. *
  22156. * @name Highcharts.PointerAxisCoordinateObject#value
  22157. * @type {number}
  22158. */
  22159. /**
  22160. * Positions in terms of axis values.
  22161. *
  22162. * @interface Highcharts.PointerAxisCoordinatesObject
  22163. */ /**
  22164. * Positions on the x-axis.
  22165. * @name Highcharts.PointerAxisCoordinatesObject#xAxis
  22166. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  22167. */ /**
  22168. * Positions on the y-axis.
  22169. * @name Highcharts.PointerAxisCoordinatesObject#yAxis
  22170. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  22171. */
  22172. /**
  22173. * Pointer coordinates.
  22174. *
  22175. * @interface Highcharts.PointerCoordinatesObject
  22176. */ /**
  22177. * @name Highcharts.PointerCoordinatesObject#chartX
  22178. * @type {number}
  22179. */ /**
  22180. * @name Highcharts.PointerCoordinatesObject#chartY
  22181. * @type {number}
  22182. */
  22183. /**
  22184. * A native browser mouse or touch event, extended with position information
  22185. * relative to the {@link Chart.container}.
  22186. *
  22187. * @interface Highcharts.PointerEventObject
  22188. * @extends global.PointerEvent
  22189. */ /**
  22190. * The X coordinate of the pointer interaction relative to the chart.
  22191. *
  22192. * @name Highcharts.PointerEventObject#chartX
  22193. * @type {number}
  22194. */ /**
  22195. * The Y coordinate of the pointer interaction relative to the chart.
  22196. *
  22197. * @name Highcharts.PointerEventObject#chartY
  22198. * @type {number}
  22199. */
  22200. /**
  22201. * Axis-specific data of a selection.
  22202. *
  22203. * @interface Highcharts.SelectDataObject
  22204. */ /**
  22205. * @name Highcharts.SelectDataObject#axis
  22206. * @type {Highcharts.Axis}
  22207. */ /**
  22208. * @name Highcharts.SelectDataObject#max
  22209. * @type {number}
  22210. */ /**
  22211. * @name Highcharts.SelectDataObject#min
  22212. * @type {number}
  22213. */
  22214. /**
  22215. * Object for select events.
  22216. *
  22217. * @interface Highcharts.SelectEventObject
  22218. */ /**
  22219. * @name Highcharts.SelectEventObject#originalEvent
  22220. * @type {global.Event}
  22221. */ /**
  22222. * @name Highcharts.SelectEventObject#xAxis
  22223. * @type {Array<Highcharts.SelectDataObject>}
  22224. */ /**
  22225. * @name Highcharts.SelectEventObject#yAxis
  22226. * @type {Array<Highcharts.SelectDataObject>}
  22227. */
  22228. ''; // detach doclets above
  22229. /* eslint-disable no-invalid-this, valid-jsdoc */
  22230. /**
  22231. * The mouse and touch tracker object. Each {@link Chart} item has one
  22232. * assosiated Pointer item that can be accessed from the {@link Chart.pointer}
  22233. * property.
  22234. *
  22235. * @class
  22236. * @name Highcharts.Pointer
  22237. *
  22238. * @param {Highcharts.Chart} chart
  22239. * The chart instance.
  22240. *
  22241. * @param {Highcharts.Options} options
  22242. * The root options object. The pointer uses options from the chart and
  22243. * tooltip structures.
  22244. */
  22245. var Pointer = /** @class */ (function () {
  22246. /* *
  22247. *
  22248. * Constructors
  22249. *
  22250. * */
  22251. function Pointer(chart, options) {
  22252. this.lastValidTouch = {};
  22253. this.pinchDown = [];
  22254. this.runChartClick = false;
  22255. this.chart = chart;
  22256. this.hasDragged = false;
  22257. this.options = options;
  22258. this.unbindContainerMouseLeave = function () { };
  22259. this.init(chart, options);
  22260. }
  22261. /* *
  22262. *
  22263. * Functions
  22264. *
  22265. * */
  22266. /**
  22267. * Set inactive state to all series that are not currently hovered,
  22268. * or, if `inactiveOtherPoints` is set to true, set inactive state to
  22269. * all points within that series.
  22270. *
  22271. * @private
  22272. * @function Highcharts.Pointer#applyInactiveState
  22273. * @param {Array<Highcharts.Point>} points
  22274. * Currently hovered points
  22275. */
  22276. Pointer.prototype.applyInactiveState = function (points) {
  22277. var activeSeries = [], series;
  22278. // Get all active series from the hovered points
  22279. (points || []).forEach(function (item) {
  22280. series = item.series;
  22281. // Include itself
  22282. activeSeries.push(series);
  22283. // Include parent series
  22284. if (series.linkedParent) {
  22285. activeSeries.push(series.linkedParent);
  22286. }
  22287. // Include all child series
  22288. if (series.linkedSeries) {
  22289. activeSeries = activeSeries.concat(series.linkedSeries);
  22290. }
  22291. // Include navigator series
  22292. if (series.navigatorSeries) {
  22293. activeSeries.push(series.navigatorSeries);
  22294. }
  22295. });
  22296. // Now loop over all series, filtering out active series
  22297. this.chart.series.forEach(function (inactiveSeries) {
  22298. if (activeSeries.indexOf(inactiveSeries) === -1) {
  22299. // Inactive series
  22300. inactiveSeries.setState('inactive', true);
  22301. }
  22302. else if (inactiveSeries.options.inactiveOtherPoints) {
  22303. // Active series, but other points should be inactivated
  22304. inactiveSeries.setAllPointsToState('inactive');
  22305. }
  22306. });
  22307. };
  22308. /**
  22309. * Destroys the Pointer object and disconnects DOM events.
  22310. *
  22311. * @function Highcharts.Pointer#destroy
  22312. */
  22313. Pointer.prototype.destroy = function () {
  22314. var pointer = this;
  22315. if (typeof pointer.unDocMouseMove !== 'undefined') {
  22316. pointer.unDocMouseMove();
  22317. }
  22318. this.unbindContainerMouseLeave();
  22319. if (!H.chartCount) {
  22320. if (H.unbindDocumentMouseUp) {
  22321. H.unbindDocumentMouseUp = H.unbindDocumentMouseUp();
  22322. }
  22323. if (H.unbindDocumentTouchEnd) {
  22324. H.unbindDocumentTouchEnd = H.unbindDocumentTouchEnd();
  22325. }
  22326. }
  22327. // memory and CPU leak
  22328. clearInterval(pointer.tooltipTimeout);
  22329. objectEach(pointer, function (_val, prop) {
  22330. pointer[prop] = void 0;
  22331. });
  22332. };
  22333. /**
  22334. * Perform a drag operation in response to a mousemove event while the mouse
  22335. * is down.
  22336. *
  22337. * @private
  22338. * @function Highcharts.Pointer#drag
  22339. *
  22340. * @param {Highcharts.PointerEventObject} e
  22341. *
  22342. * @return {void}
  22343. */
  22344. Pointer.prototype.drag = function (e) {
  22345. var chart = this.chart, chartOptions = chart.options.chart, chartX = e.chartX, chartY = e.chartY, zoomHor = this.zoomHor, zoomVert = this.zoomVert, plotLeft = chart.plotLeft, plotTop = chart.plotTop, plotWidth = chart.plotWidth, plotHeight = chart.plotHeight, clickedInside, size, selectionMarker = this.selectionMarker, mouseDownX = (this.mouseDownX || 0), mouseDownY = (this.mouseDownY || 0), panningEnabled = isObject(chartOptions.panning) ?
  22346. chartOptions.panning && chartOptions.panning.enabled :
  22347. chartOptions.panning, panKey = (chartOptions.panKey && e[chartOptions.panKey + 'Key']);
  22348. // If the device supports both touch and mouse (like IE11), and we are
  22349. // touch-dragging inside the plot area, don't handle the mouse event.
  22350. // #4339.
  22351. if (selectionMarker && selectionMarker.touch) {
  22352. return;
  22353. }
  22354. // If the mouse is outside the plot area, adjust to cooordinates
  22355. // inside to prevent the selection marker from going outside
  22356. if (chartX < plotLeft) {
  22357. chartX = plotLeft;
  22358. }
  22359. else if (chartX > plotLeft + plotWidth) {
  22360. chartX = plotLeft + plotWidth;
  22361. }
  22362. if (chartY < plotTop) {
  22363. chartY = plotTop;
  22364. }
  22365. else if (chartY > plotTop + plotHeight) {
  22366. chartY = plotTop + plotHeight;
  22367. }
  22368. // determine if the mouse has moved more than 10px
  22369. this.hasDragged = Math.sqrt(Math.pow(mouseDownX - chartX, 2) +
  22370. Math.pow(mouseDownY - chartY, 2));
  22371. if (this.hasDragged > 10) {
  22372. clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop);
  22373. // make a selection
  22374. if (chart.hasCartesianSeries &&
  22375. (this.zoomX || this.zoomY) &&
  22376. clickedInside &&
  22377. !panKey) {
  22378. if (!selectionMarker) {
  22379. this.selectionMarker = selectionMarker =
  22380. chart.renderer.rect(plotLeft, plotTop, zoomHor ? 1 : plotWidth, zoomVert ? 1 : plotHeight, 0)
  22381. .attr({
  22382. 'class': 'highcharts-selection-marker',
  22383. zIndex: 7
  22384. })
  22385. .add();
  22386. if (!chart.styledMode) {
  22387. selectionMarker.attr({
  22388. fill: (chartOptions.selectionMarkerFill ||
  22389. color('#335cad')
  22390. .setOpacity(0.25).get())
  22391. });
  22392. }
  22393. }
  22394. }
  22395. // adjust the width of the selection marker
  22396. if (selectionMarker && zoomHor) {
  22397. size = chartX - mouseDownX;
  22398. selectionMarker.attr({
  22399. width: Math.abs(size),
  22400. x: (size > 0 ? 0 : size) + mouseDownX
  22401. });
  22402. }
  22403. // adjust the height of the selection marker
  22404. if (selectionMarker && zoomVert) {
  22405. size = chartY - mouseDownY;
  22406. selectionMarker.attr({
  22407. height: Math.abs(size),
  22408. y: (size > 0 ? 0 : size) + mouseDownY
  22409. });
  22410. }
  22411. // panning
  22412. if (clickedInside &&
  22413. !selectionMarker &&
  22414. panningEnabled) {
  22415. chart.pan(e, chartOptions.panning);
  22416. }
  22417. }
  22418. };
  22419. /**
  22420. * Start a drag operation.
  22421. *
  22422. * @private
  22423. * @function Highcharts.Pointer#dragStart
  22424. *
  22425. * @param {Highcharts.PointerEventObject} e
  22426. *
  22427. * @return {void}
  22428. */
  22429. Pointer.prototype.dragStart = function (e) {
  22430. var chart = this.chart;
  22431. // Record the start position
  22432. chart.mouseIsDown = e.type;
  22433. chart.cancelClick = false;
  22434. chart.mouseDownX = this.mouseDownX = e.chartX;
  22435. chart.mouseDownY = this.mouseDownY = e.chartY;
  22436. };
  22437. /**
  22438. * On mouse up or touch end across the entire document, drop the selection.
  22439. *
  22440. * @private
  22441. * @function Highcharts.Pointer#drop
  22442. *
  22443. * @param {global.Event} e
  22444. */
  22445. Pointer.prototype.drop = function (e) {
  22446. var pointer = this, chart = this.chart, hasPinched = this.hasPinched;
  22447. if (this.selectionMarker) {
  22448. var selectionData = {
  22449. originalEvent: e,
  22450. xAxis: [],
  22451. yAxis: []
  22452. }, selectionBox = this.selectionMarker, selectionLeft = selectionBox.attr ?
  22453. selectionBox.attr('x') :
  22454. selectionBox.x, selectionTop = selectionBox.attr ?
  22455. selectionBox.attr('y') :
  22456. selectionBox.y, selectionWidth = selectionBox.attr ?
  22457. selectionBox.attr('width') :
  22458. selectionBox.width, selectionHeight = selectionBox.attr ?
  22459. selectionBox.attr('height') :
  22460. selectionBox.height, runZoom;
  22461. // a selection has been made
  22462. if (this.hasDragged || hasPinched) {
  22463. // record each axis' min and max
  22464. chart.axes.forEach(function (axis) {
  22465. if (axis.zoomEnabled &&
  22466. defined(axis.min) &&
  22467. (hasPinched ||
  22468. pointer[{
  22469. xAxis: 'zoomX',
  22470. yAxis: 'zoomY'
  22471. }[axis.coll]]) &&
  22472. isNumber(selectionLeft) &&
  22473. isNumber(selectionTop)) { // #859, #3569
  22474. var horiz = axis.horiz, minPixelPadding = e.type === 'touchend' ?
  22475. axis.minPixelPadding :
  22476. 0, // #1207, #3075
  22477. selectionMin = axis.toValue((horiz ? selectionLeft : selectionTop) +
  22478. minPixelPadding), selectionMax = axis.toValue((horiz ?
  22479. selectionLeft + selectionWidth :
  22480. selectionTop + selectionHeight) - minPixelPadding);
  22481. selectionData[axis.coll].push({
  22482. axis: axis,
  22483. // Min/max for reversed axes
  22484. min: Math.min(selectionMin, selectionMax),
  22485. max: Math.max(selectionMin, selectionMax)
  22486. });
  22487. runZoom = true;
  22488. }
  22489. });
  22490. if (runZoom) {
  22491. fireEvent(chart, 'selection', selectionData, function (args) {
  22492. chart.zoom(extend(args, hasPinched ?
  22493. { animation: false } :
  22494. null));
  22495. });
  22496. }
  22497. }
  22498. if (isNumber(chart.index)) {
  22499. this.selectionMarker = this.selectionMarker.destroy();
  22500. }
  22501. // Reset scaling preview
  22502. if (hasPinched) {
  22503. this.scaleGroups();
  22504. }
  22505. }
  22506. // Reset all. Check isNumber because it may be destroyed on mouse up
  22507. // (#877)
  22508. if (chart && isNumber(chart.index)) {
  22509. css(chart.container, { cursor: chart._cursor });
  22510. chart.cancelClick = this.hasDragged > 10; // #370
  22511. chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
  22512. this.pinchDown = [];
  22513. }
  22514. };
  22515. /**
  22516. * Finds the closest point to a set of coordinates, using the k-d-tree
  22517. * algorithm.
  22518. *
  22519. * @function Highcharts.Pointer#findNearestKDPoint
  22520. *
  22521. * @param {Array<Highcharts.Series>} series
  22522. * All the series to search in.
  22523. *
  22524. * @param {boolean|undefined} shared
  22525. * Whether it is a shared tooltip or not.
  22526. *
  22527. * @param {Highcharts.PointerEventObject} e
  22528. * The pointer event object, containing chart coordinates of the
  22529. * pointer.
  22530. *
  22531. * @return {Highcharts.Point|undefined}
  22532. * The point closest to given coordinates.
  22533. */
  22534. Pointer.prototype.findNearestKDPoint = function (series, shared, e) {
  22535. var chart = this.chart;
  22536. var hoverPoint = chart.hoverPoint;
  22537. var tooltip = chart.tooltip;
  22538. if (hoverPoint &&
  22539. tooltip &&
  22540. tooltip.isStickyOnContact()) {
  22541. return hoverPoint;
  22542. }
  22543. var closest;
  22544. /** @private */
  22545. function sort(p1, p2) {
  22546. var isCloserX = p1.distX - p2.distX, isCloser = p1.dist - p2.dist, isAbove = (p2.series.group && p2.series.group.zIndex) -
  22547. (p1.series.group && p1.series.group.zIndex), result;
  22548. // We have two points which are not in the same place on xAxis
  22549. // and shared tooltip:
  22550. if (isCloserX !== 0 && shared) { // #5721
  22551. result = isCloserX;
  22552. // Points are not exactly in the same place on x/yAxis:
  22553. }
  22554. else if (isCloser !== 0) {
  22555. result = isCloser;
  22556. // The same xAxis and yAxis position, sort by z-index:
  22557. }
  22558. else if (isAbove !== 0) {
  22559. result = isAbove;
  22560. // The same zIndex, sort by array index:
  22561. }
  22562. else {
  22563. result =
  22564. p1.series.index > p2.series.index ?
  22565. -1 :
  22566. 1;
  22567. }
  22568. return result;
  22569. }
  22570. series.forEach(function (s) {
  22571. var noSharedTooltip = s.noSharedTooltip && shared, compareX = (!noSharedTooltip &&
  22572. s.options.findNearestPointBy.indexOf('y') < 0), point = s.searchPoint(e, compareX);
  22573. if ( // Check that we actually found a point on the series.
  22574. isObject(point, true) &&
  22575. // Use the new point if it is closer.
  22576. (!isObject(closest, true) ||
  22577. (sort(closest, point) > 0))) {
  22578. closest = point;
  22579. }
  22580. });
  22581. return closest;
  22582. };
  22583. /**
  22584. * @private
  22585. * @function Highcharts.Pointer#getChartCoordinatesFromPoint
  22586. * @param {Highcharts.Point} point
  22587. * @param {boolean} [inverted]
  22588. * @return {Highcharts.PointerCoordinatesObject|undefined}
  22589. */
  22590. Pointer.prototype.getChartCoordinatesFromPoint = function (point, inverted) {
  22591. var series = point.series, xAxis = series.xAxis, yAxis = series.yAxis, plotX = pick(point.clientX, point.plotX), shapeArgs = point.shapeArgs;
  22592. if (xAxis && yAxis) {
  22593. return inverted ? {
  22594. chartX: xAxis.len + xAxis.pos - plotX,
  22595. chartY: yAxis.len + yAxis.pos - point.plotY
  22596. } : {
  22597. chartX: plotX + xAxis.pos,
  22598. chartY: point.plotY + yAxis.pos
  22599. };
  22600. }
  22601. if (shapeArgs && shapeArgs.x && shapeArgs.y) {
  22602. // E.g. pies do not have axes
  22603. return {
  22604. chartX: shapeArgs.x,
  22605. chartY: shapeArgs.y
  22606. };
  22607. }
  22608. };
  22609. /**
  22610. * Return the cached chartPosition if it is available on the Pointer,
  22611. * otherwise find it. Running offset is quite expensive, so it should be
  22612. * avoided when we know the chart hasn't moved.
  22613. *
  22614. * @function Highcharts.Pointer#getChartPosition
  22615. *
  22616. * @return {Highcharts.OffsetObject}
  22617. * The offset of the chart container within the page
  22618. */
  22619. Pointer.prototype.getChartPosition = function () {
  22620. return (this.chartPosition ||
  22621. (this.chartPosition = offset(this.chart.container)));
  22622. };
  22623. /**
  22624. * Get the click position in terms of axis values.
  22625. *
  22626. * @function Highcharts.Pointer#getCoordinates
  22627. *
  22628. * @param {Highcharts.PointerEventObject} e
  22629. * Pointer event, extended with `chartX` and `chartY` properties.
  22630. *
  22631. * @return {Highcharts.PointerAxisCoordinatesObject}
  22632. */
  22633. Pointer.prototype.getCoordinates = function (e) {
  22634. var coordinates = {
  22635. xAxis: [],
  22636. yAxis: []
  22637. };
  22638. this.chart.axes.forEach(function (axis) {
  22639. coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
  22640. axis: axis,
  22641. value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
  22642. });
  22643. });
  22644. return coordinates;
  22645. };
  22646. /**
  22647. * Calculates what is the current hovered point/points and series.
  22648. *
  22649. * @private
  22650. * @function Highcharts.Pointer#getHoverData
  22651. *
  22652. * @param {Highcharts.Point|undefined} existingHoverPoint
  22653. * The point currrently beeing hovered.
  22654. *
  22655. * @param {Highcharts.Series|undefined} existingHoverSeries
  22656. * The series currently beeing hovered.
  22657. *
  22658. * @param {Array<Highcharts.Series>} series
  22659. * All the series in the chart.
  22660. *
  22661. * @param {boolean} isDirectTouch
  22662. * Is the pointer directly hovering the point.
  22663. *
  22664. * @param {boolean|undefined} shared
  22665. * Whether it is a shared tooltip or not.
  22666. *
  22667. * @param {Highcharts.PointerEventObject} [e]
  22668. * The triggering event, containing chart coordinates of the pointer.
  22669. *
  22670. * @return {object}
  22671. * Object containing resulting hover data: hoverPoint, hoverSeries,
  22672. * and hoverPoints.
  22673. */
  22674. Pointer.prototype.getHoverData = function (existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
  22675. var hoverPoint, hoverPoints = [], hoverSeries = existingHoverSeries, useExisting = !!(isDirectTouch && existingHoverPoint), notSticky = hoverSeries && !hoverSeries.stickyTracking,
  22676. // Which series to look in for the hover point
  22677. searchSeries,
  22678. // Parameters needed for beforeGetHoverData event.
  22679. eventArgs = {
  22680. chartX: e ? e.chartX : void 0,
  22681. chartY: e ? e.chartY : void 0,
  22682. shared: shared
  22683. }, filter = function (s) {
  22684. return (s.visible &&
  22685. !(!shared && s.directTouch) && // #3821
  22686. pick(s.options.enableMouseTracking, true));
  22687. };
  22688. // Find chart.hoverPane and update filter method in polar.
  22689. fireEvent(this, 'beforeGetHoverData', eventArgs);
  22690. searchSeries = notSticky ?
  22691. // Only search on hovered series if it has stickyTracking false
  22692. [hoverSeries] :
  22693. // Filter what series to look in.
  22694. series.filter(function (s) {
  22695. return eventArgs.filter ? eventArgs.filter(s) : filter(s) &&
  22696. s.stickyTracking;
  22697. });
  22698. // Use existing hovered point or find the one closest to coordinates.
  22699. hoverPoint = useExisting || !e ?
  22700. existingHoverPoint :
  22701. this.findNearestKDPoint(searchSeries, shared, e);
  22702. // Assign hover series
  22703. hoverSeries = hoverPoint && hoverPoint.series;
  22704. // If we have a hoverPoint, assign hoverPoints.
  22705. if (hoverPoint) {
  22706. // When tooltip is shared, it displays more than one point
  22707. if (shared && !hoverSeries.noSharedTooltip) {
  22708. searchSeries = series.filter(function (s) {
  22709. return eventArgs.filter ?
  22710. eventArgs.filter(s) : filter(s) && !s.noSharedTooltip;
  22711. });
  22712. // Get all points with the same x value as the hoverPoint
  22713. searchSeries.forEach(function (s) {
  22714. var point = find(s.points, function (p) {
  22715. return p.x === hoverPoint.x && !p.isNull;
  22716. });
  22717. if (isObject(point)) {
  22718. /*
  22719. * Boost returns a minimal point. Convert it to a usable
  22720. * point for tooltip and states.
  22721. */
  22722. if (s.chart.isBoosting) {
  22723. point = s.getPoint(point);
  22724. }
  22725. hoverPoints.push(point);
  22726. }
  22727. });
  22728. }
  22729. else {
  22730. hoverPoints.push(hoverPoint);
  22731. }
  22732. }
  22733. // Check whether the hoverPoint is inside pane we are hovering over.
  22734. eventArgs = { hoverPoint: hoverPoint };
  22735. fireEvent(this, 'afterGetHoverData', eventArgs);
  22736. return {
  22737. hoverPoint: eventArgs.hoverPoint,
  22738. hoverSeries: hoverSeries,
  22739. hoverPoints: hoverPoints
  22740. };
  22741. };
  22742. /**
  22743. * @private
  22744. * @function Highcharts.Pointer#getPointFromEvent
  22745. *
  22746. * @param {global.Event} e
  22747. *
  22748. * @return {Highcharts.Point|undefined}
  22749. */
  22750. Pointer.prototype.getPointFromEvent = function (e) {
  22751. var target = e.target, point;
  22752. while (target && !point) {
  22753. point = target.point;
  22754. target = target.parentNode;
  22755. }
  22756. return point;
  22757. };
  22758. /**
  22759. * @private
  22760. * @function Highcharts.Pointer#onTrackerMouseOut
  22761. *
  22762. * @param {Highcharts.PointerEventObject} e
  22763. *
  22764. * @return {void}
  22765. */
  22766. Pointer.prototype.onTrackerMouseOut = function (e) {
  22767. var chart = this.chart;
  22768. var relatedTarget = e.relatedTarget || e.toElement;
  22769. var series = chart.hoverSeries;
  22770. this.isDirectTouch = false;
  22771. if (series &&
  22772. relatedTarget &&
  22773. !series.stickyTracking &&
  22774. !this.inClass(relatedTarget, 'highcharts-tooltip') &&
  22775. (!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465, #5553
  22776. !this.inClass(relatedTarget, 'highcharts-tracker'))) {
  22777. series.onMouseOut();
  22778. }
  22779. };
  22780. /**
  22781. * Utility to detect whether an element has, or has a parent with, a
  22782. * specificclass name. Used on detection of tracker objects and on deciding
  22783. * whether hovering the tooltip should cause the active series to mouse out.
  22784. *
  22785. * @function Highcharts.Pointer#inClass
  22786. *
  22787. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  22788. * The element to investigate.
  22789. *
  22790. * @param {string} className
  22791. * The class name to look for.
  22792. *
  22793. * @return {boolean|undefined}
  22794. * True if either the element or one of its parents has the given
  22795. * class name.
  22796. */
  22797. Pointer.prototype.inClass = function (element, className) {
  22798. var elemClassName;
  22799. while (element) {
  22800. elemClassName = attr(element, 'class');
  22801. if (elemClassName) {
  22802. if (elemClassName.indexOf(className) !== -1) {
  22803. return true;
  22804. }
  22805. if (elemClassName.indexOf('highcharts-container') !== -1) {
  22806. return false;
  22807. }
  22808. }
  22809. element = element.parentNode;
  22810. }
  22811. };
  22812. /**
  22813. * Initialize the Pointer.
  22814. *
  22815. * @private
  22816. * @function Highcharts.Pointer#init
  22817. *
  22818. * @param {Highcharts.Chart} chart
  22819. * The Chart instance.
  22820. *
  22821. * @param {Highcharts.Options} options
  22822. * The root options object. The pointer uses options from the chart
  22823. * and tooltip structures.
  22824. *
  22825. * @return {void}
  22826. */
  22827. Pointer.prototype.init = function (chart, options) {
  22828. // Store references
  22829. this.options = options;
  22830. this.chart = chart;
  22831. // Do we need to handle click on a touch device?
  22832. this.runChartClick =
  22833. options.chart.events &&
  22834. !!options.chart.events.click;
  22835. this.pinchDown = [];
  22836. this.lastValidTouch = {};
  22837. if (Tooltip) {
  22838. /**
  22839. * Tooltip object for points of series.
  22840. *
  22841. * @name Highcharts.Chart#tooltip
  22842. * @type {Highcharts.Tooltip}
  22843. */
  22844. chart.tooltip = new Tooltip(chart, options.tooltip);
  22845. this.followTouchMove = pick(options.tooltip.followTouchMove, true);
  22846. }
  22847. this.setDOMEvents();
  22848. };
  22849. /**
  22850. * Takes a browser event object and extends it with custom Highcharts
  22851. * properties `chartX` and `chartY` in order to work on the internal
  22852. * coordinate system.
  22853. *
  22854. * @function Highcharts.Pointer#normalize
  22855. *
  22856. * @param {global.MouseEvent|global.PointerEvent|global.TouchEvent} e
  22857. * Event object in standard browsers.
  22858. *
  22859. * @param {Highcharts.OffsetObject} [chartPosition]
  22860. * Additional chart offset.
  22861. *
  22862. * @return {Highcharts.PointerEventObject}
  22863. * A browser event with extended properties `chartX` and `chartY`.
  22864. */
  22865. Pointer.prototype.normalize = function (e, chartPosition) {
  22866. var touches = e.touches;
  22867. // iOS (#2757)
  22868. var ePos = (touches ?
  22869. touches.length ?
  22870. touches.item(0) :
  22871. (pick(// #13534
  22872. touches.changedTouches, e.changedTouches))[0] :
  22873. e);
  22874. // Get mouse position
  22875. if (!chartPosition) {
  22876. chartPosition = this.getChartPosition();
  22877. }
  22878. var chartX = ePos.pageX - chartPosition.left, chartY = ePos.pageY - chartPosition.top;
  22879. // #11329 - when there is scaling on a parent element, we need to take
  22880. // this into account
  22881. var containerScaling = this.chart.containerScaling;
  22882. if (containerScaling) {
  22883. chartX /= containerScaling.scaleX;
  22884. chartY /= containerScaling.scaleY;
  22885. }
  22886. return extend(e, {
  22887. chartX: Math.round(chartX),
  22888. chartY: Math.round(chartY)
  22889. });
  22890. };
  22891. /**
  22892. * @private
  22893. * @function Highcharts.Pointer#onContainerClick
  22894. */
  22895. Pointer.prototype.onContainerClick = function (e) {
  22896. var chart = this.chart;
  22897. var hoverPoint = chart.hoverPoint;
  22898. var pEvt = this.normalize(e);
  22899. var plotLeft = chart.plotLeft;
  22900. var plotTop = chart.plotTop;
  22901. if (!chart.cancelClick) {
  22902. // On tracker click, fire the series and point events. #783, #1583
  22903. if (hoverPoint &&
  22904. this.inClass(pEvt.target, 'highcharts-tracker')) {
  22905. // the series click event
  22906. fireEvent(hoverPoint.series, 'click', extend(pEvt, {
  22907. point: hoverPoint
  22908. }));
  22909. // the point click event
  22910. if (chart.hoverPoint) { // it may be destroyed (#1844)
  22911. hoverPoint.firePointEvent('click', pEvt);
  22912. }
  22913. // When clicking outside a tracker, fire a chart event
  22914. }
  22915. else {
  22916. extend(pEvt, this.getCoordinates(pEvt));
  22917. // fire a click event in the chart
  22918. if (chart.isInsidePlot((pEvt.chartX - plotLeft), (pEvt.chartY - plotTop))) {
  22919. fireEvent(chart, 'click', pEvt);
  22920. }
  22921. }
  22922. }
  22923. };
  22924. /**
  22925. * @private
  22926. * @function Highcharts.Pointer#onContainerMouseDown
  22927. *
  22928. * @param {global.MouseEvent} e
  22929. */
  22930. Pointer.prototype.onContainerMouseDown = function (e) {
  22931. // Normalize before the 'if' for the legacy IE (#7850)
  22932. e = this.normalize(e);
  22933. // #11635, Firefox does not reliable fire move event after click scroll
  22934. if (H.isFirefox &&
  22935. e.button !== 0) {
  22936. this.onContainerMouseMove(e);
  22937. }
  22938. // #11635, limiting to primary button (incl. IE 8 support)
  22939. if (typeof e.button === 'undefined' ||
  22940. ((e.buttons || e.button) & 1) === 1) {
  22941. this.zoomOption(e);
  22942. this.dragStart(e);
  22943. }
  22944. };
  22945. /**
  22946. * When mouse leaves the container, hide the tooltip.
  22947. *
  22948. * @private
  22949. * @function Highcharts.Pointer#onContainerMouseLeave
  22950. *
  22951. * @param {global.MouseEvent} e
  22952. *
  22953. * @return {void}
  22954. */
  22955. Pointer.prototype.onContainerMouseLeave = function (e) {
  22956. var chart = charts[pick(H.hoverChartIndex, -1)];
  22957. var tooltip = this.chart.tooltip;
  22958. e = this.normalize(e);
  22959. // #4886, MS Touch end fires mouseleave but with no related target
  22960. if (chart &&
  22961. (e.relatedTarget || e.toElement)) {
  22962. chart.pointer.reset();
  22963. // Also reset the chart position, used in #149 fix
  22964. chart.pointer.chartPosition = void 0;
  22965. }
  22966. if ( // #11635, Firefox wheel scroll does not fire out events consistently
  22967. tooltip &&
  22968. !tooltip.isHidden) {
  22969. this.reset();
  22970. }
  22971. };
  22972. /**
  22973. * The mousemove, touchmove and touchstart event handler
  22974. *
  22975. * @private
  22976. * @function Highcharts.Pointer#onContainerMouseMove
  22977. *
  22978. * @param {global.MouseEvent} e
  22979. *
  22980. * @return {void}
  22981. */
  22982. Pointer.prototype.onContainerMouseMove = function (e) {
  22983. var chart = this.chart;
  22984. var pEvt = this.normalize(e);
  22985. this.setHoverChartIndex();
  22986. // In IE8 we apparently need this returnValue set to false in order to
  22987. // avoid text being selected. But in Chrome, e.returnValue is prevented,
  22988. // plus we don't need to run e.preventDefault to prevent selected text
  22989. // in modern browsers. So we set it conditionally. Remove it when IE8 is
  22990. // no longer needed. #2251, #3224.
  22991. if (!pEvt.preventDefault) {
  22992. pEvt.returnValue = false;
  22993. }
  22994. if (chart.mouseIsDown === 'mousedown') {
  22995. this.drag(pEvt);
  22996. }
  22997. // Show the tooltip and run mouse over events (#977)
  22998. if (!chart.openMenu &&
  22999. (this.inClass(pEvt.target, 'highcharts-tracker') ||
  23000. chart.isInsidePlot((pEvt.chartX - chart.plotLeft), (pEvt.chartY - chart.plotTop)))) {
  23001. this.runPointActions(pEvt);
  23002. }
  23003. };
  23004. /**
  23005. * @private
  23006. * @function Highcharts.Pointer#onDocumentTouchEnd
  23007. *
  23008. * @param {Highcharts.PointerEventObject} e
  23009. *
  23010. * @return {void}
  23011. */
  23012. Pointer.prototype.onDocumentTouchEnd = function (e) {
  23013. if (charts[H.hoverChartIndex]) {
  23014. charts[H.hoverChartIndex].pointer.drop(e);
  23015. }
  23016. };
  23017. /**
  23018. * @private
  23019. * @function Highcharts.Pointer#onContainerTouchMove
  23020. *
  23021. * @param {Highcharts.PointerEventObject} e
  23022. *
  23023. * @return {void}
  23024. */
  23025. Pointer.prototype.onContainerTouchMove = function (e) {
  23026. this.touch(e);
  23027. };
  23028. /**
  23029. * @private
  23030. * @function Highcharts.Pointer#onContainerTouchStart
  23031. *
  23032. * @param {Highcharts.PointerEventObject} e
  23033. *
  23034. * @return {void}
  23035. */
  23036. Pointer.prototype.onContainerTouchStart = function (e) {
  23037. this.zoomOption(e);
  23038. this.touch(e, true);
  23039. };
  23040. /**
  23041. * Special handler for mouse move that will hide the tooltip when the mouse
  23042. * leaves the plotarea. Issue #149 workaround. The mouseleave event does not
  23043. * always fire.
  23044. *
  23045. * @private
  23046. * @function Highcharts.Pointer#onDocumentMouseMove
  23047. *
  23048. * @param {global.MouseEvent} e
  23049. *
  23050. * @return {void}
  23051. */
  23052. Pointer.prototype.onDocumentMouseMove = function (e) {
  23053. var chart = this.chart;
  23054. var chartPosition = this.chartPosition;
  23055. var pEvt = this.normalize(e, chartPosition);
  23056. var tooltip = chart.tooltip;
  23057. // If we're outside, hide the tooltip
  23058. if (chartPosition &&
  23059. (!tooltip ||
  23060. !tooltip.isStickyOnContact()) &&
  23061. !chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop) &&
  23062. !this.inClass(pEvt.target, 'highcharts-tracker')) {
  23063. this.reset();
  23064. }
  23065. };
  23066. /**
  23067. * @private
  23068. * @function Highcharts.Pointer#onDocumentMouseUp
  23069. *
  23070. * @param {global.MouseEvent} e
  23071. *
  23072. * @return {void}
  23073. */
  23074. Pointer.prototype.onDocumentMouseUp = function (e) {
  23075. var chart = charts[pick(H.hoverChartIndex, -1)];
  23076. if (chart) {
  23077. chart.pointer.drop(e);
  23078. }
  23079. };
  23080. /**
  23081. * Handle touch events with two touches
  23082. *
  23083. * @private
  23084. * @function Highcharts.Pointer#pinch
  23085. *
  23086. * @param {Highcharts.PointerEventObject} e
  23087. *
  23088. * @return {void}
  23089. */
  23090. Pointer.prototype.pinch = function (e) {
  23091. var self = this, chart = self.chart, pinchDown = self.pinchDown, touches = (e.touches || []), touchesLength = touches.length, lastValidTouch = self.lastValidTouch, hasZoom = self.hasZoom, selectionMarker = self.selectionMarker, transform = {}, fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
  23092. chart.runTrackerClick) ||
  23093. self.runChartClick), clip = {};
  23094. // Don't initiate panning until the user has pinched. This prevents us
  23095. // from blocking page scrolling as users scroll down a long page
  23096. // (#4210).
  23097. if (touchesLength > 1) {
  23098. self.initiated = true;
  23099. }
  23100. // On touch devices, only proceed to trigger click if a handler is
  23101. // defined
  23102. if (hasZoom && self.initiated && !fireClickEvent) {
  23103. e.preventDefault();
  23104. }
  23105. // Normalize each touch
  23106. [].map.call(touches, function (e) {
  23107. return self.normalize(e);
  23108. });
  23109. // Register the touch start position
  23110. if (e.type === 'touchstart') {
  23111. [].forEach.call(touches, function (e, i) {
  23112. pinchDown[i] = { chartX: e.chartX, chartY: e.chartY };
  23113. });
  23114. lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] &&
  23115. pinchDown[1].chartX];
  23116. lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] &&
  23117. pinchDown[1].chartY];
  23118. // Identify the data bounds in pixels
  23119. chart.axes.forEach(function (axis) {
  23120. if (axis.zoomEnabled) {
  23121. var bounds = chart.bounds[axis.horiz ? 'h' : 'v'], minPixelPadding = axis.minPixelPadding, min = axis.toPixels(Math.min(pick(axis.options.min, axis.dataMin), axis.dataMin)), max = axis.toPixels(Math.max(pick(axis.options.max, axis.dataMax), axis.dataMax)), absMin = Math.min(min, max), absMax = Math.max(min, max);
  23122. // Store the bounds for use in the touchmove handler
  23123. bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
  23124. bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
  23125. }
  23126. });
  23127. self.res = true; // reset on next move
  23128. // Optionally move the tooltip on touchmove
  23129. }
  23130. else if (self.followTouchMove && touchesLength === 1) {
  23131. this.runPointActions(self.normalize(e));
  23132. // Event type is touchmove, handle panning and pinching
  23133. }
  23134. else if (pinchDown.length) { // can be 0 when releasing, if touchend
  23135. // fires first
  23136. // Set the marker
  23137. if (!selectionMarker) {
  23138. self.selectionMarker = selectionMarker = extend({
  23139. destroy: noop,
  23140. touch: true
  23141. }, chart.plotBox);
  23142. }
  23143. self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  23144. self.hasPinched = hasZoom;
  23145. // Scale and translate the groups to provide visual feedback during
  23146. // pinching
  23147. self.scaleGroups(transform, clip);
  23148. if (self.res) {
  23149. self.res = false;
  23150. this.reset(false, 0);
  23151. }
  23152. }
  23153. };
  23154. /**
  23155. * Run translation operations
  23156. *
  23157. * @private
  23158. * @function Highcharts.Pointer#pinchTranslate
  23159. *
  23160. * @param {Array<*>} pinchDown
  23161. *
  23162. * @param {Array<Highcharts.PointerEventObject>} touches
  23163. *
  23164. * @param {*} transform
  23165. *
  23166. * @param {*} selectionMarker
  23167. *
  23168. * @param {*} clip
  23169. *
  23170. * @param {*} lastValidTouch
  23171. *
  23172. * @return {void}
  23173. */
  23174. Pointer.prototype.pinchTranslate = function (pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  23175. if (this.zoomHor) {
  23176. this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  23177. }
  23178. if (this.zoomVert) {
  23179. this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  23180. }
  23181. };
  23182. /**
  23183. * Run translation operations for each direction (horizontal and vertical)
  23184. * independently.
  23185. *
  23186. * @private
  23187. * @function Highcharts.Pointer#pinchTranslateDirection
  23188. *
  23189. * @param {boolean} horiz
  23190. *
  23191. * @param {Array<*>} pinchDown
  23192. *
  23193. * @param {Array<Highcharts.PointerEventObject>} touches
  23194. *
  23195. * @param {*} transform
  23196. *
  23197. * @param {*} selectionMarker
  23198. *
  23199. * @param {*} clip
  23200. *
  23201. * @param {*} lastValidTouch
  23202. *
  23203. * @param {number|undefined} [forcedScale=1]
  23204. *
  23205. * @return {void}
  23206. */
  23207. Pointer.prototype.pinchTranslateDirection = function (horiz, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, forcedScale) {
  23208. 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 () {
  23209. // Don't zoom if fingers are too close on this axis
  23210. if (typeof touch1Now === 'number' &&
  23211. Math.abs(touch0Start - touch1Start) > 20) {
  23212. scale = forcedScale ||
  23213. Math.abs(touch0Now - touch1Now) /
  23214. Math.abs(touch0Start - touch1Start);
  23215. }
  23216. clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
  23217. selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
  23218. };
  23219. // Set the scale, first pass
  23220. setScale();
  23221. // The clip position (x or y) is altered if out of bounds, the selection
  23222. // position is not
  23223. selectionXY = clipXY;
  23224. // Out of bounds
  23225. if (selectionXY < bounds.min) {
  23226. selectionXY = bounds.min;
  23227. outOfBounds = true;
  23228. }
  23229. else if (selectionXY + selectionWH > bounds.max) {
  23230. selectionXY = bounds.max - selectionWH;
  23231. outOfBounds = true;
  23232. }
  23233. // Is the chart dragged off its bounds, determined by dataMin and
  23234. // dataMax?
  23235. if (outOfBounds) {
  23236. // Modify the touchNow position in order to create an elastic drag
  23237. // movement. This indicates to the user that the chart is responsive
  23238. // but can't be dragged further.
  23239. touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
  23240. if (typeof touch1Now === 'number') {
  23241. touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
  23242. }
  23243. // Set the scale, second pass to adapt to the modified touchNow
  23244. // positions
  23245. setScale();
  23246. }
  23247. else {
  23248. lastValidTouch[xy] = [touch0Now, touch1Now];
  23249. }
  23250. // Set geometry for clipping, selection and transformation
  23251. if (!inverted) {
  23252. clip[xy] = clipXY - plotLeftTop;
  23253. clip[wh] = selectionWH;
  23254. }
  23255. scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
  23256. transformScale = inverted ? 1 / scale : scale;
  23257. selectionMarker[wh] = selectionWH;
  23258. selectionMarker[xy] = selectionXY;
  23259. transform[scaleKey] = scale;
  23260. transform['translate' + XY] = (transformScale * plotLeftTop) +
  23261. (touch0Now - (transformScale * touch0Start));
  23262. };
  23263. /**
  23264. * Reset the tracking by hiding the tooltip, the hover series state and the
  23265. * hover point
  23266. *
  23267. * @function Highcharts.Pointer#reset
  23268. *
  23269. * @param {boolean} [allowMove]
  23270. * Instead of destroying the tooltip altogether, allow moving it if
  23271. * possible.
  23272. *
  23273. * @param {number} [delay]
  23274. *
  23275. * @return {void}
  23276. */
  23277. Pointer.prototype.reset = function (allowMove, delay) {
  23278. var pointer = this, chart = pointer.chart, hoverSeries = chart.hoverSeries, hoverPoint = chart.hoverPoint, hoverPoints = chart.hoverPoints, tooltip = chart.tooltip, tooltipPoints = tooltip && tooltip.shared ?
  23279. hoverPoints :
  23280. hoverPoint;
  23281. // Check if the points have moved outside the plot area (#1003, #4736,
  23282. // #5101)
  23283. if (allowMove && tooltipPoints) {
  23284. splat(tooltipPoints).forEach(function (point) {
  23285. if (point.series.isCartesian &&
  23286. typeof point.plotX === 'undefined') {
  23287. allowMove = false;
  23288. }
  23289. });
  23290. }
  23291. // Just move the tooltip, #349
  23292. if (allowMove) {
  23293. if (tooltip && tooltipPoints && splat(tooltipPoints).length) {
  23294. tooltip.refresh(tooltipPoints);
  23295. if (tooltip.shared && hoverPoints) { // #8284
  23296. hoverPoints.forEach(function (point) {
  23297. point.setState(point.state, true);
  23298. if (point.series.isCartesian) {
  23299. if (point.series.xAxis.crosshair) {
  23300. point.series.xAxis
  23301. .drawCrosshair(null, point);
  23302. }
  23303. if (point.series.yAxis.crosshair) {
  23304. point.series.yAxis
  23305. .drawCrosshair(null, point);
  23306. }
  23307. }
  23308. });
  23309. }
  23310. else if (hoverPoint) { // #2500
  23311. hoverPoint.setState(hoverPoint.state, true);
  23312. chart.axes.forEach(function (axis) {
  23313. if (axis.crosshair &&
  23314. hoverPoint.series[axis.coll] === axis) {
  23315. axis.drawCrosshair(null, hoverPoint);
  23316. }
  23317. });
  23318. }
  23319. }
  23320. // Full reset
  23321. }
  23322. else {
  23323. if (hoverPoint) {
  23324. hoverPoint.onMouseOut();
  23325. }
  23326. if (hoverPoints) {
  23327. hoverPoints.forEach(function (point) {
  23328. point.setState();
  23329. });
  23330. }
  23331. if (hoverSeries) {
  23332. hoverSeries.onMouseOut();
  23333. }
  23334. if (tooltip) {
  23335. tooltip.hide(delay);
  23336. }
  23337. if (pointer.unDocMouseMove) {
  23338. pointer.unDocMouseMove = pointer.unDocMouseMove();
  23339. }
  23340. // Remove crosshairs
  23341. chart.axes.forEach(function (axis) {
  23342. axis.hideCrosshair();
  23343. });
  23344. pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
  23345. }
  23346. };
  23347. /**
  23348. * With line type charts with a single tracker, get the point closest to the
  23349. * mouse. Run Point.onMouseOver and display tooltip for the point or points.
  23350. *
  23351. * @private
  23352. * @function Highcharts.Pointer#runPointActions
  23353. *
  23354. * @param {global.Event} e
  23355. *
  23356. * @param {Highcharts.PointerEventObject} [p]
  23357. *
  23358. * @return {void}
  23359. *
  23360. * @fires Highcharts.Point#event:mouseOut
  23361. * @fires Highcharts.Point#event:mouseOver
  23362. */
  23363. Pointer.prototype.runPointActions = function (e, p) {
  23364. var pointer = this, chart = pointer.chart, series = chart.series, tooltip = (chart.tooltip && chart.tooltip.options.enabled ?
  23365. chart.tooltip :
  23366. void 0), shared = (tooltip ?
  23367. tooltip.shared :
  23368. false), hoverPoint = p || chart.hoverPoint, hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
  23369. // onMouseOver or already hovering a series with directTouch
  23370. isDirectTouch = (!e || e.type !== 'touchmove') && (!!p || ((hoverSeries && hoverSeries.directTouch) &&
  23371. pointer.isDirectTouch)), hoverData = this.getHoverData(hoverPoint, hoverSeries, series, isDirectTouch, shared, e), useSharedTooltip, followPointer, anchor, points;
  23372. // Update variables from hoverData.
  23373. hoverPoint = hoverData.hoverPoint;
  23374. points = hoverData.hoverPoints;
  23375. hoverSeries = hoverData.hoverSeries;
  23376. followPointer = hoverSeries && hoverSeries.tooltipOptions.followPointer;
  23377. useSharedTooltip = (shared &&
  23378. hoverSeries &&
  23379. !hoverSeries.noSharedTooltip);
  23380. // Refresh tooltip for kdpoint if new hover point or tooltip was hidden
  23381. // #3926, #4200
  23382. if (hoverPoint &&
  23383. // !(hoverSeries && hoverSeries.directTouch) &&
  23384. (hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))) {
  23385. (chart.hoverPoints || []).forEach(function (p) {
  23386. if (points.indexOf(p) === -1) {
  23387. p.setState();
  23388. }
  23389. });
  23390. // Set normal state to previous series
  23391. if (chart.hoverSeries !== hoverSeries) {
  23392. hoverSeries.onMouseOver();
  23393. }
  23394. pointer.applyInactiveState(points);
  23395. // Do mouseover on all points (#3919, #3985, #4410, #5622)
  23396. (points || []).forEach(function (p) {
  23397. p.setState('hover');
  23398. });
  23399. // If tracking is on series in stead of on each point,
  23400. // fire mouseOver on hover point. // #4448
  23401. if (chart.hoverPoint) {
  23402. chart.hoverPoint.firePointEvent('mouseOut');
  23403. }
  23404. // Hover point may have been destroyed in the event handlers (#7127)
  23405. if (!hoverPoint.series) {
  23406. return;
  23407. }
  23408. /**
  23409. * Contains all hovered points.
  23410. *
  23411. * @name Highcharts.Chart#hoverPoints
  23412. * @type {Array<Highcharts.Point>|null}
  23413. */
  23414. chart.hoverPoints = points;
  23415. /**
  23416. * Contains the original hovered point.
  23417. *
  23418. * @name Highcharts.Chart#hoverPoint
  23419. * @type {Highcharts.Point|null}
  23420. */
  23421. chart.hoverPoint = hoverPoint;
  23422. /**
  23423. * Hover state should not be lost when axis is updated (#12569)
  23424. * Axis.update runs pointer.reset which uses chart.hoverPoint.state
  23425. * to apply state which does not exist in hoverPoint yet.
  23426. * The mouseOver event should be triggered when hoverPoint
  23427. * is correct.
  23428. */
  23429. hoverPoint.firePointEvent('mouseOver');
  23430. // Draw tooltip if necessary
  23431. if (tooltip) {
  23432. tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
  23433. }
  23434. // Update positions (regardless of kdpoint or hoverPoint)
  23435. }
  23436. else if (followPointer && tooltip && !tooltip.isHidden) {
  23437. anchor = tooltip.getAnchor([{}], e);
  23438. tooltip.updatePosition({ plotX: anchor[0], plotY: anchor[1] });
  23439. }
  23440. // Start the event listener to pick up the tooltip and crosshairs
  23441. if (!pointer.unDocMouseMove) {
  23442. pointer.unDocMouseMove = addEvent(chart.container.ownerDocument, 'mousemove', function (e) {
  23443. var chart = charts[H.hoverChartIndex];
  23444. if (chart) {
  23445. chart.pointer.onDocumentMouseMove(e);
  23446. }
  23447. });
  23448. }
  23449. // Issues related to crosshair #4927, #5269 #5066, #5658
  23450. chart.axes.forEach(function drawAxisCrosshair(axis) {
  23451. var snap = pick((axis.crosshair || {}).snap, true);
  23452. var point;
  23453. if (snap) {
  23454. point = chart.hoverPoint; // #13002
  23455. if (!point || point.series[axis.coll] !== axis) {
  23456. point = find(points, function (p) {
  23457. return p.series[axis.coll] === axis;
  23458. });
  23459. }
  23460. }
  23461. // Axis has snapping crosshairs, and one of the hover points belongs
  23462. // to axis. Always call drawCrosshair when it is not snap.
  23463. if (point || !snap) {
  23464. axis.drawCrosshair(e, point);
  23465. // Axis has snapping crosshairs, but no hover point belongs to axis
  23466. }
  23467. else {
  23468. axis.hideCrosshair();
  23469. }
  23470. });
  23471. };
  23472. /**
  23473. * Scale series groups to a certain scale and translation.
  23474. *
  23475. * @private
  23476. * @function Highcharts.Pointer#scaleGroups
  23477. *
  23478. * @param {Highcharts.SeriesPlotBoxObject} [attribs]
  23479. *
  23480. * @param {boolean} [clip]
  23481. *
  23482. * @return {void}
  23483. */
  23484. Pointer.prototype.scaleGroups = function (attribs, clip) {
  23485. var chart = this.chart, seriesAttribs;
  23486. // Scale each series
  23487. chart.series.forEach(function (series) {
  23488. seriesAttribs = attribs || series.getPlotBox(); // #1701
  23489. if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
  23490. series.group.attr(seriesAttribs);
  23491. if (series.markerGroup) {
  23492. series.markerGroup.attr(seriesAttribs);
  23493. series.markerGroup.clip(clip ? chart.clipRect : null);
  23494. }
  23495. if (series.dataLabelsGroup) {
  23496. series.dataLabelsGroup.attr(seriesAttribs);
  23497. }
  23498. }
  23499. });
  23500. // Clip
  23501. chart.clipRect.attr(clip || chart.clipBox);
  23502. };
  23503. /**
  23504. * Set the JS DOM events on the container and document. This method should
  23505. * contain a one-to-one assignment between methods and their handlers. Any
  23506. * advanced logic should be moved to the handler reflecting the event's
  23507. * name.
  23508. *
  23509. * @private
  23510. * @function Highcharts.Pointer#setDOMEvents
  23511. *
  23512. * @return {void}
  23513. */
  23514. Pointer.prototype.setDOMEvents = function () {
  23515. var container = this.chart.container, ownerDoc = container.ownerDocument;
  23516. container.onmousedown = this.onContainerMouseDown.bind(this);
  23517. container.onmousemove = this.onContainerMouseMove.bind(this);
  23518. container.onclick = this.onContainerClick.bind(this);
  23519. this.unbindContainerMouseLeave = addEvent(container, 'mouseleave', this.onContainerMouseLeave.bind(this));
  23520. if (!H.unbindDocumentMouseUp) {
  23521. H.unbindDocumentMouseUp = addEvent(ownerDoc, 'mouseup', this.onDocumentMouseUp.bind(this));
  23522. }
  23523. if (H.hasTouch) {
  23524. addEvent(container, 'touchstart', this.onContainerTouchStart.bind(this));
  23525. addEvent(container, 'touchmove', this.onContainerTouchMove.bind(this));
  23526. if (!H.unbindDocumentTouchEnd) {
  23527. H.unbindDocumentTouchEnd = addEvent(ownerDoc, 'touchend', this.onDocumentTouchEnd.bind(this));
  23528. }
  23529. }
  23530. };
  23531. /**
  23532. * Sets the index of the hovered chart and leaves the previous hovered
  23533. * chart, to reset states like tooltip.
  23534. *
  23535. * @private
  23536. * @function Highcharts.Pointer#setHoverChartIndex
  23537. */
  23538. Pointer.prototype.setHoverChartIndex = function () {
  23539. var chart = this.chart;
  23540. var hoverChart = H.charts[pick(H.hoverChartIndex, -1)];
  23541. if (hoverChart &&
  23542. hoverChart !== chart) {
  23543. hoverChart.pointer.onContainerMouseLeave({ relatedTarget: true });
  23544. }
  23545. if (!hoverChart ||
  23546. !hoverChart.mouseIsDown) {
  23547. H.hoverChartIndex = chart.index;
  23548. }
  23549. };
  23550. /**
  23551. * General touch handler shared by touchstart and touchmove.
  23552. *
  23553. * @private
  23554. * @function Highcharts.Pointer#touch
  23555. *
  23556. * @param {Highcharts.PointerEventObject} e
  23557. *
  23558. * @param {boolean} [start]
  23559. *
  23560. * @return {void}
  23561. */
  23562. Pointer.prototype.touch = function (e, start) {
  23563. var chart = this.chart, hasMoved, pinchDown, isInside;
  23564. this.setHoverChartIndex();
  23565. if (e.touches.length === 1) {
  23566. e = this.normalize(e);
  23567. isInside = chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop);
  23568. if (isInside && !chart.openMenu) {
  23569. // Run mouse events and display tooltip etc
  23570. if (start) {
  23571. this.runPointActions(e);
  23572. }
  23573. // Android fires touchmove events after the touchstart even if
  23574. // the finger hasn't moved, or moved only a pixel or two. In iOS
  23575. // however, the touchmove doesn't fire unless the finger moves
  23576. // more than ~4px. So we emulate this behaviour in Android by
  23577. // checking how much it moved, and cancelling on small
  23578. // distances. #3450.
  23579. if (e.type === 'touchmove') {
  23580. pinchDown = this.pinchDown;
  23581. hasMoved = pinchDown[0] ? Math.sqrt(// #5266
  23582. Math.pow(pinchDown[0].chartX - e.chartX, 2) +
  23583. Math.pow(pinchDown[0].chartY - e.chartY, 2)) >= 4 : false;
  23584. }
  23585. if (pick(hasMoved, true)) {
  23586. this.pinch(e);
  23587. }
  23588. }
  23589. else if (start) {
  23590. // Hide the tooltip on touching outside the plot area (#1203)
  23591. this.reset();
  23592. }
  23593. }
  23594. else if (e.touches.length === 2) {
  23595. this.pinch(e);
  23596. }
  23597. };
  23598. /**
  23599. * Resolve the zoomType option, this is reset on all touch start and mouse
  23600. * down events.
  23601. *
  23602. * @private
  23603. * @function Highcharts.Pointer#zoomOption
  23604. *
  23605. * @param {global.Event} e
  23606. * Event object.
  23607. *
  23608. * @param {void}
  23609. */
  23610. Pointer.prototype.zoomOption = function (e) {
  23611. var chart = this.chart, options = chart.options.chart, zoomType = options.zoomType || '', inverted = chart.inverted, zoomX, zoomY;
  23612. // Look for the pinchType option
  23613. if (/touch/.test(e.type)) {
  23614. zoomType = pick(options.pinchType, zoomType);
  23615. }
  23616. this.zoomX = zoomX = /x/.test(zoomType);
  23617. this.zoomY = zoomY = /y/.test(zoomType);
  23618. this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
  23619. this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
  23620. this.hasZoom = zoomX || zoomY;
  23621. };
  23622. return Pointer;
  23623. }());
  23624. H.Pointer = Pointer;
  23625. return Pointer;
  23626. });
  23627. _registerModule(_modules, 'parts/MSPointer.js', [_modules['parts/Globals.js'], _modules['parts/Pointer.js'], _modules['parts/Utilities.js']], function (H, Pointer, U) {
  23628. /* *
  23629. *
  23630. * (c) 2010-2020 Torstein Honsi
  23631. *
  23632. * License: www.highcharts.com/license
  23633. *
  23634. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  23635. *
  23636. * */
  23637. var __extends = (this && this.__extends) || (function () {
  23638. var extendStatics = function (d, b) {
  23639. extendStatics = Object.setPrototypeOf ||
  23640. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  23641. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  23642. return extendStatics(d, b);
  23643. };
  23644. return function (d, b) {
  23645. extendStatics(d, b);
  23646. function __() { this.constructor = d; }
  23647. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23648. };
  23649. })();
  23650. var charts = H.charts, doc = H.doc, noop = H.noop, win = H.win;
  23651. var addEvent = U.addEvent, css = U.css, objectEach = U.objectEach, removeEvent = U.removeEvent;
  23652. /* globals MSPointerEvent, PointerEvent */
  23653. // The touches object keeps track of the points being touched at all times
  23654. var touches = {};
  23655. var hasPointerEvent = !!win.PointerEvent;
  23656. /* eslint-disable valid-jsdoc */
  23657. /** @private */
  23658. function getWebkitTouches() {
  23659. var fake = [];
  23660. fake.item = function (i) {
  23661. return this[i];
  23662. };
  23663. objectEach(touches, function (touch) {
  23664. fake.push({
  23665. pageX: touch.pageX,
  23666. pageY: touch.pageY,
  23667. target: touch.target
  23668. });
  23669. });
  23670. return fake;
  23671. }
  23672. /** @private */
  23673. function translateMSPointer(e, method, wktype, func) {
  23674. var p;
  23675. if ((e.pointerType === 'touch' ||
  23676. e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
  23677. func(e);
  23678. p = charts[H.hoverChartIndex].pointer;
  23679. p[method]({
  23680. type: wktype,
  23681. target: e.currentTarget,
  23682. preventDefault: noop,
  23683. touches: getWebkitTouches()
  23684. });
  23685. }
  23686. }
  23687. /** @private */
  23688. var MSPointer = /** @class */ (function (_super) {
  23689. __extends(MSPointer, _super);
  23690. function MSPointer() {
  23691. return _super !== null && _super.apply(this, arguments) || this;
  23692. }
  23693. /* *
  23694. *
  23695. * Functions
  23696. *
  23697. * */
  23698. /**
  23699. * Add or remove the MS Pointer specific events
  23700. *
  23701. * @private
  23702. * @function Highcharts.Pointer#batchMSEvents
  23703. *
  23704. * @param {Function} fn
  23705. *
  23706. * @return {void}
  23707. */
  23708. MSPointer.prototype.batchMSEvents = function (fn) {
  23709. fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
  23710. fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
  23711. fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
  23712. };
  23713. // Destroy MS events also
  23714. MSPointer.prototype.destroy = function () {
  23715. this.batchMSEvents(removeEvent);
  23716. _super.prototype.destroy.call(this);
  23717. };
  23718. // Disable default IE actions for pinch and such on chart element
  23719. MSPointer.prototype.init = function (chart, options) {
  23720. _super.prototype.init.call(this, chart, options);
  23721. if (this.hasZoom) { // #4014
  23722. css(chart.container, {
  23723. '-ms-touch-action': 'none',
  23724. 'touch-action': 'none'
  23725. });
  23726. }
  23727. };
  23728. /**
  23729. * @private
  23730. * @function Highcharts.Pointer#onContainerPointerDown
  23731. *
  23732. * @param {Highcharts.PointerEventObject} e
  23733. *
  23734. * @return {void}
  23735. */
  23736. MSPointer.prototype.onContainerPointerDown = function (e) {
  23737. translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function (e) {
  23738. touches[e.pointerId] = {
  23739. pageX: e.pageX,
  23740. pageY: e.pageY,
  23741. target: e.currentTarget
  23742. };
  23743. });
  23744. };
  23745. /**
  23746. * @private
  23747. * @function Highcharts.Pointer#onContainerPointerMove
  23748. *
  23749. * @param {Highcharts.PointerEventObject} e
  23750. *
  23751. * @return {void}
  23752. */
  23753. MSPointer.prototype.onContainerPointerMove = function (e) {
  23754. translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function (e) {
  23755. touches[e.pointerId] = ({ pageX: e.pageX, pageY: e.pageY });
  23756. if (!touches[e.pointerId].target) {
  23757. touches[e.pointerId].target = e.currentTarget;
  23758. }
  23759. });
  23760. };
  23761. /**
  23762. * @private
  23763. * @function Highcharts.Pointer#onDocumentPointerUp
  23764. *
  23765. * @param {Highcharts.PointerEventObject} e
  23766. *
  23767. * @return {void}
  23768. */
  23769. MSPointer.prototype.onDocumentPointerUp = function (e) {
  23770. translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function (e) {
  23771. delete touches[e.pointerId];
  23772. });
  23773. };
  23774. // Add IE specific touch events to chart
  23775. MSPointer.prototype.setDOMEvents = function () {
  23776. _super.prototype.setDOMEvents.call(this);
  23777. if (this.hasZoom || this.followTouchMove) {
  23778. this.batchMSEvents(addEvent);
  23779. }
  23780. };
  23781. return MSPointer;
  23782. }(Pointer));
  23783. return MSPointer;
  23784. });
  23785. _registerModule(_modules, 'parts/Legend.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  23786. /* *
  23787. *
  23788. * (c) 2010-2020 Torstein Honsi
  23789. *
  23790. * License: www.highcharts.com/license
  23791. *
  23792. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  23793. *
  23794. * */
  23795. /**
  23796. * Gets fired when the legend item belonging to a point is clicked. The default
  23797. * action is to toggle the visibility of the point. This can be prevented by
  23798. * returning `false` or calling `event.preventDefault()`.
  23799. *
  23800. * @callback Highcharts.PointLegendItemClickCallbackFunction
  23801. *
  23802. * @param {Highcharts.Point} this
  23803. * The point on which the event occured.
  23804. *
  23805. * @param {Highcharts.PointLegendItemClickEventObject} event
  23806. * The event that occured.
  23807. */
  23808. /**
  23809. * Information about the legend click event.
  23810. *
  23811. * @interface Highcharts.PointLegendItemClickEventObject
  23812. */ /**
  23813. * Related browser event.
  23814. * @name Highcharts.PointLegendItemClickEventObject#browserEvent
  23815. * @type {Highcharts.PointerEvent}
  23816. */ /**
  23817. * Prevent the default action of toggle the visibility of the point.
  23818. * @name Highcharts.PointLegendItemClickEventObject#preventDefault
  23819. * @type {Function}
  23820. */ /**
  23821. * Related point.
  23822. * @name Highcharts.PointLegendItemClickEventObject#target
  23823. * @type {Highcharts.Point}
  23824. */ /**
  23825. * Event type.
  23826. * @name Highcharts.PointLegendItemClickEventObject#type
  23827. * @type {"legendItemClick"}
  23828. */
  23829. /**
  23830. * Gets fired when the legend item belonging to a series is clicked. The default
  23831. * action is to toggle the visibility of the series. This can be prevented by
  23832. * returning `false` or calling `event.preventDefault()`.
  23833. *
  23834. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  23835. *
  23836. * @param {Highcharts.Series} this
  23837. * The series where the event occured.
  23838. *
  23839. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  23840. * The event that occured.
  23841. */
  23842. /**
  23843. * Information about the legend click event.
  23844. *
  23845. * @interface Highcharts.SeriesLegendItemClickEventObject
  23846. */ /**
  23847. * Related browser event.
  23848. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  23849. * @type {Highcharts.PointerEvent}
  23850. */ /**
  23851. * Prevent the default action of toggle the visibility of the series.
  23852. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  23853. * @type {Function}
  23854. */ /**
  23855. * Related series.
  23856. * @name Highcharts.SeriesLegendItemClickEventObject#target
  23857. * @type {Highcharts.Series}
  23858. */ /**
  23859. * Event type.
  23860. * @name Highcharts.SeriesLegendItemClickEventObject#type
  23861. * @type {"legendItemClick"}
  23862. */
  23863. var addEvent = U.addEvent, animObject = U.animObject, css = U.css, defined = U.defined, discardElement = U.discardElement, find = U.find, fireEvent = U.fireEvent, format = U.format, isNumber = U.isNumber, merge = U.merge, pick = U.pick, relativeLength = U.relativeLength, setAnimation = U.setAnimation, stableSort = U.stableSort, syncTimeout = U.syncTimeout, wrap = U.wrap;
  23864. var isFirefox = H.isFirefox, marginNames = H.marginNames, win = H.win;
  23865. /* eslint-disable no-invalid-this, valid-jsdoc */
  23866. /**
  23867. * The overview of the chart's series. The legend object is instanciated
  23868. * internally in the chart constructor, and is available from the `chart.legend`
  23869. * property. Each chart has only one legend.
  23870. *
  23871. * @class
  23872. * @name Highcharts.Legend
  23873. *
  23874. * @param {Highcharts.Chart} chart
  23875. * The chart instance.
  23876. *
  23877. * @param {Highcharts.LegendOptions} options
  23878. * Legend options.
  23879. */
  23880. var Legend = /** @class */ (function () {
  23881. /* *
  23882. *
  23883. * Constructors
  23884. *
  23885. * */
  23886. function Legend(chart, options) {
  23887. /* *
  23888. *
  23889. * Properties
  23890. *
  23891. * */
  23892. this.allItems = [];
  23893. this.box = void 0;
  23894. this.contentGroup = void 0;
  23895. this.display = false;
  23896. this.group = void 0;
  23897. this.initialItemY = 0;
  23898. this.itemHeight = 0;
  23899. this.itemMarginBottom = 0;
  23900. this.itemMarginTop = 0;
  23901. this.itemX = 0;
  23902. this.itemY = 0;
  23903. this.lastItemY = 0;
  23904. this.lastLineHeight = 0;
  23905. this.legendHeight = 0;
  23906. this.legendWidth = 0;
  23907. this.maxItemWidth = 0;
  23908. this.maxLegendWidth = 0;
  23909. this.offsetWidth = 0;
  23910. this.options = {};
  23911. this.padding = 0;
  23912. this.pages = [];
  23913. this.proximate = false;
  23914. this.scrollGroup = void 0;
  23915. this.symbolHeight = 0;
  23916. this.symbolWidth = 0;
  23917. this.titleHeight = 0;
  23918. this.totalItemWidth = 0;
  23919. this.widthOption = 0;
  23920. this.chart = chart;
  23921. this.init(chart, options);
  23922. }
  23923. /* *
  23924. *
  23925. * Functions
  23926. *
  23927. * */
  23928. /**
  23929. * Initialize the legend.
  23930. *
  23931. * @private
  23932. * @function Highcharts.Legend#init
  23933. *
  23934. * @param {Highcharts.Chart} chart
  23935. * The chart instance.
  23936. *
  23937. * @param {Highcharts.LegendOptions} options
  23938. * Legend options.
  23939. */
  23940. Legend.prototype.init = function (chart, options) {
  23941. /**
  23942. * Chart of this legend.
  23943. *
  23944. * @readonly
  23945. * @name Highcharts.Legend#chart
  23946. * @type {Highcharts.Chart}
  23947. */
  23948. this.chart = chart;
  23949. this.setOptions(options);
  23950. if (options.enabled) {
  23951. // Render it
  23952. this.render();
  23953. // move checkboxes
  23954. addEvent(this.chart, 'endResize', function () {
  23955. this.legend.positionCheckboxes();
  23956. });
  23957. if (this.proximate) {
  23958. this.unchartrender = addEvent(this.chart, 'render', function () {
  23959. this.legend.proximatePositions();
  23960. this.legend.positionItems();
  23961. });
  23962. }
  23963. else if (this.unchartrender) {
  23964. this.unchartrender();
  23965. }
  23966. }
  23967. };
  23968. /**
  23969. * @private
  23970. * @function Highcharts.Legend#setOptions
  23971. * @param {Highcharts.LegendOptions} options
  23972. */
  23973. Legend.prototype.setOptions = function (options) {
  23974. var padding = pick(options.padding, 8);
  23975. /**
  23976. * Legend options.
  23977. *
  23978. * @readonly
  23979. * @name Highcharts.Legend#options
  23980. * @type {Highcharts.LegendOptions}
  23981. */
  23982. this.options = options;
  23983. if (!this.chart.styledMode) {
  23984. this.itemStyle = options.itemStyle;
  23985. this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
  23986. }
  23987. this.itemMarginTop = options.itemMarginTop || 0;
  23988. this.itemMarginBottom = options.itemMarginBottom || 0;
  23989. this.padding = padding;
  23990. this.initialItemY = padding - 5; // 5 is pixels above the text
  23991. this.symbolWidth = pick(options.symbolWidth, 16);
  23992. this.pages = [];
  23993. this.proximate = options.layout === 'proximate' && !this.chart.inverted;
  23994. this.baseline = void 0; // #12705: baseline has to be reset on every update
  23995. };
  23996. /**
  23997. * Update the legend with new options. Equivalent to running `chart.update`
  23998. * with a legend configuration option.
  23999. *
  24000. * @sample highcharts/legend/legend-update/
  24001. * Legend update
  24002. *
  24003. * @function Highcharts.Legend#update
  24004. *
  24005. * @param {Highcharts.LegendOptions} options
  24006. * Legend options.
  24007. *
  24008. * @param {boolean} [redraw=true]
  24009. * Whether to redraw the chart after the axis is altered. If doing more
  24010. * operations on the chart, it is a good idea to set redraw to false and
  24011. * call {@link Chart#redraw} after. Whether to redraw the chart.
  24012. *
  24013. * @fires Highcharts.Legends#event:afterUpdate
  24014. */
  24015. Legend.prototype.update = function (options, redraw) {
  24016. var chart = this.chart;
  24017. this.setOptions(merge(true, this.options, options));
  24018. this.destroy();
  24019. chart.isDirtyLegend = chart.isDirtyBox = true;
  24020. if (pick(redraw, true)) {
  24021. chart.redraw();
  24022. }
  24023. fireEvent(this, 'afterUpdate');
  24024. };
  24025. /**
  24026. * Set the colors for the legend item.
  24027. *
  24028. * @private
  24029. * @function Highcharts.Legend#colorizeItem
  24030. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  24031. * A Series or Point instance
  24032. * @param {boolean} [visible=false]
  24033. * Dimmed or colored
  24034. *
  24035. * @todo
  24036. * Make events official: Fires the event `afterColorizeItem`.
  24037. */
  24038. Legend.prototype.colorizeItem = function (item, visible) {
  24039. item.legendGroup[visible ? 'removeClass' : 'addClass']('highcharts-legend-item-hidden');
  24040. if (!this.chart.styledMode) {
  24041. var legend = this, options = legend.options, legendItem = item.legendItem, legendLine = item.legendLine, legendSymbol = item.legendSymbol, hiddenColor = legend.itemHiddenStyle.color, textColor = visible ?
  24042. options.itemStyle.color :
  24043. hiddenColor, symbolColor = visible ?
  24044. (item.color || hiddenColor) :
  24045. hiddenColor, markerOptions = item.options && item.options.marker, symbolAttr = { fill: symbolColor };
  24046. if (legendItem) {
  24047. legendItem.css({
  24048. fill: textColor,
  24049. color: textColor // #1553, oldIE
  24050. });
  24051. }
  24052. if (legendLine) {
  24053. legendLine.attr({ stroke: symbolColor });
  24054. }
  24055. if (legendSymbol) {
  24056. // Apply marker options
  24057. if (markerOptions && legendSymbol.isMarker) { // #585
  24058. symbolAttr = item.pointAttribs();
  24059. if (!visible) {
  24060. // #6769
  24061. symbolAttr.stroke = symbolAttr.fill = hiddenColor;
  24062. }
  24063. }
  24064. legendSymbol.attr(symbolAttr);
  24065. }
  24066. }
  24067. fireEvent(this, 'afterColorizeItem', { item: item, visible: visible });
  24068. };
  24069. /**
  24070. * @private
  24071. * @function Highcharts.Legend#positionItems
  24072. */
  24073. Legend.prototype.positionItems = function () {
  24074. // Now that the legend width and height are established, put the items
  24075. // in the final position
  24076. this.allItems.forEach(this.positionItem, this);
  24077. if (!this.chart.isResizing) {
  24078. this.positionCheckboxes();
  24079. }
  24080. };
  24081. /**
  24082. * Position the legend item.
  24083. *
  24084. * @private
  24085. * @function Highcharts.Legend#positionItem
  24086. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  24087. * The item to position
  24088. */
  24089. Legend.prototype.positionItem = function (item) {
  24090. var _this = this;
  24091. var legend = this, options = legend.options, symbolPadding = options.symbolPadding, ltr = !options.rtl, legendItemPos = item._legendItemPos, itemX = legendItemPos[0], itemY = legendItemPos[1], checkbox = item.checkbox, legendGroup = item.legendGroup;
  24092. if (legendGroup && legendGroup.element) {
  24093. var attribs = {
  24094. translateX: ltr ?
  24095. itemX :
  24096. legend.legendWidth - itemX - 2 * symbolPadding - 4,
  24097. translateY: itemY
  24098. };
  24099. var complete = function () {
  24100. fireEvent(_this, 'afterPositionItem', { item: item });
  24101. };
  24102. if (defined(legendGroup.translateY)) {
  24103. legendGroup.animate(attribs, { complete: complete });
  24104. }
  24105. else {
  24106. legendGroup.attr(attribs);
  24107. complete();
  24108. }
  24109. }
  24110. if (checkbox) {
  24111. checkbox.x = itemX;
  24112. checkbox.y = itemY;
  24113. }
  24114. };
  24115. /**
  24116. * Destroy a single legend item, used internally on removing series items.
  24117. *
  24118. * @private
  24119. * @function Highcharts.Legend#destroyItem
  24120. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  24121. * The item to remove
  24122. */
  24123. Legend.prototype.destroyItem = function (item) {
  24124. var checkbox = item.checkbox;
  24125. // destroy SVG elements
  24126. ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(function (key) {
  24127. if (item[key]) {
  24128. item[key] = item[key].destroy();
  24129. }
  24130. });
  24131. if (checkbox) {
  24132. discardElement(item.checkbox);
  24133. }
  24134. };
  24135. /**
  24136. * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
  24137. * must be called after destruction.
  24138. *
  24139. * @private
  24140. * @function Highcharts.Legend#destroy
  24141. */
  24142. Legend.prototype.destroy = function () {
  24143. /**
  24144. * @private
  24145. * @param {string} key
  24146. * @return {void}
  24147. */
  24148. function destroyItems(key) {
  24149. if (this[key]) {
  24150. this[key] = this[key].destroy();
  24151. }
  24152. }
  24153. // Destroy items
  24154. this.getAllItems().forEach(function (item) {
  24155. ['legendItem', 'legendGroup'].forEach(destroyItems, item);
  24156. });
  24157. // Destroy legend elements
  24158. [
  24159. 'clipRect',
  24160. 'up',
  24161. 'down',
  24162. 'pager',
  24163. 'nav',
  24164. 'box',
  24165. 'title',
  24166. 'group'
  24167. ].forEach(destroyItems, this);
  24168. this.display = null; // Reset in .render on update.
  24169. };
  24170. /**
  24171. * Position the checkboxes after the width is determined.
  24172. *
  24173. * @private
  24174. * @function Highcharts.Legend#positionCheckboxes
  24175. */
  24176. Legend.prototype.positionCheckboxes = function () {
  24177. var alignAttr = this.group && this.group.alignAttr, translateY, clipHeight = this.clipHeight || this.legendHeight, titleHeight = this.titleHeight;
  24178. if (alignAttr) {
  24179. translateY = alignAttr.translateY;
  24180. this.allItems.forEach(function (item) {
  24181. var checkbox = item.checkbox, top;
  24182. if (checkbox) {
  24183. top = translateY + titleHeight + checkbox.y +
  24184. (this.scrollOffset || 0) + 3;
  24185. css(checkbox, {
  24186. left: (alignAttr.translateX + item.checkboxOffset +
  24187. checkbox.x - 20) + 'px',
  24188. top: top + 'px',
  24189. display: this.proximate || (top > translateY - 6 &&
  24190. top < translateY + clipHeight - 6) ?
  24191. '' :
  24192. 'none'
  24193. });
  24194. }
  24195. }, this);
  24196. }
  24197. };
  24198. /**
  24199. * Render the legend title on top of the legend.
  24200. *
  24201. * @private
  24202. * @function Highcharts.Legend#renderTitle
  24203. */
  24204. Legend.prototype.renderTitle = function () {
  24205. var options = this.options, padding = this.padding, titleOptions = options.title, titleHeight = 0, bBox;
  24206. if (titleOptions.text) {
  24207. if (!this.title) {
  24208. /**
  24209. * SVG element of the legend title.
  24210. *
  24211. * @readonly
  24212. * @name Highcharts.Legend#title
  24213. * @type {Highcharts.SVGElement}
  24214. */
  24215. this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, options.useHTML, null, 'legend-title')
  24216. .attr({ zIndex: 1 });
  24217. if (!this.chart.styledMode) {
  24218. this.title.css(titleOptions.style);
  24219. }
  24220. this.title.add(this.group);
  24221. }
  24222. // Set the max title width (#7253)
  24223. if (!titleOptions.width) {
  24224. this.title.css({
  24225. width: this.maxLegendWidth + 'px'
  24226. });
  24227. }
  24228. bBox = this.title.getBBox();
  24229. titleHeight = bBox.height;
  24230. this.offsetWidth = bBox.width; // #1717
  24231. this.contentGroup.attr({ translateY: titleHeight });
  24232. }
  24233. this.titleHeight = titleHeight;
  24234. };
  24235. /**
  24236. * Set the legend item text.
  24237. *
  24238. * @function Highcharts.Legend#setText
  24239. * @param {Highcharts.Point|Highcharts.Series} item
  24240. * The item for which to update the text in the legend.
  24241. */
  24242. Legend.prototype.setText = function (item) {
  24243. var options = this.options;
  24244. item.legendItem.attr({
  24245. text: options.labelFormat ?
  24246. format(options.labelFormat, item, this.chart) :
  24247. options.labelFormatter.call(item)
  24248. });
  24249. };
  24250. /**
  24251. * Render a single specific legend item. Called internally from the `render`
  24252. * function.
  24253. *
  24254. * @private
  24255. * @function Highcharts.Legend#renderItem
  24256. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  24257. * The item to render.
  24258. */
  24259. Legend.prototype.renderItem = function (item) {
  24260. var legend = this, chart = legend.chart, renderer = chart.renderer, options = legend.options, horizontal = options.layout === 'horizontal', symbolWidth = legend.symbolWidth, symbolPadding = options.symbolPadding, itemStyle = legend.itemStyle, itemHiddenStyle = legend.itemHiddenStyle, itemDistance = horizontal ? pick(options.itemDistance, 20) : 0, ltr = !options.rtl, bBox, li = item.legendItem, isSeries = !item.series, series = !isSeries && item.series.drawLegendSymbol ?
  24261. item.series :
  24262. item, seriesOptions = series.options, showCheckbox = legend.createCheckboxForItem &&
  24263. seriesOptions &&
  24264. seriesOptions.showCheckbox,
  24265. // full width minus text width
  24266. itemExtraWidth = symbolWidth + symbolPadding +
  24267. itemDistance + (showCheckbox ? 20 : 0), useHTML = options.useHTML, itemClassName = item.options.className;
  24268. if (!li) { // generate it once, later move it
  24269. // Generate the group box, a group to hold the symbol and text. Text
  24270. // is to be appended in Legend class.
  24271. item.legendGroup = renderer
  24272. .g('legend-item')
  24273. .addClass('highcharts-' + series.type + '-series ' +
  24274. 'highcharts-color-' + item.colorIndex +
  24275. (itemClassName ? ' ' + itemClassName : '') +
  24276. (isSeries ?
  24277. ' highcharts-series-' + item.index :
  24278. ''))
  24279. .attr({ zIndex: 1 })
  24280. .add(legend.scrollGroup);
  24281. // Generate the list item text and add it to the group
  24282. item.legendItem = li = renderer.text('', ltr ?
  24283. symbolWidth + symbolPadding :
  24284. -symbolPadding, legend.baseline || 0, useHTML);
  24285. if (!chart.styledMode) {
  24286. // merge to prevent modifying original (#1021)
  24287. li.css(merge(item.visible ?
  24288. itemStyle :
  24289. itemHiddenStyle));
  24290. }
  24291. li
  24292. .attr({
  24293. align: ltr ? 'left' : 'right',
  24294. zIndex: 2
  24295. })
  24296. .add(item.legendGroup);
  24297. // Get the baseline for the first item - the font size is equal for
  24298. // all
  24299. if (!legend.baseline) {
  24300. legend.fontMetrics = renderer.fontMetrics(chart.styledMode ? 12 : itemStyle.fontSize, li);
  24301. legend.baseline =
  24302. legend.fontMetrics.f + 3 + legend.itemMarginTop;
  24303. li.attr('y', legend.baseline);
  24304. }
  24305. // Draw the legend symbol inside the group box
  24306. legend.symbolHeight =
  24307. options.symbolHeight || legend.fontMetrics.f;
  24308. series.drawLegendSymbol(legend, item);
  24309. if (legend.setItemEvents) {
  24310. legend.setItemEvents(item, li, useHTML);
  24311. }
  24312. }
  24313. // Add the HTML checkbox on top
  24314. if (showCheckbox && !item.checkbox && legend.createCheckboxForItem) {
  24315. legend.createCheckboxForItem(item);
  24316. }
  24317. // Colorize the items
  24318. legend.colorizeItem(item, item.visible);
  24319. // Take care of max width and text overflow (#6659)
  24320. if (chart.styledMode || !itemStyle.width) {
  24321. li.css({
  24322. width: ((options.itemWidth ||
  24323. legend.widthOption ||
  24324. chart.spacingBox.width) - itemExtraWidth) + 'px'
  24325. });
  24326. }
  24327. // Always update the text
  24328. legend.setText(item);
  24329. // calculate the positions for the next line
  24330. bBox = li.getBBox();
  24331. item.itemWidth = item.checkboxOffset =
  24332. options.itemWidth ||
  24333. item.legendItemWidth ||
  24334. bBox.width + itemExtraWidth;
  24335. legend.maxItemWidth = Math.max(legend.maxItemWidth, item.itemWidth);
  24336. legend.totalItemWidth += item.itemWidth;
  24337. legend.itemHeight = item.itemHeight = Math.round(item.legendItemHeight || bBox.height || legend.symbolHeight);
  24338. };
  24339. /**
  24340. * Get the position of the item in the layout. We now know the
  24341. * maxItemWidth from the previous loop.
  24342. *
  24343. * @private
  24344. * @function Highcharts.Legend#layoutItem
  24345. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  24346. */
  24347. Legend.prototype.layoutItem = function (item) {
  24348. var options = this.options, padding = this.padding, horizontal = options.layout === 'horizontal', itemHeight = item.itemHeight, itemMarginBottom = this.itemMarginBottom, itemMarginTop = this.itemMarginTop, itemDistance = horizontal ? pick(options.itemDistance, 20) : 0, maxLegendWidth = this.maxLegendWidth, itemWidth = (options.alignColumns &&
  24349. this.totalItemWidth > maxLegendWidth) ?
  24350. this.maxItemWidth :
  24351. item.itemWidth;
  24352. // If the item exceeds the width, start a new line
  24353. if (horizontal &&
  24354. this.itemX - padding + itemWidth > maxLegendWidth) {
  24355. this.itemX = padding;
  24356. if (this.lastLineHeight) { // Not for the first line (#10167)
  24357. this.itemY += (itemMarginTop +
  24358. this.lastLineHeight +
  24359. itemMarginBottom);
  24360. }
  24361. this.lastLineHeight = 0; // reset for next line (#915, #3976)
  24362. }
  24363. // Set the edge positions
  24364. this.lastItemY = itemMarginTop + this.itemY + itemMarginBottom;
  24365. this.lastLineHeight = Math.max(// #915
  24366. itemHeight, this.lastLineHeight);
  24367. // cache the position of the newly generated or reordered items
  24368. item._legendItemPos = [this.itemX, this.itemY];
  24369. // advance
  24370. if (horizontal) {
  24371. this.itemX += itemWidth;
  24372. }
  24373. else {
  24374. this.itemY +=
  24375. itemMarginTop + itemHeight + itemMarginBottom;
  24376. this.lastLineHeight = itemHeight;
  24377. }
  24378. // the width of the widest item
  24379. this.offsetWidth = this.widthOption || Math.max((horizontal ? this.itemX - padding - (item.checkbox ?
  24380. // decrease by itemDistance only when no checkbox #4853
  24381. 0 :
  24382. itemDistance) : itemWidth) + padding, this.offsetWidth);
  24383. };
  24384. /**
  24385. * Get all items, which is one item per series for most series and one
  24386. * item per point for pie series and its derivatives. Fires the event
  24387. * `afterGetAllItems`.
  24388. *
  24389. * @private
  24390. * @function Highcharts.Legend#getAllItems
  24391. * @return {Array<(Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series)>}
  24392. * The current items in the legend.
  24393. * @fires Highcharts.Legend#event:afterGetAllItems
  24394. */
  24395. Legend.prototype.getAllItems = function () {
  24396. var allItems = [];
  24397. this.chart.series.forEach(function (series) {
  24398. var seriesOptions = series && series.options;
  24399. // Handle showInLegend. If the series is linked to another series,
  24400. // defaults to false.
  24401. if (series && pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? void 0 : false, true)) {
  24402. // Use points or series for the legend item depending on
  24403. // legendType
  24404. allItems = allItems.concat(series.legendItems ||
  24405. (seriesOptions.legendType === 'point' ?
  24406. series.data :
  24407. series));
  24408. }
  24409. });
  24410. fireEvent(this, 'afterGetAllItems', { allItems: allItems });
  24411. return allItems;
  24412. };
  24413. /**
  24414. * Get a short, three letter string reflecting the alignment and layout.
  24415. *
  24416. * @private
  24417. * @function Highcharts.Legend#getAlignment
  24418. * @return {string}
  24419. * The alignment, empty string if floating
  24420. */
  24421. Legend.prototype.getAlignment = function () {
  24422. var options = this.options;
  24423. // Use the first letter of each alignment option in order to detect
  24424. // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
  24425. if (this.proximate) {
  24426. return options.align.charAt(0) + 'tv';
  24427. }
  24428. return options.floating ? '' : (options.align.charAt(0) +
  24429. options.verticalAlign.charAt(0) +
  24430. options.layout.charAt(0));
  24431. };
  24432. /**
  24433. * Adjust the chart margins by reserving space for the legend on only one
  24434. * side of the chart. If the position is set to a corner, top or bottom is
  24435. * reserved for horizontal legends and left or right for vertical ones.
  24436. *
  24437. * @private
  24438. * @function Highcharts.Legend#adjustMargins
  24439. * @param {Array<number>} margin
  24440. * @param {Array<number>} spacing
  24441. */
  24442. Legend.prototype.adjustMargins = function (margin, spacing) {
  24443. var chart = this.chart, options = this.options, alignment = this.getAlignment();
  24444. if (alignment) {
  24445. ([
  24446. /(lth|ct|rth)/,
  24447. /(rtv|rm|rbv)/,
  24448. /(rbh|cb|lbh)/,
  24449. /(lbv|lm|ltv)/
  24450. ]).forEach(function (alignments, side) {
  24451. if (alignments.test(alignment) && !defined(margin[side])) {
  24452. // Now we have detected on which side of the chart we should
  24453. // reserve space for the legend
  24454. chart[marginNames[side]] = Math.max(chart[marginNames[side]], (chart.legend[(side + 1) % 2 ? 'legendHeight' : 'legendWidth'] +
  24455. [1, -1, -1, 1][side] * options[(side % 2) ? 'x' : 'y'] +
  24456. pick(options.margin, 12) +
  24457. spacing[side] +
  24458. (chart.titleOffset[side] || 0)));
  24459. }
  24460. });
  24461. }
  24462. };
  24463. /**
  24464. * @private
  24465. * @function Highcharts.Legend#proximatePositions
  24466. */
  24467. Legend.prototype.proximatePositions = function () {
  24468. var chart = this.chart, boxes = [], alignLeft = this.options.align === 'left';
  24469. this.allItems.forEach(function (item) {
  24470. var lastPoint, height, useFirstPoint = alignLeft, target, top;
  24471. if (item.yAxis && item.points) {
  24472. if (item.xAxis.options.reversed) {
  24473. useFirstPoint = !useFirstPoint;
  24474. }
  24475. lastPoint = find(useFirstPoint ?
  24476. item.points :
  24477. item.points.slice(0).reverse(), function (item) {
  24478. return isNumber(item.plotY);
  24479. });
  24480. height = this.itemMarginTop +
  24481. item.legendItem.getBBox().height +
  24482. this.itemMarginBottom;
  24483. top = item.yAxis.top - chart.plotTop;
  24484. if (item.visible) {
  24485. target = lastPoint ?
  24486. lastPoint.plotY :
  24487. item.yAxis.height;
  24488. target += top - 0.3 * height;
  24489. }
  24490. else {
  24491. target = top + item.yAxis.height;
  24492. }
  24493. boxes.push({
  24494. target: target,
  24495. size: height,
  24496. item: item
  24497. });
  24498. }
  24499. }, this);
  24500. H.distribute(boxes, chart.plotHeight);
  24501. boxes.forEach(function (box) {
  24502. box.item._legendItemPos[1] =
  24503. chart.plotTop - chart.spacing[0] + box.pos;
  24504. });
  24505. };
  24506. /**
  24507. * Render the legend. This method can be called both before and after
  24508. * `chart.render`. If called after, it will only rearrange items instead
  24509. * of creating new ones. Called internally on initial render and after
  24510. * redraws.
  24511. *
  24512. * @private
  24513. * @function Highcharts.Legend#render
  24514. */
  24515. Legend.prototype.render = function () {
  24516. var legend = this, chart = legend.chart, renderer = chart.renderer, legendGroup = legend.group, allItems, display, legendWidth, legendHeight, box = legend.box, options = legend.options, padding = legend.padding, allowedWidth;
  24517. legend.itemX = padding;
  24518. legend.itemY = legend.initialItemY;
  24519. legend.offsetWidth = 0;
  24520. legend.lastItemY = 0;
  24521. legend.widthOption = relativeLength(options.width, chart.spacingBox.width - padding);
  24522. // Compute how wide the legend is allowed to be
  24523. allowedWidth =
  24524. chart.spacingBox.width - 2 * padding - options.x;
  24525. if (['rm', 'lm'].indexOf(legend.getAlignment().substring(0, 2)) > -1) {
  24526. allowedWidth /= 2;
  24527. }
  24528. legend.maxLegendWidth = legend.widthOption || allowedWidth;
  24529. if (!legendGroup) {
  24530. /**
  24531. * SVG group of the legend.
  24532. *
  24533. * @readonly
  24534. * @name Highcharts.Legend#group
  24535. * @type {Highcharts.SVGElement}
  24536. */
  24537. legend.group = legendGroup = renderer.g('legend')
  24538. .attr({ zIndex: 7 })
  24539. .add();
  24540. legend.contentGroup = renderer.g()
  24541. .attr({ zIndex: 1 }) // above background
  24542. .add(legendGroup);
  24543. legend.scrollGroup = renderer.g()
  24544. .add(legend.contentGroup);
  24545. }
  24546. legend.renderTitle();
  24547. // add each series or point
  24548. allItems = legend.getAllItems();
  24549. // sort by legendIndex
  24550. stableSort(allItems, function (a, b) {
  24551. return ((a.options && a.options.legendIndex) || 0) -
  24552. ((b.options && b.options.legendIndex) || 0);
  24553. });
  24554. // reversed legend
  24555. if (options.reversed) {
  24556. allItems.reverse();
  24557. }
  24558. /**
  24559. * All items for the legend, which is an array of series for most series
  24560. * and an array of points for pie series and its derivatives.
  24561. *
  24562. * @readonly
  24563. * @name Highcharts.Legend#allItems
  24564. * @type {Array<(Highcharts.Point|Highcharts.Series)>}
  24565. */
  24566. legend.allItems = allItems;
  24567. legend.display = display = !!allItems.length;
  24568. // Render the items. First we run a loop to set the text and properties
  24569. // and read all the bounding boxes. The next loop computes the item
  24570. // positions based on the bounding boxes.
  24571. legend.lastLineHeight = 0;
  24572. legend.maxItemWidth = 0;
  24573. legend.totalItemWidth = 0;
  24574. legend.itemHeight = 0;
  24575. allItems.forEach(legend.renderItem, legend);
  24576. allItems.forEach(legend.layoutItem, legend);
  24577. // Get the box
  24578. legendWidth = (legend.widthOption || legend.offsetWidth) + padding;
  24579. legendHeight = legend.lastItemY + legend.lastLineHeight +
  24580. legend.titleHeight;
  24581. legendHeight = legend.handleOverflow(legendHeight);
  24582. legendHeight += padding;
  24583. // Draw the border and/or background
  24584. if (!box) {
  24585. /**
  24586. * SVG element of the legend box.
  24587. *
  24588. * @readonly
  24589. * @name Highcharts.Legend#box
  24590. * @type {Highcharts.SVGElement}
  24591. */
  24592. legend.box = box = renderer.rect()
  24593. .addClass('highcharts-legend-box')
  24594. .attr({
  24595. r: options.borderRadius
  24596. })
  24597. .add(legendGroup);
  24598. box.isNew = true;
  24599. }
  24600. // Presentational
  24601. if (!chart.styledMode) {
  24602. box
  24603. .attr({
  24604. stroke: options.borderColor,
  24605. 'stroke-width': options.borderWidth || 0,
  24606. fill: options.backgroundColor || 'none'
  24607. })
  24608. .shadow(options.shadow);
  24609. }
  24610. if (legendWidth > 0 && legendHeight > 0) {
  24611. box[box.isNew ? 'attr' : 'animate'](box.crisp.call({}, {
  24612. x: 0,
  24613. y: 0,
  24614. width: legendWidth,
  24615. height: legendHeight
  24616. }, box.strokeWidth()));
  24617. box.isNew = false;
  24618. }
  24619. // hide the border if no items
  24620. box[display ? 'show' : 'hide']();
  24621. // Open for responsiveness
  24622. if (chart.styledMode && legendGroup.getStyle('display') === 'none') {
  24623. legendWidth = legendHeight = 0;
  24624. }
  24625. legend.legendWidth = legendWidth;
  24626. legend.legendHeight = legendHeight;
  24627. if (display) {
  24628. legend.align();
  24629. }
  24630. if (!this.proximate) {
  24631. this.positionItems();
  24632. }
  24633. fireEvent(this, 'afterRender');
  24634. };
  24635. /**
  24636. * Align the legend to chart's box.
  24637. *
  24638. * @private
  24639. * @function Highcharts.align
  24640. * @param {Highcharts.BBoxObject} alignTo
  24641. * @return {void}
  24642. */
  24643. Legend.prototype.align = function (alignTo) {
  24644. if (alignTo === void 0) { alignTo = this.chart.spacingBox; }
  24645. var chart = this.chart, options = this.options;
  24646. // If aligning to the top and the layout is horizontal, adjust for
  24647. // the title (#7428)
  24648. var y = alignTo.y;
  24649. if (/(lth|ct|rth)/.test(this.getAlignment()) &&
  24650. chart.titleOffset[0] > 0) {
  24651. y += chart.titleOffset[0];
  24652. }
  24653. else if (/(lbh|cb|rbh)/.test(this.getAlignment()) &&
  24654. chart.titleOffset[2] > 0) {
  24655. y -= chart.titleOffset[2];
  24656. }
  24657. if (y !== alignTo.y) {
  24658. alignTo = merge(alignTo, { y: y });
  24659. }
  24660. this.group.align(merge(options, {
  24661. width: this.legendWidth,
  24662. height: this.legendHeight,
  24663. verticalAlign: this.proximate ? 'top' : options.verticalAlign
  24664. }), true, alignTo);
  24665. };
  24666. /**
  24667. * Set up the overflow handling by adding navigation with up and down arrows
  24668. * below the legend.
  24669. *
  24670. * @private
  24671. * @function Highcharts.Legend#handleOverflow
  24672. * @param {number} legendHeight
  24673. * @return {number}
  24674. */
  24675. Legend.prototype.handleOverflow = function (legendHeight) {
  24676. var legend = this, chart = this.chart, renderer = chart.renderer, options = this.options, optionsY = options.y, alignTop = options.verticalAlign === 'top', padding = this.padding, spaceHeight = (chart.spacingBox.height +
  24677. (alignTop ? -optionsY : optionsY) - padding), maxHeight = options.maxHeight, clipHeight, clipRect = this.clipRect, navOptions = options.navigation, animation = pick(navOptions.animation, true), arrowSize = navOptions.arrowSize || 12, nav = this.nav, pages = this.pages, lastY, allItems = this.allItems, clipToHeight = function (height) {
  24678. if (typeof height === 'number') {
  24679. clipRect.attr({
  24680. height: height
  24681. });
  24682. }
  24683. else if (clipRect) { // Reset (#5912)
  24684. legend.clipRect = clipRect.destroy();
  24685. legend.contentGroup.clip();
  24686. }
  24687. // useHTML
  24688. if (legend.contentGroup.div) {
  24689. legend.contentGroup.div.style.clip = height ?
  24690. 'rect(' + padding + 'px,9999px,' +
  24691. (padding + height) + 'px,0)' :
  24692. 'auto';
  24693. }
  24694. }, addTracker = function (key) {
  24695. legend[key] = renderer
  24696. .circle(0, 0, arrowSize * 1.3)
  24697. .translate(arrowSize / 2, arrowSize / 2)
  24698. .add(nav);
  24699. if (!chart.styledMode) {
  24700. legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
  24701. }
  24702. return legend[key];
  24703. };
  24704. // Adjust the height
  24705. if (options.layout === 'horizontal' &&
  24706. options.verticalAlign !== 'middle' &&
  24707. !options.floating) {
  24708. spaceHeight /= 2;
  24709. }
  24710. if (maxHeight) {
  24711. spaceHeight = Math.min(spaceHeight, maxHeight);
  24712. }
  24713. // Reset the legend height and adjust the clipping rectangle
  24714. pages.length = 0;
  24715. if (legendHeight > spaceHeight &&
  24716. navOptions.enabled !== false) {
  24717. this.clipHeight = clipHeight =
  24718. Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
  24719. this.currentPage = pick(this.currentPage, 1);
  24720. this.fullHeight = legendHeight;
  24721. // Fill pages with Y positions so that the top of each a legend item
  24722. // defines the scroll top for each page (#2098)
  24723. allItems.forEach(function (item, i) {
  24724. var y = item._legendItemPos[1], h = Math.round(item.legendItem.getBBox().height), len = pages.length;
  24725. if (!len || (y - pages[len - 1] > clipHeight &&
  24726. (lastY || y) !== pages[len - 1])) {
  24727. pages.push(lastY || y);
  24728. len++;
  24729. }
  24730. // Keep track of which page each item is on
  24731. item.pageIx = len - 1;
  24732. if (lastY) {
  24733. allItems[i - 1].pageIx = len - 1;
  24734. }
  24735. if (i === allItems.length - 1 &&
  24736. y + h - pages[len - 1] > clipHeight &&
  24737. y !== lastY // #2617
  24738. ) {
  24739. pages.push(y);
  24740. item.pageIx = len;
  24741. }
  24742. if (y !== lastY) {
  24743. lastY = y;
  24744. }
  24745. });
  24746. // Only apply clipping if needed. Clipping causes blurred legend in
  24747. // PDF export (#1787)
  24748. if (!clipRect) {
  24749. clipRect = legend.clipRect =
  24750. renderer.clipRect(0, padding, 9999, 0);
  24751. legend.contentGroup.clip(clipRect);
  24752. }
  24753. clipToHeight(clipHeight);
  24754. // Add navigation elements
  24755. if (!nav) {
  24756. this.nav = nav = renderer.g()
  24757. .attr({ zIndex: 1 })
  24758. .add(this.group);
  24759. this.up = renderer
  24760. .symbol('triangle', 0, 0, arrowSize, arrowSize)
  24761. .add(nav);
  24762. addTracker('upTracker')
  24763. .on('click', function () {
  24764. legend.scroll(-1, animation);
  24765. });
  24766. this.pager = renderer.text('', 15, 10)
  24767. .addClass('highcharts-legend-navigation');
  24768. if (!chart.styledMode) {
  24769. this.pager.css(navOptions.style);
  24770. }
  24771. this.pager.add(nav);
  24772. this.down = renderer
  24773. .symbol('triangle-down', 0, 0, arrowSize, arrowSize)
  24774. .add(nav);
  24775. addTracker('downTracker')
  24776. .on('click', function () {
  24777. legend.scroll(1, animation);
  24778. });
  24779. }
  24780. // Set initial position
  24781. legend.scroll(0);
  24782. legendHeight = spaceHeight;
  24783. // Reset
  24784. }
  24785. else if (nav) {
  24786. clipToHeight();
  24787. this.nav = nav.destroy(); // #6322
  24788. this.scrollGroup.attr({
  24789. translateY: 1
  24790. });
  24791. this.clipHeight = 0; // #1379
  24792. }
  24793. return legendHeight;
  24794. };
  24795. /**
  24796. * Scroll the legend by a number of pages.
  24797. *
  24798. * @private
  24799. * @function Highcharts.Legend#scroll
  24800. *
  24801. * @param {number} scrollBy
  24802. * The number of pages to scroll.
  24803. *
  24804. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  24805. * Whether and how to apply animation.
  24806. *
  24807. * @return {void}
  24808. */
  24809. Legend.prototype.scroll = function (scrollBy, animation) {
  24810. var _this = this;
  24811. var chart = this.chart, pages = this.pages, pageCount = pages.length, currentPage = this.currentPage + scrollBy, clipHeight = this.clipHeight, navOptions = this.options.navigation, pager = this.pager, padding = this.padding;
  24812. // When resizing while looking at the last page
  24813. if (currentPage > pageCount) {
  24814. currentPage = pageCount;
  24815. }
  24816. if (currentPage > 0) {
  24817. if (typeof animation !== 'undefined') {
  24818. setAnimation(animation, chart);
  24819. }
  24820. this.nav.attr({
  24821. translateX: padding,
  24822. translateY: clipHeight + this.padding + 7 + this.titleHeight,
  24823. visibility: 'visible'
  24824. });
  24825. [this.up, this.upTracker].forEach(function (elem) {
  24826. elem.attr({
  24827. 'class': currentPage === 1 ?
  24828. 'highcharts-legend-nav-inactive' :
  24829. 'highcharts-legend-nav-active'
  24830. });
  24831. });
  24832. pager.attr({
  24833. text: currentPage + '/' + pageCount
  24834. });
  24835. [this.down, this.downTracker].forEach(function (elem) {
  24836. elem.attr({
  24837. // adjust to text width
  24838. x: 18 + this.pager.getBBox().width,
  24839. 'class': currentPage === pageCount ?
  24840. 'highcharts-legend-nav-inactive' :
  24841. 'highcharts-legend-nav-active'
  24842. });
  24843. }, this);
  24844. if (!chart.styledMode) {
  24845. this.up
  24846. .attr({
  24847. fill: currentPage === 1 ?
  24848. navOptions.inactiveColor :
  24849. navOptions.activeColor
  24850. });
  24851. this.upTracker
  24852. .css({
  24853. cursor: currentPage === 1 ? 'default' : 'pointer'
  24854. });
  24855. this.down
  24856. .attr({
  24857. fill: currentPage === pageCount ?
  24858. navOptions.inactiveColor :
  24859. navOptions.activeColor
  24860. });
  24861. this.downTracker
  24862. .css({
  24863. cursor: currentPage === pageCount ?
  24864. 'default' :
  24865. 'pointer'
  24866. });
  24867. }
  24868. this.scrollOffset = -pages[currentPage - 1] + this.initialItemY;
  24869. this.scrollGroup.animate({
  24870. translateY: this.scrollOffset
  24871. });
  24872. this.currentPage = currentPage;
  24873. this.positionCheckboxes();
  24874. // Fire event after scroll animation is complete
  24875. var animOptions = animObject(pick(animation, chart.renderer.globalAnimation, true));
  24876. syncTimeout(function () {
  24877. fireEvent(_this, 'afterScroll', { currentPage: currentPage });
  24878. }, animOptions.duration || 0);
  24879. }
  24880. };
  24881. return Legend;
  24882. }());
  24883. // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
  24884. // and for #2580, a similar drawing flaw in Firefox 26.
  24885. // Explore if there's a general cause for this. The problem may be related
  24886. // to nested group elements, as the legend item texts are within 4 group
  24887. // elements.
  24888. if (/Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
  24889. isFirefox) {
  24890. wrap(Legend.prototype, 'positionItem', function (proceed, item) {
  24891. var legend = this,
  24892. // If chart destroyed in sync, this is undefined (#2030)
  24893. runPositionItem = function () {
  24894. if (item._legendItemPos) {
  24895. proceed.call(legend, item);
  24896. }
  24897. };
  24898. // Do it now, for export and to get checkbox placement
  24899. runPositionItem();
  24900. // Do it after to work around the core issue
  24901. if (!legend.bubbleLegend) {
  24902. setTimeout(runPositionItem);
  24903. }
  24904. });
  24905. }
  24906. H.Legend = Legend;
  24907. return H.Legend;
  24908. });
  24909. _registerModule(_modules, 'parts/Chart.js', [_modules['parts/Axis.js'], _modules['parts/Globals.js'], _modules['parts/Legend.js'], _modules['parts/MSPointer.js'], _modules['parts/Options.js'], _modules['parts/Pointer.js'], _modules['parts/Time.js'], _modules['parts/Utilities.js']], function (Axis, H, Legend, MSPointer, O, Pointer, Time, U) {
  24910. /* *
  24911. *
  24912. * (c) 2010-2020 Torstein Honsi
  24913. *
  24914. * License: www.highcharts.com/license
  24915. *
  24916. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  24917. *
  24918. * */
  24919. var charts = H.charts, doc = H.doc, seriesTypes = H.seriesTypes, win = H.win;
  24920. var defaultOptions = O.defaultOptions;
  24921. var addEvent = U.addEvent, animate = U.animate, animObject = U.animObject, attr = U.attr, createElement = U.createElement, css = U.css, defined = U.defined, discardElement = U.discardElement, erase = U.erase, error = U.error, extend = U.extend, find = U.find, fireEvent = U.fireEvent, getStyle = U.getStyle, isArray = U.isArray, isFunction = U.isFunction, isNumber = U.isNumber, isObject = U.isObject, isString = U.isString, merge = U.merge, numberFormat = U.numberFormat, objectEach = U.objectEach, pick = U.pick, pInt = U.pInt, relativeLength = U.relativeLength, removeEvent = U.removeEvent, setAnimation = U.setAnimation, splat = U.splat, syncTimeout = U.syncTimeout, uniqueKey = U.uniqueKey;
  24922. /**
  24923. * Callback for chart constructors.
  24924. *
  24925. * @callback Highcharts.ChartCallbackFunction
  24926. *
  24927. * @param {Highcharts.Chart} chart
  24928. * Created chart.
  24929. */
  24930. /**
  24931. * Format a number and return a string based on input settings.
  24932. *
  24933. * @callback Highcharts.NumberFormatterCallbackFunction
  24934. *
  24935. * @param {number} number
  24936. * The input number to format.
  24937. *
  24938. * @param {number} decimals
  24939. * The amount of decimals. A value of -1 preserves the amount in the
  24940. * input number.
  24941. *
  24942. * @param {string} [decimalPoint]
  24943. * The decimal point, defaults to the one given in the lang options, or
  24944. * a dot.
  24945. *
  24946. * @param {string} [thousandsSep]
  24947. * The thousands separator, defaults to the one given in the lang
  24948. * options, or a space character.
  24949. *
  24950. * @return {string} The formatted number.
  24951. */
  24952. /**
  24953. * The chart title. The title has an `update` method that allows modifying the
  24954. * options directly or indirectly via `chart.update`.
  24955. *
  24956. * @interface Highcharts.TitleObject
  24957. * @extends Highcharts.SVGElement
  24958. */ /**
  24959. * Modify options for the title.
  24960. *
  24961. * @function Highcharts.TitleObject#update
  24962. *
  24963. * @param {Highcharts.TitleOptions} titleOptions
  24964. * Options to modify.
  24965. *
  24966. * @param {boolean} [redraw=true]
  24967. * Whether to redraw the chart after the title is altered. If doing more
  24968. * operations on the chart, it is a good idea to set redraw to false and
  24969. * call {@link Chart#redraw} after.
  24970. */
  24971. /**
  24972. * The chart subtitle. The subtitle has an `update` method that
  24973. * allows modifying the options directly or indirectly via
  24974. * `chart.update`.
  24975. *
  24976. * @interface Highcharts.SubtitleObject
  24977. * @extends Highcharts.SVGElement
  24978. */ /**
  24979. * Modify options for the subtitle.
  24980. *
  24981. * @function Highcharts.SubtitleObject#update
  24982. *
  24983. * @param {Highcharts.SubtitleOptions} subtitleOptions
  24984. * Options to modify.
  24985. *
  24986. * @param {boolean} [redraw=true]
  24987. * Whether to redraw the chart after the subtitle is altered. If doing
  24988. * more operations on the chart, it is a good idea to set redraw to false
  24989. * and call {@link Chart#redraw} after.
  24990. */
  24991. /**
  24992. * The chart caption. The caption has an `update` method that
  24993. * allows modifying the options directly or indirectly via
  24994. * `chart.update`.
  24995. *
  24996. * @interface Highcharts.CaptionObject
  24997. * @extends Highcharts.SVGElement
  24998. */ /**
  24999. * Modify options for the caption.
  25000. *
  25001. * @function Highcharts.CaptionObject#update
  25002. *
  25003. * @param {Highcharts.CaptionOptions} captionOptions
  25004. * Options to modify.
  25005. *
  25006. * @param {boolean} [redraw=true]
  25007. * Whether to redraw the chart after the caption is altered. If doing
  25008. * more operations on the chart, it is a good idea to set redraw to false
  25009. * and call {@link Chart#redraw} after.
  25010. */
  25011. var marginNames = H.marginNames;
  25012. /* eslint-disable no-invalid-this, valid-jsdoc */
  25013. /**
  25014. * The Chart class. The recommended constructor is {@link Highcharts#chart}.
  25015. *
  25016. * @example
  25017. * var chart = Highcharts.chart('container', {
  25018. * title: {
  25019. * text: 'My chart'
  25020. * },
  25021. * series: [{
  25022. * data: [1, 3, 2, 4]
  25023. * }]
  25024. * })
  25025. *
  25026. * @class
  25027. * @name Highcharts.Chart
  25028. *
  25029. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  25030. * The DOM element to render to, or its id.
  25031. *
  25032. * @param {Highcharts.Options} options
  25033. * The chart options structure.
  25034. *
  25035. * @param {Highcharts.ChartCallbackFunction} [callback]
  25036. * Function to run when the chart has loaded and and all external images
  25037. * are loaded. Defining a
  25038. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  25039. * handler is equivalent.
  25040. */
  25041. var Chart = /** @class */ (function () {
  25042. function Chart(a, b, c) {
  25043. this.axes = void 0;
  25044. this.axisOffset = void 0;
  25045. this.bounds = void 0;
  25046. this.chartHeight = void 0;
  25047. this.chartWidth = void 0;
  25048. this.clipBox = void 0;
  25049. this.colorCounter = void 0;
  25050. this.container = void 0;
  25051. this.index = void 0;
  25052. this.isResizing = void 0;
  25053. this.labelCollectors = void 0;
  25054. this.legend = void 0;
  25055. this.margin = void 0;
  25056. this.numberFormatter = void 0;
  25057. this.options = void 0;
  25058. this.plotBox = void 0;
  25059. this.plotHeight = void 0;
  25060. this.plotLeft = void 0;
  25061. this.plotTop = void 0;
  25062. this.plotWidth = void 0;
  25063. this.pointCount = void 0;
  25064. this.pointer = void 0;
  25065. this.renderer = void 0;
  25066. this.renderTo = void 0;
  25067. this.series = void 0;
  25068. this.spacing = void 0;
  25069. this.spacingBox = void 0;
  25070. this.symbolCounter = void 0;
  25071. this.time = void 0;
  25072. this.titleOffset = void 0;
  25073. this.userOptions = void 0;
  25074. this.xAxis = void 0;
  25075. this.yAxis = void 0;
  25076. this.getArgs(a, b, c);
  25077. }
  25078. /* *
  25079. *
  25080. * Functions
  25081. *
  25082. * */
  25083. /**
  25084. * Handle the arguments passed to the constructor.
  25085. *
  25086. * @private
  25087. * @function Highcharts.Chart#getArgs
  25088. *
  25089. * @param {...Array<*>} arguments
  25090. * All arguments for the constructor.
  25091. *
  25092. * @fires Highcharts.Chart#event:init
  25093. * @fires Highcharts.Chart#event:afterInit
  25094. */
  25095. Chart.prototype.getArgs = function (a, b, c) {
  25096. // Remove the optional first argument, renderTo, and
  25097. // set it on this.
  25098. if (isString(a) || a.nodeName) {
  25099. this.renderTo = a;
  25100. this.init(b, c);
  25101. }
  25102. else {
  25103. this.init(a, b);
  25104. }
  25105. };
  25106. /**
  25107. * Overridable function that initializes the chart. The constructor's
  25108. * arguments are passed on directly.
  25109. *
  25110. * @function Highcharts.Chart#init
  25111. *
  25112. * @param {Highcharts.Options} userOptions
  25113. * Custom options.
  25114. *
  25115. * @param {Function} [callback]
  25116. * Function to run when the chart has loaded and and all external
  25117. * images are loaded.
  25118. *
  25119. * @return {void}
  25120. *
  25121. * @fires Highcharts.Chart#event:init
  25122. * @fires Highcharts.Chart#event:afterInit
  25123. */
  25124. Chart.prototype.init = function (userOptions, callback) {
  25125. // Handle regular options
  25126. var options,
  25127. // skip merging data points to increase performance
  25128. seriesOptions = userOptions.series, userPlotOptions = userOptions.plotOptions || {};
  25129. // Fire the event with a default function
  25130. fireEvent(this, 'init', { args: arguments }, function () {
  25131. userOptions.series = null;
  25132. options = merge(defaultOptions, userOptions); // do the merge
  25133. var optionsChart = options.chart || {};
  25134. // Override (by copy of user options) or clear tooltip options
  25135. // in chart.options.plotOptions (#6218)
  25136. objectEach(options.plotOptions, function (typeOptions, type) {
  25137. if (isObject(typeOptions)) { // #8766
  25138. typeOptions.tooltip = (userPlotOptions[type] && // override by copy:
  25139. merge(userPlotOptions[type].tooltip)) || void 0; // or clear
  25140. }
  25141. });
  25142. // User options have higher priority than default options
  25143. // (#6218). In case of exporting: path is changed
  25144. options.tooltip.userOptions = (userOptions.chart &&
  25145. userOptions.chart.forExport &&
  25146. userOptions.tooltip.userOptions) || userOptions.tooltip;
  25147. // set back the series data
  25148. options.series = userOptions.series = seriesOptions;
  25149. /**
  25150. * The original options given to the constructor or a chart factory
  25151. * like {@link Highcharts.chart} and {@link Highcharts.stockChart}.
  25152. *
  25153. * @name Highcharts.Chart#userOptions
  25154. * @type {Highcharts.Options}
  25155. */
  25156. this.userOptions = userOptions;
  25157. var chartEvents = optionsChart.events;
  25158. this.margin = [];
  25159. this.spacing = [];
  25160. // Pixel data bounds for touch zoom
  25161. this.bounds = { h: {}, v: {} };
  25162. // An array of functions that returns labels that should be
  25163. // considered for anti-collision
  25164. this.labelCollectors = [];
  25165. this.callback = callback;
  25166. this.isResizing = 0;
  25167. /**
  25168. * The options structure for the chart after merging
  25169. * {@link #defaultOptions} and {@link #userOptions}. It contains
  25170. * members for the sub elements like series, legend, tooltip etc.
  25171. *
  25172. * @name Highcharts.Chart#options
  25173. * @type {Highcharts.Options}
  25174. */
  25175. this.options = options;
  25176. /**
  25177. * All the axes in the chart.
  25178. *
  25179. * @see Highcharts.Chart.xAxis
  25180. * @see Highcharts.Chart.yAxis
  25181. *
  25182. * @name Highcharts.Chart#axes
  25183. * @type {Array<Highcharts.Axis>}
  25184. */
  25185. this.axes = [];
  25186. /**
  25187. * All the current series in the chart.
  25188. *
  25189. * @name Highcharts.Chart#series
  25190. * @type {Array<Highcharts.Series>}
  25191. */
  25192. this.series = [];
  25193. /**
  25194. * The `Time` object associated with the chart. Since v6.0.5,
  25195. * time settings can be applied individually for each chart. If
  25196. * no individual settings apply, the `Time` object is shared by
  25197. * all instances.
  25198. *
  25199. * @name Highcharts.Chart#time
  25200. * @type {Highcharts.Time}
  25201. */
  25202. this.time =
  25203. userOptions.time && Object.keys(userOptions.time).length ?
  25204. new Time(userOptions.time) :
  25205. H.time;
  25206. /**
  25207. * Callback function to override the default function that formats
  25208. * all the numbers in the chart. Returns a string with the formatted
  25209. * number.
  25210. *
  25211. * @name Highcharts.Chart#numberFormatter
  25212. * @type {Highcharts.NumberFormatterCallbackFunction}
  25213. */
  25214. this.numberFormatter = optionsChart.numberFormatter || numberFormat;
  25215. /**
  25216. * Whether the chart is in styled mode, meaning all presentatinoal
  25217. * attributes are avoided.
  25218. *
  25219. * @name Highcharts.Chart#styledMode
  25220. * @type {boolean}
  25221. */
  25222. this.styledMode = optionsChart.styledMode;
  25223. this.hasCartesianSeries = optionsChart.showAxes;
  25224. var chart = this;
  25225. /**
  25226. * Index position of the chart in the {@link Highcharts#charts}
  25227. * property.
  25228. *
  25229. * @name Highcharts.Chart#index
  25230. * @type {number}
  25231. * @readonly
  25232. */
  25233. chart.index = charts.length; // Add the chart to the global lookup
  25234. charts.push(chart);
  25235. H.chartCount++;
  25236. // Chart event handlers
  25237. if (chartEvents) {
  25238. objectEach(chartEvents, function (event, eventType) {
  25239. if (isFunction(event)) {
  25240. addEvent(chart, eventType, event);
  25241. }
  25242. });
  25243. }
  25244. /**
  25245. * A collection of the X axes in the chart.
  25246. *
  25247. * @name Highcharts.Chart#xAxis
  25248. * @type {Array<Highcharts.Axis>}
  25249. */
  25250. chart.xAxis = [];
  25251. /**
  25252. * A collection of the Y axes in the chart.
  25253. *
  25254. * @name Highcharts.Chart#yAxis
  25255. * @type {Array<Highcharts.Axis>}
  25256. *
  25257. * @todo
  25258. * Make events official: Fire the event `afterInit`.
  25259. */
  25260. chart.yAxis = [];
  25261. chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
  25262. // Fire after init but before first render, before axes and series
  25263. // have been initialized.
  25264. fireEvent(chart, 'afterInit');
  25265. chart.firstRender();
  25266. });
  25267. };
  25268. /**
  25269. * Internal function to unitialize an individual series.
  25270. *
  25271. * @private
  25272. * @function Highcharts.Chart#initSeries
  25273. */
  25274. Chart.prototype.initSeries = function (options) {
  25275. var chart = this, optionsChart = chart.options.chart, type = (options.type ||
  25276. optionsChart.type ||
  25277. optionsChart.defaultSeriesType), series, Constr = seriesTypes[type];
  25278. // No such series type
  25279. if (!Constr) {
  25280. error(17, true, chart, { missingModuleFor: type });
  25281. }
  25282. series = new Constr();
  25283. series.init(this, options);
  25284. return series;
  25285. };
  25286. /**
  25287. * Internal function to set data for all series with enabled sorting.
  25288. *
  25289. * @private
  25290. * @function Highcharts.Chart#setSeriesData
  25291. */
  25292. Chart.prototype.setSeriesData = function () {
  25293. this.getSeriesOrderByLinks().forEach(function (series) {
  25294. // We need to set data for series with sorting after series init
  25295. if (!series.points && !series.data && series.enabledDataSorting) {
  25296. series.setData(series.options.data, false);
  25297. }
  25298. });
  25299. };
  25300. /**
  25301. * Sort and return chart series in order depending on the number of linked
  25302. * series.
  25303. *
  25304. * @private
  25305. * @function Highcharts.Series#getSeriesOrderByLinks
  25306. * @return {Array<Highcharts.Series>}
  25307. */
  25308. Chart.prototype.getSeriesOrderByLinks = function () {
  25309. return this.series.concat().sort(function (a, b) {
  25310. if (a.linkedSeries.length || b.linkedSeries.length) {
  25311. return b.linkedSeries.length - a.linkedSeries.length;
  25312. }
  25313. return 0;
  25314. });
  25315. };
  25316. /**
  25317. * Order all series above a given index. When series are added and ordered
  25318. * by configuration, only the last series is handled (#248, #1123, #2456,
  25319. * #6112). This function is called on series initialization and destroy.
  25320. *
  25321. * @private
  25322. * @function Highcharts.Series#orderSeries
  25323. * @param {number} [fromIndex]
  25324. * If this is given, only the series above this index are handled.
  25325. */
  25326. Chart.prototype.orderSeries = function (fromIndex) {
  25327. var series = this.series, i = fromIndex || 0;
  25328. for (; i < series.length; i++) {
  25329. if (series[i]) {
  25330. /**
  25331. * Contains the series' index in the `Chart.series` array.
  25332. *
  25333. * @name Highcharts.Series#index
  25334. * @type {number}
  25335. * @readonly
  25336. */
  25337. series[i].index = i;
  25338. series[i].name = series[i].getName();
  25339. }
  25340. }
  25341. };
  25342. /**
  25343. * Check whether a given point is within the plot area.
  25344. *
  25345. * @function Highcharts.Chart#isInsidePlot
  25346. *
  25347. * @param {number} plotX
  25348. * Pixel x relative to the plot area.
  25349. *
  25350. * @param {number} plotY
  25351. * Pixel y relative to the plot area.
  25352. *
  25353. * @param {boolean} [inverted]
  25354. * Whether the chart is inverted.
  25355. *
  25356. * @return {boolean}
  25357. * Returns true if the given point is inside the plot area.
  25358. */
  25359. Chart.prototype.isInsidePlot = function (plotX, plotY, inverted) {
  25360. var x = inverted ? plotY : plotX, y = inverted ? plotX : plotY, e = {
  25361. x: x,
  25362. y: y,
  25363. isInsidePlot: x >= 0 &&
  25364. x <= this.plotWidth &&
  25365. y >= 0 &&
  25366. y <= this.plotHeight
  25367. };
  25368. fireEvent(this, 'afterIsInsidePlot', e);
  25369. return e.isInsidePlot;
  25370. };
  25371. /**
  25372. * Redraw the chart after changes have been done to the data, axis extremes
  25373. * chart size or chart elements. All methods for updating axes, series or
  25374. * points have a parameter for redrawing the chart. This is `true` by
  25375. * default. But in many cases you want to do more than one operation on the
  25376. * chart before redrawing, for example add a number of points. In those
  25377. * cases it is a waste of resources to redraw the chart for each new point
  25378. * added. So you add the points and call `chart.redraw()` after.
  25379. *
  25380. * @function Highcharts.Chart#redraw
  25381. *
  25382. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  25383. * If or how to apply animation to the redraw.
  25384. *
  25385. * @fires Highcharts.Chart#event:afterSetExtremes
  25386. * @fires Highcharts.Chart#event:beforeRedraw
  25387. * @fires Highcharts.Chart#event:predraw
  25388. * @fires Highcharts.Chart#event:redraw
  25389. * @fires Highcharts.Chart#event:render
  25390. * @fires Highcharts.Chart#event:updatedData
  25391. */
  25392. Chart.prototype.redraw = function (animation) {
  25393. fireEvent(this, 'beforeRedraw');
  25394. var chart = this, axes = chart.axes, series = chart.series, pointer = chart.pointer, legend = chart.legend, legendUserOptions = chart.userOptions.legend, redrawLegend = chart.isDirtyLegend, hasStackedSeries, hasDirtyStacks, hasCartesianSeries = chart.hasCartesianSeries, isDirtyBox = chart.isDirtyBox, i, serie, renderer = chart.renderer, isHiddenChart = renderer.isHidden(), afterRedraw = [];
  25395. // Handle responsive rules, not only on resize (#6130)
  25396. if (chart.setResponsive) {
  25397. chart.setResponsive(false);
  25398. }
  25399. // Set the global animation. When chart.hasRendered is not true, the
  25400. // redraw call comes from a responsive rule and animation should not
  25401. // occur.
  25402. setAnimation(chart.hasRendered ? animation : false, chart);
  25403. if (isHiddenChart) {
  25404. chart.temporaryDisplay();
  25405. }
  25406. // Adjust title layout (reflow multiline text)
  25407. chart.layOutTitles();
  25408. // link stacked series
  25409. i = series.length;
  25410. while (i--) {
  25411. serie = series[i];
  25412. if (serie.options.stacking) {
  25413. hasStackedSeries = true;
  25414. if (serie.isDirty) {
  25415. hasDirtyStacks = true;
  25416. break;
  25417. }
  25418. }
  25419. }
  25420. if (hasDirtyStacks) { // mark others as dirty
  25421. i = series.length;
  25422. while (i--) {
  25423. serie = series[i];
  25424. if (serie.options.stacking) {
  25425. serie.isDirty = true;
  25426. }
  25427. }
  25428. }
  25429. // Handle updated data in the series
  25430. series.forEach(function (serie) {
  25431. if (serie.isDirty) {
  25432. if (serie.options.legendType === 'point') {
  25433. if (serie.updateTotals) {
  25434. serie.updateTotals();
  25435. }
  25436. redrawLegend = true;
  25437. }
  25438. else if (legendUserOptions &&
  25439. (legendUserOptions.labelFormatter ||
  25440. legendUserOptions.labelFormat)) {
  25441. redrawLegend = true; // #2165
  25442. }
  25443. }
  25444. if (serie.isDirtyData) {
  25445. fireEvent(serie, 'updatedData');
  25446. }
  25447. });
  25448. // handle added or removed series
  25449. if (redrawLegend && legend && legend.options.enabled) {
  25450. // draw legend graphics
  25451. legend.render();
  25452. chart.isDirtyLegend = false;
  25453. }
  25454. // reset stacks
  25455. if (hasStackedSeries) {
  25456. chart.getStacks();
  25457. }
  25458. if (hasCartesianSeries) {
  25459. // set axes scales
  25460. axes.forEach(function (axis) {
  25461. // Don't do setScale again if we're only resizing. Regression
  25462. // #13507. But we need it after chart.update (responsive), as
  25463. // axis is initialized again (#12137).
  25464. if (!chart.isResizing || !isNumber(axis.min)) {
  25465. axis.updateNames();
  25466. axis.setScale();
  25467. }
  25468. });
  25469. }
  25470. chart.getMargins(); // #3098
  25471. if (hasCartesianSeries) {
  25472. // If one axis is dirty, all axes must be redrawn (#792, #2169)
  25473. axes.forEach(function (axis) {
  25474. if (axis.isDirty) {
  25475. isDirtyBox = true;
  25476. }
  25477. });
  25478. // redraw axes
  25479. axes.forEach(function (axis) {
  25480. // Fire 'afterSetExtremes' only if extremes are set
  25481. var key = axis.min + ',' + axis.max;
  25482. if (axis.extKey !== key) { // #821, #4452
  25483. axis.extKey = key;
  25484. // prevent a recursive call to chart.redraw() (#1119)
  25485. afterRedraw.push(function () {
  25486. fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
  25487. delete axis.eventArgs;
  25488. });
  25489. }
  25490. if (isDirtyBox || hasStackedSeries) {
  25491. axis.redraw();
  25492. }
  25493. });
  25494. }
  25495. // the plot areas size has changed
  25496. if (isDirtyBox) {
  25497. chart.drawChartBox();
  25498. }
  25499. // Fire an event before redrawing series, used by the boost module to
  25500. // clear previous series renderings.
  25501. fireEvent(chart, 'predraw');
  25502. // redraw affected series
  25503. series.forEach(function (serie) {
  25504. if ((isDirtyBox || serie.isDirty) && serie.visible) {
  25505. serie.redraw();
  25506. }
  25507. // Set it here, otherwise we will have unlimited 'updatedData' calls
  25508. // for a hidden series after setData(). Fixes #6012
  25509. serie.isDirtyData = false;
  25510. });
  25511. // move tooltip or reset
  25512. if (pointer) {
  25513. pointer.reset(true);
  25514. }
  25515. // redraw if canvas
  25516. renderer.draw();
  25517. // Fire the events
  25518. fireEvent(chart, 'redraw');
  25519. fireEvent(chart, 'render');
  25520. if (isHiddenChart) {
  25521. chart.temporaryDisplay(true);
  25522. }
  25523. // Fire callbacks that are put on hold until after the redraw
  25524. afterRedraw.forEach(function (callback) {
  25525. callback.call();
  25526. });
  25527. };
  25528. /**
  25529. * Get an axis, series or point object by `id` as given in the configuration
  25530. * options. Returns `undefined` if no item is found.
  25531. *
  25532. * @sample highcharts/plotoptions/series-id/
  25533. * Get series by id
  25534. *
  25535. * @function Highcharts.Chart#get
  25536. *
  25537. * @param {string} id
  25538. * The id as given in the configuration options.
  25539. *
  25540. * @return {Highcharts.Axis|Highcharts.Series|Highcharts.Point|undefined}
  25541. * The retrieved item.
  25542. */
  25543. Chart.prototype.get = function (id) {
  25544. var ret, series = this.series, i;
  25545. /**
  25546. * @private
  25547. * @param {Highcharts.Axis|Highcharts.Series} item
  25548. * @return {boolean}
  25549. */
  25550. function itemById(item) {
  25551. return (item.id === id ||
  25552. (item.options && item.options.id === id));
  25553. }
  25554. ret =
  25555. // Search axes
  25556. find(this.axes, itemById) ||
  25557. // Search series
  25558. find(this.series, itemById);
  25559. // Search points
  25560. for (i = 0; !ret && i < series.length; i++) {
  25561. ret = find(series[i].points || [], itemById);
  25562. }
  25563. return ret;
  25564. };
  25565. /**
  25566. * Create the Axis instances based on the config options.
  25567. *
  25568. * @private
  25569. * @function Highcharts.Chart#getAxes
  25570. * @fires Highcharts.Chart#event:afterGetAxes
  25571. * @fires Highcharts.Chart#event:getAxes
  25572. */
  25573. Chart.prototype.getAxes = function () {
  25574. var chart = this, options = this.options, xAxisOptions = options.xAxis = splat(options.xAxis || {}), yAxisOptions = options.yAxis = splat(options.yAxis || {}), optionsArray;
  25575. fireEvent(this, 'getAxes');
  25576. // make sure the options are arrays and add some members
  25577. xAxisOptions.forEach(function (axis, i) {
  25578. axis.index = i;
  25579. axis.isX = true;
  25580. });
  25581. yAxisOptions.forEach(function (axis, i) {
  25582. axis.index = i;
  25583. });
  25584. // concatenate all axis options into one array
  25585. optionsArray = xAxisOptions.concat(yAxisOptions);
  25586. optionsArray.forEach(function (axisOptions) {
  25587. new Axis(chart, axisOptions); // eslint-disable-line no-new
  25588. });
  25589. fireEvent(this, 'afterGetAxes');
  25590. };
  25591. /**
  25592. * Returns an array of all currently selected points in the chart. Points
  25593. * can be selected by clicking or programmatically by the
  25594. * {@link Highcharts.Point#select}
  25595. * function.
  25596. *
  25597. * @sample highcharts/plotoptions/series-allowpointselect-line/
  25598. * Get selected points
  25599. *
  25600. * @function Highcharts.Chart#getSelectedPoints
  25601. *
  25602. * @return {Array<Highcharts.Point>}
  25603. * The currently selected points.
  25604. */
  25605. Chart.prototype.getSelectedPoints = function () {
  25606. var points = [];
  25607. this.series.forEach(function (serie) {
  25608. // For one-to-one points inspect series.data in order to retrieve
  25609. // points outside the visible range (#6445). For grouped data,
  25610. // inspect the generated series.points.
  25611. points = points.concat(serie.getPointsCollection().filter(function (point) {
  25612. return pick(point.selectedStaging, point.selected);
  25613. }));
  25614. });
  25615. return points;
  25616. };
  25617. /**
  25618. * Returns an array of all currently selected series in the chart. Series
  25619. * can be selected either programmatically by the
  25620. * {@link Highcharts.Series#select}
  25621. * function or by checking the checkbox next to the legend item if
  25622. * [series.showCheckBox](https://api.highcharts.com/highcharts/plotOptions.series.showCheckbox)
  25623. * is true.
  25624. *
  25625. * @sample highcharts/members/chart-getselectedseries/
  25626. * Get selected series
  25627. *
  25628. * @function Highcharts.Chart#getSelectedSeries
  25629. *
  25630. * @return {Array<Highcharts.Series>}
  25631. * The currently selected series.
  25632. */
  25633. Chart.prototype.getSelectedSeries = function () {
  25634. return this.series.filter(function (serie) {
  25635. return serie.selected;
  25636. });
  25637. };
  25638. /**
  25639. * Set a new title or subtitle for the chart.
  25640. *
  25641. * @sample highcharts/members/chart-settitle/
  25642. * Set title text and styles
  25643. *
  25644. * @function Highcharts.Chart#setTitle
  25645. *
  25646. * @param {Highcharts.TitleOptions} [titleOptions]
  25647. * New title options. The title text itself is set by the
  25648. * `titleOptions.text` property.
  25649. *
  25650. * @param {Highcharts.SubtitleOptions} [subtitleOptions]
  25651. * New subtitle options. The subtitle text itself is set by the
  25652. * `subtitleOptions.text` property.
  25653. *
  25654. * @param {boolean} [redraw]
  25655. * Whether to redraw the chart or wait for a later call to
  25656. * `chart.redraw()`.
  25657. */
  25658. Chart.prototype.setTitle = function (titleOptions, subtitleOptions, redraw) {
  25659. this.applyDescription('title', titleOptions);
  25660. this.applyDescription('subtitle', subtitleOptions);
  25661. // The initial call also adds the caption. On update, chart.update will
  25662. // relay to Chart.setCaption.
  25663. this.applyDescription('caption', void 0);
  25664. this.layOutTitles(redraw);
  25665. };
  25666. /**
  25667. * Apply a title, subtitle or caption for the chart
  25668. *
  25669. * @private
  25670. * @function Highcharts.Chart#applyDescription
  25671. * @param name {string}
  25672. * Either title, subtitle or caption
  25673. * @param {Highcharts.TitleOptions|Highcharts.SubtitleOptions|Highcharts.CaptionOptions|undefined} explicitOptions
  25674. * The options to set, will be merged with default options.
  25675. */
  25676. Chart.prototype.applyDescription = function (name, explicitOptions) {
  25677. var chart = this;
  25678. // Default style
  25679. var style = name === 'title' ? {
  25680. color: '#333333',
  25681. fontSize: this.options.isStock ? '16px' : '18px' // #2944
  25682. } : {
  25683. color: '#666666'
  25684. };
  25685. // Merge default options with explicit options
  25686. var options = this.options[name] = merge(
  25687. // Default styles
  25688. (!this.styledMode && { style: style }), this.options[name], explicitOptions);
  25689. var elem = this[name];
  25690. if (elem && explicitOptions) {
  25691. this[name] = elem = elem.destroy(); // remove old
  25692. }
  25693. if (options && !elem) {
  25694. elem = this.renderer.text(options.text, 0, 0, options.useHTML)
  25695. .attr({
  25696. align: options.align,
  25697. 'class': 'highcharts-' + name,
  25698. zIndex: options.zIndex || 4
  25699. })
  25700. .add();
  25701. // Update methods, shortcut to Chart.setTitle, Chart.setSubtitle and
  25702. // Chart.setCaption
  25703. elem.update = function (updateOptions) {
  25704. var fn = {
  25705. title: 'setTitle',
  25706. subtitle: 'setSubtitle',
  25707. caption: 'setCaption'
  25708. }[name];
  25709. chart[fn](updateOptions);
  25710. };
  25711. // Presentational
  25712. if (!this.styledMode) {
  25713. elem.css(options.style);
  25714. }
  25715. /**
  25716. * The chart title. The title has an `update` method that allows
  25717. * modifying the options directly or indirectly via
  25718. * `chart.update`.
  25719. *
  25720. * @sample highcharts/members/title-update/
  25721. * Updating titles
  25722. *
  25723. * @name Highcharts.Chart#title
  25724. * @type {Highcharts.TitleObject}
  25725. */
  25726. /**
  25727. * The chart subtitle. The subtitle has an `update` method that
  25728. * allows modifying the options directly or indirectly via
  25729. * `chart.update`.
  25730. *
  25731. * @name Highcharts.Chart#subtitle
  25732. * @type {Highcharts.SubtitleObject}
  25733. */
  25734. this[name] = elem;
  25735. }
  25736. };
  25737. /**
  25738. * Internal function to lay out the chart title, subtitle and caption, and
  25739. * cache the full offset height for use in `getMargins`. The result is
  25740. * stored in `this.titleOffset`.
  25741. *
  25742. * @private
  25743. * @function Highcharts.Chart#layOutTitles
  25744. *
  25745. * @param {boolean} [redraw=true]
  25746. * @fires Highcharts.Chart#event:afterLayOutTitles
  25747. */
  25748. Chart.prototype.layOutTitles = function (redraw) {
  25749. var titleOffset = [0, 0, 0], requiresDirtyBox, renderer = this.renderer, spacingBox = this.spacingBox;
  25750. // Lay out the title and the subtitle respectively
  25751. ['title', 'subtitle', 'caption'].forEach(function (key) {
  25752. var title = this[key], titleOptions = this.options[key], verticalAlign = titleOptions.verticalAlign || 'top', offset = key === 'title' ? -3 :
  25753. // Floating subtitle (#6574)
  25754. verticalAlign === 'top' ? titleOffset[0] + 2 : 0, titleSize, height;
  25755. if (title) {
  25756. if (!this.styledMode) {
  25757. titleSize = titleOptions.style.fontSize;
  25758. }
  25759. titleSize = renderer.fontMetrics(titleSize, title).b;
  25760. title
  25761. .css({
  25762. width: (titleOptions.width ||
  25763. spacingBox.width + (titleOptions.widthAdjust || 0)) + 'px'
  25764. });
  25765. // Skip the cache for HTML (#3481, #11666)
  25766. height = Math.round(title.getBBox(titleOptions.useHTML).height);
  25767. title.align(extend({
  25768. y: verticalAlign === 'bottom' ?
  25769. titleSize :
  25770. offset + titleSize,
  25771. height: height
  25772. }, titleOptions), false, 'spacingBox');
  25773. if (!titleOptions.floating) {
  25774. if (verticalAlign === 'top') {
  25775. titleOffset[0] = Math.ceil(titleOffset[0] +
  25776. height);
  25777. }
  25778. else if (verticalAlign === 'bottom') {
  25779. titleOffset[2] = Math.ceil(titleOffset[2] +
  25780. height);
  25781. }
  25782. }
  25783. }
  25784. }, this);
  25785. // Handle title.margin and caption.margin
  25786. if (titleOffset[0] &&
  25787. (this.options.title.verticalAlign || 'top') === 'top') {
  25788. titleOffset[0] += this.options.title.margin;
  25789. }
  25790. if (titleOffset[2] &&
  25791. this.options.caption.verticalAlign === 'bottom') {
  25792. titleOffset[2] += this.options.caption.margin;
  25793. }
  25794. requiresDirtyBox = (!this.titleOffset ||
  25795. this.titleOffset.join(',') !== titleOffset.join(','));
  25796. // Used in getMargins
  25797. this.titleOffset = titleOffset;
  25798. fireEvent(this, 'afterLayOutTitles');
  25799. if (!this.isDirtyBox && requiresDirtyBox) {
  25800. this.isDirtyBox = this.isDirtyLegend = requiresDirtyBox;
  25801. // Redraw if necessary (#2719, #2744)
  25802. if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
  25803. this.redraw();
  25804. }
  25805. }
  25806. };
  25807. /**
  25808. * Internal function to get the chart width and height according to options
  25809. * and container size. Sets {@link Chart.chartWidth} and
  25810. * {@link Chart.chartHeight}.
  25811. *
  25812. * @private
  25813. * @function Highcharts.Chart#getChartSize
  25814. */
  25815. Chart.prototype.getChartSize = function () {
  25816. var chart = this, optionsChart = chart.options.chart, widthOption = optionsChart.width, heightOption = optionsChart.height, renderTo = chart.renderTo;
  25817. // Get inner width and height
  25818. if (!defined(widthOption)) {
  25819. chart.containerWidth = getStyle(renderTo, 'width');
  25820. }
  25821. if (!defined(heightOption)) {
  25822. chart.containerHeight = getStyle(renderTo, 'height');
  25823. }
  25824. /**
  25825. * The current pixel width of the chart.
  25826. *
  25827. * @name Highcharts.Chart#chartWidth
  25828. * @type {number}
  25829. */
  25830. chart.chartWidth = Math.max(// #1393
  25831. 0, widthOption || chart.containerWidth || 600 // #1460
  25832. );
  25833. /**
  25834. * The current pixel height of the chart.
  25835. *
  25836. * @name Highcharts.Chart#chartHeight
  25837. * @type {number}
  25838. */
  25839. chart.chartHeight = Math.max(0, relativeLength(heightOption, chart.chartWidth) ||
  25840. (chart.containerHeight > 1 ?
  25841. chart.containerHeight :
  25842. 400));
  25843. };
  25844. /**
  25845. * If the renderTo element has no offsetWidth, most likely one or more of
  25846. * its parents are hidden. Loop up the DOM tree to temporarily display the
  25847. * parents, then save the original display properties, and when the true
  25848. * size is retrieved, reset them. Used on first render and on redraws.
  25849. *
  25850. * @private
  25851. * @function Highcharts.Chart#temporaryDisplay
  25852. *
  25853. * @param {boolean} [revert]
  25854. * Revert to the saved original styles.
  25855. */
  25856. Chart.prototype.temporaryDisplay = function (revert) {
  25857. var node = this.renderTo, tempStyle;
  25858. if (!revert) {
  25859. while (node && node.style) {
  25860. // When rendering to a detached node, it needs to be temporarily
  25861. // attached in order to read styling and bounding boxes (#5783,
  25862. // #7024).
  25863. if (!doc.body.contains(node) && !node.parentNode) {
  25864. node.hcOrigDetached = true;
  25865. doc.body.appendChild(node);
  25866. }
  25867. if (getStyle(node, 'display', false) === 'none' ||
  25868. node.hcOricDetached) {
  25869. node.hcOrigStyle = {
  25870. display: node.style.display,
  25871. height: node.style.height,
  25872. overflow: node.style.overflow
  25873. };
  25874. tempStyle = {
  25875. display: 'block',
  25876. overflow: 'hidden'
  25877. };
  25878. if (node !== this.renderTo) {
  25879. tempStyle.height = 0;
  25880. }
  25881. css(node, tempStyle);
  25882. // If it still doesn't have an offset width after setting
  25883. // display to block, it probably has an !important priority
  25884. // #2631, 6803
  25885. if (!node.offsetWidth) {
  25886. node.style.setProperty('display', 'block', 'important');
  25887. }
  25888. }
  25889. node = node.parentNode;
  25890. if (node === doc.body) {
  25891. break;
  25892. }
  25893. }
  25894. }
  25895. else {
  25896. while (node && node.style) {
  25897. if (node.hcOrigStyle) {
  25898. css(node, node.hcOrigStyle);
  25899. delete node.hcOrigStyle;
  25900. }
  25901. if (node.hcOrigDetached) {
  25902. doc.body.removeChild(node);
  25903. node.hcOrigDetached = false;
  25904. }
  25905. node = node.parentNode;
  25906. }
  25907. }
  25908. };
  25909. /**
  25910. * Set the {@link Chart.container|chart container's} class name, in
  25911. * addition to `highcharts-container`.
  25912. *
  25913. * @function Highcharts.Chart#setClassName
  25914. *
  25915. * @param {string} [className]
  25916. * The additional class name.
  25917. */
  25918. Chart.prototype.setClassName = function (className) {
  25919. this.container.className = 'highcharts-container ' + (className || '');
  25920. };
  25921. /**
  25922. * Get the containing element, determine the size and create the inner
  25923. * container div to hold the chart.
  25924. *
  25925. * @private
  25926. * @function Highcharts.Chart#afterGetContainer
  25927. * @fires Highcharts.Chart#event:afterGetContainer
  25928. */
  25929. Chart.prototype.getContainer = function () {
  25930. var chart = this, container, options = chart.options, optionsChart = options.chart, chartWidth, chartHeight, renderTo = chart.renderTo, indexAttrName = 'data-highcharts-chart', oldChartIndex, Ren, containerId = uniqueKey(), containerStyle, key;
  25931. if (!renderTo) {
  25932. chart.renderTo = renderTo =
  25933. optionsChart.renderTo;
  25934. }
  25935. if (isString(renderTo)) {
  25936. chart.renderTo = renderTo =
  25937. doc.getElementById(renderTo);
  25938. }
  25939. // Display an error if the renderTo is wrong
  25940. if (!renderTo) {
  25941. error(13, true, chart);
  25942. }
  25943. // If the container already holds a chart, destroy it. The check for
  25944. // hasRendered is there because web pages that are saved to disk from
  25945. // the browser, will preserve the data-highcharts-chart attribute and
  25946. // the SVG contents, but not an interactive chart. So in this case,
  25947. // charts[oldChartIndex] will point to the wrong chart if any (#2609).
  25948. oldChartIndex = pInt(attr(renderTo, indexAttrName));
  25949. if (isNumber(oldChartIndex) &&
  25950. charts[oldChartIndex] &&
  25951. charts[oldChartIndex].hasRendered) {
  25952. charts[oldChartIndex].destroy();
  25953. }
  25954. // Make a reference to the chart from the div
  25955. attr(renderTo, indexAttrName, chart.index);
  25956. // remove previous chart
  25957. renderTo.innerHTML = '';
  25958. // If the container doesn't have an offsetWidth, it has or is a child of
  25959. // a node that has display:none. We need to temporarily move it out to a
  25960. // visible state to determine the size, else the legend and tooltips
  25961. // won't render properly. The skipClone option is used in sparklines as
  25962. // a micro optimization, saving about 1-2 ms each chart.
  25963. if (!optionsChart.skipClone && !renderTo.offsetWidth) {
  25964. chart.temporaryDisplay();
  25965. }
  25966. // get the width and height
  25967. chart.getChartSize();
  25968. chartWidth = chart.chartWidth;
  25969. chartHeight = chart.chartHeight;
  25970. // Allow table cells and flex-boxes to shrink without the chart blocking
  25971. // them out (#6427)
  25972. css(renderTo, { overflow: 'hidden' });
  25973. // Create the inner container
  25974. if (!chart.styledMode) {
  25975. containerStyle = extend({
  25976. position: 'relative',
  25977. // needed for context menu (avoidscrollbars) and content
  25978. // overflow in IE
  25979. overflow: 'hidden',
  25980. width: chartWidth + 'px',
  25981. height: chartHeight + 'px',
  25982. textAlign: 'left',
  25983. lineHeight: 'normal',
  25984. zIndex: 0,
  25985. '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
  25986. userSelect: 'none' // #13503
  25987. }, optionsChart.style);
  25988. }
  25989. /**
  25990. * The containing HTML element of the chart. The container is
  25991. * dynamically inserted into the element given as the `renderTo`
  25992. * parameter in the {@link Highcharts#chart} constructor.
  25993. *
  25994. * @name Highcharts.Chart#container
  25995. * @type {Highcharts.HTMLDOMElement}
  25996. */
  25997. container = createElement('div', {
  25998. id: containerId
  25999. }, containerStyle, renderTo);
  26000. chart.container = container;
  26001. // cache the cursor (#1650)
  26002. chart._cursor = container.style.cursor;
  26003. // Initialize the renderer
  26004. Ren = H[optionsChart.renderer] || H.Renderer;
  26005. /**
  26006. * The renderer instance of the chart. Each chart instance has only one
  26007. * associated renderer.
  26008. *
  26009. * @name Highcharts.Chart#renderer
  26010. * @type {Highcharts.SVGRenderer}
  26011. */
  26012. chart.renderer = new Ren(container, chartWidth, chartHeight, null, optionsChart.forExport, options.exporting && options.exporting.allowHTML, chart.styledMode);
  26013. // Set the initial animation from the options
  26014. setAnimation(void 0, chart);
  26015. chart.setClassName(optionsChart.className);
  26016. if (!chart.styledMode) {
  26017. chart.renderer.setStyle(optionsChart.style);
  26018. }
  26019. else {
  26020. // Initialize definitions
  26021. for (key in options.defs) { // eslint-disable-line guard-for-in
  26022. this.renderer.definition(options.defs[key]);
  26023. }
  26024. }
  26025. // Add a reference to the charts index
  26026. chart.renderer.chartIndex = chart.index;
  26027. fireEvent(this, 'afterGetContainer');
  26028. };
  26029. /**
  26030. * Calculate margins by rendering axis labels in a preliminary position.
  26031. * Title, subtitle and legend have already been rendered at this stage, but
  26032. * will be moved into their final positions.
  26033. *
  26034. * @private
  26035. * @function Highcharts.Chart#getMargins
  26036. * @fires Highcharts.Chart#event:getMargins
  26037. */
  26038. Chart.prototype.getMargins = function (skipAxes) {
  26039. var _a = this, spacing = _a.spacing, margin = _a.margin, titleOffset = _a.titleOffset;
  26040. this.resetMargins();
  26041. // Adjust for title and subtitle
  26042. if (titleOffset[0] && !defined(margin[0])) {
  26043. this.plotTop = Math.max(this.plotTop, titleOffset[0] + spacing[0]);
  26044. }
  26045. if (titleOffset[2] && !defined(margin[2])) {
  26046. this.marginBottom = Math.max(this.marginBottom, titleOffset[2] + spacing[2]);
  26047. }
  26048. // Adjust for legend
  26049. if (this.legend && this.legend.display) {
  26050. this.legend.adjustMargins(margin, spacing);
  26051. }
  26052. fireEvent(this, 'getMargins');
  26053. if (!skipAxes) {
  26054. this.getAxisMargins();
  26055. }
  26056. };
  26057. /**
  26058. * @private
  26059. * @function Highcharts.Chart#getAxisMargins
  26060. */
  26061. Chart.prototype.getAxisMargins = function () {
  26062. var chart = this,
  26063. // [top, right, bottom, left]
  26064. axisOffset = chart.axisOffset = [0, 0, 0, 0], colorAxis = chart.colorAxis, margin = chart.margin, getOffset = function (axes) {
  26065. axes.forEach(function (axis) {
  26066. if (axis.visible) {
  26067. axis.getOffset();
  26068. }
  26069. });
  26070. };
  26071. // pre-render axes to get labels offset width
  26072. if (chart.hasCartesianSeries) {
  26073. getOffset(chart.axes);
  26074. }
  26075. else if (colorAxis && colorAxis.length) {
  26076. getOffset(colorAxis);
  26077. }
  26078. // Add the axis offsets
  26079. marginNames.forEach(function (m, side) {
  26080. if (!defined(margin[side])) {
  26081. chart[m] += axisOffset[side];
  26082. }
  26083. });
  26084. chart.setChartSize();
  26085. };
  26086. /**
  26087. * Reflows the chart to its container. By default, the chart reflows
  26088. * automatically to its container following a `window.resize` event, as per
  26089. * the [chart.reflow](https://api.highcharts.com/highcharts/chart.reflow)
  26090. * option. However, there are no reliable events for div resize, so if the
  26091. * container is resized without a window resize event, this must be called
  26092. * explicitly.
  26093. *
  26094. * @sample highcharts/members/chart-reflow/
  26095. * Resize div and reflow
  26096. * @sample highcharts/chart/events-container/
  26097. * Pop up and reflow
  26098. *
  26099. * @function Highcharts.Chart#reflow
  26100. *
  26101. * @param {global.Event} [e]
  26102. * Event arguments. Used primarily when the function is called
  26103. * internally as a response to window resize.
  26104. */
  26105. Chart.prototype.reflow = function (e) {
  26106. var chart = this, optionsChart = chart.options.chart, renderTo = chart.renderTo, hasUserSize = (defined(optionsChart.width) &&
  26107. defined(optionsChart.height)), width = optionsChart.width || getStyle(renderTo, 'width'), height = optionsChart.height || getStyle(renderTo, 'height'), target = e ? e.target : win;
  26108. // Width and height checks for display:none. Target is doc in IE8 and
  26109. // Opera, win in Firefox, Chrome and IE9.
  26110. if (!hasUserSize &&
  26111. !chart.isPrinting &&
  26112. width &&
  26113. height &&
  26114. (target === win || target === doc)) {
  26115. if (width !== chart.containerWidth ||
  26116. height !== chart.containerHeight) {
  26117. U.clearTimeout(chart.reflowTimeout);
  26118. // When called from window.resize, e is set, else it's called
  26119. // directly (#2224)
  26120. chart.reflowTimeout = syncTimeout(function () {
  26121. // Set size, it may have been destroyed in the meantime
  26122. // (#1257)
  26123. if (chart.container) {
  26124. chart.setSize(void 0, void 0, false);
  26125. }
  26126. }, e ? 100 : 0);
  26127. }
  26128. chart.containerWidth = width;
  26129. chart.containerHeight = height;
  26130. }
  26131. };
  26132. /**
  26133. * Toggle the event handlers necessary for auto resizing, depending on the
  26134. * `chart.reflow` option.
  26135. *
  26136. * @private
  26137. * @function Highcharts.Chart#setReflow
  26138. */
  26139. Chart.prototype.setReflow = function (reflow) {
  26140. var chart = this;
  26141. if (reflow !== false && !this.unbindReflow) {
  26142. this.unbindReflow = addEvent(win, 'resize', function (e) {
  26143. // a removed event listener still runs in Edge and IE if the
  26144. // listener was removed while the event runs, so check if the
  26145. // chart is not destroyed (#11609)
  26146. if (chart.options) {
  26147. chart.reflow(e);
  26148. }
  26149. });
  26150. addEvent(this, 'destroy', this.unbindReflow);
  26151. }
  26152. else if (reflow === false && this.unbindReflow) {
  26153. // Unbind and unset
  26154. this.unbindReflow = this.unbindReflow();
  26155. }
  26156. // The following will add listeners to re-fit the chart before and after
  26157. // printing (#2284). However it only works in WebKit. Should have worked
  26158. // in Firefox, but not supported in IE.
  26159. /*
  26160. if (win.matchMedia) {
  26161. win.matchMedia('print').addListener(function reflow() {
  26162. chart.reflow();
  26163. });
  26164. }
  26165. //*/
  26166. };
  26167. /**
  26168. * Resize the chart to a given width and height. In order to set the width
  26169. * only, the height argument may be skipped. To set the height only, pass
  26170. * `undefined` for the width.
  26171. *
  26172. * @sample highcharts/members/chart-setsize-button/
  26173. * Test resizing from buttons
  26174. * @sample highcharts/members/chart-setsize-jquery-resizable/
  26175. * Add a jQuery UI resizable
  26176. * @sample stock/members/chart-setsize/
  26177. * Highstock with UI resizable
  26178. *
  26179. * @function Highcharts.Chart#setSize
  26180. *
  26181. * @param {number|null} [width]
  26182. * The new pixel width of the chart. Since v4.2.6, the argument can
  26183. * be `undefined` in order to preserve the current value (when
  26184. * setting height only), or `null` to adapt to the width of the
  26185. * containing element.
  26186. *
  26187. * @param {number|null} [height]
  26188. * The new pixel height of the chart. Since v4.2.6, the argument can
  26189. * be `undefined` in order to preserve the current value, or `null`
  26190. * in order to adapt to the height of the containing element.
  26191. *
  26192. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=true]
  26193. * Whether and how to apply animation.
  26194. *
  26195. * @return {void}
  26196. *
  26197. * @fires Highcharts.Chart#event:endResize
  26198. * @fires Highcharts.Chart#event:resize
  26199. */
  26200. Chart.prototype.setSize = function (width, height, animation) {
  26201. var chart = this, renderer = chart.renderer, globalAnimation;
  26202. // Handle the isResizing counter
  26203. chart.isResizing += 1;
  26204. // set the animation for the current process
  26205. setAnimation(animation, chart);
  26206. globalAnimation = renderer.globalAnimation;
  26207. chart.oldChartHeight = chart.chartHeight;
  26208. chart.oldChartWidth = chart.chartWidth;
  26209. if (typeof width !== 'undefined') {
  26210. chart.options.chart.width = width;
  26211. }
  26212. if (typeof height !== 'undefined') {
  26213. chart.options.chart.height = height;
  26214. }
  26215. chart.getChartSize();
  26216. // Resize the container with the global animation applied if enabled
  26217. // (#2503)
  26218. if (!chart.styledMode) {
  26219. (globalAnimation ? animate : css)(chart.container, {
  26220. width: chart.chartWidth + 'px',
  26221. height: chart.chartHeight + 'px'
  26222. }, globalAnimation);
  26223. }
  26224. chart.setChartSize(true);
  26225. renderer.setSize(chart.chartWidth, chart.chartHeight, globalAnimation);
  26226. // handle axes
  26227. chart.axes.forEach(function (axis) {
  26228. axis.isDirty = true;
  26229. axis.setScale();
  26230. });
  26231. chart.isDirtyLegend = true; // force legend redraw
  26232. chart.isDirtyBox = true; // force redraw of plot and chart border
  26233. chart.layOutTitles(); // #2857
  26234. chart.getMargins();
  26235. chart.redraw(globalAnimation);
  26236. chart.oldChartHeight = null;
  26237. fireEvent(chart, 'resize');
  26238. // Fire endResize and set isResizing back. If animation is disabled,
  26239. // fire without delay
  26240. syncTimeout(function () {
  26241. if (chart) {
  26242. fireEvent(chart, 'endResize', null, function () {
  26243. chart.isResizing -= 1;
  26244. });
  26245. }
  26246. }, animObject(globalAnimation).duration || 0);
  26247. };
  26248. /**
  26249. * Set the public chart properties. This is done before and after the
  26250. * pre-render to determine margin sizes.
  26251. *
  26252. * @private
  26253. * @function Highcharts.Chart#setChartSize
  26254. * @fires Highcharts.Chart#event:afterSetChartSize
  26255. */
  26256. Chart.prototype.setChartSize = function (skipAxes) {
  26257. var chart = this, inverted = chart.inverted, renderer = chart.renderer, chartWidth = chart.chartWidth, chartHeight = chart.chartHeight, optionsChart = chart.options.chart, spacing = chart.spacing, clipOffset = chart.clipOffset, clipX, clipY, plotLeft, plotTop, plotWidth, plotHeight, plotBorderWidth;
  26258. /**
  26259. * The current left position of the plot area in pixels.
  26260. *
  26261. * @name Highcharts.Chart#plotLeft
  26262. * @type {number}
  26263. */
  26264. chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
  26265. /**
  26266. * The current top position of the plot area in pixels.
  26267. *
  26268. * @name Highcharts.Chart#plotTop
  26269. * @type {number}
  26270. */
  26271. chart.plotTop = plotTop = Math.round(chart.plotTop);
  26272. /**
  26273. * The current width of the plot area in pixels.
  26274. *
  26275. * @name Highcharts.Chart#plotWidth
  26276. * @type {number}
  26277. */
  26278. chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
  26279. /**
  26280. * The current height of the plot area in pixels.
  26281. *
  26282. * @name Highcharts.Chart#plotHeight
  26283. * @type {number}
  26284. */
  26285. chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
  26286. chart.plotSizeX = inverted ? plotHeight : plotWidth;
  26287. chart.plotSizeY = inverted ? plotWidth : plotHeight;
  26288. chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
  26289. // Set boxes used for alignment
  26290. chart.spacingBox = renderer.spacingBox = {
  26291. x: spacing[3],
  26292. y: spacing[0],
  26293. width: chartWidth - spacing[3] - spacing[1],
  26294. height: chartHeight - spacing[0] - spacing[2]
  26295. };
  26296. chart.plotBox = renderer.plotBox = {
  26297. x: plotLeft,
  26298. y: plotTop,
  26299. width: plotWidth,
  26300. height: plotHeight
  26301. };
  26302. plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
  26303. clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
  26304. clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
  26305. chart.clipBox = {
  26306. x: clipX,
  26307. y: clipY,
  26308. width: Math.floor(chart.plotSizeX -
  26309. Math.max(plotBorderWidth, clipOffset[1]) / 2 -
  26310. clipX),
  26311. height: Math.max(0, Math.floor(chart.plotSizeY -
  26312. Math.max(plotBorderWidth, clipOffset[2]) / 2 -
  26313. clipY))
  26314. };
  26315. if (!skipAxes) {
  26316. chart.axes.forEach(function (axis) {
  26317. axis.setAxisSize();
  26318. axis.setAxisTranslation();
  26319. });
  26320. }
  26321. fireEvent(chart, 'afterSetChartSize', { skipAxes: skipAxes });
  26322. };
  26323. /**
  26324. * Initial margins before auto size margins are applied.
  26325. *
  26326. * @private
  26327. * @function Highcharts.Chart#resetMargins
  26328. */
  26329. Chart.prototype.resetMargins = function () {
  26330. fireEvent(this, 'resetMargins');
  26331. var chart = this, chartOptions = chart.options.chart;
  26332. // Create margin and spacing array
  26333. ['margin', 'spacing'].forEach(function splashArrays(target) {
  26334. var value = chartOptions[target], values = isObject(value) ? value : [value, value, value, value];
  26335. [
  26336. 'Top',
  26337. 'Right',
  26338. 'Bottom',
  26339. 'Left'
  26340. ].forEach(function (sideName, side) {
  26341. chart[target][side] = pick(chartOptions[target + sideName], values[side]);
  26342. });
  26343. });
  26344. // Set margin names like chart.plotTop, chart.plotLeft,
  26345. // chart.marginRight, chart.marginBottom.
  26346. marginNames.forEach(function (m, side) {
  26347. chart[m] = pick(chart.margin[side], chart.spacing[side]);
  26348. });
  26349. chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
  26350. chart.clipOffset = [0, 0, 0, 0];
  26351. };
  26352. /**
  26353. * Internal function to draw or redraw the borders and backgrounds for chart
  26354. * and plot area.
  26355. *
  26356. * @private
  26357. * @function Highcharts.Chart#drawChartBox
  26358. * @fires Highcharts.Chart#event:afterDrawChartBox
  26359. */
  26360. Chart.prototype.drawChartBox = function () {
  26361. var chart = this, optionsChart = chart.options.chart, renderer = chart.renderer, chartWidth = chart.chartWidth, chartHeight = chart.chartHeight, chartBackground = chart.chartBackground, plotBackground = chart.plotBackground, plotBorder = chart.plotBorder, chartBorderWidth, styledMode = chart.styledMode, plotBGImage = chart.plotBGImage, chartBackgroundColor = optionsChart.backgroundColor, plotBackgroundColor = optionsChart.plotBackgroundColor, plotBackgroundImage = optionsChart.plotBackgroundImage, mgn, bgAttr, plotLeft = chart.plotLeft, plotTop = chart.plotTop, plotWidth = chart.plotWidth, plotHeight = chart.plotHeight, plotBox = chart.plotBox, clipRect = chart.clipRect, clipBox = chart.clipBox, verb = 'animate';
  26362. // Chart area
  26363. if (!chartBackground) {
  26364. chart.chartBackground = chartBackground = renderer.rect()
  26365. .addClass('highcharts-background')
  26366. .add();
  26367. verb = 'attr';
  26368. }
  26369. if (!styledMode) {
  26370. // Presentational
  26371. chartBorderWidth = optionsChart.borderWidth || 0;
  26372. mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
  26373. bgAttr = {
  26374. fill: chartBackgroundColor || 'none'
  26375. };
  26376. if (chartBorderWidth || chartBackground['stroke-width']) { // #980
  26377. bgAttr.stroke = optionsChart.borderColor;
  26378. bgAttr['stroke-width'] = chartBorderWidth;
  26379. }
  26380. chartBackground
  26381. .attr(bgAttr)
  26382. .shadow(optionsChart.shadow);
  26383. }
  26384. else {
  26385. chartBorderWidth = mgn = chartBackground.strokeWidth();
  26386. }
  26387. chartBackground[verb]({
  26388. x: mgn / 2,
  26389. y: mgn / 2,
  26390. width: chartWidth - mgn - chartBorderWidth % 2,
  26391. height: chartHeight - mgn - chartBorderWidth % 2,
  26392. r: optionsChart.borderRadius
  26393. });
  26394. // Plot background
  26395. verb = 'animate';
  26396. if (!plotBackground) {
  26397. verb = 'attr';
  26398. chart.plotBackground = plotBackground = renderer.rect()
  26399. .addClass('highcharts-plot-background')
  26400. .add();
  26401. }
  26402. plotBackground[verb](plotBox);
  26403. if (!styledMode) {
  26404. // Presentational attributes for the background
  26405. plotBackground
  26406. .attr({
  26407. fill: plotBackgroundColor || 'none'
  26408. })
  26409. .shadow(optionsChart.plotShadow);
  26410. // Create the background image
  26411. if (plotBackgroundImage) {
  26412. if (!plotBGImage) {
  26413. chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight).add();
  26414. }
  26415. else {
  26416. if (plotBackgroundImage !== plotBGImage.attr('href')) {
  26417. plotBGImage.attr('href', plotBackgroundImage);
  26418. }
  26419. plotBGImage.animate(plotBox);
  26420. }
  26421. }
  26422. }
  26423. // Plot clip
  26424. if (!clipRect) {
  26425. chart.clipRect = renderer.clipRect(clipBox);
  26426. }
  26427. else {
  26428. clipRect.animate({
  26429. width: clipBox.width,
  26430. height: clipBox.height
  26431. });
  26432. }
  26433. // Plot area border
  26434. verb = 'animate';
  26435. if (!plotBorder) {
  26436. verb = 'attr';
  26437. chart.plotBorder = plotBorder = renderer.rect()
  26438. .addClass('highcharts-plot-border')
  26439. .attr({
  26440. zIndex: 1 // Above the grid
  26441. })
  26442. .add();
  26443. }
  26444. if (!styledMode) {
  26445. // Presentational
  26446. plotBorder.attr({
  26447. stroke: optionsChart.plotBorderColor,
  26448. 'stroke-width': optionsChart.plotBorderWidth || 0,
  26449. fill: 'none'
  26450. });
  26451. }
  26452. plotBorder[verb](plotBorder.crisp({
  26453. x: plotLeft,
  26454. y: plotTop,
  26455. width: plotWidth,
  26456. height: plotHeight
  26457. }, -plotBorder.strokeWidth())); // #3282 plotBorder should be negative;
  26458. // reset
  26459. chart.isDirtyBox = false;
  26460. fireEvent(this, 'afterDrawChartBox');
  26461. };
  26462. /**
  26463. * Detect whether a certain chart property is needed based on inspecting its
  26464. * options and series. This mainly applies to the chart.inverted property,
  26465. * and in extensions to the chart.angular and chart.polar properties.
  26466. *
  26467. * @private
  26468. * @function Highcharts.Chart#propFromSeries
  26469. * @return {void}
  26470. */
  26471. Chart.prototype.propFromSeries = function () {
  26472. var chart = this, optionsChart = chart.options.chart, klass, seriesOptions = chart.options.series, i, value;
  26473. /**
  26474. * The flag is set to `true` if a series of the chart is inverted.
  26475. *
  26476. * @name Highcharts.Chart#inverted
  26477. * @type {boolean|undefined}
  26478. */
  26479. ['inverted', 'angular', 'polar'].forEach(function (key) {
  26480. // The default series type's class
  26481. klass = seriesTypes[(optionsChart.type ||
  26482. optionsChart.defaultSeriesType)];
  26483. // Get the value from available chart-wide properties
  26484. value =
  26485. // It is set in the options:
  26486. optionsChart[key] ||
  26487. // The default series class:
  26488. (klass && klass.prototype[key]);
  26489. // requires it
  26490. // 4. Check if any the chart's series require it
  26491. i = seriesOptions && seriesOptions.length;
  26492. while (!value && i--) {
  26493. klass = seriesTypes[seriesOptions[i].type];
  26494. if (klass && klass.prototype[key]) {
  26495. value = true;
  26496. }
  26497. }
  26498. // Set the chart property
  26499. chart[key] = value;
  26500. });
  26501. };
  26502. /**
  26503. * Internal function to link two or more series together, based on the
  26504. * `linkedTo` option. This is done from `Chart.render`, and after
  26505. * `Chart.addSeries` and `Series.remove`.
  26506. *
  26507. * @private
  26508. * @function Highcharts.Chart#linkSeries
  26509. * @fires Highcharts.Chart#event:afterLinkSeries
  26510. */
  26511. Chart.prototype.linkSeries = function () {
  26512. var chart = this, chartSeries = chart.series;
  26513. // Reset links
  26514. chartSeries.forEach(function (series) {
  26515. series.linkedSeries.length = 0;
  26516. });
  26517. // Apply new links
  26518. chartSeries.forEach(function (series) {
  26519. var linkedTo = series.options.linkedTo;
  26520. if (isString(linkedTo)) {
  26521. if (linkedTo === ':previous') {
  26522. linkedTo = chart.series[series.index - 1];
  26523. }
  26524. else {
  26525. linkedTo = chart.get(linkedTo);
  26526. }
  26527. // #3341 avoid mutual linking
  26528. if (linkedTo && linkedTo.linkedParent !== series) {
  26529. linkedTo.linkedSeries.push(series);
  26530. series.linkedParent = linkedTo;
  26531. if (linkedTo.enabledDataSorting) {
  26532. series.setDataSortingOptions();
  26533. }
  26534. series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
  26535. }
  26536. }
  26537. });
  26538. fireEvent(this, 'afterLinkSeries');
  26539. };
  26540. /**
  26541. * Render series for the chart.
  26542. *
  26543. * @private
  26544. * @function Highcharts.Chart#renderSeries
  26545. */
  26546. Chart.prototype.renderSeries = function () {
  26547. this.series.forEach(function (serie) {
  26548. serie.translate();
  26549. serie.render();
  26550. });
  26551. };
  26552. /**
  26553. * Render labels for the chart.
  26554. *
  26555. * @private
  26556. * @function Highcharts.Chart#renderLabels
  26557. */
  26558. Chart.prototype.renderLabels = function () {
  26559. var chart = this, labels = chart.options.labels;
  26560. if (labels.items) {
  26561. labels.items.forEach(function (label) {
  26562. var style = extend(labels.style, label.style), x = pInt(style.left) + chart.plotLeft, y = pInt(style.top) + chart.plotTop + 12;
  26563. // delete to prevent rewriting in IE
  26564. delete style.left;
  26565. delete style.top;
  26566. chart.renderer.text(label.html, x, y)
  26567. .attr({ zIndex: 2 })
  26568. .css(style)
  26569. .add();
  26570. });
  26571. }
  26572. };
  26573. /**
  26574. * Render all graphics for the chart. Runs internally on initialization.
  26575. *
  26576. * @private
  26577. * @function Highcharts.Chart#render
  26578. */
  26579. Chart.prototype.render = function () {
  26580. var chart = this, axes = chart.axes, colorAxis = chart.colorAxis, renderer = chart.renderer, options = chart.options, correction = 0, // correction for X axis labels
  26581. tempWidth, tempHeight, redoHorizontal, redoVertical, renderAxes = function (axes) {
  26582. axes.forEach(function (axis) {
  26583. if (axis.visible) {
  26584. axis.render();
  26585. }
  26586. });
  26587. };
  26588. // Title
  26589. chart.setTitle();
  26590. /**
  26591. * The overview of the chart's series.
  26592. *
  26593. * @name Highcharts.Chart#legend
  26594. * @type {Highcharts.Legend}
  26595. */
  26596. chart.legend = new Legend(chart, options.legend);
  26597. // Get stacks
  26598. if (chart.getStacks) {
  26599. chart.getStacks();
  26600. }
  26601. // Get chart margins
  26602. chart.getMargins(true);
  26603. chart.setChartSize();
  26604. // Record preliminary dimensions for later comparison
  26605. tempWidth = chart.plotWidth;
  26606. axes.some(function (axis) {
  26607. if (axis.horiz &&
  26608. axis.visible &&
  26609. axis.options.labels.enabled &&
  26610. axis.series.length) {
  26611. // 21 is the most common correction for X axis labels
  26612. correction = 21;
  26613. return true;
  26614. }
  26615. });
  26616. // use Math.max to prevent negative plotHeight
  26617. chart.plotHeight = Math.max(chart.plotHeight - correction, 0);
  26618. tempHeight = chart.plotHeight;
  26619. // Get margins by pre-rendering axes
  26620. axes.forEach(function (axis) {
  26621. axis.setScale();
  26622. });
  26623. chart.getAxisMargins();
  26624. // If the plot area size has changed significantly, calculate tick
  26625. // positions again
  26626. redoHorizontal = tempWidth / chart.plotWidth > 1.1;
  26627. // Height is more sensitive, use lower threshold
  26628. redoVertical = tempHeight / chart.plotHeight > 1.05;
  26629. if (redoHorizontal || redoVertical) {
  26630. axes.forEach(function (axis) {
  26631. if ((axis.horiz && redoHorizontal) ||
  26632. (!axis.horiz && redoVertical)) {
  26633. // update to reflect the new margins
  26634. axis.setTickInterval(true);
  26635. }
  26636. });
  26637. chart.getMargins(); // second pass to check for new labels
  26638. }
  26639. // Draw the borders and backgrounds
  26640. chart.drawChartBox();
  26641. // Axes
  26642. if (chart.hasCartesianSeries) {
  26643. renderAxes(axes);
  26644. }
  26645. else if (colorAxis && colorAxis.length) {
  26646. renderAxes(colorAxis);
  26647. }
  26648. // The series
  26649. if (!chart.seriesGroup) {
  26650. chart.seriesGroup = renderer.g('series-group')
  26651. .attr({ zIndex: 3 })
  26652. .add();
  26653. }
  26654. chart.renderSeries();
  26655. // Labels
  26656. chart.renderLabels();
  26657. // Credits
  26658. chart.addCredits();
  26659. // Handle responsiveness
  26660. if (chart.setResponsive) {
  26661. chart.setResponsive();
  26662. }
  26663. // Handle scaling
  26664. chart.updateContainerScaling();
  26665. // Set flag
  26666. chart.hasRendered = true;
  26667. };
  26668. /**
  26669. * Set a new credits label for the chart.
  26670. *
  26671. * @sample highcharts/credits/credits-update/
  26672. * Add and update credits
  26673. *
  26674. * @function Highcharts.Chart#addCredits
  26675. *
  26676. * @param {Highcharts.CreditsOptions} [credits]
  26677. * A configuration object for the new credits.
  26678. */
  26679. Chart.prototype.addCredits = function (credits) {
  26680. var chart = this, creds = merge(true, this.options.credits, credits);
  26681. if (creds.enabled && !this.credits) {
  26682. /**
  26683. * The chart's credits label. The label has an `update` method that
  26684. * allows setting new options as per the
  26685. * [credits options set](https://api.highcharts.com/highcharts/credits).
  26686. *
  26687. * @name Highcharts.Chart#credits
  26688. * @type {Highcharts.SVGElement}
  26689. */
  26690. this.credits = this.renderer.text(creds.text + (this.mapCredits || ''), 0, 0)
  26691. .addClass('highcharts-credits')
  26692. .on('click', function () {
  26693. if (creds.href) {
  26694. win.location.href = creds.href;
  26695. }
  26696. })
  26697. .attr({
  26698. align: creds.position.align,
  26699. zIndex: 8
  26700. });
  26701. if (!chart.styledMode) {
  26702. this.credits.css(creds.style);
  26703. }
  26704. this.credits
  26705. .add()
  26706. .align(creds.position);
  26707. // Dynamically update
  26708. this.credits.update = function (options) {
  26709. chart.credits = chart.credits.destroy();
  26710. chart.addCredits(options);
  26711. };
  26712. }
  26713. };
  26714. /**
  26715. * Handle scaling, #11329 - when there is scaling/transform on the container
  26716. * or on a parent element, we need to take this into account. We calculate
  26717. * the scaling once here and it is picked up where we need to use it
  26718. * (Pointer, Tooltip).
  26719. *
  26720. * @private
  26721. * @function Highcharts.Chart#updateContainerScaling
  26722. */
  26723. Chart.prototype.updateContainerScaling = function () {
  26724. var container = this.container;
  26725. // #13342 - tooltip was not visible in Chrome, when chart
  26726. // updates height.
  26727. if (container.offsetWidth > 2 && // #13342
  26728. container.offsetHeight > 2 && // #13342
  26729. container.getBoundingClientRect) {
  26730. var bb = container.getBoundingClientRect(), scaleX = bb.width / container.offsetWidth, scaleY = bb.height / container.offsetHeight;
  26731. if (scaleX !== 1 || scaleY !== 1) {
  26732. this.containerScaling = { scaleX: scaleX, scaleY: scaleY };
  26733. }
  26734. else {
  26735. delete this.containerScaling;
  26736. }
  26737. }
  26738. };
  26739. /**
  26740. * Remove the chart and purge memory. This method is called internally
  26741. * before adding a second chart into the same container, as well as on
  26742. * window unload to prevent leaks.
  26743. *
  26744. * @sample highcharts/members/chart-destroy/
  26745. * Destroy the chart from a button
  26746. * @sample stock/members/chart-destroy/
  26747. * Destroy with Highstock
  26748. *
  26749. * @function Highcharts.Chart#destroy
  26750. *
  26751. * @fires Highcharts.Chart#event:destroy
  26752. */
  26753. Chart.prototype.destroy = function () {
  26754. var chart = this, axes = chart.axes, series = chart.series, container = chart.container, i, parentNode = container && container.parentNode;
  26755. // fire the chart.destoy event
  26756. fireEvent(chart, 'destroy');
  26757. // Delete the chart from charts lookup array
  26758. if (chart.renderer.forExport) {
  26759. erase(charts, chart); // #6569
  26760. }
  26761. else {
  26762. charts[chart.index] = void 0;
  26763. }
  26764. H.chartCount--;
  26765. chart.renderTo.removeAttribute('data-highcharts-chart');
  26766. // remove events
  26767. removeEvent(chart);
  26768. // ==== Destroy collections:
  26769. // Destroy axes
  26770. i = axes.length;
  26771. while (i--) {
  26772. axes[i] = axes[i].destroy();
  26773. }
  26774. // Destroy scroller & scroller series before destroying base series
  26775. if (this.scroller && this.scroller.destroy) {
  26776. this.scroller.destroy();
  26777. }
  26778. // Destroy each series
  26779. i = series.length;
  26780. while (i--) {
  26781. series[i] = series[i].destroy();
  26782. }
  26783. // ==== Destroy chart properties:
  26784. [
  26785. 'title', 'subtitle', 'chartBackground', 'plotBackground',
  26786. 'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
  26787. 'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
  26788. 'renderer'
  26789. ].forEach(function (name) {
  26790. var prop = chart[name];
  26791. if (prop && prop.destroy) {
  26792. chart[name] = prop.destroy();
  26793. }
  26794. });
  26795. // Remove container and all SVG, check container as it can break in IE
  26796. // when destroyed before finished loading
  26797. if (container) {
  26798. container.innerHTML = '';
  26799. removeEvent(container);
  26800. if (parentNode) {
  26801. discardElement(container);
  26802. }
  26803. }
  26804. // clean it all up
  26805. objectEach(chart, function (val, key) {
  26806. delete chart[key];
  26807. });
  26808. };
  26809. /**
  26810. * Prepare for first rendering after all data are loaded.
  26811. *
  26812. * @private
  26813. * @function Highcharts.Chart#firstRender
  26814. * @fires Highcharts.Chart#event:beforeRender
  26815. */
  26816. Chart.prototype.firstRender = function () {
  26817. var chart = this, options = chart.options;
  26818. // Hook for oldIE to check whether the chart is ready to render
  26819. if (chart.isReadyToRender && !chart.isReadyToRender()) {
  26820. return;
  26821. }
  26822. // Create the container
  26823. chart.getContainer();
  26824. chart.resetMargins();
  26825. chart.setChartSize();
  26826. // Set the common chart properties (mainly invert) from the given series
  26827. chart.propFromSeries();
  26828. // get axes
  26829. chart.getAxes();
  26830. // Initialize the series
  26831. (isArray(options.series) ? options.series : []).forEach(
  26832. // #9680
  26833. function (serieOptions) {
  26834. chart.initSeries(serieOptions);
  26835. });
  26836. chart.linkSeries();
  26837. chart.setSeriesData();
  26838. // Run an event after axes and series are initialized, but before
  26839. // render. At this stage, the series data is indexed and cached in the
  26840. // xData and yData arrays, so we can access those before rendering. Used
  26841. // in Highstock.
  26842. fireEvent(chart, 'beforeRender');
  26843. // depends on inverted and on margins being set
  26844. if (Pointer) {
  26845. if (!H.hasTouch && (win.PointerEvent || win.MSPointerEvent)) {
  26846. chart.pointer = new MSPointer(chart, options);
  26847. }
  26848. else {
  26849. /**
  26850. * The Pointer that keeps track of mouse and touch interaction.
  26851. *
  26852. * @memberof Highcharts.Chart
  26853. * @name pointer
  26854. * @type {Highcharts.Pointer}
  26855. * @instance
  26856. */
  26857. chart.pointer = new Pointer(chart, options);
  26858. }
  26859. }
  26860. chart.render();
  26861. // Fire the load event if there are no external images
  26862. if (!chart.renderer.imgCount && !chart.hasLoaded) {
  26863. chart.onload();
  26864. }
  26865. // If the chart was rendered outside the top container, put it back in
  26866. // (#3679)
  26867. chart.temporaryDisplay(true);
  26868. };
  26869. /**
  26870. * Internal function that runs on chart load, async if any images are loaded
  26871. * in the chart. Runs the callbacks and triggers the `load` and `render`
  26872. * events.
  26873. *
  26874. * @private
  26875. * @function Highcharts.Chart#onload
  26876. * @fires Highcharts.Chart#event:load
  26877. * @fires Highcharts.Chart#event:render
  26878. */
  26879. Chart.prototype.onload = function () {
  26880. // Run callbacks, first the ones registered by modules, then user's one
  26881. this.callbacks.concat([this.callback]).forEach(function (fn) {
  26882. // Chart destroyed in its own callback (#3600)
  26883. if (fn && typeof this.index !== 'undefined') {
  26884. fn.apply(this, [this]);
  26885. }
  26886. }, this);
  26887. fireEvent(this, 'load');
  26888. fireEvent(this, 'render');
  26889. // Set up auto resize, check for not destroyed (#6068)
  26890. if (defined(this.index)) {
  26891. this.setReflow(this.options.chart.reflow);
  26892. }
  26893. // Don't run again
  26894. this.hasLoaded = true;
  26895. };
  26896. return Chart;
  26897. }());
  26898. // Hook for adding callbacks in modules
  26899. Chart.prototype.callbacks = [];
  26900. /**
  26901. * Factory function for basic charts.
  26902. *
  26903. * @example
  26904. * // Render a chart in to div#container
  26905. * var chart = Highcharts.chart('container', {
  26906. * title: {
  26907. * text: 'My chart'
  26908. * },
  26909. * series: [{
  26910. * data: [1, 3, 2, 4]
  26911. * }]
  26912. * });
  26913. *
  26914. * @function Highcharts.chart
  26915. *
  26916. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  26917. * The DOM element to render to, or its id.
  26918. *
  26919. * @param {Highcharts.Options} options
  26920. * The chart options structure.
  26921. *
  26922. * @param {Highcharts.ChartCallbackFunction} [callback]
  26923. * Function to run when the chart has loaded and and all external images
  26924. * are loaded. Defining a
  26925. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  26926. * handler is equivalent.
  26927. *
  26928. * @return {Highcharts.Chart}
  26929. * Returns the Chart object.
  26930. */
  26931. function chart(a, b, c) {
  26932. return new Chart(a, b, c);
  26933. }
  26934. H.chart = chart;
  26935. H.Chart = Chart;
  26936. return Chart;
  26937. });
  26938. _registerModule(_modules, 'parts/ScrollablePlotArea.js', [_modules['parts/Chart.js'], _modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (Chart, H, U) {
  26939. /* *
  26940. *
  26941. * (c) 2010-2020 Torstein Honsi
  26942. *
  26943. * License: www.highcharts.com/license
  26944. *
  26945. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26946. *
  26947. * Highcharts feature to make the Y axis stay fixed when scrolling the chart
  26948. * horizontally on mobile devices. Supports left and right side axes.
  26949. */
  26950. /*
  26951. WIP on vertical scrollable plot area (#9378). To do:
  26952. - Bottom axis positioning
  26953. - Test with Gantt
  26954. - Look for size optimizing the code
  26955. - API and demos
  26956. */
  26957. var addEvent = U.addEvent, createElement = U.createElement, pick = U.pick, stop = U.stop;
  26958. /**
  26959. * Options for a scrollable plot area. This feature provides a minimum size for
  26960. * the plot area of the chart. If the size gets smaller than this, typically
  26961. * on mobile devices, a native browser scrollbar is presented. This scrollbar
  26962. * provides smooth scrolling for the contents of the plot area, whereas the
  26963. * title, legend and unaffected axes are fixed.
  26964. *
  26965. * Since v7.1.2, a scrollable plot area can be defined for either horizontal or
  26966. * vertical scrolling, depending on whether the `minWidth` or `minHeight`
  26967. * option is set.
  26968. *
  26969. * @sample highcharts/chart/scrollable-plotarea
  26970. * Scrollable plot area
  26971. * @sample highcharts/chart/scrollable-plotarea-vertical
  26972. * Vertically scrollable plot area
  26973. * @sample {gantt} highcharts/chart/scrollable-plotarea-vertical
  26974. * Gantt chart with vertically scrollable plot area
  26975. *
  26976. * @since 6.1.0
  26977. * @product highcharts gantt
  26978. * @apioption chart.scrollablePlotArea
  26979. */
  26980. /**
  26981. * The minimum height for the plot area. If it gets smaller than this, the plot
  26982. * area will become scrollable.
  26983. *
  26984. * @type {number}
  26985. * @apioption chart.scrollablePlotArea.minHeight
  26986. */
  26987. /**
  26988. * The minimum width for the plot area. If it gets smaller than this, the plot
  26989. * area will become scrollable.
  26990. *
  26991. * @type {number}
  26992. * @apioption chart.scrollablePlotArea.minWidth
  26993. */
  26994. /**
  26995. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  26996. * 1, where 0 aligns the plot area to the left and 1 aligns it to the right.
  26997. * Typically we would use 1 if the chart has right aligned Y axes.
  26998. *
  26999. * @type {number}
  27000. * @apioption chart.scrollablePlotArea.scrollPositionX
  27001. */
  27002. /**
  27003. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  27004. * 1, where 0 aligns the plot area to the top and 1 aligns it to the bottom.
  27005. *
  27006. * @type {number}
  27007. * @apioption chart.scrollablePlotArea.scrollPositionY
  27008. */
  27009. /**
  27010. * The opacity of mask applied on one of the sides of the plot
  27011. * area.
  27012. *
  27013. * @sample {highcharts} highcharts/chart/scrollable-plotarea-opacity
  27014. * Disabled opacity for the mask
  27015. *
  27016. * @type {number}
  27017. * @default 0.85
  27018. * @since 7.1.1
  27019. * @apioption chart.scrollablePlotArea.opacity
  27020. */
  27021. ''; // detach API doclets
  27022. /* eslint-disable no-invalid-this, valid-jsdoc */
  27023. addEvent(Chart, 'afterSetChartSize', function (e) {
  27024. var scrollablePlotArea = this.options.chart.scrollablePlotArea, scrollableMinWidth = scrollablePlotArea && scrollablePlotArea.minWidth, scrollableMinHeight = scrollablePlotArea && scrollablePlotArea.minHeight, scrollablePixelsX, scrollablePixelsY, corrections;
  27025. if (!this.renderer.forExport) {
  27026. // The amount of pixels to scroll, the difference between chart
  27027. // width and scrollable width
  27028. if (scrollableMinWidth) {
  27029. this.scrollablePixelsX = scrollablePixelsX = Math.max(0, scrollableMinWidth - this.chartWidth);
  27030. if (scrollablePixelsX) {
  27031. this.plotWidth += scrollablePixelsX;
  27032. if (this.inverted) {
  27033. this.clipBox.height += scrollablePixelsX;
  27034. this.plotBox.height += scrollablePixelsX;
  27035. }
  27036. else {
  27037. this.clipBox.width += scrollablePixelsX;
  27038. this.plotBox.width += scrollablePixelsX;
  27039. }
  27040. corrections = {
  27041. // Corrections for right side
  27042. 1: { name: 'right', value: scrollablePixelsX }
  27043. };
  27044. }
  27045. // Currently we can only do either X or Y
  27046. }
  27047. else if (scrollableMinHeight) {
  27048. this.scrollablePixelsY = scrollablePixelsY = Math.max(0, scrollableMinHeight - this.chartHeight);
  27049. if (scrollablePixelsY) {
  27050. this.plotHeight += scrollablePixelsY;
  27051. if (this.inverted) {
  27052. this.clipBox.width += scrollablePixelsY;
  27053. this.plotBox.width += scrollablePixelsY;
  27054. }
  27055. else {
  27056. this.clipBox.height += scrollablePixelsY;
  27057. this.plotBox.height += scrollablePixelsY;
  27058. }
  27059. corrections = {
  27060. 2: { name: 'bottom', value: scrollablePixelsY }
  27061. };
  27062. }
  27063. }
  27064. if (corrections && !e.skipAxes) {
  27065. this.axes.forEach(function (axis) {
  27066. // For right and bottom axes, only fix the plot line length
  27067. if (corrections[axis.side]) {
  27068. // Get the plot lines right in getPlotLinePath,
  27069. // temporarily set it to the adjusted plot width.
  27070. axis.getPlotLinePath = function () {
  27071. var marginName = corrections[axis.side].name, correctionValue = corrections[axis.side].value,
  27072. // axis.right or axis.bottom
  27073. margin = this[marginName], path;
  27074. // Temporarily adjust
  27075. this[marginName] = margin - correctionValue;
  27076. path = H.Axis.prototype.getPlotLinePath.apply(this, arguments);
  27077. // Reset
  27078. this[marginName] = margin;
  27079. return path;
  27080. };
  27081. }
  27082. else {
  27083. // Apply the corrected plotWidth
  27084. axis.setAxisSize();
  27085. axis.setAxisTranslation();
  27086. }
  27087. });
  27088. }
  27089. }
  27090. });
  27091. addEvent(Chart, 'render', function () {
  27092. if (this.scrollablePixelsX || this.scrollablePixelsY) {
  27093. if (this.setUpScrolling) {
  27094. this.setUpScrolling();
  27095. }
  27096. this.applyFixed();
  27097. }
  27098. else if (this.fixedDiv) { // Has been in scrollable mode
  27099. this.applyFixed();
  27100. }
  27101. });
  27102. /**
  27103. * @private
  27104. * @function Highcharts.Chart#setUpScrolling
  27105. * @return {void}
  27106. */
  27107. Chart.prototype.setUpScrolling = function () {
  27108. var _this = this;
  27109. var attribs = {
  27110. WebkitOverflowScrolling: 'touch',
  27111. overflowX: 'hidden',
  27112. overflowY: 'hidden'
  27113. };
  27114. if (this.scrollablePixelsX) {
  27115. attribs.overflowX = 'auto';
  27116. }
  27117. if (this.scrollablePixelsY) {
  27118. attribs.overflowY = 'auto';
  27119. }
  27120. // Add the necessary divs to provide scrolling
  27121. this.scrollingContainer = createElement('div', {
  27122. 'className': 'highcharts-scrolling'
  27123. }, attribs, this.renderTo);
  27124. // On scroll, reset the chart position because it applies to the scrolled
  27125. // container
  27126. addEvent(this.scrollingContainer, 'scroll', function () {
  27127. if (_this.pointer) {
  27128. delete _this.pointer.chartPosition;
  27129. }
  27130. });
  27131. this.innerContainer = createElement('div', {
  27132. 'className': 'highcharts-inner-container'
  27133. }, null, this.scrollingContainer);
  27134. // Now move the container inside
  27135. this.innerContainer.appendChild(this.container);
  27136. // Don't run again
  27137. this.setUpScrolling = null;
  27138. };
  27139. /**
  27140. * These elements are moved over to the fixed renderer and stay fixed when the
  27141. * user scrolls the chart
  27142. * @private
  27143. */
  27144. Chart.prototype.moveFixedElements = function () {
  27145. var container = this.container, fixedRenderer = this.fixedRenderer, fixedSelectors = [
  27146. '.highcharts-contextbutton',
  27147. '.highcharts-credits',
  27148. '.highcharts-legend',
  27149. '.highcharts-legend-checkbox',
  27150. '.highcharts-navigator-series',
  27151. '.highcharts-navigator-xaxis',
  27152. '.highcharts-navigator-yaxis',
  27153. '.highcharts-navigator',
  27154. '.highcharts-reset-zoom',
  27155. '.highcharts-scrollbar',
  27156. '.highcharts-subtitle',
  27157. '.highcharts-title'
  27158. ], axisClass;
  27159. if (this.scrollablePixelsX && !this.inverted) {
  27160. axisClass = '.highcharts-yaxis';
  27161. }
  27162. else if (this.scrollablePixelsX && this.inverted) {
  27163. axisClass = '.highcharts-xaxis';
  27164. }
  27165. else if (this.scrollablePixelsY && !this.inverted) {
  27166. axisClass = '.highcharts-xaxis';
  27167. }
  27168. else if (this.scrollablePixelsY && this.inverted) {
  27169. axisClass = '.highcharts-yaxis';
  27170. }
  27171. fixedSelectors.push(axisClass, axisClass + '-labels');
  27172. fixedSelectors.forEach(function (className) {
  27173. [].forEach.call(container.querySelectorAll(className), function (elem) {
  27174. (elem.namespaceURI === fixedRenderer.SVG_NS ?
  27175. fixedRenderer.box :
  27176. fixedRenderer.box.parentNode).appendChild(elem);
  27177. elem.style.pointerEvents = 'auto';
  27178. });
  27179. });
  27180. };
  27181. /**
  27182. * @private
  27183. * @function Highcharts.Chart#applyFixed
  27184. * @return {void}
  27185. */
  27186. Chart.prototype.applyFixed = function () {
  27187. var _a;
  27188. var fixedRenderer, scrollableWidth, scrollableHeight, firstTime = !this.fixedDiv, scrollableOptions = this.options.chart.scrollablePlotArea;
  27189. // First render
  27190. if (firstTime) {
  27191. this.fixedDiv = createElement('div', {
  27192. className: 'highcharts-fixed'
  27193. }, {
  27194. position: 'absolute',
  27195. overflow: 'hidden',
  27196. pointerEvents: 'none',
  27197. zIndex: 2
  27198. }, null, true);
  27199. this.renderTo.insertBefore(this.fixedDiv, this.renderTo.firstChild);
  27200. this.renderTo.style.overflow = 'visible';
  27201. this.fixedRenderer = fixedRenderer = new H.Renderer(this.fixedDiv, this.chartWidth, this.chartHeight, (_a = this.options.chart) === null || _a === void 0 ? void 0 : _a.style);
  27202. // Mask
  27203. this.scrollableMask = fixedRenderer
  27204. .path()
  27205. .attr({
  27206. fill: this.options.chart.backgroundColor || '#fff',
  27207. 'fill-opacity': pick(scrollableOptions.opacity, 0.85),
  27208. zIndex: -1
  27209. })
  27210. .addClass('highcharts-scrollable-mask')
  27211. .add();
  27212. this.moveFixedElements();
  27213. addEvent(this, 'afterShowResetZoom', this.moveFixedElements);
  27214. addEvent(this, 'afterLayOutTitles', this.moveFixedElements);
  27215. }
  27216. else {
  27217. // Set the size of the fixed renderer to the visible width
  27218. this.fixedRenderer.setSize(this.chartWidth, this.chartHeight);
  27219. }
  27220. // Increase the size of the scrollable renderer and background
  27221. scrollableWidth = this.chartWidth + (this.scrollablePixelsX || 0);
  27222. scrollableHeight = this.chartHeight + (this.scrollablePixelsY || 0);
  27223. stop(this.container);
  27224. this.container.style.width = scrollableWidth + 'px';
  27225. this.container.style.height = scrollableHeight + 'px';
  27226. this.renderer.boxWrapper.attr({
  27227. width: scrollableWidth,
  27228. height: scrollableHeight,
  27229. viewBox: [0, 0, scrollableWidth, scrollableHeight].join(' ')
  27230. });
  27231. this.chartBackground.attr({
  27232. width: scrollableWidth,
  27233. height: scrollableHeight
  27234. });
  27235. this.scrollingContainer.style.height = this.chartHeight + 'px';
  27236. // Set scroll position
  27237. if (firstTime) {
  27238. if (scrollableOptions.scrollPositionX) {
  27239. this.scrollingContainer.scrollLeft =
  27240. this.scrollablePixelsX *
  27241. scrollableOptions.scrollPositionX;
  27242. }
  27243. if (scrollableOptions.scrollPositionY) {
  27244. this.scrollingContainer.scrollTop =
  27245. this.scrollablePixelsY *
  27246. scrollableOptions.scrollPositionY;
  27247. }
  27248. }
  27249. // Mask behind the left and right side
  27250. var axisOffset = this.axisOffset, maskTop = this.plotTop - axisOffset[0] - 1, maskLeft = this.plotLeft - axisOffset[3] - 1, maskBottom = this.plotTop + this.plotHeight + axisOffset[2] + 1, maskRight = this.plotLeft + this.plotWidth + axisOffset[1] + 1, maskPlotRight = this.plotLeft + this.plotWidth -
  27251. (this.scrollablePixelsX || 0), maskPlotBottom = this.plotTop + this.plotHeight -
  27252. (this.scrollablePixelsY || 0), d;
  27253. if (this.scrollablePixelsX) {
  27254. d = [
  27255. // Left side
  27256. ['M', 0, maskTop],
  27257. ['L', this.plotLeft - 1, maskTop],
  27258. ['L', this.plotLeft - 1, maskBottom],
  27259. ['L', 0, maskBottom],
  27260. ['Z'],
  27261. // Right side
  27262. ['M', maskPlotRight, maskTop],
  27263. ['L', this.chartWidth, maskTop],
  27264. ['L', this.chartWidth, maskBottom],
  27265. ['L', maskPlotRight, maskBottom],
  27266. ['Z']
  27267. ];
  27268. }
  27269. else if (this.scrollablePixelsY) {
  27270. d = [
  27271. // Top side
  27272. ['M', maskLeft, 0],
  27273. ['L', maskLeft, this.plotTop - 1],
  27274. ['L', maskRight, this.plotTop - 1],
  27275. ['L', maskRight, 0],
  27276. ['Z'],
  27277. // Bottom side
  27278. ['M', maskLeft, maskPlotBottom],
  27279. ['L', maskLeft, this.chartHeight],
  27280. ['L', maskRight, this.chartHeight],
  27281. ['L', maskRight, maskPlotBottom],
  27282. ['Z']
  27283. ];
  27284. }
  27285. else {
  27286. d = [['M', 0, 0]];
  27287. }
  27288. if (this.redrawTrigger !== 'adjustHeight') {
  27289. this.scrollableMask.attr({ d: d });
  27290. }
  27291. };
  27292. });
  27293. _registerModule(_modules, 'parts/StackingAxis.js', [_modules['parts/Utilities.js']], function (U) {
  27294. /* *
  27295. *
  27296. * (c) 2010-2020 Torstein Honsi
  27297. *
  27298. * License: www.highcharts.com/license
  27299. *
  27300. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27301. *
  27302. * */
  27303. var addEvent = U.addEvent, destroyObjectProperties = U.destroyObjectProperties, fireEvent = U.fireEvent, objectEach = U.objectEach, pick = U.pick;
  27304. /* eslint-disable valid-jsdoc */
  27305. /**
  27306. * Adds stacking support to axes.
  27307. * @private
  27308. * @class
  27309. */
  27310. var StackingAxisAdditions = /** @class */ (function () {
  27311. /* *
  27312. *
  27313. * Constructors
  27314. *
  27315. * */
  27316. function StackingAxisAdditions(axis) {
  27317. this.oldStacks = {};
  27318. this.stacks = {};
  27319. this.stacksTouched = 0;
  27320. this.axis = axis;
  27321. }
  27322. /* *
  27323. *
  27324. * Functions
  27325. *
  27326. * */
  27327. /**
  27328. * Build the stacks from top down
  27329. * @private
  27330. */
  27331. StackingAxisAdditions.prototype.buildStacks = function () {
  27332. var stacking = this;
  27333. var axis = stacking.axis;
  27334. var axisSeries = axis.series;
  27335. var reversedStacks = pick(axis.options.reversedStacks, true);
  27336. var len = axisSeries.length;
  27337. var actualSeries, i;
  27338. if (!axis.isXAxis) {
  27339. stacking.usePercentage = false;
  27340. i = len;
  27341. while (i--) {
  27342. actualSeries = axisSeries[reversedStacks ? i : len - i - 1];
  27343. actualSeries.setStackedPoints();
  27344. actualSeries.setGroupedPoints();
  27345. }
  27346. // Loop up again to compute percent and stream stack
  27347. for (i = 0; i < len; i++) {
  27348. axisSeries[i].modifyStacks();
  27349. }
  27350. fireEvent(axis, 'afterBuildStacks');
  27351. }
  27352. };
  27353. /**
  27354. * @private
  27355. */
  27356. StackingAxisAdditions.prototype.cleanStacks = function () {
  27357. var stacking = this;
  27358. var axis = stacking.axis;
  27359. var stacks;
  27360. if (!axis.isXAxis) {
  27361. if (stacking.oldStacks) {
  27362. stacks = stacking.stacks = stacking.oldStacks;
  27363. }
  27364. // reset stacks
  27365. objectEach(stacks, function (type) {
  27366. objectEach(type, function (stack) {
  27367. stack.cumulative = stack.total;
  27368. });
  27369. });
  27370. }
  27371. };
  27372. /**
  27373. * Set all the stacks to initial states and destroy unused ones.
  27374. * @private
  27375. */
  27376. StackingAxisAdditions.prototype.resetStacks = function () {
  27377. var stacking = this;
  27378. var axis = stacking.axis;
  27379. var stacks = stacking.stacks;
  27380. if (!axis.isXAxis) {
  27381. objectEach(stacks, function (type) {
  27382. objectEach(type, function (stack, key) {
  27383. // Clean up memory after point deletion (#1044, #4320)
  27384. if (stack.touched < stacking.stacksTouched) {
  27385. stack.destroy();
  27386. delete type[key];
  27387. // Reset stacks
  27388. }
  27389. else {
  27390. stack.total = null;
  27391. stack.cumulative = null;
  27392. }
  27393. });
  27394. });
  27395. }
  27396. };
  27397. /**
  27398. * @private
  27399. */
  27400. StackingAxisAdditions.prototype.renderStackTotals = function () {
  27401. var stacking = this;
  27402. var axis = stacking.axis;
  27403. var chart = axis.chart;
  27404. var renderer = chart.renderer;
  27405. var stacks = stacking.stacks;
  27406. var stackTotalGroup = stacking.stackTotalGroup = (stacking.stackTotalGroup ||
  27407. renderer
  27408. .g('stack-labels')
  27409. .attr({
  27410. visibility: 'visible',
  27411. zIndex: 6
  27412. })
  27413. .add());
  27414. // plotLeft/Top will change when y axis gets wider so we need to
  27415. // translate the stackTotalGroup at every render call. See bug #506
  27416. // and #516
  27417. stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
  27418. // Render each stack total
  27419. objectEach(stacks, function (type) {
  27420. objectEach(type, function (stack) {
  27421. stack.render(stackTotalGroup);
  27422. });
  27423. });
  27424. };
  27425. return StackingAxisAdditions;
  27426. }());
  27427. /**
  27428. * Axis with stacking support.
  27429. * @private
  27430. * @class
  27431. */
  27432. var StackingAxis = /** @class */ (function () {
  27433. function StackingAxis() {
  27434. }
  27435. /* *
  27436. *
  27437. * Static Functions
  27438. *
  27439. * */
  27440. /**
  27441. * Extends axis with stacking support.
  27442. * @private
  27443. */
  27444. StackingAxis.compose = function (AxisClass) {
  27445. var axisProto = AxisClass.prototype;
  27446. addEvent(AxisClass, 'init', StackingAxis.onInit);
  27447. addEvent(AxisClass, 'destroy', StackingAxis.onDestroy);
  27448. };
  27449. /**
  27450. * @private
  27451. */
  27452. StackingAxis.onDestroy = function () {
  27453. var stacking = this.stacking;
  27454. if (!stacking) {
  27455. return;
  27456. }
  27457. var stacks = stacking.stacks;
  27458. // Destroy each stack total
  27459. objectEach(stacks, function (stack, stackKey) {
  27460. destroyObjectProperties(stack);
  27461. stacks[stackKey] = null;
  27462. });
  27463. if (stacking &&
  27464. stacking.stackTotalGroup) {
  27465. stacking.stackTotalGroup.destroy();
  27466. }
  27467. };
  27468. /**
  27469. * @private
  27470. */
  27471. StackingAxis.onInit = function () {
  27472. var axis = this;
  27473. if (!axis.stacking) {
  27474. axis.stacking = new StackingAxisAdditions(axis);
  27475. }
  27476. };
  27477. return StackingAxis;
  27478. }());
  27479. return StackingAxis;
  27480. });
  27481. _registerModule(_modules, 'mixins/legend-symbol.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  27482. /* *
  27483. *
  27484. * (c) 2010-2020 Torstein Honsi
  27485. *
  27486. * License: www.highcharts.com/license
  27487. *
  27488. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27489. *
  27490. * */
  27491. var merge = U.merge, pick = U.pick;
  27492. /* eslint-disable valid-jsdoc */
  27493. /**
  27494. * Legend symbol mixin.
  27495. *
  27496. * @private
  27497. * @mixin Highcharts.LegendSymbolMixin
  27498. */
  27499. H.LegendSymbolMixin = {
  27500. /**
  27501. * Get the series' symbol in the legend
  27502. *
  27503. * @private
  27504. * @function Highcharts.LegendSymbolMixin.drawRectangle
  27505. *
  27506. * @param {Highcharts.Legend} legend
  27507. * The legend object
  27508. *
  27509. * @param {Highcharts.Point|Highcharts.Series} item
  27510. * The series (this) or point
  27511. */
  27512. drawRectangle: function (legend, item) {
  27513. var options = legend.options, symbolHeight = legend.symbolHeight, square = options.squareSymbol, symbolWidth = square ? symbolHeight : legend.symbolWidth;
  27514. item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, // #3988
  27515. symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2))
  27516. .addClass('highcharts-point')
  27517. .attr({
  27518. zIndex: 3
  27519. }).add(item.legendGroup);
  27520. },
  27521. /**
  27522. * Get the series' symbol in the legend. This method should be overridable
  27523. * to create custom symbols through
  27524. * Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
  27525. *
  27526. * @private
  27527. * @function Highcharts.LegendSymbolMixin.drawLineMarker
  27528. *
  27529. * @param {Highcharts.Legend} legend
  27530. * The legend object.
  27531. */
  27532. drawLineMarker: function (legend) {
  27533. var options = this.options, markerOptions = options.marker, radius, legendSymbol, symbolWidth = legend.symbolWidth, symbolHeight = legend.symbolHeight, generalRadius = symbolHeight / 2, renderer = this.chart.renderer, legendItemGroup = this.legendGroup, verticalCenter = legend.baseline -
  27534. Math.round(legend.fontMetrics.b * 0.3), attr = {};
  27535. // Draw the line
  27536. if (!this.chart.styledMode) {
  27537. attr = {
  27538. 'stroke-width': options.lineWidth || 0
  27539. };
  27540. if (options.dashStyle) {
  27541. attr.dashstyle = options.dashStyle;
  27542. }
  27543. }
  27544. this.legendLine = renderer
  27545. .path([
  27546. 'M',
  27547. 0,
  27548. verticalCenter,
  27549. 'L',
  27550. symbolWidth,
  27551. verticalCenter
  27552. ])
  27553. .addClass('highcharts-graph')
  27554. .attr(attr)
  27555. .add(legendItemGroup);
  27556. // Draw the marker
  27557. if (markerOptions && markerOptions.enabled !== false && symbolWidth) {
  27558. // Do not allow the marker to be larger than the symbolHeight
  27559. radius = Math.min(pick(markerOptions.radius, generalRadius), generalRadius);
  27560. // Restrict symbol markers size
  27561. if (this.symbol.indexOf('url') === 0) {
  27562. markerOptions = merge(markerOptions, {
  27563. width: symbolHeight,
  27564. height: symbolHeight
  27565. });
  27566. radius = 0;
  27567. }
  27568. this.legendSymbol = legendSymbol = renderer.symbol(this.symbol, (symbolWidth / 2) - radius, verticalCenter - radius, 2 * radius, 2 * radius, markerOptions)
  27569. .addClass('highcharts-point')
  27570. .add(legendItemGroup);
  27571. legendSymbol.isMarker = true;
  27572. }
  27573. }
  27574. };
  27575. return H.LegendSymbolMixin;
  27576. });
  27577. _registerModule(_modules, 'parts/Point.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  27578. /* *
  27579. *
  27580. * (c) 2010-2020 Torstein Honsi
  27581. *
  27582. * License: www.highcharts.com/license
  27583. *
  27584. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27585. *
  27586. * */
  27587. var animObject = U.animObject, defined = U.defined, erase = U.erase, extend = U.extend, fireEvent = U.fireEvent, format = U.format, getNestedProperty = U.getNestedProperty, isArray = U.isArray, isNumber = U.isNumber, isObject = U.isObject, syncTimeout = U.syncTimeout, pick = U.pick, removeEvent = U.removeEvent, uniqueKey = U.uniqueKey;
  27588. /**
  27589. * Function callback when a series point is clicked. Return false to cancel the
  27590. * action.
  27591. *
  27592. * @callback Highcharts.PointClickCallbackFunction
  27593. *
  27594. * @param {Highcharts.Point} this
  27595. * The point where the event occured.
  27596. *
  27597. * @param {Highcharts.PointClickEventObject} event
  27598. * Event arguments.
  27599. */
  27600. /**
  27601. * Common information for a click event on a series point.
  27602. *
  27603. * @interface Highcharts.PointClickEventObject
  27604. * @extends Highcharts.PointerEventObject
  27605. */ /**
  27606. * Clicked point.
  27607. * @name Highcharts.PointClickEventObject#point
  27608. * @type {Highcharts.Point}
  27609. */
  27610. /**
  27611. * Configuration hash for the data label and tooltip formatters.
  27612. *
  27613. * @interface Highcharts.PointLabelObject
  27614. */ /**
  27615. * The point's current color.
  27616. * @name Highcharts.PointLabelObject#color
  27617. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  27618. */ /**
  27619. * The point's current color index, used in styled mode instead of `color`. The
  27620. * color index is inserted in class names used for styling.
  27621. * @name Highcharts.PointLabelObject#colorIndex
  27622. * @type {number}
  27623. */ /**
  27624. * The name of the related point.
  27625. * @name Highcharts.PointLabelObject#key
  27626. * @type {string|undefined}
  27627. */ /**
  27628. * The percentage for related points in a stacked series or pies.
  27629. * @name Highcharts.PointLabelObject#percentage
  27630. * @type {number}
  27631. */ /**
  27632. * The related point. The point name, if defined, is available through
  27633. * `this.point.name`.
  27634. * @name Highcharts.PointLabelObject#point
  27635. * @type {Highcharts.Point}
  27636. */ /**
  27637. * The related series. The series name is available through `this.series.name`.
  27638. * @name Highcharts.PointLabelObject#series
  27639. * @type {Highcharts.Series}
  27640. */ /**
  27641. * The total of values in either a stack for stacked series, or a pie in a pie
  27642. * series.
  27643. * @name Highcharts.PointLabelObject#total
  27644. * @type {number|undefined}
  27645. */ /**
  27646. * For categorized axes this property holds the category name for the point. For
  27647. * other axes it holds the X value.
  27648. * @name Highcharts.PointLabelObject#x
  27649. * @type {number|string|undefined}
  27650. */ /**
  27651. * The y value of the point.
  27652. * @name Highcharts.PointLabelObject#y
  27653. * @type {number|undefined}
  27654. */
  27655. /**
  27656. * Gets fired when the mouse leaves the area close to the point.
  27657. *
  27658. * @callback Highcharts.PointMouseOutCallbackFunction
  27659. *
  27660. * @param {Highcharts.Point} this
  27661. * Point where the event occured.
  27662. *
  27663. * @param {global.PointerEvent} event
  27664. * Event that occured.
  27665. */
  27666. /**
  27667. * Gets fired when the mouse enters the area close to the point.
  27668. *
  27669. * @callback Highcharts.PointMouseOverCallbackFunction
  27670. *
  27671. * @param {Highcharts.Point} this
  27672. * Point where the event occured.
  27673. *
  27674. * @param {global.Event} event
  27675. * Event that occured.
  27676. */
  27677. /**
  27678. * The generic point options for all series.
  27679. *
  27680. * In TypeScript you have to extend `PointOptionsObject` with an additional
  27681. * declaration to allow custom data options:
  27682. *
  27683. * ```
  27684. * declare interface PointOptionsObject {
  27685. * customProperty: string;
  27686. * }
  27687. * ```
  27688. *
  27689. * @interface Highcharts.PointOptionsObject
  27690. */
  27691. /**
  27692. * Possible option types for a data point.
  27693. *
  27694. * @typedef {number|string|Array<(number|string)>|Highcharts.PointOptionsObject|null} Highcharts.PointOptionsType
  27695. */
  27696. /**
  27697. * Gets fired when the point is removed using the `.remove()` method.
  27698. *
  27699. * @callback Highcharts.PointRemoveCallbackFunction
  27700. *
  27701. * @param {Highcharts.Point} this
  27702. * Point where the event occured.
  27703. *
  27704. * @param {global.Event} event
  27705. * Event that occured.
  27706. */
  27707. /**
  27708. * Possible key values for the point state options.
  27709. *
  27710. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.PointStateValue
  27711. */
  27712. /**
  27713. * Gets fired when the point is updated programmatically through the `.update()`
  27714. * method.
  27715. *
  27716. * @callback Highcharts.PointUpdateCallbackFunction
  27717. *
  27718. * @param {Highcharts.Point} this
  27719. * Point where the event occured.
  27720. *
  27721. * @param {Highcharts.PointUpdateEventObject} event
  27722. * Event that occured.
  27723. */
  27724. /**
  27725. * Information about the update event.
  27726. *
  27727. * @interface Highcharts.PointUpdateEventObject
  27728. * @extends global.Event
  27729. */ /**
  27730. * Options data of the update event.
  27731. * @name Highcharts.PointUpdateEventObject#options
  27732. * @type {Highcharts.PointOptionsType}
  27733. */
  27734. ''; // detach doclet above
  27735. /* eslint-disable no-invalid-this, valid-jsdoc */
  27736. /**
  27737. * The Point object. The point objects are generated from the `series.data`
  27738. * configuration objects or raw numbers. They can be accessed from the
  27739. * `Series.points` array. Other ways to instantiate points are through {@link
  27740. * Highcharts.Series#addPoint} or {@link Highcharts.Series#setData}.
  27741. *
  27742. * @class
  27743. * @name Highcharts.Point
  27744. */
  27745. var Point = /** @class */ (function () {
  27746. function Point() {
  27747. /* *
  27748. *
  27749. * Properties
  27750. *
  27751. * */
  27752. /**
  27753. * For categorized axes this property holds the category name for the
  27754. * point. For other axes it holds the X value.
  27755. *
  27756. * @name Highcharts.Point#category
  27757. * @type {string}
  27758. */
  27759. this.category = void 0;
  27760. /**
  27761. * The point's current color index, used in styled mode instead of
  27762. * `color`. The color index is inserted in class names used for styling.
  27763. *
  27764. * @name Highcharts.Point#colorIndex
  27765. * @type {number}
  27766. */
  27767. this.colorIndex = void 0;
  27768. this.formatPrefix = 'point';
  27769. this.id = void 0;
  27770. this.isNull = false;
  27771. /**
  27772. * The name of the point. The name can be given as the first position of the
  27773. * point configuration array, or as a `name` property in the configuration:
  27774. *
  27775. * @example
  27776. * // Array config
  27777. * data: [
  27778. * ['John', 1],
  27779. * ['Jane', 2]
  27780. * ]
  27781. *
  27782. * // Object config
  27783. * data: [{
  27784. * name: 'John',
  27785. * y: 1
  27786. * }, {
  27787. * name: 'Jane',
  27788. * y: 2
  27789. * }]
  27790. *
  27791. * @name Highcharts.Point#name
  27792. * @type {string}
  27793. */
  27794. this.name = void 0;
  27795. /**
  27796. * The point's options as applied in the initial configuration, or
  27797. * extended through `Point.update`.
  27798. *
  27799. * In TypeScript you have to extend `PointOptionsObject` via an
  27800. * additional interface to allow custom data options:
  27801. *
  27802. * ```
  27803. * declare interface PointOptionsObject {
  27804. * customProperty: string;
  27805. * }
  27806. * ```
  27807. *
  27808. * @name Highcharts.Point#options
  27809. * @type {Highcharts.PointOptionsObject}
  27810. */
  27811. this.options = void 0;
  27812. /**
  27813. * The percentage for points in a stacked series or pies.
  27814. *
  27815. * @name Highcharts.Point#percentage
  27816. * @type {number|undefined}
  27817. */
  27818. this.percentage = void 0;
  27819. this.selected = false;
  27820. /**
  27821. * The series object associated with the point.
  27822. *
  27823. * @name Highcharts.Point#series
  27824. * @type {Highcharts.Series}
  27825. */
  27826. this.series = void 0;
  27827. /**
  27828. * The total of values in either a stack for stacked series, or a pie in a
  27829. * pie series.
  27830. *
  27831. * @name Highcharts.Point#total
  27832. * @type {number|undefined}
  27833. */
  27834. this.total = void 0;
  27835. /**
  27836. * For certain series types, like pie charts, where individual points can
  27837. * be shown or hidden.
  27838. *
  27839. * @name Highcharts.Point#visible
  27840. * @type {boolean}
  27841. * @default true
  27842. */
  27843. this.visible = true;
  27844. this.x = void 0;
  27845. }
  27846. /* *
  27847. *
  27848. * Functions
  27849. *
  27850. * */
  27851. /**
  27852. * Animate SVG elements associated with the point.
  27853. *
  27854. * @private
  27855. * @function Highcharts.Point#animateBeforeDestroy
  27856. */
  27857. Point.prototype.animateBeforeDestroy = function () {
  27858. var point = this, animateParams = { x: point.startXPos, opacity: 0 }, isDataLabel, graphicalProps = point.getGraphicalProps();
  27859. graphicalProps.singular.forEach(function (prop) {
  27860. isDataLabel = prop === 'dataLabel';
  27861. point[prop] = point[prop].animate(isDataLabel ? {
  27862. x: point[prop].startXPos,
  27863. y: point[prop].startYPos,
  27864. opacity: 0
  27865. } : animateParams);
  27866. });
  27867. graphicalProps.plural.forEach(function (plural) {
  27868. point[plural].forEach(function (item) {
  27869. if (item.element) {
  27870. item.animate(extend({ x: point.startXPos }, (item.startYPos ? {
  27871. x: item.startXPos,
  27872. y: item.startYPos
  27873. } : {})));
  27874. }
  27875. });
  27876. });
  27877. };
  27878. /**
  27879. * Apply the options containing the x and y data and possible some extra
  27880. * properties. Called on point init or from point.update.
  27881. *
  27882. * @private
  27883. * @function Highcharts.Point#applyOptions
  27884. *
  27885. * @param {Highcharts.PointOptionsType} options
  27886. * The point options as defined in series.data.
  27887. *
  27888. * @param {number} [x]
  27889. * Optionally, the x value.
  27890. *
  27891. * @return {Highcharts.Point}
  27892. * The Point instance.
  27893. */
  27894. Point.prototype.applyOptions = function (options, x) {
  27895. var point = this, series = point.series, pointValKey = series.options.pointValKey || series.pointValKey;
  27896. options = Point.prototype.optionsToObject.call(this, options);
  27897. // copy options directly to point
  27898. extend(point, options);
  27899. point.options = point.options ? extend(point.options, options) : options;
  27900. // Since options are copied into the Point instance, some accidental
  27901. // options must be shielded (#5681)
  27902. if (options.group) {
  27903. delete point.group;
  27904. }
  27905. if (options.dataLabels) {
  27906. delete point.dataLabels;
  27907. }
  27908. /**
  27909. * The y value of the point.
  27910. * @name Highcharts.Point#y
  27911. * @type {number|undefined}
  27912. */
  27913. // For higher dimension series types. For instance, for ranges, point.y
  27914. // is mapped to point.low.
  27915. if (pointValKey) {
  27916. point.y = Point.prototype.getNestedProperty.call(point, pointValKey);
  27917. }
  27918. point.isNull = pick(point.isValid && !point.isValid(), point.x === null || !isNumber(point.y)); // #3571, check for NaN
  27919. point.formatPrefix = point.isNull ? 'null' : 'point'; // #9233, #10874
  27920. // The point is initially selected by options (#5777)
  27921. if (point.selected) {
  27922. point.state = 'select';
  27923. }
  27924. /**
  27925. * The x value of the point.
  27926. * @name Highcharts.Point#x
  27927. * @type {number}
  27928. */
  27929. // If no x is set by now, get auto incremented value. All points must
  27930. // have an x value, however the y value can be null to create a gap in
  27931. // the series
  27932. if ('name' in point &&
  27933. typeof x === 'undefined' &&
  27934. series.xAxis &&
  27935. series.xAxis.hasNames) {
  27936. point.x = series.xAxis.nameToX(point);
  27937. }
  27938. if (typeof point.x === 'undefined' && series) {
  27939. if (typeof x === 'undefined') {
  27940. point.x = series.autoIncrement(point);
  27941. }
  27942. else {
  27943. point.x = x;
  27944. }
  27945. }
  27946. return point;
  27947. };
  27948. /**
  27949. * Destroy a point to clear memory. Its reference still stays in
  27950. * `series.data`.
  27951. *
  27952. * @private
  27953. * @function Highcharts.Point#destroy
  27954. */
  27955. Point.prototype.destroy = function () {
  27956. var point = this, series = point.series, chart = series.chart, dataSorting = series.options.dataSorting, hoverPoints = chart.hoverPoints, globalAnimation = point.series.chart.renderer.globalAnimation, animation = animObject(globalAnimation), prop;
  27957. /**
  27958. * Allow to call after animation.
  27959. * @private
  27960. */
  27961. function destroyPoint() {
  27962. // Remove all events and elements
  27963. if (point.graphic || point.dataLabel || point.dataLabels) {
  27964. removeEvent(point);
  27965. point.destroyElements();
  27966. }
  27967. for (prop in point) { // eslint-disable-line guard-for-in
  27968. point[prop] = null;
  27969. }
  27970. }
  27971. if (point.legendItem) { // pies have legend items
  27972. chart.legend.destroyItem(point);
  27973. }
  27974. if (hoverPoints) {
  27975. point.setState();
  27976. erase(hoverPoints, point);
  27977. if (!hoverPoints.length) {
  27978. chart.hoverPoints = null;
  27979. }
  27980. }
  27981. if (point === chart.hoverPoint) {
  27982. point.onMouseOut();
  27983. }
  27984. // Remove properties after animation
  27985. if (!dataSorting || !dataSorting.enabled) {
  27986. destroyPoint();
  27987. }
  27988. else {
  27989. this.animateBeforeDestroy();
  27990. syncTimeout(destroyPoint, animation.duration);
  27991. }
  27992. chart.pointCount--;
  27993. };
  27994. /**
  27995. * Destroy SVG elements associated with the point.
  27996. *
  27997. * @private
  27998. * @function Highcharts.Point#destroyElements
  27999. * @param {Highcharts.Dictionary<number>} [kinds]
  28000. */
  28001. Point.prototype.destroyElements = function (kinds) {
  28002. var point = this, props = point.getGraphicalProps(kinds);
  28003. props.singular.forEach(function (prop) {
  28004. point[prop] = point[prop].destroy();
  28005. });
  28006. props.plural.forEach(function (plural) {
  28007. point[plural].forEach(function (item) {
  28008. if (item.element) {
  28009. item.destroy();
  28010. }
  28011. });
  28012. delete point[plural];
  28013. });
  28014. };
  28015. /**
  28016. * Fire an event on the Point object.
  28017. *
  28018. * @private
  28019. * @function Highcharts.Point#firePointEvent
  28020. *
  28021. * @param {string} eventType
  28022. * Type of the event.
  28023. *
  28024. * @param {Highcharts.Dictionary<any>|Event} [eventArgs]
  28025. * Additional event arguments.
  28026. *
  28027. * @param {Highcharts.EventCallbackFunction<Highcharts.Point>|Function} [defaultFunction]
  28028. * Default event handler.
  28029. *
  28030. * @fires Highcharts.Point#event:*
  28031. */
  28032. Point.prototype.firePointEvent = function (eventType, eventArgs, defaultFunction) {
  28033. var point = this, series = this.series, seriesOptions = series.options;
  28034. // load event handlers on demand to save time on mouseover/out
  28035. if (seriesOptions.point.events[eventType] ||
  28036. (point.options &&
  28037. point.options.events &&
  28038. point.options.events[eventType])) {
  28039. point.importEvents();
  28040. }
  28041. // add default handler if in selection mode
  28042. if (eventType === 'click' && seriesOptions.allowPointSelect) {
  28043. defaultFunction = function (event) {
  28044. // Control key is for Windows, meta (= Cmd key) for Mac, Shift
  28045. // for Opera.
  28046. if (point.select) { // #2911
  28047. point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
  28048. }
  28049. };
  28050. }
  28051. fireEvent(point, eventType, eventArgs, defaultFunction);
  28052. };
  28053. /**
  28054. * Get the CSS class names for individual points. Used internally where the
  28055. * returned value is set on every point.
  28056. *
  28057. * @function Highcharts.Point#getClassName
  28058. *
  28059. * @return {string}
  28060. * The class names.
  28061. */
  28062. Point.prototype.getClassName = function () {
  28063. var point = this;
  28064. return 'highcharts-point' +
  28065. (point.selected ? ' highcharts-point-select' : '') +
  28066. (point.negative ? ' highcharts-negative' : '') +
  28067. (point.isNull ? ' highcharts-null-point' : '') +
  28068. (typeof point.colorIndex !== 'undefined' ?
  28069. ' highcharts-color-' + point.colorIndex : '') +
  28070. (point.options.className ? ' ' + point.options.className : '') +
  28071. (point.zone && point.zone.className ? ' ' +
  28072. point.zone.className.replace('highcharts-negative', '') : '');
  28073. };
  28074. /**
  28075. * Get props of all existing graphical point elements.
  28076. *
  28077. * @private
  28078. * @function Highcharts.Point#getGraphicalProps
  28079. * @param {Highcharts.Dictionary<number>} [kinds]
  28080. * @return {Highcharts.PointGraphicalProps}
  28081. */
  28082. Point.prototype.getGraphicalProps = function (kinds) {
  28083. var point = this, props = [], prop, i, graphicalProps = { singular: [], plural: [] };
  28084. kinds = kinds || { graphic: 1, dataLabel: 1 };
  28085. if (kinds.graphic) {
  28086. props.push('graphic', 'shadowGroup');
  28087. }
  28088. if (kinds.dataLabel) {
  28089. props.push('dataLabel', 'dataLabelUpper', 'connector');
  28090. }
  28091. i = props.length;
  28092. while (i--) {
  28093. prop = props[i];
  28094. if (point[prop]) {
  28095. graphicalProps.singular.push(prop);
  28096. }
  28097. }
  28098. ['dataLabel', 'connector'].forEach(function (prop) {
  28099. var plural = prop + 's';
  28100. if (kinds[prop] && point[plural]) {
  28101. graphicalProps.plural.push(plural);
  28102. }
  28103. });
  28104. return graphicalProps;
  28105. };
  28106. /**
  28107. * Return the configuration hash needed for the data label and tooltip
  28108. * formatters.
  28109. *
  28110. * @function Highcharts.Point#getLabelConfig
  28111. *
  28112. * @return {Highcharts.PointLabelObject}
  28113. * Abstract object used in formatters and formats.
  28114. */
  28115. Point.prototype.getLabelConfig = function () {
  28116. return {
  28117. x: this.category,
  28118. y: this.y,
  28119. color: this.color,
  28120. colorIndex: this.colorIndex,
  28121. key: this.name || this.category,
  28122. series: this.series,
  28123. point: this,
  28124. percentage: this.percentage,
  28125. total: this.total || this.stackTotal
  28126. };
  28127. };
  28128. /**
  28129. * Returns the value of the point property for a given value.
  28130. * @private
  28131. */
  28132. Point.prototype.getNestedProperty = function (key) {
  28133. if (!key) {
  28134. return;
  28135. }
  28136. if (key.indexOf('custom.') === 0) {
  28137. return getNestedProperty(key, this.options);
  28138. }
  28139. return this[key];
  28140. };
  28141. /**
  28142. * In a series with `zones`, return the zone that the point belongs to.
  28143. *
  28144. * @function Highcharts.Point#getZone
  28145. *
  28146. * @return {Highcharts.SeriesZonesOptionsObject}
  28147. * The zone item.
  28148. */
  28149. Point.prototype.getZone = function () {
  28150. var series = this.series, zones = series.zones, zoneAxis = series.zoneAxis || 'y', i = 0, zone;
  28151. zone = zones[i];
  28152. while (this[zoneAxis] >= zone.value) {
  28153. zone = zones[++i];
  28154. }
  28155. // For resetting or reusing the point (#8100)
  28156. if (!this.nonZonedColor) {
  28157. this.nonZonedColor = this.color;
  28158. }
  28159. if (zone && zone.color && !this.options.color) {
  28160. this.color = zone.color;
  28161. }
  28162. else {
  28163. this.color = this.nonZonedColor;
  28164. }
  28165. return zone;
  28166. };
  28167. /**
  28168. * Utility to check if point has new shape type. Used in column series and
  28169. * all others that are based on column series.
  28170. *
  28171. * @return boolean|undefined
  28172. */
  28173. Point.prototype.hasNewShapeType = function () {
  28174. var point = this;
  28175. var oldShapeType = point.graphic &&
  28176. (point.graphic.symbolName || point.graphic.element.nodeName);
  28177. return oldShapeType !== this.shapeType;
  28178. };
  28179. /**
  28180. * Initialize the point. Called internally based on the `series.data`
  28181. * option.
  28182. *
  28183. * @function Highcharts.Point#init
  28184. *
  28185. * @param {Highcharts.Series} series
  28186. * The series object containing this point.
  28187. *
  28188. * @param {Highcharts.PointOptionsType} options
  28189. * The data in either number, array or object format.
  28190. *
  28191. * @param {number} [x]
  28192. * Optionally, the X value of the point.
  28193. *
  28194. * @return {Highcharts.Point}
  28195. * The Point instance.
  28196. *
  28197. * @fires Highcharts.Point#event:afterInit
  28198. */
  28199. Point.prototype.init = function (series, options, x) {
  28200. this.series = series;
  28201. this.applyOptions(options, x);
  28202. // Add a unique ID to the point if none is assigned
  28203. this.id = defined(this.id) ? this.id : uniqueKey();
  28204. this.resolveColor();
  28205. series.chart.pointCount++;
  28206. fireEvent(this, 'afterInit');
  28207. return this;
  28208. };
  28209. /**
  28210. * Transform number or array configs into objects. Also called for object
  28211. * configs. Used internally to unify the different configuration formats for
  28212. * points. For example, a simple number `10` in a line series will be
  28213. * transformed to `{ y: 10 }`, and an array config like `[1, 10]` in a
  28214. * scatter series will be transformed to `{ x: 1, y: 10 }`.
  28215. *
  28216. * @function Highcharts.Point#optionsToObject
  28217. *
  28218. * @param {Highcharts.PointOptionsType} options
  28219. * The input option.
  28220. *
  28221. * @return {Highcharts.Dictionary<*>}
  28222. * Transformed options.
  28223. */
  28224. Point.prototype.optionsToObject = function (options) {
  28225. var ret = {}, series = this.series, keys = series.options.keys, pointArrayMap = keys || series.pointArrayMap || ['y'], valueCount = pointArrayMap.length, firstItemType, i = 0, j = 0;
  28226. if (isNumber(options) || options === null) {
  28227. ret[pointArrayMap[0]] = options;
  28228. }
  28229. else if (isArray(options)) {
  28230. // with leading x value
  28231. if (!keys && options.length > valueCount) {
  28232. firstItemType = typeof options[0];
  28233. if (firstItemType === 'string') {
  28234. ret.name = options[0];
  28235. }
  28236. else if (firstItemType === 'number') {
  28237. ret.x = options[0];
  28238. }
  28239. i++;
  28240. }
  28241. while (j < valueCount) {
  28242. // Skip undefined positions for keys
  28243. if (!keys || typeof options[i] !== 'undefined') {
  28244. if (pointArrayMap[j].indexOf('.') > 0) {
  28245. // Handle nested keys, e.g. ['color.pattern.image']
  28246. // Avoid function call unless necessary.
  28247. Point.prototype.setNestedProperty(ret, options[i], pointArrayMap[j]);
  28248. }
  28249. else {
  28250. ret[pointArrayMap[j]] = options[i];
  28251. }
  28252. }
  28253. i++;
  28254. j++;
  28255. }
  28256. }
  28257. else if (typeof options === 'object') {
  28258. ret = options;
  28259. // This is the fastest way to detect if there are individual point
  28260. // dataLabels that need to be considered in drawDataLabels. These
  28261. // can only occur in object configs.
  28262. if (options.dataLabels) {
  28263. series._hasPointLabels = true;
  28264. }
  28265. // Same approach as above for markers
  28266. if (options.marker) {
  28267. series._hasPointMarkers = true;
  28268. }
  28269. }
  28270. return ret;
  28271. };
  28272. /**
  28273. * @private
  28274. * @function Highcharts.Point#resolveColor
  28275. * @return {void}
  28276. */
  28277. Point.prototype.resolveColor = function () {
  28278. var series = this.series, colors, optionsChart = series.chart.options.chart, colorCount = optionsChart.colorCount, styledMode = series.chart.styledMode, colorIndex;
  28279. // remove points nonZonedColor for later recalculation
  28280. delete this.nonZonedColor;
  28281. /**
  28282. * The point's current color.
  28283. *
  28284. * @name Highcharts.Point#color
  28285. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  28286. */
  28287. if (!styledMode && !this.options.color) {
  28288. this.color = series.color; // #3445
  28289. }
  28290. if (series.options.colorByPoint) {
  28291. if (!styledMode) {
  28292. colors = series.options.colors || series.chart.options.colors;
  28293. this.color = this.color || colors[series.colorCounter];
  28294. colorCount = colors.length;
  28295. }
  28296. colorIndex = series.colorCounter;
  28297. series.colorCounter++;
  28298. // loop back to zero
  28299. if (series.colorCounter === colorCount) {
  28300. series.colorCounter = 0;
  28301. }
  28302. }
  28303. else {
  28304. colorIndex = series.colorIndex;
  28305. }
  28306. this.colorIndex = pick(this.colorIndex, colorIndex);
  28307. };
  28308. /**
  28309. * Set a value in an object, on the property defined by key. The key
  28310. * supports nested properties using dot notation. The function modifies the
  28311. * input object and does not make a copy.
  28312. *
  28313. * @function Highcharts.Point#setNestedProperty<T>
  28314. *
  28315. * @param {T} object
  28316. * The object to set the value on.
  28317. *
  28318. * @param {*} value
  28319. * The value to set.
  28320. *
  28321. * @param {string} key
  28322. * Key to the property to set.
  28323. *
  28324. * @return {T}
  28325. * The modified object.
  28326. */
  28327. Point.prototype.setNestedProperty = function (object, value, key) {
  28328. var nestedKeys = key.split('.');
  28329. nestedKeys.reduce(function (result, key, i, arr) {
  28330. var isLastKey = arr.length - 1 === i;
  28331. result[key] = (isLastKey ?
  28332. value :
  28333. isObject(result[key], true) ?
  28334. result[key] :
  28335. {});
  28336. return result[key];
  28337. }, object);
  28338. return object;
  28339. };
  28340. /**
  28341. * Extendable method for formatting each point's tooltip line.
  28342. *
  28343. * @function Highcharts.Point#tooltipFormatter
  28344. *
  28345. * @param {string} pointFormat
  28346. * The point format.
  28347. *
  28348. * @return {string}
  28349. * A string to be concatenated in to the common tooltip text.
  28350. */
  28351. Point.prototype.tooltipFormatter = function (pointFormat) {
  28352. // Insert options for valueDecimals, valuePrefix, and valueSuffix
  28353. var series = this.series, seriesTooltipOptions = series.tooltipOptions, valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''), valuePrefix = seriesTooltipOptions.valuePrefix || '', valueSuffix = seriesTooltipOptions.valueSuffix || '';
  28354. // Replace default point style with class name
  28355. if (series.chart.styledMode) {
  28356. pointFormat =
  28357. series.chart.tooltip.styledModeFormat(pointFormat);
  28358. }
  28359. // Loop over the point array map and replace unformatted values with
  28360. // sprintf formatting markup
  28361. (series.pointArrayMap || ['y']).forEach(function (key) {
  28362. key = '{point.' + key; // without the closing bracket
  28363. if (valuePrefix || valueSuffix) {
  28364. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), valuePrefix + key + '}' + valueSuffix);
  28365. }
  28366. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), key + ':,.' + valueDecimals + 'f}');
  28367. });
  28368. return format(pointFormat, {
  28369. point: this,
  28370. series: this.series
  28371. }, series.chart);
  28372. };
  28373. return Point;
  28374. }());
  28375. H.Point = Point;
  28376. return Point;
  28377. });
  28378. _registerModule(_modules, 'parts/Series.js', [_modules['parts/Globals.js'], _modules['mixins/legend-symbol.js'], _modules['parts/Options.js'], _modules['parts/Point.js'], _modules['parts/SVGElement.js'], _modules['parts/Utilities.js']], function (H, LegendSymbolMixin, O, Point, SVGElement, U) {
  28379. /* *
  28380. *
  28381. * (c) 2010-2020 Torstein Honsi
  28382. *
  28383. * License: www.highcharts.com/license
  28384. *
  28385. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  28386. *
  28387. * */
  28388. var defaultOptions = O.defaultOptions;
  28389. var addEvent = U.addEvent, animObject = U.animObject, arrayMax = U.arrayMax, arrayMin = U.arrayMin, clamp = U.clamp, correctFloat = U.correctFloat, defined = U.defined, erase = U.erase, error = U.error, extend = U.extend, find = U.find, fireEvent = U.fireEvent, getNestedProperty = U.getNestedProperty, isArray = U.isArray, isFunction = U.isFunction, isNumber = U.isNumber, isString = U.isString, merge = U.merge, objectEach = U.objectEach, pick = U.pick, removeEvent = U.removeEvent, seriesType = U.seriesType, splat = U.splat, syncTimeout = U.syncTimeout;
  28390. /**
  28391. * This is a placeholder type of the possible series options for
  28392. * [Highcharts](../highcharts/series), [Highstock](../highstock/series),
  28393. * [Highmaps](../highmaps/series), and [Gantt](../gantt/series).
  28394. *
  28395. * In TypeScript is this dynamically generated to reference all possible types
  28396. * of series options.
  28397. *
  28398. * @ignore-declaration
  28399. * @typedef {Highcharts.SeriesOptions|Highcharts.Dictionary<*>} Highcharts.SeriesOptionsType
  28400. */
  28401. /**
  28402. * Options for `dataSorting`.
  28403. *
  28404. * @interface Highcharts.DataSortingOptionsObject
  28405. * @since 8.0.0
  28406. */ /**
  28407. * Enable or disable data sorting for the series.
  28408. * @name Highcharts.DataSortingOptionsObject#enabled
  28409. * @type {boolean|undefined}
  28410. */ /**
  28411. * Whether to allow matching points by name in an update.
  28412. * @name Highcharts.DataSortingOptionsObject#matchByName
  28413. * @type {boolean|undefined}
  28414. */ /**
  28415. * Determines what data value should be used to sort by.
  28416. * @name Highcharts.DataSortingOptionsObject#sortKey
  28417. * @type {string|undefined}
  28418. */
  28419. /**
  28420. * Function callback when a series has been animated.
  28421. *
  28422. * @callback Highcharts.SeriesAfterAnimateCallbackFunction
  28423. *
  28424. * @param {Highcharts.Series} this
  28425. * The series where the event occured.
  28426. *
  28427. * @param {Highcharts.SeriesAfterAnimateEventObject} event
  28428. * Event arguments.
  28429. */
  28430. /**
  28431. * Event information regarding completed animation of a series.
  28432. *
  28433. * @interface Highcharts.SeriesAfterAnimateEventObject
  28434. */ /**
  28435. * Animated series.
  28436. * @name Highcharts.SeriesAfterAnimateEventObject#target
  28437. * @type {Highcharts.Series}
  28438. */ /**
  28439. * Event type.
  28440. * @name Highcharts.SeriesAfterAnimateEventObject#type
  28441. * @type {"afterAnimate"}
  28442. */
  28443. /**
  28444. * Function callback when the checkbox next to the series' name in the legend is
  28445. * clicked.
  28446. *
  28447. * @callback Highcharts.SeriesCheckboxClickCallbackFunction
  28448. *
  28449. * @param {Highcharts.Series} this
  28450. * The series where the event occured.
  28451. *
  28452. * @param {Highcharts.SeriesCheckboxClickEventObject} event
  28453. * Event arguments.
  28454. */
  28455. /**
  28456. * Event information regarding check of a series box.
  28457. *
  28458. * @interface Highcharts.SeriesCheckboxClickEventObject
  28459. */ /**
  28460. * Whether the box has been checked.
  28461. * @name Highcharts.SeriesCheckboxClickEventObject#checked
  28462. * @type {boolean}
  28463. */ /**
  28464. * Related series.
  28465. * @name Highcharts.SeriesCheckboxClickEventObject#item
  28466. * @type {Highcharts.Series}
  28467. */ /**
  28468. * Related series.
  28469. * @name Highcharts.SeriesCheckboxClickEventObject#target
  28470. * @type {Highcharts.Series}
  28471. */ /**
  28472. * Event type.
  28473. * @name Highcharts.SeriesCheckboxClickEventObject#type
  28474. * @type {"checkboxClick"}
  28475. */
  28476. /**
  28477. * Function callback when a series is clicked. Return false to cancel toogle
  28478. * actions.
  28479. *
  28480. * @callback Highcharts.SeriesClickCallbackFunction
  28481. *
  28482. * @param {Highcharts.Series} this
  28483. * The series where the event occured.
  28484. *
  28485. * @param {Highcharts.SeriesClickEventObject} event
  28486. * Event arguments.
  28487. */
  28488. /**
  28489. * Common information for a click event on a series.
  28490. *
  28491. * @interface Highcharts.SeriesClickEventObject
  28492. * @extends global.Event
  28493. */ /**
  28494. * Nearest point on the graph.
  28495. * @name Highcharts.SeriesClickEventObject#point
  28496. * @type {Highcharts.Point}
  28497. */
  28498. /**
  28499. * Gets fired when the series is hidden after chart generation time, either by
  28500. * clicking the legend item or by calling `.hide()`.
  28501. *
  28502. * @callback Highcharts.SeriesHideCallbackFunction
  28503. *
  28504. * @param {Highcharts.Series} this
  28505. * The series where the event occured.
  28506. *
  28507. * @param {global.Event} event
  28508. * The event that occured.
  28509. */
  28510. /**
  28511. * The SVG value used for the `stroke-linecap` and `stroke-linejoin` of a line
  28512. * graph.
  28513. *
  28514. * @typedef {"butt"|"round"|"square"|string} Highcharts.SeriesLinecapValue
  28515. */
  28516. /**
  28517. * Gets fired when the legend item belonging to the series is clicked. The
  28518. * default action is to toggle the visibility of the series. This can be
  28519. * prevented by returning `false` or calling `event.preventDefault()`.
  28520. *
  28521. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  28522. *
  28523. * @param {Highcharts.Series} this
  28524. * The series where the event occured.
  28525. *
  28526. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  28527. * The event that occured.
  28528. */
  28529. /**
  28530. * Information about the event.
  28531. *
  28532. * @interface Highcharts.SeriesLegendItemClickEventObject
  28533. */ /**
  28534. * Related browser event.
  28535. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  28536. * @type {global.PointerEvent}
  28537. */ /**
  28538. * Prevent the default action of toggle the visibility of the series.
  28539. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  28540. * @type {Function}
  28541. */ /**
  28542. * Related series.
  28543. * @name Highcharts.SeriesCheckboxClickEventObject#target
  28544. * @type {Highcharts.Series}
  28545. */ /**
  28546. * Event type.
  28547. * @name Highcharts.SeriesCheckboxClickEventObject#type
  28548. * @type {"checkboxClick"}
  28549. */
  28550. /**
  28551. * Gets fired when the mouse leaves the graph.
  28552. *
  28553. * @callback Highcharts.SeriesMouseOutCallbackFunction
  28554. *
  28555. * @param {Highcharts.Series} this
  28556. * Series where the event occured.
  28557. *
  28558. * @param {global.PointerEvent} event
  28559. * Event that occured.
  28560. */
  28561. /**
  28562. * Gets fired when the mouse enters the graph.
  28563. *
  28564. * @callback Highcharts.SeriesMouseOverCallbackFunction
  28565. *
  28566. * @param {Highcharts.Series} this
  28567. * Series where the event occured.
  28568. *
  28569. * @param {global.PointerEvent} event
  28570. * Event that occured.
  28571. */
  28572. /**
  28573. * Translation and scale for the plot area of a series.
  28574. *
  28575. * @interface Highcharts.SeriesPlotBoxObject
  28576. */ /**
  28577. * @name Highcharts.SeriesPlotBoxObject#scaleX
  28578. * @type {number}
  28579. */ /**
  28580. * @name Highcharts.SeriesPlotBoxObject#scaleY
  28581. * @type {number}
  28582. */ /**
  28583. * @name Highcharts.SeriesPlotBoxObject#translateX
  28584. * @type {number}
  28585. */ /**
  28586. * @name Highcharts.SeriesPlotBoxObject#translateY
  28587. * @type {number}
  28588. */
  28589. /**
  28590. * Gets fired when the series is shown after chart generation time, either by
  28591. * clicking the legend item or by calling `.show()`.
  28592. *
  28593. * @callback Highcharts.SeriesShowCallbackFunction
  28594. *
  28595. * @param {Highcharts.Series} this
  28596. * Series where the event occured.
  28597. *
  28598. * @param {global.Event} event
  28599. * Event that occured.
  28600. */
  28601. /**
  28602. * Possible key values for the series state options.
  28603. *
  28604. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.SeriesStateValue
  28605. */
  28606. ''; // detach doclets above
  28607. var seriesTypes = H.seriesTypes, win = H.win;
  28608. /**
  28609. * This is the base series prototype that all other series types inherit from.
  28610. * A new series is initialized either through the
  28611. * [series](https://api.highcharts.com/highcharts/series)
  28612. * option structure, or after the chart is initialized, through
  28613. * {@link Highcharts.Chart#addSeries}.
  28614. *
  28615. * The object can be accessed in a number of ways. All series and point event
  28616. * handlers give a reference to the `series` object. The chart object has a
  28617. * {@link Highcharts.Chart#series|series} property that is a collection of all
  28618. * the chart's series. The point objects and axis objects also have the same
  28619. * reference.
  28620. *
  28621. * Another way to reference the series programmatically is by `id`. Add an id
  28622. * in the series configuration options, and get the series object by
  28623. * {@link Highcharts.Chart#get}.
  28624. *
  28625. * Configuration options for the series are given in three levels. Options for
  28626. * all series in a chart are given in the
  28627. * [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
  28628. * object. Then options for all series of a specific type
  28629. * are given in the plotOptions of that type, for example `plotOptions.line`.
  28630. * Next, options for one single series are given in the series array, or as
  28631. * arguments to `chart.addSeries`.
  28632. *
  28633. * The data in the series is stored in various arrays.
  28634. *
  28635. * - First, `series.options.data` contains all the original config options for
  28636. * each point whether added by options or methods like `series.addPoint`.
  28637. *
  28638. * - Next, `series.data` contains those values converted to points, but in case
  28639. * the series data length exceeds the `cropThreshold`, or if the data is
  28640. * grouped, `series.data` doesn't contain all the points. It only contains the
  28641. * points that have been created on demand.
  28642. *
  28643. * - Then there's `series.points` that contains all currently visible point
  28644. * objects. In case of cropping, the cropped-away points are not part of this
  28645. * array. The `series.points` array starts at `series.cropStart` compared to
  28646. * `series.data` and `series.options.data`. If however the series data is
  28647. * grouped, these can't be correlated one to one.
  28648. *
  28649. * - `series.xData` and `series.processedXData` contain clean x values,
  28650. * equivalent to `series.data` and `series.points`.
  28651. *
  28652. * - `series.yData` and `series.processedYData` contain clean y values,
  28653. * equivalent to `series.data` and `series.points`.
  28654. *
  28655. * @class
  28656. * @name Highcharts.Series
  28657. *
  28658. * @param {Highcharts.Chart} chart
  28659. * The chart instance.
  28660. *
  28661. * @param {Highcharts.SeriesOptionsType|object} options
  28662. * The series options.
  28663. */ /**
  28664. * The line series is the base type and is therefor the series base prototype.
  28665. *
  28666. * @private
  28667. * @class
  28668. * @name Highcharts.seriesTypes.line
  28669. *
  28670. * @augments Highcharts.Series
  28671. */
  28672. H.Series = seriesType('line',
  28673. /**
  28674. * Series options for specific data and the data itself. In TypeScript you
  28675. * have to cast the series options to specific series types, to get all
  28676. * possible options for a series.
  28677. *
  28678. * @example
  28679. * // TypeScript example
  28680. * Highcharts.chart('container', {
  28681. * series: [{
  28682. * color: '#06C',
  28683. * data: [[0, 1], [2, 3]]
  28684. * } as Highcharts.SeriesLineOptions ]
  28685. * });
  28686. *
  28687. * @type {Array<*>}
  28688. * @apioption series
  28689. */
  28690. /**
  28691. * An id for the series. This can be used after render time to get a pointer
  28692. * to the series object through `chart.get()`.
  28693. *
  28694. * @sample {highcharts} highcharts/plotoptions/series-id/
  28695. * Get series by id
  28696. *
  28697. * @type {string}
  28698. * @since 1.2.0
  28699. * @apioption series.id
  28700. */
  28701. /**
  28702. * The index of the series in the chart, affecting the internal index in the
  28703. * `chart.series` array, the visible Z index as well as the order in the
  28704. * legend.
  28705. *
  28706. * @type {number}
  28707. * @since 2.3.0
  28708. * @apioption series.index
  28709. */
  28710. /**
  28711. * The sequential index of the series in the legend.
  28712. *
  28713. * @see [legend.reversed](#legend.reversed),
  28714. * [yAxis.reversedStacks](#yAxis.reversedStacks)
  28715. *
  28716. * @sample {highcharts|highstock} highcharts/series/legendindex/
  28717. * Legend in opposite order
  28718. *
  28719. * @type {number}
  28720. * @apioption series.legendIndex
  28721. */
  28722. /**
  28723. * The name of the series as shown in the legend, tooltip etc.
  28724. *
  28725. * @sample {highcharts} highcharts/series/name/
  28726. * Series name
  28727. * @sample {highmaps} maps/demo/category-map/
  28728. * Series name
  28729. *
  28730. * @type {string}
  28731. * @apioption series.name
  28732. */
  28733. /**
  28734. * This option allows grouping series in a stacked chart. The stack option
  28735. * can be a string or anything else, as long as the grouped series' stack
  28736. * options match each other after conversion into a string.
  28737. *
  28738. * @sample {highcharts} highcharts/series/stack/
  28739. * Stacked and grouped columns
  28740. *
  28741. * @type {number|string}
  28742. * @since 2.1
  28743. * @product highcharts highstock
  28744. * @apioption series.stack
  28745. */
  28746. /**
  28747. * The type of series, for example `line` or `column`. By default, the
  28748. * series type is inherited from [chart.type](#chart.type), so unless the
  28749. * chart is a combination of series types, there is no need to set it on the
  28750. * series level.
  28751. *
  28752. * @sample {highcharts} highcharts/series/type/
  28753. * Line and column in the same chart
  28754. * @sample highcharts/series/type-dynamic/
  28755. * Dynamic types with button selector
  28756. * @sample {highmaps} maps/demo/mapline-mappoint/
  28757. * Multiple types in the same map
  28758. *
  28759. * @type {string}
  28760. * @apioption series.type
  28761. */
  28762. /**
  28763. * When using dual or multiple x axes, this number defines which xAxis the
  28764. * particular series is connected to. It refers to either the
  28765. * {@link #xAxis.id|axis id}
  28766. * or the index of the axis in the xAxis array, with 0 being the first.
  28767. *
  28768. * @type {number|string}
  28769. * @default 0
  28770. * @product highcharts highstock
  28771. * @apioption series.xAxis
  28772. */
  28773. /**
  28774. * When using dual or multiple y axes, this number defines which yAxis the
  28775. * particular series is connected to. It refers to either the
  28776. * {@link #yAxis.id|axis id}
  28777. * or the index of the axis in the yAxis array, with 0 being the first.
  28778. *
  28779. * @sample {highcharts} highcharts/series/yaxis/
  28780. * Apply the column series to the secondary Y axis
  28781. *
  28782. * @type {number|string}
  28783. * @default 0
  28784. * @product highcharts highstock
  28785. * @apioption series.yAxis
  28786. */
  28787. /**
  28788. * Define the visual z index of the series.
  28789. *
  28790. * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
  28791. * With no z index, the series defined last are on top
  28792. * @sample {highcharts} highcharts/plotoptions/series-zindex/
  28793. * With a z index, the series with the highest z index is on top
  28794. * @sample {highstock} highcharts/plotoptions/series-zindex-default/
  28795. * With no z index, the series defined last are on top
  28796. * @sample {highstock} highcharts/plotoptions/series-zindex/
  28797. * With a z index, the series with the highest z index is on top
  28798. *
  28799. * @type {number}
  28800. * @product highcharts highstock
  28801. * @apioption series.zIndex
  28802. */
  28803. null,
  28804. /**
  28805. * General options for all series types.
  28806. *
  28807. * @optionparent plotOptions.series
  28808. */
  28809. {
  28810. /**
  28811. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  28812. * of a line graph. Round means that lines are rounded in the ends and
  28813. * bends.
  28814. *
  28815. * @type {Highcharts.SeriesLinecapValue}
  28816. * @default round
  28817. * @since 3.0.7
  28818. * @apioption plotOptions.line.linecap
  28819. */
  28820. /**
  28821. * Pixel width of the graph line.
  28822. *
  28823. * @see In styled mode, the line stroke-width can be set with the
  28824. * `.highcharts-graph` class name.
  28825. *
  28826. * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
  28827. * On all series
  28828. * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
  28829. * On one single series
  28830. *
  28831. * @product highcharts highstock
  28832. *
  28833. * @private
  28834. */
  28835. lineWidth: 2,
  28836. /**
  28837. * For some series, there is a limit that shuts down initial animation
  28838. * by default when the total number of points in the chart is too high.
  28839. * For example, for a column chart and its derivatives, animation does
  28840. * not run if there is more than 250 points totally. To disable this
  28841. * cap, set `animationLimit` to `Infinity`.
  28842. *
  28843. * @type {number}
  28844. * @apioption plotOptions.series.animationLimit
  28845. */
  28846. /**
  28847. * Allow this series' points to be selected by clicking on the graphic
  28848. * (columns, point markers, pie slices, map areas etc).
  28849. *
  28850. * The selected points can be handled by point select and unselect
  28851. * events, or collectively by the [getSelectedPoints
  28852. * ](/class-reference/Highcharts.Chart#getSelectedPoints) function.
  28853. *
  28854. * And alternative way of selecting points is through dragging.
  28855. *
  28856. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
  28857. * Line
  28858. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-column/
  28859. * Column
  28860. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
  28861. * Pie
  28862. * @sample {highcharts} highcharts/chart/events-selection-points/
  28863. * Select a range of points through a drag selection
  28864. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  28865. * Map area
  28866. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  28867. * Map bubble
  28868. *
  28869. * @since 1.2.0
  28870. *
  28871. * @private
  28872. */
  28873. allowPointSelect: false,
  28874. /**
  28875. * When true, each point or column edge is rounded to its nearest pixel
  28876. * in order to render sharp on screen. In some cases, when there are a
  28877. * lot of densely packed columns, this leads to visible difference
  28878. * in column widths or distance between columns. In these cases,
  28879. * setting `crisp` to `false` may look better, even though each column
  28880. * is rendered blurry.
  28881. *
  28882. * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
  28883. * Crisp is false
  28884. *
  28885. * @since 5.0.10
  28886. * @product highcharts highstock gantt
  28887. *
  28888. * @private
  28889. */
  28890. crisp: true,
  28891. /**
  28892. * If true, a checkbox is displayed next to the legend item to allow
  28893. * selecting the series. The state of the checkbox is determined by
  28894. * the `selected` option.
  28895. *
  28896. * @productdesc {highmaps}
  28897. * Note that if a `colorAxis` is defined, the color axis is represented
  28898. * in the legend, not the series.
  28899. *
  28900. * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
  28901. * Show select box
  28902. *
  28903. * @since 1.2.0
  28904. *
  28905. * @private
  28906. */
  28907. showCheckbox: false,
  28908. /**
  28909. * Enable or disable the initial animation when a series is displayed.
  28910. * The animation can also be set as a configuration object. Please
  28911. * note that this option only applies to the initial animation of the
  28912. * series itself. For other animations, see [chart.animation](
  28913. * #chart.animation) and the animation parameter under the API methods.
  28914. * The following properties are supported:
  28915. *
  28916. * - `duration`: The duration of the animation in milliseconds.
  28917. *
  28918. * - `easing`: Can be a string reference to an easing function set on
  28919. * the `Math` object or a function. See the _Custom easing function_
  28920. * demo below.
  28921. *
  28922. * Due to poor performance, animation is disabled in old IE browsers
  28923. * for several chart types.
  28924. *
  28925. * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
  28926. * Animation disabled
  28927. * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
  28928. * Slower animation
  28929. * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
  28930. * Custom easing function
  28931. * @sample {highstock} stock/plotoptions/animation-slower/
  28932. * Slower animation
  28933. * @sample {highstock} stock/plotoptions/animation-easing/
  28934. * Custom easing function
  28935. * @sample {highmaps} maps/plotoptions/series-animation-true/
  28936. * Animation enabled on map series
  28937. * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
  28938. * Disabled on mapbubble series
  28939. *
  28940. * @type {boolean|Highcharts.AnimationOptionsObject}
  28941. * @default {highcharts} true
  28942. * @default {highstock} true
  28943. * @default {highmaps} false
  28944. *
  28945. * @private
  28946. */
  28947. animation: {
  28948. /** @internal */
  28949. duration: 1000
  28950. },
  28951. /**
  28952. * An additional class name to apply to the series' graphical elements.
  28953. * This option does not replace default class names of the graphical
  28954. * element.
  28955. *
  28956. * @type {string}
  28957. * @since 5.0.0
  28958. * @apioption plotOptions.series.className
  28959. */
  28960. /**
  28961. * Disable this option to allow series rendering in the whole plotting
  28962. * area.
  28963. *
  28964. * **Note:** Clipping should be always enabled when
  28965. * [chart.zoomType](#chart.zoomType) is set
  28966. *
  28967. * @sample {highcharts} highcharts/plotoptions/series-clip/
  28968. * Disabled clipping
  28969. *
  28970. * @default true
  28971. * @type {boolean}
  28972. * @since 3.0.0
  28973. * @apioption plotOptions.series.clip
  28974. */
  28975. /**
  28976. * The main color of the series. In line type series it applies to the
  28977. * line and the point markers unless otherwise specified. In bar type
  28978. * series it applies to the bars unless a color is specified per point.
  28979. * The default value is pulled from the `options.colors` array.
  28980. *
  28981. * In styled mode, the color can be defined by the
  28982. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  28983. * color can be set with the `.highcharts-series`,
  28984. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  28985. * `.highcharts-series-{n}` class, or individual classes given by the
  28986. * `className` option.
  28987. *
  28988. * @productdesc {highmaps}
  28989. * In maps, the series color is rarely used, as most choropleth maps use
  28990. * the color to denote the value of each point. The series color can
  28991. * however be used in a map with multiple series holding categorized
  28992. * data.
  28993. *
  28994. * @sample {highcharts} highcharts/plotoptions/series-color-general/
  28995. * General plot option
  28996. * @sample {highcharts} highcharts/plotoptions/series-color-specific/
  28997. * One specific series
  28998. * @sample {highcharts} highcharts/plotoptions/series-color-area/
  28999. * Area color
  29000. * @sample {highcharts} highcharts/series/infographic/
  29001. * Pattern fill
  29002. * @sample {highmaps} maps/demo/category-map/
  29003. * Category map by multiple series
  29004. *
  29005. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  29006. * @apioption plotOptions.series.color
  29007. */
  29008. /**
  29009. * Styled mode only. A specific color index to use for the series, so
  29010. * its graphic representations are given the class name
  29011. * `highcharts-color-{n}`.
  29012. *
  29013. * @type {number}
  29014. * @since 5.0.0
  29015. * @apioption plotOptions.series.colorIndex
  29016. */
  29017. /**
  29018. * Whether to connect a graph line across null points, or render a gap
  29019. * between the two points on either side of the null.
  29020. *
  29021. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
  29022. * False by default
  29023. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
  29024. * True
  29025. *
  29026. * @type {boolean}
  29027. * @default false
  29028. * @product highcharts highstock
  29029. * @apioption plotOptions.series.connectNulls
  29030. */
  29031. /**
  29032. * You can set the cursor to "pointer" if you have click events attached
  29033. * to the series, to signal to the user that the points and lines can
  29034. * be clicked.
  29035. *
  29036. * In styled mode, the series cursor can be set with the same classes
  29037. * as listed under [series.color](#plotOptions.series.color).
  29038. *
  29039. * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
  29040. * On line graph
  29041. * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
  29042. * On columns
  29043. * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
  29044. * On scatter markers
  29045. * @sample {highstock} stock/plotoptions/cursor/
  29046. * Pointer on a line graph
  29047. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  29048. * Map area
  29049. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  29050. * Map bubble
  29051. *
  29052. * @type {string|Highcharts.CursorValue}
  29053. * @apioption plotOptions.series.cursor
  29054. */
  29055. /**
  29056. * A reserved subspace to store options and values for customized
  29057. * functionality. Here you can add additional data for your own event
  29058. * callbacks and formatter callbacks.
  29059. *
  29060. * @sample {highcharts} highcharts/point/custom/
  29061. * Point and series with custom data
  29062. *
  29063. * @type {Highcharts.Dictionary<*>}
  29064. * @apioption plotOptions.series.custom
  29065. */
  29066. /**
  29067. * Name of the dash style to use for the graph, or for some series types
  29068. * the outline of each shape.
  29069. *
  29070. * In styled mode, the
  29071. * [stroke dash-array](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-dashstyle/)
  29072. * can be set with the same classes as listed under
  29073. * [series.color](#plotOptions.series.color).
  29074. *
  29075. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  29076. * Possible values demonstrated
  29077. * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
  29078. * Chart suitable for printing in black and white
  29079. * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
  29080. * Possible values demonstrated
  29081. * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
  29082. * Possible values demonstrated
  29083. * @sample {highmaps} maps/plotoptions/series-dashstyle/
  29084. * Dotted borders on a map
  29085. *
  29086. * @type {Highcharts.DashStyleValue}
  29087. * @default Solid
  29088. * @since 2.1
  29089. * @apioption plotOptions.series.dashStyle
  29090. */
  29091. /**
  29092. * A description of the series to add to the screen reader information
  29093. * about the series.
  29094. *
  29095. * @type {string}
  29096. * @since 5.0.0
  29097. * @requires modules/accessibility
  29098. * @apioption plotOptions.series.description
  29099. */
  29100. /**
  29101. * Options for the series data sorting.
  29102. *
  29103. * @type {Highcharts.DataSortingOptionsObject}
  29104. * @since 8.0.0
  29105. * @product highcharts highstock
  29106. * @apioption plotOptions.series.dataSorting
  29107. */
  29108. /**
  29109. * Enable or disable data sorting for the series. Use [xAxis.reversed](
  29110. * #xAxis.reversed) to change the sorting order.
  29111. *
  29112. * @sample {highcharts} highcharts/datasorting/animation/
  29113. * Data sorting in scatter-3d
  29114. * @sample {highcharts} highcharts/datasorting/labels-animation/
  29115. * Axis labels animation
  29116. * @sample {highcharts} highcharts/datasorting/dependent-sorting/
  29117. * Dependent series sorting
  29118. * @sample {highcharts} highcharts/datasorting/independent-sorting/
  29119. * Independent series sorting
  29120. *
  29121. * @type {boolean}
  29122. * @since 8.0.0
  29123. * @apioption plotOptions.series.dataSorting.enabled
  29124. */
  29125. /**
  29126. * Whether to allow matching points by name in an update. If this option
  29127. * is disabled, points will be matched by order.
  29128. *
  29129. * @sample {highcharts} highcharts/datasorting/match-by-name/
  29130. * Enabled match by name
  29131. *
  29132. * @type {boolean}
  29133. * @since 8.0.0
  29134. * @apioption plotOptions.series.dataSorting.matchByName
  29135. */
  29136. /**
  29137. * Determines what data value should be used to sort by.
  29138. *
  29139. * @sample {highcharts} highcharts/datasorting/sort-key/
  29140. * Sort key as `z` value
  29141. *
  29142. * @type {string}
  29143. * @since 8.0.0
  29144. * @default y
  29145. * @apioption plotOptions.series.dataSorting.sortKey
  29146. */
  29147. /**
  29148. * Enable or disable the mouse tracking for a specific series. This
  29149. * includes point tooltips and click events on graphs and points. For
  29150. * large datasets it improves performance.
  29151. *
  29152. * @sample {highcharts} highcharts/plotoptions/series-enablemousetracking-false/
  29153. * No mouse tracking
  29154. * @sample {highmaps} maps/plotoptions/series-enablemousetracking-false/
  29155. * No mouse tracking
  29156. *
  29157. * @type {boolean}
  29158. * @default true
  29159. * @apioption plotOptions.series.enableMouseTracking
  29160. */
  29161. /**
  29162. * Whether to use the Y extremes of the total chart width or only the
  29163. * zoomed area when zooming in on parts of the X axis. By default, the
  29164. * Y axis adjusts to the min and max of the visible data. Cartesian
  29165. * series only.
  29166. *
  29167. * @type {boolean}
  29168. * @default false
  29169. * @since 4.1.6
  29170. * @product highcharts highstock gantt
  29171. * @apioption plotOptions.series.getExtremesFromAll
  29172. */
  29173. /**
  29174. * An array specifying which option maps to which key in the data point
  29175. * array. This makes it convenient to work with unstructured data arrays
  29176. * from different sources.
  29177. *
  29178. * @see [series.data](#series.line.data)
  29179. *
  29180. * @sample {highcharts|highstock} highcharts/series/data-keys/
  29181. * An extended data array with keys
  29182. * @sample {highcharts|highstock} highcharts/series/data-nested-keys/
  29183. * Nested keys used to access object properties
  29184. *
  29185. * @type {Array<string>}
  29186. * @since 4.1.6
  29187. * @apioption plotOptions.series.keys
  29188. */
  29189. /**
  29190. * The line cap used for line ends and line joins on the graph.
  29191. *
  29192. * @type {Highcharts.SeriesLinecapValue}
  29193. * @default round
  29194. * @product highcharts highstock
  29195. * @apioption plotOptions.series.linecap
  29196. */
  29197. /**
  29198. * The [id](#series.id) of another series to link to. Additionally,
  29199. * the value can be ":previous" to link to the previous series. When
  29200. * two series are linked, only the first one appears in the legend.
  29201. * Toggling the visibility of this also toggles the linked series.
  29202. *
  29203. * If master series uses data sorting and linked series does not have
  29204. * its own sorting definition, the linked series will be sorted in the
  29205. * same order as the master one.
  29206. *
  29207. * @sample {highcharts|highstock} highcharts/demo/arearange-line/
  29208. * Linked series
  29209. *
  29210. * @type {string}
  29211. * @since 3.0
  29212. * @product highcharts highstock gantt
  29213. * @apioption plotOptions.series.linkedTo
  29214. */
  29215. /**
  29216. * Options for the corresponding navigator series if `showInNavigator`
  29217. * is `true` for this series. Available options are the same as any
  29218. * series, documented at [plotOptions](#plotOptions.series) and
  29219. * [series](#series).
  29220. *
  29221. * These options are merged with options in [navigator.series](
  29222. * #navigator.series), and will take precedence if the same option is
  29223. * defined both places.
  29224. *
  29225. * @see [navigator.series](#navigator.series)
  29226. *
  29227. * @type {Highcharts.PlotSeriesOptions}
  29228. * @since 5.0.0
  29229. * @product highstock
  29230. * @apioption plotOptions.series.navigatorOptions
  29231. */
  29232. /**
  29233. * The color for the parts of the graph or points that are below the
  29234. * [threshold](#plotOptions.series.threshold). Note that `zones` takes
  29235. * precedence over the negative color. Using `negativeColor` is
  29236. * equivalent to applying a zone with value of 0.
  29237. *
  29238. * @see In styled mode, a negative color is applied by setting this option
  29239. * to `true` combined with the `.highcharts-negative` class name.
  29240. *
  29241. * @sample {highcharts} highcharts/plotoptions/series-negative-color/
  29242. * Spline, area and column
  29243. * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
  29244. * Arearange
  29245. * @sample {highcharts} highcharts/css/series-negative-color/
  29246. * Styled mode
  29247. * @sample {highstock} highcharts/plotoptions/series-negative-color/
  29248. * Spline, area and column
  29249. * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
  29250. * Arearange
  29251. * @sample {highmaps} highcharts/plotoptions/series-negative-color/
  29252. * Spline, area and column
  29253. * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
  29254. * Arearange
  29255. *
  29256. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  29257. * @since 3.0
  29258. * @apioption plotOptions.series.negativeColor
  29259. */
  29260. /**
  29261. * Same as
  29262. * [accessibility.pointDescriptionFormatter](#accessibility.pointDescriptionFormatter),
  29263. * but for an individual series. Overrides the chart wide configuration.
  29264. *
  29265. * @type {Function}
  29266. * @since 5.0.12
  29267. * @apioption plotOptions.series.pointDescriptionFormatter
  29268. */
  29269. /**
  29270. * If no x values are given for the points in a series, `pointInterval`
  29271. * defines the interval of the x values. For example, if a series
  29272. * contains one value every decade starting from year 0, set
  29273. * `pointInterval` to `10`. In true `datetime` axes, the `pointInterval`
  29274. * is set in milliseconds.
  29275. *
  29276. * It can be also be combined with `pointIntervalUnit` to draw irregular
  29277. * time intervals.
  29278. *
  29279. * Please note that this options applies to the _series data_, not the
  29280. * interval of the axis ticks, which is independent.
  29281. *
  29282. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  29283. * Datetime X axis
  29284. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  29285. * Using pointStart and pointInterval
  29286. *
  29287. * @type {number}
  29288. * @default 1
  29289. * @product highcharts highstock gantt
  29290. * @apioption plotOptions.series.pointInterval
  29291. */
  29292. /**
  29293. * On datetime series, this allows for setting the
  29294. * [pointInterval](#plotOptions.series.pointInterval) to irregular time
  29295. * units, `day`, `month` and `year`. A day is usually the same as 24
  29296. * hours, but `pointIntervalUnit` also takes the DST crossover into
  29297. * consideration when dealing with local time. Combine this option with
  29298. * `pointInterval` to draw weeks, quarters, 6 months, 10 years etc.
  29299. *
  29300. * Please note that this options applies to the _series data_, not the
  29301. * interval of the axis ticks, which is independent.
  29302. *
  29303. * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
  29304. * One point a month
  29305. * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
  29306. * One point a month
  29307. *
  29308. * @type {string}
  29309. * @since 4.1.0
  29310. * @product highcharts highstock gantt
  29311. * @validvalue ["day", "month", "year"]
  29312. * @apioption plotOptions.series.pointIntervalUnit
  29313. */
  29314. /**
  29315. * Possible values: `"on"`, `"between"`, `number`.
  29316. *
  29317. * In a column chart, when pointPlacement is `"on"`, the point will not
  29318. * create any padding of the X axis. In a polar column chart this means
  29319. * that the first column points directly north. If the pointPlacement is
  29320. * `"between"`, the columns will be laid out between ticks. This is
  29321. * useful for example for visualising an amount between two points in
  29322. * time or in a certain sector of a polar chart.
  29323. *
  29324. * Since Highcharts 3.0.2, the point placement can also be numeric,
  29325. * where 0 is on the axis value, -0.5 is between this value and the
  29326. * previous, and 0.5 is between this value and the next. Unlike the
  29327. * textual options, numeric point placement options won't affect axis
  29328. * padding.
  29329. *
  29330. * Note that pointPlacement needs a [pointRange](
  29331. * #plotOptions.series.pointRange) to work. For column series this is
  29332. * computed, but for line-type series it needs to be set.
  29333. *
  29334. * For the `xrange` series type and gantt charts, if the Y axis is a
  29335. * category axis, the `pointPlacement` applies to the Y axis rather than
  29336. * the (typically datetime) X axis.
  29337. *
  29338. * Defaults to `undefined` in cartesian charts, `"between"` in polar
  29339. * charts.
  29340. *
  29341. * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
  29342. *
  29343. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-between/
  29344. * Between in a column chart
  29345. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-numeric/
  29346. * Numeric placement for custom layout
  29347. * @sample {highcharts|highstock} maps/plotoptions/heatmap-pointplacement/
  29348. * Placement in heatmap
  29349. *
  29350. * @type {string|number}
  29351. * @since 2.3.0
  29352. * @product highcharts highstock gantt
  29353. * @apioption plotOptions.series.pointPlacement
  29354. */
  29355. /**
  29356. * If no x values are given for the points in a series, pointStart
  29357. * defines on what value to start. For example, if a series contains one
  29358. * yearly value starting from 1945, set pointStart to 1945.
  29359. *
  29360. * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
  29361. * Linear
  29362. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  29363. * Datetime
  29364. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  29365. * Using pointStart and pointInterval
  29366. *
  29367. * @type {number}
  29368. * @default 0
  29369. * @product highcharts highstock gantt
  29370. * @apioption plotOptions.series.pointStart
  29371. */
  29372. /**
  29373. * Whether to select the series initially. If `showCheckbox` is true,
  29374. * the checkbox next to the series name in the legend will be checked
  29375. * for a selected series.
  29376. *
  29377. * @sample {highcharts} highcharts/plotoptions/series-selected/
  29378. * One out of two series selected
  29379. *
  29380. * @type {boolean}
  29381. * @default false
  29382. * @since 1.2.0
  29383. * @apioption plotOptions.series.selected
  29384. */
  29385. /**
  29386. * Whether to apply a drop shadow to the graph line. Since 2.3 the
  29387. * shadow can be an object configuration containing `color`, `offsetX`,
  29388. * `offsetY`, `opacity` and `width`.
  29389. *
  29390. * @sample {highcharts} highcharts/plotoptions/series-shadow/
  29391. * Shadow enabled
  29392. *
  29393. * @type {boolean|Highcharts.ShadowOptionsObject}
  29394. * @default false
  29395. * @apioption plotOptions.series.shadow
  29396. */
  29397. /**
  29398. * Whether to display this particular series or series type in the
  29399. * legend. Standalone series are shown in legend by default, and linked
  29400. * series are not. Since v7.2.0 it is possible to show series that use
  29401. * colorAxis by setting this option to `true`.
  29402. *
  29403. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  29404. * One series in the legend, one hidden
  29405. *
  29406. * @type {boolean}
  29407. * @apioption plotOptions.series.showInLegend
  29408. */
  29409. /**
  29410. * Whether or not to show the series in the navigator. Takes precedence
  29411. * over [navigator.baseSeries](#navigator.baseSeries) if defined.
  29412. *
  29413. * @type {boolean}
  29414. * @since 5.0.0
  29415. * @product highstock
  29416. * @apioption plotOptions.series.showInNavigator
  29417. */
  29418. /**
  29419. * If set to `true`, the accessibility module will skip past the points
  29420. * in this series for keyboard navigation.
  29421. *
  29422. * @type {boolean}
  29423. * @since 5.0.12
  29424. * @apioption plotOptions.series.skipKeyboardNavigation
  29425. */
  29426. /**
  29427. * Whether to stack the values of each series on top of each other.
  29428. * Possible values are `undefined` to disable, `"normal"` to stack by
  29429. * value or `"percent"`.
  29430. *
  29431. * When stacking is enabled, data must be sorted
  29432. * in ascending X order.
  29433. *
  29434. * Some stacking options are related to specific series types. In the
  29435. * streamgraph series type, the stacking option is set to `"stream"`.
  29436. * The second one is `"overlap"`, which only applies to waterfall
  29437. * series.
  29438. *
  29439. * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
  29440. *
  29441. * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
  29442. * Line
  29443. * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
  29444. * Column
  29445. * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
  29446. * Bar
  29447. * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
  29448. * Area
  29449. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
  29450. * Line
  29451. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-column/
  29452. * Column
  29453. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
  29454. * Bar
  29455. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
  29456. * Area
  29457. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-normal-stacking
  29458. * Waterfall with normal stacking
  29459. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-overlap-stacking
  29460. * Waterfall with overlap stacking
  29461. * @sample {highstock} stock/plotoptions/stacking/
  29462. * Area
  29463. *
  29464. * @type {string}
  29465. * @product highcharts highstock
  29466. * @validvalue ["normal", "overlap", "percent", "stream"]
  29467. * @apioption plotOptions.series.stacking
  29468. */
  29469. /**
  29470. * Whether to apply steps to the line. Possible values are `left`,
  29471. * `center` and `right`.
  29472. *
  29473. * @sample {highcharts} highcharts/plotoptions/line-step/
  29474. * Different step line options
  29475. * @sample {highcharts} highcharts/plotoptions/area-step/
  29476. * Stepped, stacked area
  29477. * @sample {highstock} stock/plotoptions/line-step/
  29478. * Step line
  29479. *
  29480. * @type {string}
  29481. * @since 1.2.5
  29482. * @product highcharts highstock
  29483. * @validvalue ["left", "center", "right"]
  29484. * @apioption plotOptions.series.step
  29485. */
  29486. /**
  29487. * The threshold, also called zero level or base level. For line type
  29488. * series this is only used in conjunction with
  29489. * [negativeColor](#plotOptions.series.negativeColor).
  29490. *
  29491. * @see [softThreshold](#plotOptions.series.softThreshold).
  29492. *
  29493. * @type {number}
  29494. * @default 0
  29495. * @since 3.0
  29496. * @product highcharts highstock
  29497. * @apioption plotOptions.series.threshold
  29498. */
  29499. /**
  29500. * Set the initial visibility of the series.
  29501. *
  29502. * @sample {highcharts} highcharts/plotoptions/series-visible/
  29503. * Two series, one hidden and one visible
  29504. * @sample {highstock} stock/plotoptions/series-visibility/
  29505. * Hidden series
  29506. *
  29507. * @type {boolean}
  29508. * @default true
  29509. * @apioption plotOptions.series.visible
  29510. */
  29511. /**
  29512. * Defines the Axis on which the zones are applied.
  29513. *
  29514. * @see [zones](#plotOptions.series.zones)
  29515. *
  29516. * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
  29517. * Zones on the X-Axis
  29518. * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
  29519. * Zones on the X-Axis
  29520. *
  29521. * @type {string}
  29522. * @default y
  29523. * @since 4.1.0
  29524. * @product highcharts highstock
  29525. * @apioption plotOptions.series.zoneAxis
  29526. */
  29527. /**
  29528. * General event handlers for the series items. These event hooks can
  29529. * also be attached to the series at run time using the
  29530. * `Highcharts.addEvent` function.
  29531. *
  29532. * @declare Highcharts.SeriesEventsOptionsObject
  29533. *
  29534. * @private
  29535. */
  29536. events: {},
  29537. /**
  29538. * Fires after the series has finished its initial animation, or in case
  29539. * animation is disabled, immediately as the series is displayed.
  29540. *
  29541. * @sample {highcharts} highcharts/plotoptions/series-events-afteranimate/
  29542. * Show label after animate
  29543. * @sample {highstock} highcharts/plotoptions/series-events-afteranimate/
  29544. * Show label after animate
  29545. *
  29546. * @type {Highcharts.SeriesAfterAnimateCallbackFunction}
  29547. * @since 4.0
  29548. * @product highcharts highstock gantt
  29549. * @context Highcharts.Series
  29550. * @apioption plotOptions.series.events.afterAnimate
  29551. */
  29552. /**
  29553. * Fires when the checkbox next to the series' name in the legend is
  29554. * clicked. One parameter, `event`, is passed to the function. The state
  29555. * of the checkbox is found by `event.checked`. The checked item is
  29556. * found by `event.item`. Return `false` to prevent the default action
  29557. * which is to toggle the select state of the series.
  29558. *
  29559. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  29560. * Alert checkbox status
  29561. *
  29562. * @type {Highcharts.SeriesCheckboxClickCallbackFunction}
  29563. * @since 1.2.0
  29564. * @context Highcharts.Series
  29565. * @apioption plotOptions.series.events.checkboxClick
  29566. */
  29567. /**
  29568. * Fires when the series is clicked. One parameter, `event`, is passed
  29569. * to the function, containing common event information. Additionally,
  29570. * `event.point` holds a pointer to the nearest point on the graph.
  29571. *
  29572. * @sample {highcharts} highcharts/plotoptions/series-events-click/
  29573. * Alert click info
  29574. * @sample {highstock} stock/plotoptions/series-events-click/
  29575. * Alert click info
  29576. * @sample {highmaps} maps/plotoptions/series-events-click/
  29577. * Display click info in subtitle
  29578. *
  29579. * @type {Highcharts.SeriesClickCallbackFunction}
  29580. * @context Highcharts.Series
  29581. * @apioption plotOptions.series.events.click
  29582. */
  29583. /**
  29584. * Fires when the series is hidden after chart generation time, either
  29585. * by clicking the legend item or by calling `.hide()`.
  29586. *
  29587. * @sample {highcharts} highcharts/plotoptions/series-events-hide/
  29588. * Alert when the series is hidden by clicking the legend item
  29589. *
  29590. * @type {Highcharts.SeriesHideCallbackFunction}
  29591. * @since 1.2.0
  29592. * @context Highcharts.Series
  29593. * @apioption plotOptions.series.events.hide
  29594. */
  29595. /**
  29596. * Fires when the legend item belonging to the series is clicked. One
  29597. * parameter, `event`, is passed to the function. The default action
  29598. * is to toggle the visibility of the series. This can be prevented
  29599. * by returning `false` or calling `event.preventDefault()`.
  29600. *
  29601. * @sample {highcharts} highcharts/plotoptions/series-events-legenditemclick/
  29602. * Confirm hiding and showing
  29603. *
  29604. * @type {Highcharts.SeriesLegendItemClickCallbackFunction}
  29605. * @context Highcharts.Series
  29606. * @apioption plotOptions.series.events.legendItemClick
  29607. */
  29608. /**
  29609. * Fires when the mouse leaves the graph. One parameter, `event`, is
  29610. * passed to the function, containing common event information. If the
  29611. * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
  29612. * doesn't happen before the mouse enters another graph or leaves the
  29613. * plot area.
  29614. *
  29615. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  29616. * With sticky tracking by default
  29617. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  29618. * Without sticky tracking
  29619. *
  29620. * @type {Highcharts.SeriesMouseOutCallbackFunction}
  29621. * @context Highcharts.Series
  29622. * @apioption plotOptions.series.events.mouseOut
  29623. */
  29624. /**
  29625. * Fires when the mouse enters the graph. One parameter, `event`, is
  29626. * passed to the function, containing common event information.
  29627. *
  29628. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  29629. * With sticky tracking by default
  29630. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  29631. * Without sticky tracking
  29632. *
  29633. * @type {Highcharts.SeriesMouseOverCallbackFunction}
  29634. * @context Highcharts.Series
  29635. * @apioption plotOptions.series.events.mouseOver
  29636. */
  29637. /**
  29638. * Fires when the series is shown after chart generation time, either
  29639. * by clicking the legend item or by calling `.show()`.
  29640. *
  29641. * @sample {highcharts} highcharts/plotoptions/series-events-show/
  29642. * Alert when the series is shown by clicking the legend item.
  29643. *
  29644. * @type {Highcharts.SeriesShowCallbackFunction}
  29645. * @since 1.2.0
  29646. * @context Highcharts.Series
  29647. * @apioption plotOptions.series.events.show
  29648. */
  29649. /**
  29650. * Options for the point markers of line-like series. Properties like
  29651. * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
  29652. * of the markers. Other series types, like column series, don't have
  29653. * markers, but have visual options on the series level instead.
  29654. *
  29655. * In styled mode, the markers can be styled with the
  29656. * `.highcharts-point`, `.highcharts-point-hover` and
  29657. * `.highcharts-point-select` class names.
  29658. *
  29659. * @declare Highcharts.PointMarkerOptionsObject
  29660. *
  29661. * @private
  29662. */
  29663. marker: {
  29664. /**
  29665. * Enable or disable the point marker. If `undefined`, the markers
  29666. * are hidden when the data is dense, and shown for more widespread
  29667. * data points.
  29668. *
  29669. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
  29670. * Disabled markers
  29671. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled-false/
  29672. * Disabled in normal state but enabled on hover
  29673. * @sample {highstock} stock/plotoptions/series-marker/
  29674. * Enabled markers
  29675. *
  29676. * @type {boolean}
  29677. * @default {highcharts} undefined
  29678. * @default {highstock} false
  29679. * @apioption plotOptions.series.marker.enabled
  29680. */
  29681. /**
  29682. * The threshold for how dense the point markers should be before
  29683. * they are hidden, given that `enabled` is not defined. The number
  29684. * indicates the horizontal distance between the two closest points
  29685. * in the series, as multiples of the `marker.radius`. In other
  29686. * words, the default value of 2 means points are hidden if
  29687. * overlapping horizontally.
  29688. *
  29689. * @sample highcharts/plotoptions/series-marker-enabledthreshold
  29690. * A higher threshold
  29691. *
  29692. * @since 6.0.5
  29693. */
  29694. enabledThreshold: 2,
  29695. /**
  29696. * The fill color of the point marker. When `undefined`, the series'
  29697. * or point's color is used.
  29698. *
  29699. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  29700. * White fill
  29701. *
  29702. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  29703. * @apioption plotOptions.series.marker.fillColor
  29704. */
  29705. /**
  29706. * Image markers only. Set the image width explicitly. When using
  29707. * this option, a `width` must also be set.
  29708. *
  29709. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  29710. * Fixed width and height
  29711. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  29712. * Fixed width and height
  29713. *
  29714. * @type {number}
  29715. * @since 4.0.4
  29716. * @apioption plotOptions.series.marker.height
  29717. */
  29718. /**
  29719. * The color of the point marker's outline. When `undefined`, the
  29720. * series' or point's color is used.
  29721. *
  29722. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  29723. * Inherit from series color (undefined)
  29724. *
  29725. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  29726. */
  29727. lineColor: '#ffffff',
  29728. /**
  29729. * The width of the point marker's outline.
  29730. *
  29731. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  29732. * 2px blue marker
  29733. */
  29734. lineWidth: 0,
  29735. /**
  29736. * The radius of the point marker.
  29737. *
  29738. * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
  29739. * Bigger markers
  29740. *
  29741. * @default {highstock} 2
  29742. */
  29743. radius: 4,
  29744. /**
  29745. * A predefined shape or symbol for the marker. When undefined, the
  29746. * symbol is pulled from options.symbols. Other possible values are
  29747. * `'circle'`, `'square'`,`'diamond'`, `'triangle'` and
  29748. * `'triangle-down'`.
  29749. *
  29750. * Additionally, the URL to a graphic can be given on this form:
  29751. * `'url(graphic.png)'`. Note that for the image to be applied to
  29752. * exported charts, its URL needs to be accessible by the export
  29753. * server.
  29754. *
  29755. * Custom callbacks for symbol path generation can also be added to
  29756. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  29757. * used by its method name, as shown in the demo.
  29758. *
  29759. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  29760. * Predefined, graphic and custom markers
  29761. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  29762. * Predefined, graphic and custom markers
  29763. *
  29764. * @type {string}
  29765. * @apioption plotOptions.series.marker.symbol
  29766. */
  29767. /**
  29768. * Image markers only. Set the image width explicitly. When using
  29769. * this option, a `height` must also be set.
  29770. *
  29771. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  29772. * Fixed width and height
  29773. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  29774. * Fixed width and height
  29775. *
  29776. * @type {number}
  29777. * @since 4.0.4
  29778. * @apioption plotOptions.series.marker.width
  29779. */
  29780. /**
  29781. * States for a single point marker.
  29782. *
  29783. * @declare Highcharts.PointStatesOptionsObject
  29784. */
  29785. states: {
  29786. /**
  29787. * The normal state of a single point marker. Currently only
  29788. * used for setting animation when returning to normal state
  29789. * from hover.
  29790. *
  29791. * @declare Highcharts.PointStatesNormalOptionsObject
  29792. */
  29793. normal: {
  29794. /**
  29795. * Animation when returning to normal state after hovering.
  29796. *
  29797. * @type {boolean|Highcharts.AnimationOptionsObject}
  29798. */
  29799. animation: true
  29800. },
  29801. /**
  29802. * The hover state for a single point marker.
  29803. *
  29804. * @declare Highcharts.PointStatesHoverOptionsObject
  29805. */
  29806. hover: {
  29807. /**
  29808. * Animation when hovering over the marker.
  29809. *
  29810. * @type {boolean|Highcharts.AnimationOptionsObject}
  29811. */
  29812. animation: {
  29813. /** @internal */
  29814. duration: 50
  29815. },
  29816. /**
  29817. * Enable or disable the point marker.
  29818. *
  29819. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-enabled/
  29820. * Disabled hover state
  29821. */
  29822. enabled: true,
  29823. /**
  29824. * The fill color of the marker in hover state. When
  29825. * `undefined`, the series' or point's fillColor for normal
  29826. * state is used.
  29827. *
  29828. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  29829. * @apioption plotOptions.series.marker.states.hover.fillColor
  29830. */
  29831. /**
  29832. * The color of the point marker's outline. When
  29833. * `undefined`, the series' or point's lineColor for normal
  29834. * state is used.
  29835. *
  29836. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linecolor/
  29837. * White fill color, black line color
  29838. *
  29839. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  29840. * @apioption plotOptions.series.marker.states.hover.lineColor
  29841. */
  29842. /**
  29843. * The width of the point marker's outline. When
  29844. * `undefined`, the series' or point's lineWidth for normal
  29845. * state is used.
  29846. *
  29847. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linewidth/
  29848. * 3px line width
  29849. *
  29850. * @type {number}
  29851. * @apioption plotOptions.series.marker.states.hover.lineWidth
  29852. */
  29853. /**
  29854. * The radius of the point marker. In hover state, it
  29855. * defaults to the normal state's radius + 2 as per the
  29856. * [radiusPlus](#plotOptions.series.marker.states.hover.radiusPlus)
  29857. * option.
  29858. *
  29859. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/
  29860. * 10px radius
  29861. *
  29862. * @type {number}
  29863. * @apioption plotOptions.series.marker.states.hover.radius
  29864. */
  29865. /**
  29866. * The number of pixels to increase the radius of the
  29867. * hovered point.
  29868. *
  29869. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  29870. * 5 pixels greater radius on hover
  29871. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  29872. * 5 pixels greater radius on hover
  29873. *
  29874. * @since 4.0.3
  29875. */
  29876. radiusPlus: 2,
  29877. /**
  29878. * The additional line width for a hovered point.
  29879. *
  29880. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  29881. * 2 pixels wider on hover
  29882. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  29883. * 2 pixels wider on hover
  29884. *
  29885. * @since 4.0.3
  29886. */
  29887. lineWidthPlus: 1
  29888. },
  29889. /**
  29890. * The appearance of the point marker when selected. In order to
  29891. * allow a point to be selected, set the
  29892. * `series.allowPointSelect` option to true.
  29893. *
  29894. * @declare Highcharts.PointStatesSelectOptionsObject
  29895. */
  29896. select: {
  29897. /**
  29898. * Enable or disable visible feedback for selection.
  29899. *
  29900. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
  29901. * Disabled select state
  29902. *
  29903. * @type {boolean}
  29904. * @default true
  29905. * @apioption plotOptions.series.marker.states.select.enabled
  29906. */
  29907. /**
  29908. * The radius of the point marker. In hover state, it
  29909. * defaults to the normal state's radius + 2.
  29910. *
  29911. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
  29912. * 10px radius for selected points
  29913. *
  29914. * @type {number}
  29915. * @apioption plotOptions.series.marker.states.select.radius
  29916. */
  29917. /**
  29918. * The fill color of the point marker.
  29919. *
  29920. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
  29921. * Solid red discs for selected points
  29922. *
  29923. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  29924. */
  29925. fillColor: '#cccccc',
  29926. /**
  29927. * The color of the point marker's outline. When
  29928. * `undefined`, the series' or point's color is used.
  29929. *
  29930. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
  29931. * Red line color for selected points
  29932. *
  29933. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  29934. */
  29935. lineColor: '#000000',
  29936. /**
  29937. * The width of the point marker's outline.
  29938. *
  29939. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
  29940. * 3px line width for selected points
  29941. */
  29942. lineWidth: 2
  29943. }
  29944. }
  29945. },
  29946. /**
  29947. * Properties for each single point.
  29948. *
  29949. * @declare Highcharts.PlotSeriesPointOptions
  29950. *
  29951. * @private
  29952. */
  29953. point: {
  29954. /**
  29955. * Fires when a point is clicked. One parameter, `event`, is passed
  29956. * to the function, containing common event information.
  29957. *
  29958. * If the `series.allowPointSelect` option is true, the default
  29959. * action for the point's click event is to toggle the point's
  29960. * select state. Returning `false` cancels this action.
  29961. *
  29962. * @sample {highcharts} highcharts/plotoptions/series-point-events-click/
  29963. * Click marker to alert values
  29964. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/
  29965. * Click column
  29966. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/
  29967. * Go to URL
  29968. * @sample {highmaps} maps/plotoptions/series-point-events-click/
  29969. * Click marker to display values
  29970. * @sample {highmaps} maps/plotoptions/series-point-events-click-url/
  29971. * Go to URL
  29972. *
  29973. * @type {Highcharts.PointClickCallbackFunction}
  29974. * @context Highcharts.Point
  29975. * @apioption plotOptions.series.point.events.click
  29976. */
  29977. /**
  29978. * Fires when the mouse leaves the area close to the point. One
  29979. * parameter, `event`, is passed to the function, containing common
  29980. * event information.
  29981. *
  29982. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  29983. * Show values in the chart's corner on mouse over
  29984. *
  29985. * @type {Highcharts.PointMouseOutCallbackFunction}
  29986. * @context Highcharts.Point
  29987. * @apioption plotOptions.series.point.events.mouseOut
  29988. */
  29989. /**
  29990. * Fires when the mouse enters the area close to the point. One
  29991. * parameter, `event`, is passed to the function, containing common
  29992. * event information.
  29993. *
  29994. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  29995. * Show values in the chart's corner on mouse over
  29996. *
  29997. * @type {Highcharts.PointMouseOverCallbackFunction}
  29998. * @context Highcharts.Point
  29999. * @apioption plotOptions.series.point.events.mouseOver
  30000. */
  30001. /**
  30002. * Fires when the point is removed using the `.remove()` method. One
  30003. * parameter, `event`, is passed to the function. Returning `false`
  30004. * cancels the operation.
  30005. *
  30006. * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/
  30007. * Remove point and confirm
  30008. *
  30009. * @type {Highcharts.PointRemoveCallbackFunction}
  30010. * @since 1.2.0
  30011. * @context Highcharts.Point
  30012. * @apioption plotOptions.series.point.events.remove
  30013. */
  30014. /**
  30015. * Fires when the point is selected either programmatically or
  30016. * following a click on the point. One parameter, `event`, is passed
  30017. * to the function. Returning `false` cancels the operation.
  30018. *
  30019. * @sample {highcharts} highcharts/plotoptions/series-point-events-select/
  30020. * Report the last selected point
  30021. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  30022. * Report select and unselect
  30023. *
  30024. * @type {Highcharts.PointSelectCallbackFunction}
  30025. * @since 1.2.0
  30026. * @context Highcharts.Point
  30027. * @apioption plotOptions.series.point.events.select
  30028. */
  30029. /**
  30030. * Fires when the point is unselected either programmatically or
  30031. * following a click on the point. One parameter, `event`, is passed
  30032. * to the function.
  30033. * Returning `false` cancels the operation.
  30034. *
  30035. * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/
  30036. * Report the last unselected point
  30037. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  30038. * Report select and unselect
  30039. *
  30040. * @type {Highcharts.PointUnselectCallbackFunction}
  30041. * @since 1.2.0
  30042. * @context Highcharts.Point
  30043. * @apioption plotOptions.series.point.events.unselect
  30044. */
  30045. /**
  30046. * Fires when the point is updated programmatically through the
  30047. * `.update()` method. One parameter, `event`, is passed to the
  30048. * function. The new point options can be accessed through
  30049. * `event.options`. Returning `false` cancels the operation.
  30050. *
  30051. * @sample {highcharts} highcharts/plotoptions/series-point-events-update/
  30052. * Confirm point updating
  30053. *
  30054. * @type {Highcharts.PointUpdateCallbackFunction}
  30055. * @since 1.2.0
  30056. * @context Highcharts.Point
  30057. * @apioption plotOptions.series.point.events.update
  30058. */
  30059. /**
  30060. * Events for each single point.
  30061. *
  30062. * @declare Highcharts.PointEventsOptionsObject
  30063. */
  30064. events: {}
  30065. },
  30066. /**
  30067. * Options for the series data labels, appearing next to each data
  30068. * point.
  30069. *
  30070. * Since v6.2.0, multiple data labels can be applied to each single
  30071. * point by defining them as an array of configs.
  30072. *
  30073. * In styled mode, the data labels can be styled with the
  30074. * `.highcharts-data-label-box` and `.highcharts-data-label` class names
  30075. * ([see example](https://www.highcharts.com/samples/highcharts/css/series-datalabels)).
  30076. *
  30077. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled
  30078. * Data labels enabled
  30079. * @sample {highcharts} highcharts/plotoptions/series-datalabels-multiple
  30080. * Multiple data labels on a bar series
  30081. * @sample {highcharts} highcharts/css/series-datalabels
  30082. * Style mode example
  30083. *
  30084. * @type {*|Array<*>}
  30085. * @product highcharts highstock highmaps gantt
  30086. *
  30087. * @private
  30088. */
  30089. dataLabels: {
  30090. /**
  30091. * The alignment of the data label compared to the point. If
  30092. * `right`, the right side of the label should be touching the
  30093. * point. For points with an extent, like columns, the alignments
  30094. * also dictates how to align it inside the box, as given with the
  30095. * [inside](#plotOptions.column.dataLabels.inside)
  30096. * option. Can be one of `left`, `center` or `right`.
  30097. *
  30098. * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/
  30099. * Left aligned
  30100. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  30101. * Data labels inside the bar
  30102. *
  30103. * @type {Highcharts.AlignValue|null}
  30104. */
  30105. align: 'center',
  30106. /**
  30107. * Whether to allow data labels to overlap. To make the labels less
  30108. * sensitive for overlapping, the
  30109. * [dataLabels.padding](#plotOptions.series.dataLabels.padding)
  30110. * can be set to 0.
  30111. *
  30112. * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/
  30113. * Don't allow overlap
  30114. *
  30115. * @type {boolean}
  30116. * @default false
  30117. * @since 4.1.0
  30118. * @apioption plotOptions.series.dataLabels.allowOverlap
  30119. */
  30120. /**
  30121. * The background color or gradient for the data label.
  30122. *
  30123. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  30124. * Data labels box options
  30125. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  30126. * Data labels box options
  30127. *
  30128. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  30129. * @since 2.2.1
  30130. * @apioption plotOptions.series.dataLabels.backgroundColor
  30131. */
  30132. /**
  30133. * The border color for the data label. Defaults to `undefined`.
  30134. *
  30135. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  30136. * Data labels box options
  30137. *
  30138. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  30139. * @since 2.2.1
  30140. * @apioption plotOptions.series.dataLabels.borderColor
  30141. */
  30142. /**
  30143. * The border radius in pixels for the data label.
  30144. *
  30145. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  30146. * Data labels box options
  30147. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  30148. * Data labels box options
  30149. *
  30150. * @type {number}
  30151. * @default 0
  30152. * @since 2.2.1
  30153. * @apioption plotOptions.series.dataLabels.borderRadius
  30154. */
  30155. /**
  30156. * The border width in pixels for the data label.
  30157. *
  30158. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  30159. * Data labels box options
  30160. *
  30161. * @type {number}
  30162. * @default 0
  30163. * @since 2.2.1
  30164. * @apioption plotOptions.series.dataLabels.borderWidth
  30165. */
  30166. /**
  30167. * A class name for the data label. Particularly in styled mode,
  30168. * this can be used to give each series' or point's data label
  30169. * unique styling. In addition to this option, a default color class
  30170. * name is added so that we can give the labels a contrast text
  30171. * shadow.
  30172. *
  30173. * @sample {highcharts} highcharts/css/data-label-contrast/
  30174. * Contrast text shadow
  30175. * @sample {highcharts} highcharts/css/series-datalabels/
  30176. * Styling by CSS
  30177. *
  30178. * @type {string}
  30179. * @since 5.0.0
  30180. * @apioption plotOptions.series.dataLabels.className
  30181. */
  30182. /**
  30183. * The text color for the data labels. Defaults to `undefined`. For
  30184. * certain series types, like column or map, the data labels can be
  30185. * drawn inside the points. In this case the data label will be
  30186. * drawn with maximum contrast by default. Additionally, it will be
  30187. * given a `text-outline` style with the opposite color, to further
  30188. * increase the contrast. This can be overridden by setting the
  30189. * `text-outline` style to `none` in the `dataLabels.style` option.
  30190. *
  30191. * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
  30192. * Red data labels
  30193. * @sample {highmaps} maps/demo/color-axis/
  30194. * White data labels
  30195. *
  30196. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  30197. * @apioption plotOptions.series.dataLabels.color
  30198. */
  30199. /**
  30200. * Whether to hide data labels that are outside the plot area. By
  30201. * default, the data label is moved inside the plot area according
  30202. * to the
  30203. * [overflow](#plotOptions.series.dataLabels.overflow)
  30204. * option.
  30205. *
  30206. * @type {boolean}
  30207. * @default true
  30208. * @since 2.3.3
  30209. * @apioption plotOptions.series.dataLabels.crop
  30210. */
  30211. /**
  30212. * Whether to defer displaying the data labels until the initial
  30213. * series animation has finished.
  30214. *
  30215. * @type {boolean}
  30216. * @default true
  30217. * @since 4.0.0
  30218. * @product highcharts highstock gantt
  30219. * @apioption plotOptions.series.dataLabels.defer
  30220. */
  30221. /**
  30222. * Enable or disable the data labels.
  30223. *
  30224. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/
  30225. * Data labels enabled
  30226. * @sample {highmaps} maps/demo/color-axis/
  30227. * Data labels enabled
  30228. *
  30229. * @type {boolean}
  30230. * @default false
  30231. * @apioption plotOptions.series.dataLabels.enabled
  30232. */
  30233. /**
  30234. * A declarative filter to control of which data labels to display.
  30235. * The declarative filter is designed for use when callback
  30236. * functions are not available, like when the chart options require
  30237. * a pure JSON structure or for use with graphical editors. For
  30238. * programmatic control, use the `formatter` instead, and return
  30239. * `undefined` to disable a single data label.
  30240. *
  30241. * @example
  30242. * filter: {
  30243. * property: 'percentage',
  30244. * operator: '>',
  30245. * value: 4
  30246. * }
  30247. *
  30248. * @sample {highcharts} highcharts/demo/pie-monochrome
  30249. * Data labels filtered by percentage
  30250. *
  30251. * @declare Highcharts.DataLabelsFilterOptionsObject
  30252. * @since 6.0.3
  30253. * @apioption plotOptions.series.dataLabels.filter
  30254. */
  30255. /**
  30256. * The operator to compare by. Can be one of `>`, `<`, `>=`, `<=`,
  30257. * `==`, and `===`.
  30258. *
  30259. * @type {string}
  30260. * @validvalue [">", "<", ">=", "<=", "==", "==="]
  30261. * @apioption plotOptions.series.dataLabels.filter.operator
  30262. */
  30263. /**
  30264. * The point property to filter by. Point options are passed
  30265. * directly to properties, additionally there are `y` value,
  30266. * `percentage` and others listed under {@link Highcharts.Point}
  30267. * members.
  30268. *
  30269. * @type {string}
  30270. * @apioption plotOptions.series.dataLabels.filter.property
  30271. */
  30272. /**
  30273. * The value to compare against.
  30274. *
  30275. * @type {number}
  30276. * @apioption plotOptions.series.dataLabels.filter.value
  30277. */
  30278. /**
  30279. * A
  30280. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  30281. * for the data label. Available variables are the same as for
  30282. * `formatter`.
  30283. *
  30284. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  30285. * Add a unit
  30286. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  30287. * Formatted value in the data label
  30288. *
  30289. * @type {string}
  30290. * @default y
  30291. * @default point.value
  30292. * @since 3.0
  30293. * @apioption plotOptions.series.dataLabels.format
  30294. */
  30295. // eslint-disable-next-line valid-jsdoc
  30296. /**
  30297. * Callback JavaScript function to format the data label. Note that
  30298. * if a `format` is defined, the format takes precedence and the
  30299. * formatter is ignored.
  30300. *
  30301. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  30302. * Formatted value
  30303. *
  30304. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  30305. */
  30306. formatter: function () {
  30307. var numberFormatter = this.series.chart.numberFormatter;
  30308. return typeof this.y !== 'number' ? '' : numberFormatter(this.y, -1);
  30309. },
  30310. /**
  30311. * For points with an extent, like columns or map areas, whether to
  30312. * align the data label inside the box or to the actual value point.
  30313. * Defaults to `false` in most cases, `true` in stacked columns.
  30314. *
  30315. * @type {boolean}
  30316. * @since 3.0
  30317. * @apioption plotOptions.series.dataLabels.inside
  30318. */
  30319. /**
  30320. * Format for points with the value of null. Works analogously to
  30321. * [format](#plotOptions.series.dataLabels.format). `nullFormat` can
  30322. * be applied only to series which support displaying null points.
  30323. *
  30324. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  30325. * Format data label and tooltip for null point.
  30326. *
  30327. * @type {boolean|string}
  30328. * @since 7.1.0
  30329. * @apioption plotOptions.series.dataLabels.nullFormat
  30330. */
  30331. /**
  30332. * Callback JavaScript function that defines formatting for points
  30333. * with the value of null. Works analogously to
  30334. * [formatter](#plotOptions.series.dataLabels.formatter).
  30335. * `nullPointFormatter` can be applied only to series which support
  30336. * displaying null points.
  30337. *
  30338. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  30339. * Format data label and tooltip for null point.
  30340. *
  30341. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  30342. * @since 7.1.0
  30343. * @apioption plotOptions.series.dataLabels.nullFormatter
  30344. */
  30345. /**
  30346. * How to handle data labels that flow outside the plot area. The
  30347. * default is `"justify"`, which aligns them inside the plot area.
  30348. * For columns and bars, this means it will be moved inside the bar.
  30349. * To display data labels outside the plot area, set `crop` to
  30350. * `false` and `overflow` to `"allow"`.
  30351. *
  30352. * @type {Highcharts.DataLabelsOverflowValue}
  30353. * @default justify
  30354. * @since 3.0.6
  30355. * @apioption plotOptions.series.dataLabels.overflow
  30356. */
  30357. /**
  30358. * When either the `borderWidth` or the `backgroundColor` is set,
  30359. * this is the padding within the box.
  30360. *
  30361. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  30362. * Data labels box options
  30363. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  30364. * Data labels box options
  30365. *
  30366. * @since 2.2.1
  30367. */
  30368. padding: 5,
  30369. /**
  30370. * Aligns data labels relative to points. If `center` alignment is
  30371. * not possible, it defaults to `right`.
  30372. *
  30373. * @type {Highcharts.AlignValue}
  30374. * @default center
  30375. * @apioption plotOptions.series.dataLabels.position
  30376. */
  30377. /**
  30378. * Text rotation in degrees. Note that due to a more complex
  30379. * structure, backgrounds, borders and padding will be lost on a
  30380. * rotated data label.
  30381. *
  30382. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  30383. * Vertical labels
  30384. *
  30385. * @type {number}
  30386. * @default 0
  30387. * @apioption plotOptions.series.dataLabels.rotation
  30388. */
  30389. /**
  30390. * The shadow of the box. Works best with `borderWidth` or
  30391. * `backgroundColor`. Since 2.3 the shadow can be an object
  30392. * configuration containing `color`, `offsetX`, `offsetY`, `opacity`
  30393. * and `width`.
  30394. *
  30395. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  30396. * Data labels box options
  30397. *
  30398. * @type {boolean|Highcharts.ShadowOptionsObject}
  30399. * @default false
  30400. * @since 2.2.1
  30401. * @apioption plotOptions.series.dataLabels.shadow
  30402. */
  30403. /**
  30404. * The name of a symbol to use for the border around the label.
  30405. * Symbols are predefined functions on the Renderer object.
  30406. *
  30407. * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/
  30408. * A callout for annotations
  30409. *
  30410. * @type {string}
  30411. * @default square
  30412. * @since 4.1.2
  30413. * @apioption plotOptions.series.dataLabels.shape
  30414. */
  30415. /**
  30416. * Styles for the label. The default `color` setting is
  30417. * `"contrast"`, which is a pseudo color that Highcharts picks up
  30418. * and applies the maximum contrast to the underlying point item,
  30419. * for example the bar in a bar chart.
  30420. *
  30421. * The `textOutline` is a pseudo property that applies an outline of
  30422. * the given width with the given color, which by default is the
  30423. * maximum contrast to the text. So a bright text color will result
  30424. * in a black text outline for maximum readability on a mixed
  30425. * background. In some cases, especially with grayscale text, the
  30426. * text outline doesn't work well, in which cases it can be disabled
  30427. * by setting it to `"none"`. When `useHTML` is true, the
  30428. * `textOutline` will not be picked up. In this, case, the same
  30429. * effect can be acheived through the `text-shadow` CSS property.
  30430. *
  30431. * For some series types, where each point has an extent, like for
  30432. * example tree maps, the data label may overflow the point. There
  30433. * are two strategies for handling overflow. By default, the text
  30434. * will wrap to multiple lines. The other strategy is to set
  30435. * `style.textOverflow` to `ellipsis`, which will keep the text on
  30436. * one line plus it will break inside long words.
  30437. *
  30438. * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
  30439. * Bold labels
  30440. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow/
  30441. * Long labels truncated with an ellipsis in a pie
  30442. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap/
  30443. * Long labels are wrapped in a pie
  30444. * @sample {highmaps} maps/demo/color-axis/
  30445. * Bold labels
  30446. *
  30447. * @type {Highcharts.CSSObject}
  30448. * @since 4.1.0
  30449. * @apioption plotOptions.series.dataLabels.style
  30450. */
  30451. style: {
  30452. /** @internal */
  30453. fontSize: '11px',
  30454. /** @internal */
  30455. fontWeight: 'bold',
  30456. /** @internal */
  30457. color: 'contrast',
  30458. /** @internal */
  30459. textOutline: '1px contrast'
  30460. },
  30461. /**
  30462. * Options for a label text which should follow marker's shape.
  30463. * Border and background are disabled for a label that follows a
  30464. * path.
  30465. *
  30466. * **Note:** Only SVG-based renderer supports this option. Setting
  30467. * `useHTML` to true will disable this option.
  30468. *
  30469. * @declare Highcharts.DataLabelsTextPathOptionsObject
  30470. * @since 7.1.0
  30471. * @apioption plotOptions.series.dataLabels.textPath
  30472. */
  30473. /**
  30474. * Presentation attributes for the text path.
  30475. *
  30476. * @type {Highcharts.SVGAttributes}
  30477. * @since 7.1.0
  30478. * @apioption plotOptions.series.dataLabels.textPath.attributes
  30479. */
  30480. /**
  30481. * Enable or disable `textPath` option for link's or marker's data
  30482. * labels.
  30483. *
  30484. * @type {boolean}
  30485. * @since 7.1.0
  30486. * @apioption plotOptions.series.dataLabels.textPath.enabled
  30487. */
  30488. /**
  30489. * Whether to
  30490. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  30491. * to render the labels.
  30492. *
  30493. * @type {boolean}
  30494. * @default false
  30495. * @apioption plotOptions.series.dataLabels.useHTML
  30496. */
  30497. /**
  30498. * The vertical alignment of a data label. Can be one of `top`,
  30499. * `middle` or `bottom`. The default value depends on the data, for
  30500. * instance in a column chart, the label is above positive values
  30501. * and below negative values.
  30502. *
  30503. * @type {Highcharts.VerticalAlignValue|null}
  30504. * @since 2.3.3
  30505. */
  30506. verticalAlign: 'bottom',
  30507. /**
  30508. * The x position offset of the label relative to the point in
  30509. * pixels.
  30510. *
  30511. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  30512. * Vertical and positioned
  30513. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  30514. * Data labels inside the bar
  30515. */
  30516. x: 0,
  30517. /**
  30518. * The Z index of the data labels. The default Z index puts it above
  30519. * the series. Use a Z index of 2 to display it behind the series.
  30520. *
  30521. * @type {number}
  30522. * @default 6
  30523. * @since 2.3.5
  30524. * @apioption plotOptions.series.dataLabels.z
  30525. */
  30526. /**
  30527. * The y position offset of the label relative to the point in
  30528. * pixels.
  30529. *
  30530. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  30531. * Vertical and positioned
  30532. */
  30533. y: 0
  30534. },
  30535. /**
  30536. * When the series contains less points than the crop threshold, all
  30537. * points are drawn, even if the points fall outside the visible plot
  30538. * area at the current zoom. The advantage of drawing all points
  30539. * (including markers and columns), is that animation is performed on
  30540. * updates. On the other hand, when the series contains more points than
  30541. * the crop threshold, the series data is cropped to only contain points
  30542. * that fall within the plot area. The advantage of cropping away
  30543. * invisible points is to increase performance on large series.
  30544. *
  30545. * @since 2.2
  30546. * @product highcharts highstock
  30547. *
  30548. * @private
  30549. */
  30550. cropThreshold: 300,
  30551. /**
  30552. * Opacity of a series parts: line, fill (e.g. area) and dataLabels.
  30553. *
  30554. * @see [states.inactive.opacity](#plotOptions.series.states.inactive.opacity)
  30555. *
  30556. * @since 7.1.0
  30557. *
  30558. * @private
  30559. */
  30560. opacity: 1,
  30561. /**
  30562. * The width of each point on the x axis. For example in a column chart
  30563. * with one value each day, the pointRange would be 1 day (= 24 * 3600
  30564. * * 1000 milliseconds). This is normally computed automatically, but
  30565. * this option can be used to override the automatic value.
  30566. *
  30567. * @product highstock
  30568. *
  30569. * @private
  30570. */
  30571. pointRange: 0,
  30572. /**
  30573. * When this is true, the series will not cause the Y axis to cross
  30574. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  30575. * unless the data actually crosses the plane.
  30576. *
  30577. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  30578. * 3 will make the Y axis show negative values according to the
  30579. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  30580. * at 0.
  30581. *
  30582. * @since 4.1.9
  30583. * @product highcharts highstock
  30584. *
  30585. * @private
  30586. */
  30587. softThreshold: true,
  30588. /**
  30589. * @declare Highcharts.SeriesStatesOptionsObject
  30590. *
  30591. * @private
  30592. */
  30593. states: {
  30594. /**
  30595. * The normal state of a series, or for point items in column, pie
  30596. * and similar series. Currently only used for setting animation
  30597. * when returning to normal state from hover.
  30598. *
  30599. * @declare Highcharts.SeriesStatesNormalOptionsObject
  30600. */
  30601. normal: {
  30602. /**
  30603. * Animation when returning to normal state after hovering.
  30604. *
  30605. * @type {boolean|Highcharts.AnimationOptionsObject}
  30606. */
  30607. animation: true
  30608. },
  30609. /**
  30610. * Options for the hovered series. These settings override the
  30611. * normal state options when a series is moused over or touched.
  30612. *
  30613. * @declare Highcharts.SeriesStatesHoverOptionsObject
  30614. */
  30615. hover: {
  30616. /**
  30617. * Enable separate styles for the hovered series to visualize
  30618. * that the user hovers either the series itself or the legend.
  30619. *
  30620. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/
  30621. * Line
  30622. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/
  30623. * Column
  30624. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/
  30625. * Pie
  30626. *
  30627. * @type {boolean}
  30628. * @default true
  30629. * @since 1.2
  30630. * @apioption plotOptions.series.states.hover.enabled
  30631. */
  30632. /**
  30633. * Animation setting for hovering the graph in line-type series.
  30634. *
  30635. * @type {boolean|Highcharts.AnimationOptionsObject}
  30636. * @since 5.0.8
  30637. * @product highcharts highstock
  30638. */
  30639. animation: {
  30640. /**
  30641. * The duration of the hover animation in milliseconds. By
  30642. * default the hover state animates quickly in, and slowly
  30643. * back to normal.
  30644. *
  30645. * @internal
  30646. */
  30647. duration: 50
  30648. },
  30649. /**
  30650. * Pixel width of the graph line. By default this property is
  30651. * undefined, and the `lineWidthPlus` property dictates how much
  30652. * to increase the linewidth from normal state.
  30653. *
  30654. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
  30655. * 5px line on hover
  30656. *
  30657. * @type {number}
  30658. * @product highcharts highstock
  30659. * @apioption plotOptions.series.states.hover.lineWidth
  30660. */
  30661. /**
  30662. * The additional line width for the graph of a hovered series.
  30663. *
  30664. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  30665. * 5 pixels wider
  30666. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  30667. * 5 pixels wider
  30668. *
  30669. * @since 4.0.3
  30670. * @product highcharts highstock
  30671. */
  30672. lineWidthPlus: 1,
  30673. /**
  30674. * In Highcharts 1.0, the appearance of all markers belonging
  30675. * to the hovered series. For settings on the hover state of the
  30676. * individual point, see
  30677. * [marker.states.hover](#plotOptions.series.marker.states.hover).
  30678. *
  30679. * @deprecated
  30680. *
  30681. * @extends plotOptions.series.marker
  30682. * @excluding states
  30683. * @product highcharts highstock
  30684. */
  30685. marker: {
  30686. // lineWidth: base + 1,
  30687. // radius: base + 1
  30688. },
  30689. /**
  30690. * Options for the halo appearing around the hovered point in
  30691. * line-type series as well as outside the hovered slice in pie
  30692. * charts. By default the halo is filled by the current point or
  30693. * series color with an opacity of 0.25\. The halo can be
  30694. * disabled by setting the `halo` option to `null`.
  30695. *
  30696. * In styled mode, the halo is styled with the
  30697. * `.highcharts-halo` class, with colors inherited from
  30698. * `.highcharts-color-{n}`.
  30699. *
  30700. * @sample {highcharts} highcharts/plotoptions/halo/
  30701. * Halo options
  30702. * @sample {highstock} highcharts/plotoptions/halo/
  30703. * Halo options
  30704. *
  30705. * @declare Highcharts.SeriesStatesHoverHaloOptionsObject
  30706. * @type {null|*}
  30707. * @since 4.0
  30708. * @product highcharts highstock
  30709. */
  30710. halo: {
  30711. /**
  30712. * A collection of SVG attributes to override the appearance
  30713. * of the halo, for example `fill`, `stroke` and
  30714. * `stroke-width`.
  30715. *
  30716. * @type {Highcharts.SVGAttributes}
  30717. * @since 4.0
  30718. * @product highcharts highstock
  30719. * @apioption plotOptions.series.states.hover.halo.attributes
  30720. */
  30721. /**
  30722. * The pixel size of the halo. For point markers this is the
  30723. * radius of the halo. For pie slices it is the width of the
  30724. * halo outside the slice. For bubbles it defaults to 5 and
  30725. * is the width of the halo outside the bubble.
  30726. *
  30727. * @since 4.0
  30728. * @product highcharts highstock
  30729. */
  30730. size: 10,
  30731. /**
  30732. * Opacity for the halo unless a specific fill is overridden
  30733. * using the `attributes` setting. Note that Highcharts is
  30734. * only able to apply opacity to colors of hex or rgb(a)
  30735. * formats.
  30736. *
  30737. * @since 4.0
  30738. * @product highcharts highstock
  30739. */
  30740. opacity: 0.25
  30741. }
  30742. },
  30743. /**
  30744. * Specific options for point in selected states, after being
  30745. * selected by
  30746. * [allowPointSelect](#plotOptions.series.allowPointSelect)
  30747. * or programmatically.
  30748. *
  30749. * @sample maps/plotoptions/series-allowpointselect/
  30750. * Allow point select demo
  30751. *
  30752. * @declare Highcharts.SeriesStatesSelectOptionsObject
  30753. * @extends plotOptions.series.states.hover
  30754. * @excluding brightness
  30755. */
  30756. select: {
  30757. animation: {
  30758. /** @internal */
  30759. duration: 0
  30760. }
  30761. },
  30762. /**
  30763. * The opposite state of a hover for series.
  30764. *
  30765. * @sample highcharts/plotoptions/series-states-inactive-disabled
  30766. * Disabled inactive state
  30767. *
  30768. * @declare Highcharts.SeriesStatesInactiveOptionsObject
  30769. */
  30770. inactive: {
  30771. /**
  30772. * Enable or disable the inactive state for a series
  30773. *
  30774. * @sample highcharts/plotoptions/series-states-inactive-disabled
  30775. * Disabled inactive state
  30776. *
  30777. * @type {boolean}
  30778. * @default true
  30779. * @apioption plotOptions.series.states.inactive.enabled
  30780. */
  30781. /**
  30782. * The animation for entering the inactive state.
  30783. *
  30784. * @type {boolean|Highcharts.AnimationOptionsObject}
  30785. */
  30786. animation: {
  30787. /** @internal */
  30788. duration: 50
  30789. },
  30790. /**
  30791. * Opacity of series elements (dataLabels, line, area).
  30792. *
  30793. * @type {number}
  30794. */
  30795. opacity: 0.2
  30796. }
  30797. },
  30798. /**
  30799. * Sticky tracking of mouse events. When true, the `mouseOut` event on a
  30800. * series isn't triggered until the mouse moves over another series, or
  30801. * out of the plot area. When false, the `mouseOut` event on a series is
  30802. * triggered when the mouse leaves the area around the series' graph or
  30803. * markers. This also implies the tooltip when not shared. When
  30804. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  30805. * will be hidden when moving the mouse between series. Defaults to true
  30806. * for line and area type series, but to false for columns, pies etc.
  30807. *
  30808. * **Note:** The boost module will force this option because of
  30809. * technical limitations.
  30810. *
  30811. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
  30812. * True by default
  30813. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
  30814. * False
  30815. *
  30816. * @default {highcharts} true
  30817. * @default {highstock} true
  30818. * @default {highmaps} false
  30819. * @since 2.0
  30820. *
  30821. * @private
  30822. */
  30823. stickyTracking: true,
  30824. /**
  30825. * A configuration object for the tooltip rendering of each single
  30826. * series. Properties are inherited from [tooltip](#tooltip), but only
  30827. * the following properties can be defined on a series level.
  30828. *
  30829. * @declare Highcharts.SeriesTooltipOptionsObject
  30830. * @since 2.3
  30831. * @extends tooltip
  30832. * @excluding animation, backgroundColor, borderColor, borderRadius,
  30833. * borderWidth, className, crosshairs, enabled, formatter,
  30834. * headerShape, hideDelay, outside, padding, positioner,
  30835. * shadow, shape, shared, snap, split, style, useHTML
  30836. * @apioption plotOptions.series.tooltip
  30837. */
  30838. /**
  30839. * When a series contains a data array that is longer than this, only
  30840. * one dimensional arrays of numbers, or two dimensional arrays with
  30841. * x and y values are allowed. Also, only the first point is tested,
  30842. * and the rest are assumed to be the same format. This saves expensive
  30843. * data checking and indexing in long series. Set it to `0` disable.
  30844. *
  30845. * Note:
  30846. * In boost mode turbo threshold is forced. Only array of numbers or
  30847. * two dimensional arrays are allowed.
  30848. *
  30849. * @since 2.2
  30850. * @product highcharts highstock gantt
  30851. *
  30852. * @private
  30853. */
  30854. turboThreshold: 1000,
  30855. /**
  30856. * An array defining zones within a series. Zones can be applied to the
  30857. * X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
  30858. * option. The zone definitions have to be in ascending order regarding
  30859. * to the value.
  30860. *
  30861. * In styled mode, the color zones are styled with the
  30862. * `.highcharts-zone-{n}` class, or custom classed from the `className`
  30863. * option
  30864. * ([view live demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-zones/)).
  30865. *
  30866. * @see [zoneAxis](#plotOptions.series.zoneAxis)
  30867. *
  30868. * @sample {highcharts} highcharts/series/color-zones-simple/
  30869. * Color zones
  30870. * @sample {highstock} highcharts/series/color-zones-simple/
  30871. * Color zones
  30872. *
  30873. * @declare Highcharts.SeriesZonesOptionsObject
  30874. * @type {Array<*>}
  30875. * @since 4.1.0
  30876. * @product highcharts highstock
  30877. * @apioption plotOptions.series.zones
  30878. */
  30879. /**
  30880. * Styled mode only. A custom class name for the zone.
  30881. *
  30882. * @sample highcharts/css/color-zones/
  30883. * Zones styled by class name
  30884. *
  30885. * @type {string}
  30886. * @since 5.0.0
  30887. * @apioption plotOptions.series.zones.className
  30888. */
  30889. /**
  30890. * Defines the color of the series.
  30891. *
  30892. * @see [series color](#plotOptions.series.color)
  30893. *
  30894. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  30895. * @since 4.1.0
  30896. * @product highcharts highstock
  30897. * @apioption plotOptions.series.zones.color
  30898. */
  30899. /**
  30900. * A name for the dash style to use for the graph.
  30901. *
  30902. * @see [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  30903. *
  30904. * @sample {highcharts|highstock} highcharts/series/color-zones-dashstyle-dot/
  30905. * Dashed line indicates prognosis
  30906. *
  30907. * @type {Highcharts.DashStyleValue}
  30908. * @since 4.1.0
  30909. * @product highcharts highstock
  30910. * @apioption plotOptions.series.zones.dashStyle
  30911. */
  30912. /**
  30913. * Defines the fill color for the series (in area type series)
  30914. *
  30915. * @see [fillColor](#plotOptions.area.fillColor)
  30916. *
  30917. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  30918. * @since 4.1.0
  30919. * @product highcharts highstock
  30920. * @apioption plotOptions.series.zones.fillColor
  30921. */
  30922. /**
  30923. * The value up to where the zone extends, if undefined the zones
  30924. * stretches to the last value in the series.
  30925. *
  30926. * @type {number}
  30927. * @since 4.1.0
  30928. * @product highcharts highstock
  30929. * @apioption plotOptions.series.zones.value
  30930. */
  30931. /**
  30932. * When using dual or multiple color axes, this number defines which
  30933. * colorAxis the particular series is connected to. It refers to
  30934. * either the
  30935. * {@link #colorAxis.id|axis id}
  30936. * or the index of the axis in the colorAxis array, with 0 being the
  30937. * first. Set this option to false to prevent a series from connecting
  30938. * to the default color axis.
  30939. *
  30940. * Since v7.2.0 the option can also be an axis id or an axis index
  30941. * instead of a boolean flag.
  30942. *
  30943. * @sample highcharts/coloraxis/coloraxis-with-pie/
  30944. * Color axis with pie series
  30945. * @sample highcharts/coloraxis/multiple-coloraxis/
  30946. * Multiple color axis
  30947. *
  30948. * @type {number|string|boolean}
  30949. * @default 0
  30950. * @product highcharts highstock highmaps
  30951. * @apioption plotOptions.series.colorAxis
  30952. */
  30953. /**
  30954. * Determines what data value should be used to calculate point color
  30955. * if `colorAxis` is used. Requires to set `min` and `max` if some
  30956. * custom point property is used or if approximation for data grouping
  30957. * is set to `'sum'`.
  30958. *
  30959. * @sample highcharts/coloraxis/custom-color-key/
  30960. * Custom color key
  30961. * @sample highcharts/coloraxis/changed-default-color-key/
  30962. * Changed default color key
  30963. *
  30964. * @type {string}
  30965. * @default y
  30966. * @since 7.2.0
  30967. * @product highcharts highstock highmaps
  30968. * @apioption plotOptions.series.colorKey
  30969. */
  30970. /**
  30971. * Determines whether the series should look for the nearest point
  30972. * in both dimensions or just the x-dimension when hovering the series.
  30973. * Defaults to `'xy'` for scatter series and `'x'` for most other
  30974. * series. If the data has duplicate x-values, it is recommended to
  30975. * set this to `'xy'` to allow hovering over all points.
  30976. *
  30977. * Applies only to series types using nearest neighbor search (not
  30978. * direct hover) for tooltip.
  30979. *
  30980. * @sample {highcharts} highcharts/series/findnearestpointby/
  30981. * Different hover behaviors
  30982. * @sample {highstock} highcharts/series/findnearestpointby/
  30983. * Different hover behaviors
  30984. * @sample {highmaps} highcharts/series/findnearestpointby/
  30985. * Different hover behaviors
  30986. *
  30987. * @since 5.0.10
  30988. * @validvalue ["x", "xy"]
  30989. *
  30990. * @private
  30991. */
  30992. findNearestPointBy: 'x'
  30993. },
  30994. /* eslint-disable no-invalid-this, valid-jsdoc */
  30995. /** @lends Highcharts.Series.prototype */
  30996. {
  30997. axisTypes: ['xAxis', 'yAxis'],
  30998. coll: 'series',
  30999. colorCounter: 0,
  31000. cropShoulder: 1,
  31001. directTouch: false,
  31002. eventsToUnbind: [],
  31003. isCartesian: true,
  31004. // each point's x and y values are stored in this.xData and this.yData
  31005. parallelArrays: ['x', 'y'],
  31006. pointClass: Point,
  31007. requireSorting: true,
  31008. sorted: true,
  31009. init: function (chart, options) {
  31010. fireEvent(this, 'init', { options: options });
  31011. var series = this, events, chartSeries = chart.series, lastSeries;
  31012. // A lookup over those events that are added by _options_ (not
  31013. // programmatically). These are updated through Series.update()
  31014. // (#10861).
  31015. this.eventOptions = this.eventOptions || {};
  31016. /**
  31017. * Read only. The chart that the series belongs to.
  31018. *
  31019. * @name Highcharts.Series#chart
  31020. * @type {Highcharts.Chart}
  31021. */
  31022. series.chart = chart;
  31023. /**
  31024. * Read only. The series' type, like "line", "area", "column" etc.
  31025. * The type in the series options anc can be altered using
  31026. * {@link Series#update}.
  31027. *
  31028. * @name Highcharts.Series#type
  31029. * @type {string}
  31030. */
  31031. /**
  31032. * Read only. The series' current options. To update, use
  31033. * {@link Series#update}.
  31034. *
  31035. * @name Highcharts.Series#options
  31036. * @type {Highcharts.SeriesOptionsType}
  31037. */
  31038. series.options = options = series.setOptions(options);
  31039. series.linkedSeries = [];
  31040. // bind the axes
  31041. series.bindAxes();
  31042. // set some variables
  31043. extend(series, {
  31044. /**
  31045. * The series name as given in the options. Defaults to
  31046. * "Series {n}".
  31047. *
  31048. * @name Highcharts.Series#name
  31049. * @type {string}
  31050. */
  31051. name: options.name,
  31052. state: '',
  31053. /**
  31054. * Read only. The series' visibility state as set by {@link
  31055. * Series#show}, {@link Series#hide}, or in the initial
  31056. * configuration.
  31057. *
  31058. * @name Highcharts.Series#visible
  31059. * @type {boolean}
  31060. */
  31061. visible: options.visible !== false,
  31062. /**
  31063. * Read only. The series' selected state as set by {@link
  31064. * Highcharts.Series#select}.
  31065. *
  31066. * @name Highcharts.Series#selected
  31067. * @type {boolean}
  31068. */
  31069. selected: options.selected === true // false by default
  31070. });
  31071. // Register event listeners
  31072. events = options.events;
  31073. objectEach(events, function (event, eventType) {
  31074. if (isFunction(event)) {
  31075. // If event does not exist, or is changed by Series.update
  31076. if (series.eventOptions[eventType] !== event) {
  31077. // Remove existing if set by option
  31078. if (isFunction(series.eventOptions[eventType])) {
  31079. removeEvent(series, eventType, series.eventOptions[eventType]);
  31080. }
  31081. series.eventOptions[eventType] = event;
  31082. addEvent(series, eventType, event);
  31083. }
  31084. }
  31085. });
  31086. if ((events && events.click) ||
  31087. (options.point &&
  31088. options.point.events &&
  31089. options.point.events.click) ||
  31090. options.allowPointSelect) {
  31091. chart.runTrackerClick = true;
  31092. }
  31093. series.getColor();
  31094. series.getSymbol();
  31095. // Initialize the parallel data arrays
  31096. series.parallelArrays.forEach(function (key) {
  31097. if (!series[key + 'Data']) {
  31098. series[key + 'Data'] = [];
  31099. }
  31100. });
  31101. // Mark cartesian
  31102. if (series.isCartesian) {
  31103. chart.hasCartesianSeries = true;
  31104. }
  31105. // Get the index and register the series in the chart. The index is
  31106. // one more than the current latest series index (#5960).
  31107. if (chartSeries.length) {
  31108. lastSeries = chartSeries[chartSeries.length - 1];
  31109. }
  31110. series._i = pick(lastSeries && lastSeries._i, -1) + 1;
  31111. series.opacity = series.options.opacity;
  31112. // Insert the series and re-order all series above the insertion
  31113. // point.
  31114. chart.orderSeries(this.insert(chartSeries));
  31115. // Set options for series with sorting and set data later.
  31116. if (options.dataSorting && options.dataSorting.enabled) {
  31117. series.setDataSortingOptions();
  31118. }
  31119. else if (!series.points && !series.data) {
  31120. series.setData(options.data, false);
  31121. }
  31122. fireEvent(this, 'afterInit');
  31123. },
  31124. /**
  31125. * Check whether the series item is itself or inherits from a certain
  31126. * series type.
  31127. *
  31128. * @function Highcharts.Series#is
  31129. * @param {string} type The type of series to check for, can be either
  31130. * featured or custom series types. For example `column`, `pie`,
  31131. * `ohlc` etc.
  31132. *
  31133. * @return {boolean}
  31134. * True if this item is or inherits from the given type.
  31135. */
  31136. is: function (type) {
  31137. return seriesTypes[type] && this instanceof seriesTypes[type];
  31138. },
  31139. /**
  31140. * Insert the series in a collection with other series, either the chart
  31141. * series or yAxis series, in the correct order according to the index
  31142. * option. Used internally when adding series.
  31143. *
  31144. * @private
  31145. * @function Highcharts.Series#insert
  31146. * @param {Array<Highcharts.Series>} collection
  31147. * A collection of series, like `chart.series` or `xAxis.series`.
  31148. * @return {number}
  31149. * The index of the series in the collection.
  31150. */
  31151. insert: function (collection) {
  31152. var indexOption = this.options.index, i;
  31153. // Insert by index option
  31154. if (isNumber(indexOption)) {
  31155. i = collection.length;
  31156. while (i--) {
  31157. // Loop down until the interted element has higher index
  31158. if (indexOption >=
  31159. pick(collection[i].options.index, collection[i]._i)) {
  31160. collection.splice(i + 1, 0, this);
  31161. break;
  31162. }
  31163. }
  31164. if (i === -1) {
  31165. collection.unshift(this);
  31166. }
  31167. i = i + 1;
  31168. // Or just push it to the end
  31169. }
  31170. else {
  31171. collection.push(this);
  31172. }
  31173. return pick(i, collection.length - 1);
  31174. },
  31175. /**
  31176. * Set the xAxis and yAxis properties of cartesian series, and register
  31177. * the series in the `axis.series` array.
  31178. *
  31179. * @private
  31180. * @function Highcharts.Series#bindAxes
  31181. * @return {void}
  31182. * @exception 18
  31183. */
  31184. bindAxes: function () {
  31185. var series = this, seriesOptions = series.options, chart = series.chart, axisOptions;
  31186. fireEvent(this, 'bindAxes', null, function () {
  31187. // repeat for xAxis and yAxis
  31188. (series.axisTypes || []).forEach(function (AXIS) {
  31189. // loop through the chart's axis objects
  31190. chart[AXIS].forEach(function (axis) {
  31191. axisOptions = axis.options;
  31192. // apply if the series xAxis or yAxis option mathches
  31193. // the number of the axis, or if undefined, use the
  31194. // first axis
  31195. if (seriesOptions[AXIS] ===
  31196. axisOptions.index ||
  31197. (typeof seriesOptions[AXIS] !==
  31198. 'undefined' &&
  31199. seriesOptions[AXIS] === axisOptions.id) ||
  31200. (typeof seriesOptions[AXIS] ===
  31201. 'undefined' &&
  31202. axisOptions.index === 0)) {
  31203. // register this series in the axis.series lookup
  31204. series.insert(axis.series);
  31205. // set this series.xAxis or series.yAxis reference
  31206. /**
  31207. * Read only. The unique xAxis object associated
  31208. * with the series.
  31209. *
  31210. * @name Highcharts.Series#xAxis
  31211. * @type {Highcharts.Axis}
  31212. */
  31213. /**
  31214. * Read only. The unique yAxis object associated
  31215. * with the series.
  31216. *
  31217. * @name Highcharts.Series#yAxis
  31218. * @type {Highcharts.Axis}
  31219. */
  31220. series[AXIS] = axis;
  31221. // mark dirty for redraw
  31222. axis.isDirty = true;
  31223. }
  31224. });
  31225. // The series needs an X and an Y axis
  31226. if (!series[AXIS] &&
  31227. series.optionalAxis !== AXIS) {
  31228. error(18, true, chart);
  31229. }
  31230. });
  31231. });
  31232. fireEvent(this, 'afterBindAxes');
  31233. },
  31234. /**
  31235. * For simple series types like line and column, the data values are
  31236. * held in arrays like xData and yData for quick lookup to find extremes
  31237. * and more. For multidimensional series like bubble and map, this can
  31238. * be extended with arrays like zData and valueData by adding to the
  31239. * `series.parallelArrays` array.
  31240. *
  31241. * @private
  31242. * @function Highcharts.Series#updateParallelArrays
  31243. * @param {Highcharts.Point} point
  31244. * @param {number|string} i
  31245. * @return {void}
  31246. */
  31247. updateParallelArrays: function (point, i) {
  31248. var series = point.series, args = arguments, fn = isNumber(i) ?
  31249. // Insert the value in the given position
  31250. function (key) {
  31251. var val = key === 'y' && series.toYData ?
  31252. series.toYData(point) :
  31253. point[key];
  31254. series[key + 'Data'][i] = val;
  31255. } :
  31256. // Apply the method specified in i with the following
  31257. // arguments as arguments
  31258. function (key) {
  31259. Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
  31260. };
  31261. series.parallelArrays.forEach(fn);
  31262. },
  31263. /**
  31264. * Define hasData functions for series. These return true if there
  31265. * are data points on this series within the plot area.
  31266. *
  31267. * @private
  31268. * @function Highcharts.Series#hasData
  31269. * @return {boolean}
  31270. */
  31271. hasData: function () {
  31272. return ((this.visible &&
  31273. typeof this.dataMax !== 'undefined' &&
  31274. typeof this.dataMin !== 'undefined') || ( // #3703
  31275. this.visible &&
  31276. this.yData &&
  31277. this.yData.length > 0) // #9758
  31278. );
  31279. },
  31280. /**
  31281. * Return an auto incremented x value based on the pointStart and
  31282. * pointInterval options. This is only used if an x value is not given
  31283. * for the point that calls autoIncrement.
  31284. *
  31285. * @private
  31286. * @function Highcharts.Series#autoIncrement
  31287. * @return {number}
  31288. */
  31289. autoIncrement: function () {
  31290. var options = this.options, xIncrement = this.xIncrement, date, pointInterval, pointIntervalUnit = options.pointIntervalUnit, time = this.chart.time;
  31291. xIncrement = pick(xIncrement, options.pointStart, 0);
  31292. this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
  31293. // Added code for pointInterval strings
  31294. if (pointIntervalUnit) {
  31295. date = new time.Date(xIncrement);
  31296. if (pointIntervalUnit === 'day') {
  31297. time.set('Date', date, time.get('Date', date) + pointInterval);
  31298. }
  31299. else if (pointIntervalUnit === 'month') {
  31300. time.set('Month', date, time.get('Month', date) + pointInterval);
  31301. }
  31302. else if (pointIntervalUnit === 'year') {
  31303. time.set('FullYear', date, time.get('FullYear', date) + pointInterval);
  31304. }
  31305. pointInterval = date.getTime() - xIncrement;
  31306. }
  31307. this.xIncrement = xIncrement + pointInterval;
  31308. return xIncrement;
  31309. },
  31310. /**
  31311. * Internal function to set properties for series if data sorting is
  31312. * enabled.
  31313. *
  31314. * @private
  31315. * @function Highcharts.Series#setDataSortingOptions
  31316. * @return {void}
  31317. */
  31318. setDataSortingOptions: function () {
  31319. var options = this.options;
  31320. extend(this, {
  31321. requireSorting: false,
  31322. sorted: false,
  31323. enabledDataSorting: true,
  31324. allowDG: false
  31325. });
  31326. // To allow unsorted data for column series.
  31327. if (!defined(options.pointRange)) {
  31328. options.pointRange = 1;
  31329. }
  31330. },
  31331. /**
  31332. * Set the series options by merging from the options tree. Called
  31333. * internally on initializing and updating series. This function will
  31334. * not redraw the series. For API usage, use {@link Series#update}.
  31335. * @private
  31336. * @function Highcharts.Series#setOptions
  31337. * @param {Highcharts.SeriesOptionsType} itemOptions
  31338. * The series options.
  31339. * @return {Highcharts.SeriesOptionsType}
  31340. * @fires Highcharts.Series#event:afterSetOptions
  31341. */
  31342. setOptions: function (itemOptions) {
  31343. var chart = this.chart, chartOptions = chart.options, plotOptions = chartOptions.plotOptions, userOptions = chart.userOptions || {}, seriesUserOptions = merge(itemOptions), options, zones, zone, styledMode = chart.styledMode, e = {
  31344. plotOptions: plotOptions,
  31345. userOptions: seriesUserOptions
  31346. };
  31347. fireEvent(this, 'setOptions', e);
  31348. // These may be modified by the event
  31349. var typeOptions = e.plotOptions[this.type], userPlotOptions = (userOptions.plotOptions || {});
  31350. // use copy to prevent undetected changes (#9762)
  31351. /**
  31352. * Contains series options by the user without defaults.
  31353. * @name Highcharts.Series#userOptions
  31354. * @type {Highcharts.SeriesOptionsType}
  31355. */
  31356. this.userOptions = e.userOptions;
  31357. options = merge(typeOptions, plotOptions.series,
  31358. // #3881, chart instance plotOptions[type] should trump
  31359. // plotOptions.series
  31360. userOptions.plotOptions &&
  31361. userOptions.plotOptions[this.type], seriesUserOptions);
  31362. // The tooltip options are merged between global and series specific
  31363. // options. Importance order asscendingly:
  31364. // globals: (1)tooltip, (2)plotOptions.series,
  31365. // (3)plotOptions[this.type]
  31366. // init userOptions with possible later updates: 4-6 like 1-3 and
  31367. // (7)this series options
  31368. this.tooltipOptions = merge(defaultOptions.tooltip, // 1
  31369. defaultOptions.plotOptions.series &&
  31370. defaultOptions.plotOptions.series.tooltip, // 2
  31371. defaultOptions.plotOptions[this.type].tooltip, // 3
  31372. chartOptions.tooltip.userOptions, // 4
  31373. plotOptions.series &&
  31374. plotOptions.series.tooltip, // 5
  31375. plotOptions[this.type].tooltip, // 6
  31376. seriesUserOptions.tooltip // 7
  31377. );
  31378. // When shared tooltip, stickyTracking is true by default,
  31379. // unless user says otherwise.
  31380. this.stickyTracking = pick(seriesUserOptions.stickyTracking, userPlotOptions[this.type] &&
  31381. userPlotOptions[this.type].stickyTracking, userPlotOptions.series && userPlotOptions.series.stickyTracking, (this.tooltipOptions.shared && !this.noSharedTooltip ?
  31382. true :
  31383. options.stickyTracking));
  31384. // Delete marker object if not allowed (#1125)
  31385. if (typeOptions.marker === null) {
  31386. delete options.marker;
  31387. }
  31388. // Handle color zones
  31389. this.zoneAxis = options.zoneAxis;
  31390. zones = this.zones = (options.zones || []).slice();
  31391. if ((options.negativeColor || options.negativeFillColor) &&
  31392. !options.zones) {
  31393. zone = {
  31394. value: options[this.zoneAxis + 'Threshold'] ||
  31395. options.threshold ||
  31396. 0,
  31397. className: 'highcharts-negative'
  31398. };
  31399. if (!styledMode) {
  31400. zone.color = options.negativeColor;
  31401. zone.fillColor = options.negativeFillColor;
  31402. }
  31403. zones.push(zone);
  31404. }
  31405. if (zones.length) { // Push one extra zone for the rest
  31406. if (defined(zones[zones.length - 1].value)) {
  31407. zones.push(styledMode ? {} : {
  31408. color: this.color,
  31409. fillColor: this.fillColor
  31410. });
  31411. }
  31412. }
  31413. fireEvent(this, 'afterSetOptions', { options: options });
  31414. return options;
  31415. },
  31416. /**
  31417. * Return series name in "Series {Number}" format or the one defined by
  31418. * a user. This method can be simply overridden as series name format
  31419. * can vary (e.g. technical indicators).
  31420. *
  31421. * @function Highcharts.Series#getName
  31422. * @return {string}
  31423. * The series name.
  31424. */
  31425. getName: function () {
  31426. // #4119
  31427. return pick(this.options.name, 'Series ' + (this.index + 1));
  31428. },
  31429. /**
  31430. * @private
  31431. * @function Highcharts.Series#getCyclic
  31432. * @param {string} prop
  31433. * @param {*} [value]
  31434. * @param {Highcharts.Dictionary<any>} [defaults]
  31435. * @return {void}
  31436. */
  31437. getCyclic: function (prop, value, defaults) {
  31438. 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;
  31439. if (!value) {
  31440. // Pick up either the colorIndex option, or the _colorIndex
  31441. // after Series.update()
  31442. setting = pick(userOptions[indexName], userOptions['_' + indexName]);
  31443. if (defined(setting)) { // after Series.update()
  31444. i = setting;
  31445. }
  31446. else {
  31447. // #6138
  31448. if (!chart.series.length) {
  31449. chart[counterName] = 0;
  31450. }
  31451. userOptions['_' + indexName] = i =
  31452. chart[counterName] % len;
  31453. chart[counterName] += 1;
  31454. }
  31455. if (defaults) {
  31456. value = defaults[i];
  31457. }
  31458. }
  31459. // Set the colorIndex
  31460. if (typeof i !== 'undefined') {
  31461. this[indexName] = i;
  31462. }
  31463. this[prop] = value;
  31464. },
  31465. /**
  31466. * Get the series' color based on either the options or pulled from
  31467. * global options.
  31468. *
  31469. * @private
  31470. * @function Highcharts.Series#getColor
  31471. * @return {void}
  31472. */
  31473. getColor: function () {
  31474. if (this.chart.styledMode) {
  31475. this.getCyclic('color');
  31476. }
  31477. else if (this.options.colorByPoint) {
  31478. // #4359, selected slice got series.color even when colorByPoint
  31479. // was set.
  31480. this.options.color = null;
  31481. }
  31482. else {
  31483. this.getCyclic('color', this.options.color ||
  31484. defaultOptions.plotOptions[this.type].color, this.chart.options.colors);
  31485. }
  31486. },
  31487. /**
  31488. * Get all points' instances created for this series.
  31489. *
  31490. * @private
  31491. * @function Highcharts.Series#getPointsCollection
  31492. * @return {Array<Highcharts.Point>}
  31493. */
  31494. getPointsCollection: function () {
  31495. return (this.hasGroupedData ? this.points : this.data) || [];
  31496. },
  31497. /**
  31498. * Get the series' symbol based on either the options or pulled from
  31499. * global options.
  31500. *
  31501. * @private
  31502. * @function Highcharts.Series#getSymbol
  31503. * @return {void}
  31504. */
  31505. getSymbol: function () {
  31506. var seriesMarkerOption = this.options.marker;
  31507. this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
  31508. },
  31509. /**
  31510. * Finds the index of an existing point that matches the given point
  31511. * options.
  31512. *
  31513. * @private
  31514. * @function Highcharts.Series#findPointIndex
  31515. * @param {Highcharts.PointOptionsObject} optionsObject
  31516. * The options of the point.
  31517. * @param {number} fromIndex
  31518. * The index to start searching from, used for optimizing
  31519. * series with required sorting.
  31520. * @returns {number|undefined}
  31521. * Returns the index of a matching point, or undefined if no
  31522. * match is found.
  31523. */
  31524. findPointIndex: function (optionsObject, fromIndex) {
  31525. var id = optionsObject.id, x = optionsObject.x, oldData = this.points, matchingPoint, matchedById, pointIndex, matchKey, dataSorting = this.options.dataSorting;
  31526. if (id) {
  31527. matchingPoint = this.chart.get(id);
  31528. }
  31529. else if (this.linkedParent || this.enabledDataSorting) {
  31530. matchKey = (dataSorting && dataSorting.matchByName) ?
  31531. 'name' : 'index';
  31532. matchingPoint = find(oldData, function (oldPoint) {
  31533. return !oldPoint.touched && oldPoint[matchKey] ===
  31534. optionsObject[matchKey];
  31535. });
  31536. // Add unmatched point as a new point
  31537. if (!matchingPoint) {
  31538. return void 0;
  31539. }
  31540. }
  31541. if (matchingPoint) {
  31542. pointIndex = matchingPoint && matchingPoint.index;
  31543. if (typeof pointIndex !== 'undefined') {
  31544. matchedById = true;
  31545. }
  31546. }
  31547. // Search for the same X in the existing data set
  31548. if (typeof pointIndex === 'undefined' && isNumber(x)) {
  31549. pointIndex = this.xData.indexOf(x, fromIndex);
  31550. }
  31551. // Reduce pointIndex if data is cropped
  31552. if (pointIndex !== -1 &&
  31553. typeof pointIndex !== 'undefined' &&
  31554. this.cropped) {
  31555. pointIndex = (pointIndex >= this.cropStart) ?
  31556. pointIndex - this.cropStart : pointIndex;
  31557. }
  31558. if (!matchedById &&
  31559. oldData[pointIndex] && oldData[pointIndex].touched) {
  31560. pointIndex = void 0;
  31561. }
  31562. return pointIndex;
  31563. },
  31564. /**
  31565. * @private
  31566. * @borrows LegendSymbolMixin.drawLineMarker as Highcharts.Series#drawLegendSymbol
  31567. */
  31568. drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
  31569. /**
  31570. * Internal function called from setData. If the point count is the same
  31571. * as is was, or if there are overlapping X values, just run
  31572. * Point.update which is cheaper, allows animation, and keeps references
  31573. * to points. This also allows adding or removing points if the X-es
  31574. * don't match.
  31575. *
  31576. * @private
  31577. * @function Highcharts.Series#updateData
  31578. *
  31579. * @param {Array<Highcharts.PointOptionsType>} data
  31580. *
  31581. * @return {boolean}
  31582. */
  31583. updateData: function (data, animation) {
  31584. var options = this.options, dataSorting = options.dataSorting, oldData = this.points, pointsToAdd = [], hasUpdatedByKey, i, point, lastIndex, requireSorting = this.requireSorting, equalLength = data.length === oldData.length, succeeded = true;
  31585. this.xIncrement = null;
  31586. // Iterate the new data
  31587. data.forEach(function (pointOptions, i) {
  31588. var id, x, pointIndex, optionsObject = (defined(pointOptions) &&
  31589. this.pointClass.prototype.optionsToObject.call({ series: this }, pointOptions)) || {};
  31590. // Get the x of the new data point
  31591. x = optionsObject.x;
  31592. id = optionsObject.id;
  31593. if (id || isNumber(x)) {
  31594. pointIndex = this.findPointIndex(optionsObject, lastIndex);
  31595. // Matching X not found
  31596. // or used already due to ununique x values (#8995),
  31597. // add point (but later)
  31598. if (pointIndex === -1 ||
  31599. typeof pointIndex === 'undefined') {
  31600. pointsToAdd.push(pointOptions);
  31601. // Matching X found, update
  31602. }
  31603. else if (oldData[pointIndex] &&
  31604. pointOptions !== options.data[pointIndex]) {
  31605. oldData[pointIndex].update(pointOptions, false, null, false);
  31606. // Mark it touched, below we will remove all points that
  31607. // are not touched.
  31608. oldData[pointIndex].touched = true;
  31609. // Speed optimize by only searching after last known
  31610. // index. Performs ~20% bettor on large data sets.
  31611. if (requireSorting) {
  31612. lastIndex = pointIndex + 1;
  31613. }
  31614. // Point exists, no changes, don't remove it
  31615. }
  31616. else if (oldData[pointIndex]) {
  31617. oldData[pointIndex].touched = true;
  31618. }
  31619. // If the length is equal and some of the nodes had a
  31620. // match in the same position, we don't want to remove
  31621. // non-matches.
  31622. if (!equalLength ||
  31623. i !== pointIndex ||
  31624. (dataSorting && dataSorting.enabled) ||
  31625. this.hasDerivedData) {
  31626. hasUpdatedByKey = true;
  31627. }
  31628. }
  31629. else {
  31630. // Gather all points that are not matched
  31631. pointsToAdd.push(pointOptions);
  31632. }
  31633. }, this);
  31634. // Remove points that don't exist in the updated data set
  31635. if (hasUpdatedByKey) {
  31636. i = oldData.length;
  31637. while (i--) {
  31638. point = oldData[i];
  31639. if (point && !point.touched && point.remove) {
  31640. point.remove(false, animation);
  31641. }
  31642. }
  31643. // If we did not find keys (ids or x-values), and the length is the
  31644. // same, update one-to-one
  31645. }
  31646. else if (equalLength && (!dataSorting || !dataSorting.enabled)) {
  31647. data.forEach(function (point, i) {
  31648. // .update doesn't exist on a linked, hidden series (#3709)
  31649. // (#10187)
  31650. if (oldData[i].update && point !== oldData[i].y) {
  31651. oldData[i].update(point, false, null, false);
  31652. }
  31653. });
  31654. // Don't add new points since those configs are used above
  31655. pointsToAdd.length = 0;
  31656. // Did not succeed in updating data
  31657. }
  31658. else {
  31659. succeeded = false;
  31660. }
  31661. oldData.forEach(function (point) {
  31662. if (point) {
  31663. point.touched = false;
  31664. }
  31665. });
  31666. if (!succeeded) {
  31667. return false;
  31668. }
  31669. // Add new points
  31670. pointsToAdd.forEach(function (point) {
  31671. this.addPoint(point, false, null, null, false);
  31672. }, this);
  31673. if (this.xIncrement === null &&
  31674. this.xData &&
  31675. this.xData.length) {
  31676. this.xIncrement = arrayMax(this.xData);
  31677. this.autoIncrement();
  31678. }
  31679. return true;
  31680. },
  31681. /**
  31682. * Apply a new set of data to the series and optionally redraw it. The
  31683. * new data array is passed by reference (except in case of
  31684. * `updatePoints`), and may later be mutated when updating the chart
  31685. * data.
  31686. *
  31687. * Note the difference in behaviour when setting the same amount of
  31688. * points, or a different amount of points, as handled by the
  31689. * `updatePoints` parameter.
  31690. *
  31691. * @sample highcharts/members/series-setdata/
  31692. * Set new data from a button
  31693. * @sample highcharts/members/series-setdata-pie/
  31694. * Set data in a pie
  31695. * @sample stock/members/series-setdata/
  31696. * Set new data in Highstock
  31697. * @sample maps/members/series-setdata/
  31698. * Set new data in Highmaps
  31699. *
  31700. * @function Highcharts.Series#setData
  31701. *
  31702. * @param {Array<Highcharts.PointOptionsType>} data
  31703. * Takes an array of data in the same format as described under
  31704. * `series.{type}.data` for the given series type, for example a
  31705. * line series would take data in the form described under
  31706. * [series.line.data](https://api.highcharts.com/highcharts/series.line.data).
  31707. *
  31708. * @param {boolean} [redraw=true]
  31709. * Whether to redraw the chart after the series is altered. If
  31710. * doing more operations on the chart, it is a good idea to set
  31711. * redraw to false and call {@link Chart#redraw} after.
  31712. *
  31713. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  31714. * When the updated data is the same length as the existing data,
  31715. * points will be updated by default, and animation visualizes
  31716. * how the points are changed. Set false to disable animation, or
  31717. * a configuration object to set duration or easing.
  31718. *
  31719. * @param {boolean} [updatePoints=true]
  31720. * When this is true, points will be updated instead of replaced
  31721. * whenever possible. This occurs a) when the updated data is the
  31722. * same length as the existing data, b) when points are matched
  31723. * by their id's, or c) when points can be matched by X values.
  31724. * This allows updating with animation and performs better. In
  31725. * this case, the original array is not passed by reference. Set
  31726. * `false` to prevent.
  31727. *
  31728. * @return {void}
  31729. */
  31730. setData: function (data, redraw, animation, updatePoints) {
  31731. var series = this, oldData = series.points, oldDataLength = (oldData && oldData.length) || 0, dataLength, options = series.options, chart = series.chart, dataSorting = options.dataSorting, firstPoint = null, xAxis = series.xAxis, i, turboThreshold = options.turboThreshold, pt, xData = this.xData, yData = this.yData, pointArrayMap = series.pointArrayMap, valueCount = pointArrayMap && pointArrayMap.length, keys = options.keys, indexOfX = 0, indexOfY = 1, updatedData;
  31732. data = data || [];
  31733. dataLength = data.length;
  31734. redraw = pick(redraw, true);
  31735. if (dataSorting && dataSorting.enabled) {
  31736. data = this.sortData(data);
  31737. }
  31738. // First try to run Point.update which is cheaper, allows animation,
  31739. // and keeps references to points.
  31740. if (updatePoints !== false &&
  31741. dataLength &&
  31742. oldDataLength &&
  31743. !series.cropped &&
  31744. !series.hasGroupedData &&
  31745. series.visible &&
  31746. // Soft updating has no benefit in boost, and causes JS error
  31747. // (#8355)
  31748. !series.isSeriesBoosting) {
  31749. updatedData = this.updateData(data, animation);
  31750. }
  31751. if (!updatedData) {
  31752. // Reset properties
  31753. series.xIncrement = null;
  31754. series.colorCounter = 0; // for series with colorByPoint (#1547)
  31755. // Update parallel arrays
  31756. this.parallelArrays.forEach(function (key) {
  31757. series[key + 'Data'].length = 0;
  31758. });
  31759. // In turbo mode, only one- or twodimensional arrays of numbers
  31760. // are allowed. The first value is tested, and we assume that
  31761. // all the rest are defined the same way. Although the 'for'
  31762. // loops are similar, they are repeated inside each if-else
  31763. // conditional for max performance.
  31764. if (turboThreshold && dataLength > turboThreshold) {
  31765. firstPoint = series.getFirstValidPoint(data);
  31766. if (isNumber(firstPoint)) { // assume all points are numbers
  31767. for (i = 0; i < dataLength; i++) {
  31768. xData[i] = this.autoIncrement();
  31769. yData[i] = data[i];
  31770. }
  31771. // Assume all points are arrays when first point is
  31772. }
  31773. else if (isArray(firstPoint)) {
  31774. if (valueCount) { // [x, low, high] or [x, o, h, l, c]
  31775. for (i = 0; i < dataLength; i++) {
  31776. pt = data[i];
  31777. xData[i] = pt[0];
  31778. yData[i] =
  31779. pt.slice(1, valueCount + 1);
  31780. }
  31781. }
  31782. else { // [x, y]
  31783. if (keys) {
  31784. indexOfX = keys.indexOf('x');
  31785. indexOfY = keys.indexOf('y');
  31786. indexOfX = indexOfX >= 0 ? indexOfX : 0;
  31787. indexOfY = indexOfY >= 0 ? indexOfY : 1;
  31788. }
  31789. for (i = 0; i < dataLength; i++) {
  31790. pt = data[i];
  31791. xData[i] = pt[indexOfX];
  31792. yData[i] = pt[indexOfY];
  31793. }
  31794. }
  31795. }
  31796. else {
  31797. // Highcharts expects configs to be numbers or arrays in
  31798. // turbo mode
  31799. error(12, false, chart);
  31800. }
  31801. }
  31802. else {
  31803. for (i = 0; i < dataLength; i++) {
  31804. // stray commas in oldIE:
  31805. if (typeof data[i] !== 'undefined') {
  31806. pt = { series: series };
  31807. series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
  31808. series.updateParallelArrays(pt, i);
  31809. }
  31810. }
  31811. }
  31812. // Forgetting to cast strings to numbers is a common caveat when
  31813. // handling CSV or JSON
  31814. if (yData && isString(yData[0])) {
  31815. error(14, true, chart);
  31816. }
  31817. series.data = [];
  31818. series.options.data = series.userOptions.data = data;
  31819. // destroy old points
  31820. i = oldDataLength;
  31821. while (i--) {
  31822. if (oldData[i] && oldData[i].destroy) {
  31823. oldData[i].destroy();
  31824. }
  31825. }
  31826. // reset minRange (#878)
  31827. if (xAxis) {
  31828. xAxis.minRange = xAxis.userMinRange;
  31829. }
  31830. // redraw
  31831. series.isDirty = chart.isDirtyBox = true;
  31832. series.isDirtyData = !!oldData;
  31833. animation = false;
  31834. }
  31835. // Typically for pie series, points need to be processed and
  31836. // generated prior to rendering the legend
  31837. if (options.legendType === 'point') {
  31838. this.processData();
  31839. this.generatePoints();
  31840. }
  31841. if (redraw) {
  31842. chart.redraw(animation);
  31843. }
  31844. },
  31845. /**
  31846. * Internal function to sort series data
  31847. *
  31848. * @private
  31849. * @function Highcharts.Series#sortData
  31850. * @param {Array<Highcharts.PointOptionsType>} data
  31851. * Force data grouping.
  31852. * @return {Array<Highcharts.PointOptionsObject>}
  31853. */
  31854. sortData: function (data) {
  31855. var series = this, options = series.options, dataSorting = options.dataSorting, sortKey = dataSorting.sortKey || 'y', sortedData, getPointOptionsObject = function (series, pointOptions) {
  31856. return (defined(pointOptions) &&
  31857. series.pointClass.prototype.optionsToObject.call({
  31858. series: series
  31859. }, pointOptions)) || {};
  31860. };
  31861. data.forEach(function (pointOptions, i) {
  31862. data[i] = getPointOptionsObject(series, pointOptions);
  31863. data[i].index = i;
  31864. }, this);
  31865. // Sorting
  31866. sortedData = data.concat().sort(function (a, b) {
  31867. var aValue = getNestedProperty(sortKey, a);
  31868. var bValue = getNestedProperty(sortKey, b);
  31869. return bValue < aValue ? -1 : bValue > aValue ? 1 : 0;
  31870. });
  31871. // Set x value depending on the position in the array
  31872. sortedData.forEach(function (point, i) {
  31873. point.x = i;
  31874. }, this);
  31875. // Set the same x for linked series points if they don't have their
  31876. // own sorting
  31877. if (series.linkedSeries) {
  31878. series.linkedSeries.forEach(function (linkedSeries) {
  31879. var options = linkedSeries.options, seriesData = options.data;
  31880. if ((!options.dataSorting ||
  31881. !options.dataSorting.enabled) &&
  31882. seriesData) {
  31883. seriesData.forEach(function (pointOptions, i) {
  31884. seriesData[i] = getPointOptionsObject(linkedSeries, pointOptions);
  31885. if (data[i]) {
  31886. seriesData[i].x = data[i].x;
  31887. seriesData[i].index = i;
  31888. }
  31889. });
  31890. linkedSeries.setData(seriesData, false);
  31891. }
  31892. });
  31893. }
  31894. return data;
  31895. },
  31896. /**
  31897. * Internal function to process the data by cropping away unused data
  31898. * points if the series is longer than the crop threshold. This saves
  31899. * computing time for large series.
  31900. *
  31901. * @private
  31902. * @function Highcharts.Series#getProcessedData
  31903. * @param {boolean} [forceExtremesFromAll]
  31904. * Force getting extremes of a total series data range.
  31905. * @return {Highcharts.SeriesProcessedDataObject}
  31906. */
  31907. getProcessedData: function (forceExtremesFromAll) {
  31908. var series = this,
  31909. // copied during slice operation:
  31910. processedXData = series.xData, processedYData = series.yData, dataLength = processedXData.length, croppedData, cropStart = 0, cropped, distance, closestPointRange, xAxis = series.xAxis, i, // loop variable
  31911. options = series.options, cropThreshold = options.cropThreshold, getExtremesFromAll = forceExtremesFromAll ||
  31912. series.getExtremesFromAll ||
  31913. options.getExtremesFromAll, // #4599
  31914. isCartesian = series.isCartesian, xExtremes, val2lin = xAxis && xAxis.val2lin, isLog = !!(xAxis && xAxis.logarithmic), throwOnUnsorted = series.requireSorting, min, max;
  31915. if (xAxis) {
  31916. // corrected for log axis (#3053)
  31917. xExtremes = xAxis.getExtremes();
  31918. min = xExtremes.min;
  31919. max = xExtremes.max;
  31920. }
  31921. // optionally filter out points outside the plot area
  31922. if (isCartesian &&
  31923. series.sorted &&
  31924. !getExtremesFromAll &&
  31925. (!cropThreshold ||
  31926. dataLength > cropThreshold ||
  31927. series.forceCrop)) {
  31928. // it's outside current extremes
  31929. if (processedXData[dataLength - 1] < min ||
  31930. processedXData[0] > max) {
  31931. processedXData = [];
  31932. processedYData = [];
  31933. // only crop if it's actually spilling out
  31934. }
  31935. else if (series.yData && (processedXData[0] < min ||
  31936. processedXData[dataLength - 1] > max)) {
  31937. croppedData = this.cropData(series.xData, series.yData, min, max);
  31938. processedXData = croppedData.xData;
  31939. processedYData = croppedData.yData;
  31940. cropStart = croppedData.start;
  31941. cropped = true;
  31942. }
  31943. }
  31944. // Find the closest distance between processed points
  31945. i = processedXData.length || 1;
  31946. while (--i) {
  31947. distance = (isLog ?
  31948. (val2lin(processedXData[i]) -
  31949. val2lin(processedXData[i - 1])) :
  31950. (processedXData[i] -
  31951. processedXData[i - 1]));
  31952. if (distance > 0 &&
  31953. (typeof closestPointRange === 'undefined' ||
  31954. distance < closestPointRange)) {
  31955. closestPointRange = distance;
  31956. // Unsorted data is not supported by the line tooltip, as well
  31957. // as data grouping and navigation in Stock charts (#725) and
  31958. // width calculation of columns (#1900)
  31959. }
  31960. else if (distance < 0 && throwOnUnsorted) {
  31961. error(15, false, series.chart);
  31962. throwOnUnsorted = false; // Only once
  31963. }
  31964. }
  31965. return {
  31966. xData: processedXData,
  31967. yData: processedYData,
  31968. cropped: cropped,
  31969. cropStart: cropStart,
  31970. closestPointRange: closestPointRange
  31971. };
  31972. },
  31973. /**
  31974. * Internal function to apply processed data.
  31975. * In Highstock, this function is extended to provide data grouping.
  31976. *
  31977. * @private
  31978. * @function Highcharts.Series#processData
  31979. * @param {boolean} [force]
  31980. * Force data grouping.
  31981. * @return {boolean|undefined}
  31982. */
  31983. processData: function (force) {
  31984. var series = this, xAxis = series.xAxis, processedData;
  31985. // If the series data or axes haven't changed, don't go through
  31986. // this. Return false to pass the message on to override methods
  31987. // like in data grouping.
  31988. if (series.isCartesian &&
  31989. !series.isDirty &&
  31990. !xAxis.isDirty &&
  31991. !series.yAxis.isDirty &&
  31992. !force) {
  31993. return false;
  31994. }
  31995. processedData = series.getProcessedData();
  31996. // Record the properties
  31997. series.cropped = processedData.cropped; // undefined or true
  31998. series.cropStart = processedData.cropStart;
  31999. series.processedXData = processedData.xData;
  32000. series.processedYData = processedData.yData;
  32001. series.closestPointRange =
  32002. series.basePointRange = processedData.closestPointRange;
  32003. },
  32004. /**
  32005. * Iterate over xData and crop values between min and max. Returns
  32006. * object containing crop start/end cropped xData with corresponding
  32007. * part of yData, dataMin and dataMax within the cropped range.
  32008. *
  32009. * @private
  32010. * @function Highcharts.Series#cropData
  32011. * @param {Array<number>} xData
  32012. * @param {Array<number>} yData
  32013. * @param {number} min
  32014. * @param {number} max
  32015. * @param {number} [cropShoulder]
  32016. * @return {Highcharts.SeriesCropDataObject}
  32017. */
  32018. cropData: function (xData, yData, min, max, cropShoulder) {
  32019. var dataLength = xData.length, cropStart = 0, cropEnd = dataLength, i, j;
  32020. // line-type series need one point outside
  32021. cropShoulder = pick(cropShoulder, this.cropShoulder);
  32022. // iterate up to find slice start
  32023. for (i = 0; i < dataLength; i++) {
  32024. if (xData[i] >= min) {
  32025. cropStart = Math.max(0, i - cropShoulder);
  32026. break;
  32027. }
  32028. }
  32029. // proceed to find slice end
  32030. for (j = i; j < dataLength; j++) {
  32031. if (xData[j] > max) {
  32032. cropEnd = j + cropShoulder;
  32033. break;
  32034. }
  32035. }
  32036. return {
  32037. xData: xData.slice(cropStart, cropEnd),
  32038. yData: yData.slice(cropStart, cropEnd),
  32039. start: cropStart,
  32040. end: cropEnd
  32041. };
  32042. },
  32043. /**
  32044. * Generate the data point after the data has been processed by cropping
  32045. * away unused points and optionally grouped in Highcharts Stock.
  32046. *
  32047. * @private
  32048. * @function Highcharts.Series#generatePoints
  32049. */
  32050. generatePoints: function () {
  32051. var series = this, options = series.options, dataOptions = options.data, data = series.data, dataLength, processedXData = series.processedXData, processedYData = series.processedYData, PointClass = series.pointClass, processedDataLength = processedXData.length, cropStart = series.cropStart || 0, cursor, hasGroupedData = series.hasGroupedData, keys = options.keys, point, points = [], i;
  32052. if (!data && !hasGroupedData) {
  32053. var arr = [];
  32054. arr.length = dataOptions.length;
  32055. data = series.data = arr;
  32056. }
  32057. if (keys && hasGroupedData) {
  32058. // grouped data has already applied keys (#6590)
  32059. series.options.keys = false;
  32060. }
  32061. for (i = 0; i < processedDataLength; i++) {
  32062. cursor = cropStart + i;
  32063. if (!hasGroupedData) {
  32064. point = data[cursor];
  32065. // #970:
  32066. if (!point &&
  32067. typeof dataOptions[cursor] !== 'undefined') {
  32068. data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
  32069. }
  32070. }
  32071. else {
  32072. // splat the y data in case of ohlc data array
  32073. point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
  32074. /**
  32075. * Highstock only. If a point object is created by data
  32076. * grouping, it doesn't reflect actual points in the raw
  32077. * data. In this case, the `dataGroup` property holds
  32078. * information that points back to the raw data.
  32079. *
  32080. * - `dataGroup.start` is the index of the first raw data
  32081. * point in the group.
  32082. *
  32083. * - `dataGroup.length` is the amount of points in the
  32084. * group.
  32085. *
  32086. * @product highstock
  32087. *
  32088. * @name Highcharts.Point#dataGroup
  32089. * @type {Highcharts.DataGroupingInfoObject|undefined}
  32090. */
  32091. point.dataGroup = series.groupMap[i];
  32092. if (point.dataGroup.options) {
  32093. point.options = point.dataGroup.options;
  32094. extend(point, point.dataGroup.options);
  32095. // Collision of props and options (#9770)
  32096. delete point.dataLabels;
  32097. }
  32098. }
  32099. if (point) { // #6279
  32100. /**
  32101. * Contains the point's index in the `Series.points` array.
  32102. *
  32103. * @name Highcharts.Point#index
  32104. * @type {number}
  32105. * @readonly
  32106. */
  32107. point.index = cursor; // For faster access in Point.update
  32108. points[i] = point;
  32109. }
  32110. }
  32111. // restore keys options (#6590)
  32112. series.options.keys = keys;
  32113. // Hide cropped-away points - this only runs when the number of
  32114. // points is above cropThreshold, or when swithching view from
  32115. // non-grouped data to grouped data (#637)
  32116. if (data &&
  32117. (processedDataLength !== (dataLength = data.length) ||
  32118. hasGroupedData)) {
  32119. for (i = 0; i < dataLength; i++) {
  32120. // when has grouped data, clear all points
  32121. if (i === cropStart && !hasGroupedData) {
  32122. i += processedDataLength;
  32123. }
  32124. if (data[i]) {
  32125. data[i].destroyElements();
  32126. data[i].plotX = void 0; // #1003
  32127. }
  32128. }
  32129. }
  32130. /**
  32131. * Read only. An array containing those values converted to points.
  32132. * In case the series data length exceeds the `cropThreshold`, or if
  32133. * the data is grouped, `series.data` doesn't contain all the
  32134. * points. Also, in case a series is hidden, the `data` array may be
  32135. * empty. To access raw values, `series.options.data` will always be
  32136. * up to date. `Series.data` only contains the points that have been
  32137. * created on demand. To modify the data, use
  32138. * {@link Highcharts.Series#setData} or
  32139. * {@link Highcharts.Point#update}.
  32140. *
  32141. * @see Series.points
  32142. *
  32143. * @name Highcharts.Series#data
  32144. * @type {Array<Highcharts.Point>}
  32145. */
  32146. series.data = data;
  32147. /**
  32148. * An array containing all currently visible point objects. In case
  32149. * of cropping, the cropped-away points are not part of this array.
  32150. * The `series.points` array starts at `series.cropStart` compared
  32151. * to `series.data` and `series.options.data`. If however the series
  32152. * data is grouped, these can't be correlated one to one. To modify
  32153. * the data, use {@link Highcharts.Series#setData} or
  32154. * {@link Highcharts.Point#update}.
  32155. *
  32156. * @name Highcharts.Series#points
  32157. * @type {Array<Highcharts.Point>}
  32158. */
  32159. series.points = points;
  32160. fireEvent(this, 'afterGeneratePoints');
  32161. },
  32162. /**
  32163. * Get current X extremes for the visible data.
  32164. *
  32165. * @private
  32166. * @function Highcharts.Series#getXExtremes
  32167. *
  32168. * @param {Array<number>} xData
  32169. * The data to inspect. Defaults to the current data within the
  32170. * visible range.
  32171. * @return {Highcharts.RangeObject}
  32172. */
  32173. getXExtremes: function (xData) {
  32174. return {
  32175. min: arrayMin(xData),
  32176. max: arrayMax(xData)
  32177. };
  32178. },
  32179. /**
  32180. * Calculate Y extremes for the visible data. The result is returned
  32181. * as an object with `dataMin` and `dataMax` properties.
  32182. *
  32183. * @private
  32184. * @function Highcharts.Series#getExtremes
  32185. * @param {Array<number>} [yData]
  32186. * The data to inspect. Defaults to the current data within the
  32187. * visible range.
  32188. * @param {boolean} [forceExtremesFromAll]
  32189. * Force getting extremes of a total series data range.
  32190. * @return {Highcharts.DataExtremesObject}
  32191. */
  32192. getExtremes: function (yData, forceExtremesFromAll) {
  32193. var xAxis = this.xAxis, yAxis = this.yAxis, xData = this.processedXData || this.xData, yDataLength, activeYData = [], activeCounter = 0,
  32194. // #2117, need to compensate for log X axis
  32195. xExtremes, xMin = 0, xMax = 0, validValue, withinRange,
  32196. // Handle X outside the viewed area. This does not work with
  32197. // non-sorted data like scatter (#7639).
  32198. shoulder = this.requireSorting ? this.cropShoulder : 0, positiveValuesOnly = yAxis ? yAxis.positiveValuesOnly : false, x, y, i, j;
  32199. yData = yData || this.stackedYData || this.processedYData || [];
  32200. yDataLength = yData.length;
  32201. if (xAxis) {
  32202. xExtremes = xAxis.getExtremes();
  32203. xMin = xExtremes.min;
  32204. xMax = xExtremes.max;
  32205. }
  32206. for (i = 0; i < yDataLength; i++) {
  32207. x = xData[i];
  32208. y = yData[i];
  32209. // For points within the visible range, including the first
  32210. // point outside the visible range (#7061), consider y extremes.
  32211. validValue = ((isNumber(y) || isArray(y)) &&
  32212. ((y.length || y > 0) || !positiveValuesOnly));
  32213. withinRange = (forceExtremesFromAll ||
  32214. this.getExtremesFromAll ||
  32215. this.options.getExtremesFromAll ||
  32216. this.cropped ||
  32217. !xAxis || // for colorAxis support
  32218. ((xData[i + shoulder] || x) >= xMin &&
  32219. (xData[i - shoulder] || x) <= xMax));
  32220. if (validValue && withinRange) {
  32221. j = y.length;
  32222. if (j) { // array, like ohlc or range data
  32223. while (j--) {
  32224. if (isNumber(y[j])) { // #7380, #11513
  32225. activeYData[activeCounter++] = y[j];
  32226. }
  32227. }
  32228. }
  32229. else {
  32230. activeYData[activeCounter++] = y;
  32231. }
  32232. }
  32233. }
  32234. var dataExtremes = {
  32235. dataMin: arrayMin(activeYData),
  32236. dataMax: arrayMax(activeYData)
  32237. };
  32238. fireEvent(this, 'afterGetExtremes', { dataExtremes: dataExtremes });
  32239. return dataExtremes;
  32240. },
  32241. /**
  32242. * Set the current data extremes as `dataMin` and `dataMax` on the
  32243. * Series item. Use this only when the series properties should be
  32244. * updated.
  32245. *
  32246. * @private
  32247. * @function Highcharts.Series#applyExtremes
  32248. * @return {void}
  32249. */
  32250. applyExtremes: function () {
  32251. var dataExtremes = this.getExtremes();
  32252. /**
  32253. * Contains the minimum value of the series' data point.
  32254. * @name Highcharts.Series#dataMin
  32255. * @type {number}
  32256. * @readonly
  32257. */
  32258. this.dataMin = dataExtremes.dataMin;
  32259. /* *
  32260. * Contains the maximum value of the series' data point.
  32261. * @name Highcharts.Series#dataMax
  32262. * @type {number}
  32263. * @readonly
  32264. */
  32265. this.dataMax = dataExtremes.dataMax;
  32266. return dataExtremes;
  32267. },
  32268. /**
  32269. * Find and return the first non null point in the data
  32270. *
  32271. * @private
  32272. * @function Highcharts.Series.getFirstValidPoint
  32273. * @param {Array<Highcharts.PointOptionsType>} data
  32274. * Array of options for points
  32275. *
  32276. * @return {Highcharts.PointOptionsType}
  32277. */
  32278. getFirstValidPoint: function (data) {
  32279. var firstPoint = null, dataLength = data.length, i = 0;
  32280. while (firstPoint === null && i < dataLength) {
  32281. firstPoint = data[i];
  32282. i++;
  32283. }
  32284. return firstPoint;
  32285. },
  32286. /**
  32287. * Translate data points from raw data values to chart specific
  32288. * positioning data needed later in the `drawPoints` and `drawGraph`
  32289. * functions. This function can be overridden in plugins and custom
  32290. * series type implementations.
  32291. *
  32292. * @function Highcharts.Series#translate
  32293. * @return {void}
  32294. * @fires Highcharts.Series#events:translate
  32295. */
  32296. translate: function () {
  32297. if (!this.processedXData) { // hidden series
  32298. this.processData();
  32299. }
  32300. this.generatePoints();
  32301. var series = this, options = series.options, stacking = options.stacking, xAxis = series.xAxis, categories = xAxis.categories, enabledDataSorting = series.enabledDataSorting, yAxis = series.yAxis, points = series.points, dataLength = points.length, hasModifyValue = !!series.modifyValue, i, pointPlacement = series.pointPlacementToXValue(), // #7860
  32302. dynamicallyPlaced = Boolean(pointPlacement), threshold = options.threshold, stackThreshold = options.startFromThreshold ? threshold : 0, plotX, lastPlotX, stackIndicator, zoneAxis = this.zoneAxis || 'y', closestPointRangePx = Number.MAX_VALUE;
  32303. /**
  32304. * Plotted coordinates need to be within a limited range. Drawing
  32305. * too far outside the viewport causes various rendering issues
  32306. * (#3201, #3923, #7555).
  32307. * @private
  32308. */
  32309. function limitedRange(val) {
  32310. return clamp(val, -1e5, 1e5);
  32311. }
  32312. // Translate each point
  32313. for (i = 0; i < dataLength; i++) {
  32314. var point = points[i], xValue = point.x, yValue = point.y, yBottom = point.low, stack = stacking && yAxis.stacking && yAxis.stacking.stacks[(series.negStacks &&
  32315. yValue <
  32316. (stackThreshold ? 0 : threshold) ?
  32317. '-' :
  32318. '') + series.stackKey], pointStack, stackValues;
  32319. // Discard disallowed y values for log axes (#3434)
  32320. if (yAxis.positiveValuesOnly &&
  32321. yValue !== null &&
  32322. yValue <= 0) {
  32323. point.isNull = true;
  32324. }
  32325. // Get the plotX translation
  32326. point.plotX = plotX = correctFloat(// #5236
  32327. limitedRange(xAxis.translate(// #3923
  32328. xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags')) // #3923
  32329. );
  32330. // Calculate the bottom y value for stacked series
  32331. if (stacking &&
  32332. series.visible &&
  32333. stack &&
  32334. stack[xValue]) {
  32335. stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
  32336. if (!point.isNull) {
  32337. pointStack = stack[xValue];
  32338. stackValues =
  32339. pointStack.points[stackIndicator.key];
  32340. }
  32341. }
  32342. if (isArray(stackValues)) {
  32343. yBottom = stackValues[0];
  32344. yValue = stackValues[1];
  32345. if (yBottom === stackThreshold &&
  32346. stackIndicator.key ===
  32347. stack[xValue].base) {
  32348. yBottom = pick((isNumber(threshold) && threshold), yAxis.min);
  32349. }
  32350. // #1200, #1232
  32351. if (yAxis.positiveValuesOnly && yBottom <= 0) {
  32352. yBottom = null;
  32353. }
  32354. point.total = point.stackTotal = pointStack.total;
  32355. point.percentage =
  32356. pointStack.total &&
  32357. (point.y / pointStack.total * 100);
  32358. point.stackY = yValue;
  32359. // Place the stack label
  32360. // in case of variwide series (where widths of points are
  32361. // different in most cases), stack labels are positioned
  32362. // wrongly, so the call of the setOffset is omited here and
  32363. // labels are correctly positioned later, at the end of the
  32364. // variwide's translate function (#10962)
  32365. if (!series.irregularWidths) {
  32366. pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
  32367. }
  32368. }
  32369. // Set translated yBottom or remove it
  32370. point.yBottom = defined(yBottom) ?
  32371. limitedRange(yAxis.translate(yBottom, 0, 1, 0, 1)) :
  32372. null;
  32373. // general hook, used for Highstock compare mode
  32374. if (hasModifyValue) {
  32375. yValue = series.modifyValue(yValue, point);
  32376. }
  32377. // Set the the plotY value, reset it for redraws
  32378. // #3201
  32379. point.plotY = ((typeof yValue === 'number' && yValue !== Infinity) ?
  32380. limitedRange(yAxis.translate(yValue, 0, 1, 0, 1)) :
  32381. void 0);
  32382. point.isInside = this.isPointInside(point);
  32383. // Set client related positions for mouse tracking
  32384. point.clientX = dynamicallyPlaced ?
  32385. correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) :
  32386. plotX; // #1514, #5383, #5518
  32387. // Negative points. For bubble charts, this means negative z
  32388. // values (#9728)
  32389. point.negative = point[zoneAxis] < (options[zoneAxis + 'Threshold'] ||
  32390. threshold ||
  32391. 0);
  32392. // some API data
  32393. point.category = (categories &&
  32394. typeof categories[point.x] !== 'undefined' ?
  32395. categories[point.x] :
  32396. point.x);
  32397. // Determine auto enabling of markers (#3635, #5099)
  32398. if (!point.isNull && point.visible !== false) {
  32399. if (typeof lastPlotX !== 'undefined') {
  32400. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
  32401. }
  32402. lastPlotX = plotX;
  32403. }
  32404. // Find point zone
  32405. point.zone = (this.zones.length && point.getZone());
  32406. // Animate new points with data sorting
  32407. if (!point.graphic && series.group && enabledDataSorting) {
  32408. point.isNew = true;
  32409. }
  32410. }
  32411. series.closestPointRangePx = closestPointRangePx;
  32412. fireEvent(this, 'afterTranslate');
  32413. },
  32414. /**
  32415. * Return the series points with null points filtered out.
  32416. *
  32417. * @function Highcharts.Series#getValidPoints
  32418. *
  32419. * @param {Array<Highcharts.Point>} [points]
  32420. * The points to inspect, defaults to {@link Series.points}.
  32421. *
  32422. * @param {boolean} [insideOnly=false]
  32423. * Whether to inspect only the points that are inside the visible
  32424. * view.
  32425. *
  32426. * @param {boolean} [allowNull=false]
  32427. * Whether to allow null points to pass as valid points.
  32428. *
  32429. * @return {Array<Highcharts.Point>}
  32430. * The valid points.
  32431. */
  32432. getValidPoints: function (points, insideOnly, allowNull) {
  32433. var chart = this.chart;
  32434. // #3916, #5029, #5085
  32435. return (points || this.points || []).filter(function isValidPoint(point) {
  32436. if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, chart.inverted)) {
  32437. return false;
  32438. }
  32439. return point.visible !== false &&
  32440. (allowNull || !point.isNull);
  32441. });
  32442. },
  32443. /**
  32444. * Get the clipping for the series. Could be called for a series to
  32445. * initiate animating the clip or to set the final clip (only width
  32446. * and x).
  32447. *
  32448. * @private
  32449. * @function Highcharts.Series#getClip
  32450. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  32451. * Initialize the animation.
  32452. * @param {boolean} [finalBox]
  32453. * Final size for the clip - end state for the animation.
  32454. * @return {Highcharts.Dictionary<number>}
  32455. */
  32456. getClipBox: function (animation, finalBox) {
  32457. var series = this, options = series.options, chart = series.chart, inverted = chart.inverted, xAxis = series.xAxis, yAxis = xAxis && series.yAxis, clipBox, scrollablePlotAreaOptions = chart.options.chart.scrollablePlotArea || {};
  32458. if (animation && options.clip === false && yAxis) {
  32459. // support for not clipped series animation (#10450)
  32460. clipBox = inverted ? {
  32461. y: -chart.chartWidth + yAxis.len + yAxis.pos,
  32462. height: chart.chartWidth,
  32463. width: chart.chartHeight,
  32464. x: -chart.chartHeight + xAxis.len + xAxis.pos
  32465. } : {
  32466. y: -yAxis.pos,
  32467. height: chart.chartHeight,
  32468. width: chart.chartWidth,
  32469. x: -xAxis.pos
  32470. };
  32471. // x and width will be changed later when setting for animation
  32472. // initial state in Series.setClip
  32473. }
  32474. else {
  32475. clipBox = series.clipBox || chart.clipBox;
  32476. if (finalBox) {
  32477. clipBox.width = chart.plotSizeX;
  32478. clipBox.x = (chart.scrollablePixelsX || 0) *
  32479. (scrollablePlotAreaOptions.scrollPositionX || 0);
  32480. }
  32481. }
  32482. return !finalBox ? clipBox : {
  32483. width: clipBox.width,
  32484. x: clipBox.x
  32485. };
  32486. },
  32487. /**
  32488. * Set the clipping for the series. For animated series it is called
  32489. * twice, first to initiate animating the clip then the second time
  32490. * without the animation to set the final clip.
  32491. *
  32492. * @private
  32493. * @function Highcharts.Series#setClip
  32494. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  32495. */
  32496. setClip: function (animation) {
  32497. var chart = this.chart, options = this.options, renderer = chart.renderer, inverted = chart.inverted, seriesClipBox = this.clipBox, clipBox = this.getClipBox(animation), sharedClipKey = this.sharedClipKey ||
  32498. [
  32499. '_sharedClip',
  32500. animation && animation.duration,
  32501. animation && animation.easing,
  32502. clipBox.height,
  32503. options.xAxis,
  32504. options.yAxis
  32505. ].join(','), // #4526
  32506. clipRect = chart[sharedClipKey], markerClipRect = chart[sharedClipKey + 'm'];
  32507. if (animation) {
  32508. clipBox.width = 0;
  32509. if (inverted) {
  32510. clipBox.x = chart.plotHeight +
  32511. (options.clip !== false ? 0 : chart.plotTop);
  32512. }
  32513. }
  32514. // If a clipping rectangle with the same properties is currently
  32515. // present in the chart, use that.
  32516. if (!clipRect) {
  32517. // When animation is set, prepare the initial positions
  32518. if (animation) {
  32519. chart[sharedClipKey + 'm'] = markerClipRect =
  32520. renderer.clipRect(
  32521. // include the width of the first marker
  32522. inverted ? chart.plotSizeX + 99 : -99, inverted ? -chart.plotLeft : -chart.plotTop, 99, inverted ? chart.chartWidth : chart.chartHeight);
  32523. }
  32524. chart[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
  32525. // Create hashmap for series indexes
  32526. clipRect.count = { length: 0 };
  32527. // When the series is rendered again before starting animating, in
  32528. // compliance to a responsive rule
  32529. }
  32530. else if (!chart.hasLoaded) {
  32531. clipRect.attr(clipBox);
  32532. }
  32533. if (animation) {
  32534. if (!clipRect.count[this.index]) {
  32535. clipRect.count[this.index] = true;
  32536. clipRect.count.length += 1;
  32537. }
  32538. }
  32539. if (options.clip !== false || animation) {
  32540. this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
  32541. this.markerGroup.clip(markerClipRect);
  32542. this.sharedClipKey = sharedClipKey;
  32543. }
  32544. // Remove the shared clipping rectangle when all series are shown
  32545. if (!animation) {
  32546. if (clipRect.count[this.index]) {
  32547. delete clipRect.count[this.index];
  32548. clipRect.count.length -= 1;
  32549. }
  32550. if (clipRect.count.length === 0 &&
  32551. sharedClipKey &&
  32552. chart[sharedClipKey]) {
  32553. if (!seriesClipBox) {
  32554. chart[sharedClipKey] =
  32555. chart[sharedClipKey].destroy();
  32556. }
  32557. if (chart[sharedClipKey + 'm']) {
  32558. chart[sharedClipKey + 'm'] =
  32559. chart[sharedClipKey + 'm'].destroy();
  32560. }
  32561. }
  32562. }
  32563. },
  32564. /**
  32565. * Animate in the series. Called internally twice. First with the `init`
  32566. * parameter set to true, which sets up the initial state of the
  32567. * animation. Then when ready, it is called with the `init` parameter
  32568. * undefined, in order to perform the actual animation. After the
  32569. * second run, the function is removed.
  32570. *
  32571. * @function Highcharts.Series#animate
  32572. *
  32573. * @param {boolean} [init]
  32574. * Initialize the animation.
  32575. */
  32576. animate: function (init) {
  32577. var series = this, chart = series.chart, animation = animObject(series.options.animation), clipRect, sharedClipKey, finalBox;
  32578. // Initialize the animation. Set up the clipping rectangle.
  32579. if (!chart.hasRendered) {
  32580. if (init) {
  32581. series.setClip(animation);
  32582. // Run the animation
  32583. }
  32584. else {
  32585. sharedClipKey = this.sharedClipKey;
  32586. clipRect = chart[sharedClipKey];
  32587. finalBox = series.getClipBox(animation, true);
  32588. if (clipRect) {
  32589. clipRect.animate(finalBox, animation);
  32590. }
  32591. if (chart[sharedClipKey + 'm']) {
  32592. chart[sharedClipKey + 'm'].animate({
  32593. width: finalBox.width + 99,
  32594. x: finalBox.x - (chart.inverted ? 0 : 99)
  32595. }, animation);
  32596. }
  32597. }
  32598. }
  32599. },
  32600. /**
  32601. * This runs after animation to land on the final plot clipping.
  32602. *
  32603. * @private
  32604. * @function Highcharts.Series#afterAnimate
  32605. * @fires Highcharts.Series#event:afterAnimate
  32606. */
  32607. afterAnimate: function () {
  32608. this.setClip();
  32609. fireEvent(this, 'afterAnimate');
  32610. this.finishedAnimating = true;
  32611. },
  32612. /**
  32613. * Draw the markers for line-like series types, and columns or other
  32614. * graphical representation for {@link Point} objects for other series
  32615. * types. The resulting element is typically stored as
  32616. * {@link Point.graphic}, and is created on the first call and updated
  32617. * and moved on subsequent calls.
  32618. *
  32619. * @function Highcharts.Series#drawPoints
  32620. */
  32621. drawPoints: function () {
  32622. var series = this, points = series.points, chart = series.chart, i, point, graphic, verb, options = series.options, seriesMarkerOptions = options.marker, pointMarkerOptions, hasPointMarker, markerGroup = (series[series.specialGroup] ||
  32623. series.markerGroup), xAxis = series.xAxis, markerAttribs, globallyEnabled = pick(seriesMarkerOptions.enabled, !xAxis || xAxis.isRadial ? true : null,
  32624. // Use larger or equal as radius is null in bubbles (#6321)
  32625. series.closestPointRangePx >= (seriesMarkerOptions.enabledThreshold *
  32626. seriesMarkerOptions.radius));
  32627. if (seriesMarkerOptions.enabled !== false ||
  32628. series._hasPointMarkers) {
  32629. for (i = 0; i < points.length; i++) {
  32630. point = points[i];
  32631. graphic = point.graphic;
  32632. verb = graphic ? 'animate' : 'attr';
  32633. pointMarkerOptions = point.marker || {};
  32634. hasPointMarker = !!point.marker;
  32635. var shouldDrawMarker = ((globallyEnabled &&
  32636. typeof pointMarkerOptions.enabled === 'undefined') || pointMarkerOptions.enabled) && !point.isNull && point.visible !== false;
  32637. // only draw the point if y is defined
  32638. if (shouldDrawMarker) {
  32639. // Shortcuts
  32640. var symbol = pick(pointMarkerOptions.symbol, series.symbol);
  32641. markerAttribs = series.markerAttribs(point, (point.selected && 'select'));
  32642. // Set starting position for point sliding animation.
  32643. if (series.enabledDataSorting) {
  32644. point.startXPos = xAxis.reversed ?
  32645. -markerAttribs.width :
  32646. xAxis.width;
  32647. }
  32648. var isInside = point.isInside !== false;
  32649. if (graphic) { // update
  32650. // Since the marker group isn't clipped, each
  32651. // individual marker must be toggled
  32652. graphic[isInside ? 'show' : 'hide'](isInside)
  32653. .animate(markerAttribs);
  32654. }
  32655. else if (isInside &&
  32656. (markerAttribs.width > 0 || point.hasImage)) {
  32657. /**
  32658. * The graphic representation of the point.
  32659. * Typically this is a simple shape, like a `rect`
  32660. * for column charts or `path` for line markers, but
  32661. * for some complex series types like boxplot or 3D
  32662. * charts, the graphic may be a `g` element
  32663. * containing other shapes. The graphic is generated
  32664. * the first time {@link Series#drawPoints} runs,
  32665. * and updated and moved on subsequent runs.
  32666. *
  32667. * @name Point#graphic
  32668. * @type {SVGElement}
  32669. */
  32670. point.graphic = graphic = chart.renderer
  32671. .symbol(symbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height, hasPointMarker ?
  32672. pointMarkerOptions :
  32673. seriesMarkerOptions)
  32674. .add(markerGroup);
  32675. // Sliding animation for new points
  32676. if (series.enabledDataSorting &&
  32677. chart.hasRendered) {
  32678. graphic.attr({
  32679. x: point.startXPos
  32680. });
  32681. verb = 'animate';
  32682. }
  32683. }
  32684. if (graphic && verb === 'animate') { // update
  32685. // Since the marker group isn't clipped, each
  32686. // individual marker must be toggled
  32687. graphic[isInside ? 'show' : 'hide'](isInside)
  32688. .animate(markerAttribs);
  32689. }
  32690. // Presentational attributes
  32691. if (graphic && !chart.styledMode) {
  32692. graphic[verb](series.pointAttribs(point, (point.selected && 'select')));
  32693. }
  32694. if (graphic) {
  32695. graphic.addClass(point.getClassName(), true);
  32696. }
  32697. }
  32698. else if (graphic) {
  32699. point.graphic = graphic.destroy(); // #1269
  32700. }
  32701. }
  32702. }
  32703. },
  32704. /**
  32705. * Get non-presentational attributes for a point. Used internally for
  32706. * both styled mode and classic. Can be overridden for different series
  32707. * types.
  32708. *
  32709. * @see Series#pointAttribs
  32710. *
  32711. * @function Highcharts.Series#markerAttribs
  32712. *
  32713. * @param {Highcharts.Point} point
  32714. * The Point to inspect.
  32715. *
  32716. * @param {string} [state]
  32717. * The state, can be either `hover`, `select` or undefined.
  32718. *
  32719. * @return {Highcharts.SVGAttributes}
  32720. * A hash containing those attributes that are not settable from
  32721. * CSS.
  32722. */
  32723. markerAttribs: function (point, state) {
  32724. var seriesOptions = this.options, seriesMarkerOptions = seriesOptions.marker, seriesStateOptions, pointMarkerOptions = point.marker || {}, symbol = (pointMarkerOptions.symbol ||
  32725. seriesMarkerOptions.symbol), pointStateOptions, radius = pick(pointMarkerOptions.radius, seriesMarkerOptions.radius), attribs;
  32726. // Handle hover and select states
  32727. if (state) {
  32728. seriesStateOptions = seriesMarkerOptions.states[state];
  32729. pointStateOptions = pointMarkerOptions.states &&
  32730. pointMarkerOptions.states[state];
  32731. radius = pick(pointStateOptions && pointStateOptions.radius, seriesStateOptions && seriesStateOptions.radius, radius + (seriesStateOptions && seriesStateOptions.radiusPlus ||
  32732. 0));
  32733. }
  32734. point.hasImage = symbol && symbol.indexOf('url') === 0;
  32735. if (point.hasImage) {
  32736. radius = 0; // and subsequently width and height is not set
  32737. }
  32738. attribs = {
  32739. // Math.floor for #1843:
  32740. x: seriesOptions.crisp ?
  32741. Math.floor(point.plotX) - radius :
  32742. point.plotX - radius,
  32743. y: point.plotY - radius
  32744. };
  32745. if (radius) {
  32746. attribs.width = attribs.height = 2 * radius;
  32747. }
  32748. return attribs;
  32749. },
  32750. /**
  32751. * Internal function to get presentational attributes for each point.
  32752. * Unlike {@link Series#markerAttribs}, this function should return
  32753. * those attributes that can also be set in CSS. In styled mode,
  32754. * `pointAttribs` won't be called.
  32755. *
  32756. * @private
  32757. * @function Highcharts.Series#pointAttribs
  32758. *
  32759. * @param {Highcharts.Point} [point]
  32760. * The point instance to inspect.
  32761. *
  32762. * @param {string} [state]
  32763. * The point state, can be either `hover`, `select` or 'normal'.
  32764. * If undefined, normal state is assumed.
  32765. *
  32766. * @return {Highcharts.SVGAttributes}
  32767. * The presentational attributes to be set on the point.
  32768. */
  32769. pointAttribs: function (point, state) {
  32770. var seriesMarkerOptions = this.options.marker, seriesStateOptions, pointOptions = point && point.options, pointMarkerOptions = ((pointOptions && pointOptions.marker) || {}), pointStateOptions, color = this.color, pointColorOption = pointOptions && pointOptions.color, pointColor = point && point.color, strokeWidth = pick(pointMarkerOptions.lineWidth, seriesMarkerOptions.lineWidth), zoneColor = point && point.zone && point.zone.color, fill, stroke, opacity = 1;
  32771. color = (pointColorOption ||
  32772. zoneColor ||
  32773. pointColor ||
  32774. color);
  32775. fill = (pointMarkerOptions.fillColor ||
  32776. seriesMarkerOptions.fillColor ||
  32777. color);
  32778. stroke = (pointMarkerOptions.lineColor ||
  32779. seriesMarkerOptions.lineColor ||
  32780. color);
  32781. // Handle hover and select states
  32782. state = state || 'normal';
  32783. if (state) {
  32784. seriesStateOptions = seriesMarkerOptions.states[state];
  32785. pointStateOptions = (pointMarkerOptions.states &&
  32786. pointMarkerOptions.states[state]) || {};
  32787. strokeWidth = pick(pointStateOptions.lineWidth, seriesStateOptions.lineWidth, strokeWidth + pick(pointStateOptions.lineWidthPlus, seriesStateOptions.lineWidthPlus, 0));
  32788. fill = (pointStateOptions.fillColor ||
  32789. seriesStateOptions.fillColor ||
  32790. fill);
  32791. stroke = (pointStateOptions.lineColor ||
  32792. seriesStateOptions.lineColor ||
  32793. stroke);
  32794. opacity = pick(pointStateOptions.opacity, seriesStateOptions.opacity, opacity);
  32795. }
  32796. return {
  32797. 'stroke': stroke,
  32798. 'stroke-width': strokeWidth,
  32799. 'fill': fill,
  32800. 'opacity': opacity
  32801. };
  32802. },
  32803. /**
  32804. * Clear DOM objects and free up memory.
  32805. *
  32806. * @private
  32807. * @function Highcharts.Series#destroy
  32808. * @param {boolean} [keepEventsForUpdate]
  32809. * @return {void}
  32810. * @fires Highcharts.Series#event:destroy
  32811. */
  32812. destroy: function (keepEventsForUpdate) {
  32813. var series = this, chart = series.chart, issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent), destroy, i, data = series.data || [], point, axis;
  32814. // add event hook
  32815. fireEvent(series, 'destroy');
  32816. // remove events
  32817. this.removeEvents(keepEventsForUpdate);
  32818. // erase from axes
  32819. (series.axisTypes || []).forEach(function (AXIS) {
  32820. axis = series[AXIS];
  32821. if (axis && axis.series) {
  32822. erase(axis.series, series);
  32823. axis.isDirty = axis.forceRedraw = true;
  32824. }
  32825. });
  32826. // remove legend items
  32827. if (series.legendItem) {
  32828. series.chart.legend.destroyItem(series);
  32829. }
  32830. // destroy all points with their elements
  32831. i = data.length;
  32832. while (i--) {
  32833. point = data[i];
  32834. if (point && point.destroy) {
  32835. point.destroy();
  32836. }
  32837. }
  32838. series.points = null;
  32839. // Clear the animation timeout if we are destroying the series
  32840. // during initial animation
  32841. U.clearTimeout(series.animationTimeout);
  32842. // Destroy all SVGElements associated to the series
  32843. objectEach(series, function (val, prop) {
  32844. // Survive provides a hook for not destroying
  32845. if (val instanceof SVGElement && !val.survive) {
  32846. // issue 134 workaround
  32847. destroy = issue134 && prop === 'group' ?
  32848. 'hide' :
  32849. 'destroy';
  32850. val[destroy]();
  32851. }
  32852. });
  32853. // remove from hoverSeries
  32854. if (chart.hoverSeries === series) {
  32855. chart.hoverSeries = null;
  32856. }
  32857. erase(chart.series, series);
  32858. chart.orderSeries();
  32859. // clear all members
  32860. objectEach(series, function (val, prop) {
  32861. if (!keepEventsForUpdate || prop !== 'hcEvents') {
  32862. delete series[prop];
  32863. }
  32864. });
  32865. },
  32866. /**
  32867. * Get the graph path.
  32868. *
  32869. * @private
  32870. * @function Highcharts.Series#getGraphPath
  32871. * @param {Array<Highcharts.Point>} points
  32872. * @param {boolean} [nullsAsZeroes]
  32873. * @param {boolean} [connectCliffs]
  32874. * @return {Highcharts.SVGPathArray}
  32875. */
  32876. getGraphPath: function (points, nullsAsZeroes, connectCliffs) {
  32877. var series = this, options = series.options, step = options.step, reversed, graphPath = [], xMap = [], gap;
  32878. points = points || series.points;
  32879. // Bottom of a stack is reversed
  32880. reversed = points.reversed;
  32881. if (reversed) {
  32882. points.reverse();
  32883. }
  32884. // Reverse the steps (#5004)
  32885. step = {
  32886. right: 1,
  32887. center: 2
  32888. }[step] || (step && 3);
  32889. if (step && reversed) {
  32890. step = 4 - step;
  32891. }
  32892. // Remove invalid points, especially in spline (#5015)
  32893. points = this.getValidPoints(points, false, !(options.connectNulls && !nullsAsZeroes && !connectCliffs));
  32894. // Build the line
  32895. points.forEach(function (point, i) {
  32896. var plotX = point.plotX, plotY = point.plotY, lastPoint = points[i - 1],
  32897. // the path to this point from the previous
  32898. pathToPoint;
  32899. if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) &&
  32900. !connectCliffs) {
  32901. gap = true; // ... and continue
  32902. }
  32903. // Line series, nullsAsZeroes is not handled
  32904. if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
  32905. gap = !options.connectNulls;
  32906. // Area series, nullsAsZeroes is set
  32907. }
  32908. else if (point.isNull && !nullsAsZeroes) {
  32909. gap = true;
  32910. }
  32911. else {
  32912. if (i === 0 || gap) {
  32913. pathToPoint = [[
  32914. 'M',
  32915. point.plotX,
  32916. point.plotY
  32917. ]];
  32918. // Generate the spline as defined in the SplineSeries object
  32919. }
  32920. else if (series.getPointSpline) {
  32921. pathToPoint = [series.getPointSpline(points, point, i)];
  32922. }
  32923. else if (step) {
  32924. if (step === 1) { // right
  32925. pathToPoint = [[
  32926. 'L',
  32927. lastPoint.plotX,
  32928. plotY
  32929. ]];
  32930. }
  32931. else if (step === 2) { // center
  32932. pathToPoint = [[
  32933. 'L',
  32934. (lastPoint.plotX + plotX) / 2,
  32935. lastPoint.plotY
  32936. ], [
  32937. 'L',
  32938. (lastPoint.plotX + plotX) / 2,
  32939. plotY
  32940. ]];
  32941. }
  32942. else {
  32943. pathToPoint = [[
  32944. 'L',
  32945. plotX,
  32946. lastPoint.plotY
  32947. ]];
  32948. }
  32949. pathToPoint.push([
  32950. 'L',
  32951. plotX,
  32952. plotY
  32953. ]);
  32954. }
  32955. else {
  32956. // normal line to next point
  32957. pathToPoint = [[
  32958. 'L',
  32959. plotX,
  32960. plotY
  32961. ]];
  32962. }
  32963. // Prepare for animation. When step is enabled, there are
  32964. // two path nodes for each x value.
  32965. xMap.push(point.x);
  32966. if (step) {
  32967. xMap.push(point.x);
  32968. if (step === 2) { // step = center (#8073)
  32969. xMap.push(point.x);
  32970. }
  32971. }
  32972. graphPath.push.apply(graphPath, pathToPoint);
  32973. gap = false;
  32974. }
  32975. });
  32976. graphPath.xMap = xMap;
  32977. series.graphPath = graphPath;
  32978. return graphPath;
  32979. },
  32980. /**
  32981. * Draw the graph. Called internally when rendering line-like series
  32982. * types. The first time it generates the `series.graph` item and
  32983. * optionally other series-wide items like `series.area` for area
  32984. * charts. On subsequent calls these items are updated with new
  32985. * positions and attributes.
  32986. *
  32987. * @function Highcharts.Series#drawGraph
  32988. */
  32989. drawGraph: function () {
  32990. var series = this, options = this.options, graphPath = (this.gappedPath || this.getGraphPath).call(this), styledMode = this.chart.styledMode, props = [[
  32991. 'graph',
  32992. 'highcharts-graph'
  32993. ]];
  32994. // Presentational properties
  32995. if (!styledMode) {
  32996. props[0].push((options.lineColor ||
  32997. this.color ||
  32998. '#cccccc' // when colorByPoint = true
  32999. ), options.dashStyle);
  33000. }
  33001. props = series.getZonesGraphs(props);
  33002. // Draw the graph
  33003. props.forEach(function (prop, i) {
  33004. var graphKey = prop[0], graph = series[graphKey], verb = graph ? 'animate' : 'attr', attribs;
  33005. if (graph) {
  33006. graph.endX = series.preventGraphAnimation ?
  33007. null :
  33008. graphPath.xMap;
  33009. graph.animate({ d: graphPath });
  33010. }
  33011. else if (graphPath.length) { // #1487
  33012. /**
  33013. * SVG element of area-based charts. Can be used for styling
  33014. * purposes. If zones are configured, this element will be
  33015. * hidden and replaced by multiple zone areas, accessible
  33016. * via `series['zone-area-x']` (where x is a number,
  33017. * starting with 0).
  33018. *
  33019. * @name Highcharts.Series#area
  33020. * @type {Highcharts.SVGElement|undefined}
  33021. */
  33022. /**
  33023. * SVG element of line-based charts. Can be used for styling
  33024. * purposes. If zones are configured, this element will be
  33025. * hidden and replaced by multiple zone lines, accessible
  33026. * via `series['zone-graph-x']` (where x is a number,
  33027. * starting with 0).
  33028. *
  33029. * @name Highcharts.Series#graph
  33030. * @type {Highcharts.SVGElement|undefined}
  33031. */
  33032. series[graphKey] = graph = series.chart.renderer
  33033. .path(graphPath)
  33034. .addClass(prop[1])
  33035. .attr({ zIndex: 1 }) // #1069
  33036. .add(series.group);
  33037. }
  33038. if (graph && !styledMode) {
  33039. attribs = {
  33040. 'stroke': prop[2],
  33041. 'stroke-width': options.lineWidth,
  33042. // Polygon series use filled graph
  33043. 'fill': (series.fillGraph && series.color) || 'none'
  33044. };
  33045. if (prop[3]) {
  33046. attribs.dashstyle = prop[3];
  33047. }
  33048. else if (options.linecap !== 'square') {
  33049. attribs['stroke-linecap'] =
  33050. attribs['stroke-linejoin'] = 'round';
  33051. }
  33052. graph[verb](attribs)
  33053. // Add shadow to normal series (0) or to first
  33054. // zone (1) #3932
  33055. .shadow((i < 2) && options.shadow);
  33056. }
  33057. // Helpers for animation
  33058. if (graph) {
  33059. graph.startX = graphPath.xMap;
  33060. graph.isArea = graphPath.isArea; // For arearange animation
  33061. }
  33062. });
  33063. },
  33064. /**
  33065. * Get zones properties for building graphs. Extendable by series with
  33066. * multiple lines within one series.
  33067. *
  33068. * @private
  33069. * @function Highcharts.Series#getZonesGraphs
  33070. *
  33071. * @param {Array<Array<string>>} props
  33072. *
  33073. * @return {Array<Array<string>>}
  33074. */
  33075. getZonesGraphs: function (props) {
  33076. // Add the zone properties if any
  33077. this.zones.forEach(function (zone, i) {
  33078. var propset = [
  33079. 'zone-graph-' + i,
  33080. 'highcharts-graph highcharts-zone-graph-' + i + ' ' +
  33081. (zone.className || '')
  33082. ];
  33083. if (!this.chart.styledMode) {
  33084. propset.push((zone.color || this.color), (zone.dashStyle || this.options.dashStyle));
  33085. }
  33086. props.push(propset);
  33087. }, this);
  33088. return props;
  33089. },
  33090. /**
  33091. * Clip the graphs into zones for colors and styling.
  33092. *
  33093. * @private
  33094. * @function Highcharts.Series#applyZones
  33095. * @return {void}
  33096. */
  33097. applyZones: function () {
  33098. var series = this, chart = this.chart, renderer = chart.renderer, zones = this.zones, translatedFrom, translatedTo, clips = (this.clips || []), clipAttr, graph = this.graph, area = this.area, chartSizeMax = Math.max(chart.chartWidth, chart.chartHeight), axis = this[(this.zoneAxis || 'y') + 'Axis'], extremes, reversed, inverted = chart.inverted, horiz, pxRange, pxPosMin, pxPosMax, ignoreZones = false, zoneArea, zoneGraph;
  33099. if (zones.length &&
  33100. (graph || area) &&
  33101. axis &&
  33102. typeof axis.min !== 'undefined') {
  33103. reversed = axis.reversed;
  33104. horiz = axis.horiz;
  33105. // The use of the Color Threshold assumes there are no gaps
  33106. // so it is safe to hide the original graph and area
  33107. // unless it is not waterfall series, then use showLine property
  33108. // to set lines between columns to be visible (#7862)
  33109. if (graph && !this.showLine) {
  33110. graph.hide();
  33111. }
  33112. if (area) {
  33113. area.hide();
  33114. }
  33115. // Create the clips
  33116. extremes = axis.getExtremes();
  33117. zones.forEach(function (threshold, i) {
  33118. translatedFrom = reversed ?
  33119. (horiz ? chart.plotWidth : 0) :
  33120. (horiz ? 0 : (axis.toPixels(extremes.min) || 0));
  33121. translatedFrom = clamp(pick(translatedTo, translatedFrom), 0, chartSizeMax);
  33122. translatedTo = clamp(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true) || 0), 0, chartSizeMax);
  33123. if (ignoreZones) {
  33124. translatedFrom = translatedTo =
  33125. axis.toPixels(extremes.max);
  33126. }
  33127. pxRange = Math.abs(translatedFrom - translatedTo);
  33128. pxPosMin = Math.min(translatedFrom, translatedTo);
  33129. pxPosMax = Math.max(translatedFrom, translatedTo);
  33130. if (axis.isXAxis) {
  33131. clipAttr = {
  33132. x: inverted ? pxPosMax : pxPosMin,
  33133. y: 0,
  33134. width: pxRange,
  33135. height: chartSizeMax
  33136. };
  33137. if (!horiz) {
  33138. clipAttr.x = chart.plotHeight - clipAttr.x;
  33139. }
  33140. }
  33141. else {
  33142. clipAttr = {
  33143. x: 0,
  33144. y: inverted ? pxPosMax : pxPosMin,
  33145. width: chartSizeMax,
  33146. height: pxRange
  33147. };
  33148. if (horiz) {
  33149. clipAttr.y = chart.plotWidth - clipAttr.y;
  33150. }
  33151. }
  33152. // VML SUPPPORT
  33153. if (inverted && renderer.isVML) {
  33154. if (axis.isXAxis) {
  33155. clipAttr = {
  33156. x: 0,
  33157. y: reversed ? pxPosMin : pxPosMax,
  33158. height: clipAttr.width,
  33159. width: chart.chartWidth
  33160. };
  33161. }
  33162. else {
  33163. clipAttr = {
  33164. x: (clipAttr.y -
  33165. chart.plotLeft -
  33166. chart.spacingBox.x),
  33167. y: 0,
  33168. width: clipAttr.height,
  33169. height: chart.chartHeight
  33170. };
  33171. }
  33172. }
  33173. // END OF VML SUPPORT
  33174. if (clips[i]) {
  33175. clips[i].animate(clipAttr);
  33176. }
  33177. else {
  33178. clips[i] = renderer.clipRect(clipAttr);
  33179. }
  33180. // when no data, graph zone is not applied and after setData
  33181. // clip was ignored. As a result, it should be applied each
  33182. // time.
  33183. zoneArea = series['zone-area-' + i];
  33184. zoneGraph = series['zone-graph-' + i];
  33185. if (graph && zoneGraph) {
  33186. zoneGraph.clip(clips[i]);
  33187. }
  33188. if (area && zoneArea) {
  33189. zoneArea.clip(clips[i]);
  33190. }
  33191. // if this zone extends out of the axis, ignore the others
  33192. ignoreZones = threshold.value > extremes.max;
  33193. // Clear translatedTo for indicators
  33194. if (series.resetZones && translatedTo === 0) {
  33195. translatedTo = void 0;
  33196. }
  33197. });
  33198. this.clips = clips;
  33199. }
  33200. else if (series.visible) {
  33201. // If zones were removed, restore graph and area
  33202. if (graph) {
  33203. graph.show(true);
  33204. }
  33205. if (area) {
  33206. area.show(true);
  33207. }
  33208. }
  33209. },
  33210. /**
  33211. * Initialize and perform group inversion on series.group and
  33212. * series.markerGroup.
  33213. *
  33214. * @private
  33215. * @function Highcharts.Series#invertGroups
  33216. * @param {boolean} [inverted]
  33217. * @return {void}
  33218. */
  33219. invertGroups: function (inverted) {
  33220. var series = this, chart = series.chart;
  33221. /**
  33222. * @private
  33223. */
  33224. function setInvert() {
  33225. ['group', 'markerGroup'].forEach(function (groupName) {
  33226. if (series[groupName]) {
  33227. // VML/HTML needs explicit attributes for flipping
  33228. if (chart.renderer.isVML) {
  33229. series[groupName].attr({
  33230. width: series.yAxis.len,
  33231. height: series.xAxis.len
  33232. });
  33233. }
  33234. series[groupName].width = series.yAxis.len;
  33235. series[groupName].height = series.xAxis.len;
  33236. // If inverted polar, don't invert series group
  33237. series[groupName].invert(series.isRadialSeries ? false : inverted);
  33238. }
  33239. });
  33240. }
  33241. // Pie, go away (#1736)
  33242. if (!series.xAxis) {
  33243. return;
  33244. }
  33245. // A fixed size is needed for inversion to work
  33246. series.eventsToUnbind.push(addEvent(chart, 'resize', setInvert));
  33247. // Do it now
  33248. setInvert();
  33249. // On subsequent render and redraw, just do setInvert without
  33250. // setting up events again
  33251. series.invertGroups = setInvert;
  33252. },
  33253. /**
  33254. * General abstraction for creating plot groups like series.group,
  33255. * series.dataLabelsGroup and series.markerGroup. On subsequent calls,
  33256. * the group will only be adjusted to the updated plot size.
  33257. *
  33258. * @private
  33259. * @function Highcharts.Series#plotGroup
  33260. * @param {string} prop
  33261. * @param {string} name
  33262. * @param {string} visibility
  33263. * @param {number} [zIndex]
  33264. * @param {Highcharts.SVGElement} [parent]
  33265. * @return {Highcharts.SVGElement}
  33266. */
  33267. plotGroup: function (prop, name, visibility, zIndex, parent) {
  33268. var group = this[prop], isNew = !group, attrs = {
  33269. visibility: visibility,
  33270. zIndex: zIndex || 0.1 // IE8 and pointer logic use this
  33271. };
  33272. // Avoid setting undefined opacity, or in styled mode
  33273. if (typeof this.opacity !== 'undefined' &&
  33274. !this.chart.styledMode) {
  33275. attrs.opacity = this.opacity;
  33276. }
  33277. // Generate it on first call
  33278. if (isNew) {
  33279. this[prop] = group = this.chart.renderer
  33280. .g()
  33281. .add(parent);
  33282. }
  33283. // Add the class names, and replace existing ones as response to
  33284. // Series.update (#6660)
  33285. group.addClass(('highcharts-' + name +
  33286. ' highcharts-series-' + this.index +
  33287. ' highcharts-' + this.type + '-series ' +
  33288. (defined(this.colorIndex) ?
  33289. 'highcharts-color-' + this.colorIndex + ' ' :
  33290. '') +
  33291. (this.options.className || '') +
  33292. (group.hasClass('highcharts-tracker') ?
  33293. ' highcharts-tracker' :
  33294. '')), true);
  33295. // Place it on first and subsequent (redraw) calls
  33296. group.attr(attrs)[isNew ? 'attr' : 'animate'](this.getPlotBox());
  33297. return group;
  33298. },
  33299. /**
  33300. * Get the translation and scale for the plot area of this series.
  33301. *
  33302. * @function Highcharts.Series#getPlotBox
  33303. *
  33304. * @return {Highcharts.SeriesPlotBoxObject}
  33305. */
  33306. getPlotBox: function () {
  33307. var chart = this.chart, xAxis = this.xAxis, yAxis = this.yAxis;
  33308. // Swap axes for inverted (#2339)
  33309. if (chart.inverted) {
  33310. xAxis = yAxis;
  33311. yAxis = this.xAxis;
  33312. }
  33313. return {
  33314. translateX: xAxis ? xAxis.left : chart.plotLeft,
  33315. translateY: yAxis ? yAxis.top : chart.plotTop,
  33316. scaleX: 1,
  33317. scaleY: 1
  33318. };
  33319. },
  33320. /**
  33321. * Removes the event handlers attached previously with addEvents.
  33322. *
  33323. * @private
  33324. * @function Highcharts.Series#removeEvents
  33325. * @param {boolean} [keepEventsForUpdate]
  33326. * @return {void}
  33327. */
  33328. removeEvents: function (keepEventsForUpdate) {
  33329. var series = this;
  33330. if (!keepEventsForUpdate) {
  33331. // remove all events
  33332. removeEvent(series);
  33333. }
  33334. else if (series.eventsToUnbind.length) {
  33335. // remove only internal events for proper update
  33336. // #12355 - solves problem with multiple destroy events
  33337. series.eventsToUnbind.forEach(function (unbind) {
  33338. unbind();
  33339. });
  33340. series.eventsToUnbind.length = 0;
  33341. }
  33342. },
  33343. /**
  33344. * Render the graph and markers. Called internally when first rendering
  33345. * and later when redrawing the chart. This function can be extended in
  33346. * plugins, but normally shouldn't be called directly.
  33347. *
  33348. * @function Highcharts.Series#render
  33349. *
  33350. * @return {void}
  33351. *
  33352. * @fires Highcharts.Series#event:afterRender
  33353. */
  33354. render: function () {
  33355. var series = this, chart = series.chart, group, options = series.options,
  33356. // Animation doesn't work in IE8 quirks when the group div is
  33357. // hidden, and looks bad in other oldIE
  33358. animDuration = (!series.finishedAnimating &&
  33359. chart.renderer.isSVG &&
  33360. animObject(options.animation).duration), visibility = series.visible ? 'inherit' : 'hidden', // #2597
  33361. zIndex = options.zIndex, hasRendered = series.hasRendered, chartSeriesGroup = chart.seriesGroup, inverted = chart.inverted;
  33362. fireEvent(this, 'render');
  33363. // the group
  33364. group = series.plotGroup('group', 'series', visibility, zIndex, chartSeriesGroup);
  33365. series.markerGroup = series.plotGroup('markerGroup', 'markers', visibility, zIndex, chartSeriesGroup);
  33366. // initiate the animation
  33367. if (animDuration && series.animate) {
  33368. series.animate(true);
  33369. }
  33370. // SVGRenderer needs to know this before drawing elements (#1089,
  33371. // #1795)
  33372. group.inverted = series.isCartesian || series.invertable ?
  33373. inverted : false;
  33374. // Draw the graph if any
  33375. if (series.drawGraph) {
  33376. series.drawGraph();
  33377. series.applyZones();
  33378. }
  33379. // Draw the points
  33380. if (series.visible) {
  33381. series.drawPoints();
  33382. }
  33383. /* series.points.forEach(function (point) {
  33384. if (point.redraw) {
  33385. point.redraw();
  33386. }
  33387. }); */
  33388. // Draw the data labels
  33389. if (series.drawDataLabels) {
  33390. series.drawDataLabels();
  33391. }
  33392. // In pie charts, slices are added to the DOM, but actual rendering
  33393. // is postponed until labels reserved their space
  33394. if (series.redrawPoints) {
  33395. series.redrawPoints();
  33396. }
  33397. // draw the mouse tracking area
  33398. if (series.drawTracker &&
  33399. series.options.enableMouseTracking !== false) {
  33400. series.drawTracker();
  33401. }
  33402. // Handle inverted series and tracker groups
  33403. series.invertGroups(inverted);
  33404. // Initial clipping, must be defined after inverting groups for VML.
  33405. // Applies to columns etc. (#3839).
  33406. if (options.clip !== false &&
  33407. !series.sharedClipKey &&
  33408. !hasRendered) {
  33409. group.clip(chart.clipRect);
  33410. }
  33411. // Run the animation
  33412. if (animDuration && series.animate) {
  33413. series.animate();
  33414. }
  33415. // Call the afterAnimate function on animation complete (but don't
  33416. // overwrite the animation.complete option which should be available
  33417. // to the user).
  33418. if (!hasRendered) {
  33419. series.animationTimeout = syncTimeout(function () {
  33420. series.afterAnimate();
  33421. }, animDuration || 0);
  33422. }
  33423. // Means data is in accordance with what you see
  33424. series.isDirty = false;
  33425. // (See #322) series.isDirty = series.isDirtyData = false; // means
  33426. // data is in accordance with what you see
  33427. series.hasRendered = true;
  33428. fireEvent(series, 'afterRender');
  33429. },
  33430. /**
  33431. * Redraw the series. This function is called internally from
  33432. * `chart.redraw` and normally shouldn't be called directly.
  33433. *
  33434. * @private
  33435. * @function Highcharts.Series#redraw
  33436. * @return {void}
  33437. */
  33438. redraw: function () {
  33439. var series = this, chart = series.chart,
  33440. // cache it here as it is set to false in render, but used after
  33441. wasDirty = series.isDirty || series.isDirtyData, group = series.group, xAxis = series.xAxis, yAxis = series.yAxis;
  33442. // reposition on resize
  33443. if (group) {
  33444. if (chart.inverted) {
  33445. group.attr({
  33446. width: chart.plotWidth,
  33447. height: chart.plotHeight
  33448. });
  33449. }
  33450. group.animate({
  33451. translateX: pick(xAxis && xAxis.left, chart.plotLeft),
  33452. translateY: pick(yAxis && yAxis.top, chart.plotTop)
  33453. });
  33454. }
  33455. series.translate();
  33456. series.render();
  33457. if (wasDirty) { // #3868, #3945
  33458. delete this.kdTree;
  33459. }
  33460. },
  33461. kdAxisArray: ['clientX', 'plotY'],
  33462. /**
  33463. * @private
  33464. * @function Highcharts.Series#searchPoint
  33465. * @param {Highcharts.PointerEventObject} e
  33466. * @param {boolean} [compareX]
  33467. * @return {Highcharts.Point}
  33468. */
  33469. searchPoint: function (e, compareX) {
  33470. var series = this, xAxis = series.xAxis, yAxis = series.yAxis, inverted = series.chart.inverted;
  33471. return this.searchKDTree({
  33472. clientX: inverted ?
  33473. xAxis.len - e.chartY + xAxis.pos :
  33474. e.chartX - xAxis.pos,
  33475. plotY: inverted ?
  33476. yAxis.len - e.chartX + yAxis.pos :
  33477. e.chartY - yAxis.pos
  33478. }, compareX, e);
  33479. },
  33480. /**
  33481. * Build the k-d-tree that is used by mouse and touch interaction to get
  33482. * the closest point. Line-like series typically have a one-dimensional
  33483. * tree where points are searched along the X axis, while scatter-like
  33484. * series typically search in two dimensions, X and Y.
  33485. *
  33486. * @private
  33487. * @function Highcharts.Series#buildKDTree
  33488. * @param {Highcharts.PointerEventObject} [e]
  33489. * @return {void}
  33490. */
  33491. buildKDTree: function (e) {
  33492. // Prevent multiple k-d-trees from being built simultaneously
  33493. // (#6235)
  33494. this.buildingKdTree = true;
  33495. var series = this, dimensions = series.options.findNearestPointBy
  33496. .indexOf('y') > -1 ? 2 : 1;
  33497. /**
  33498. * Internal function
  33499. * @private
  33500. */
  33501. function _kdtree(points, depth, dimensions) {
  33502. var axis, median, length = points && points.length;
  33503. if (length) {
  33504. // alternate between the axis
  33505. axis = series.kdAxisArray[depth % dimensions];
  33506. // sort point array
  33507. points.sort(function (a, b) {
  33508. return a[axis] - b[axis];
  33509. });
  33510. median = Math.floor(length / 2);
  33511. // build and return nod
  33512. return {
  33513. point: points[median],
  33514. left: _kdtree(points.slice(0, median), depth + 1, dimensions),
  33515. right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
  33516. };
  33517. }
  33518. }
  33519. /**
  33520. * Start the recursive build process with a clone of the points
  33521. * array and null points filtered out. (#3873)
  33522. * @private
  33523. */
  33524. function startRecursive() {
  33525. series.kdTree = _kdtree(series.getValidPoints(null,
  33526. // For line-type series restrict to plot area, but
  33527. // column-type series not (#3916, #4511)
  33528. !series.directTouch), dimensions, dimensions);
  33529. series.buildingKdTree = false;
  33530. }
  33531. delete series.kdTree;
  33532. // For testing tooltips, don't build async. Also if touchstart, we
  33533. // may be dealing with click events on mobile, so don't delay
  33534. // (#6817).
  33535. syncTimeout(startRecursive, series.options.kdNow || (e && e.type === 'touchstart') ? 0 : 1);
  33536. },
  33537. /**
  33538. * @private
  33539. * @function Highcharts.Series#searchKDTree
  33540. * @param {Highcharts.KDPointSearchObject} point
  33541. * @param {boolean} [compareX]
  33542. * @param {Highcharts.PointerEventObject} [e]
  33543. * @return {Highcharts.Point|undefined}
  33544. */
  33545. searchKDTree: function (point, compareX, e) {
  33546. var series = this, kdX = this.kdAxisArray[0], kdY = this.kdAxisArray[1], kdComparer = compareX ? 'distX' : 'dist', kdDimensions = series.options.findNearestPointBy
  33547. .indexOf('y') > -1 ? 2 : 1;
  33548. /**
  33549. * Set the one and two dimensional distance on the point object.
  33550. * @private
  33551. */
  33552. function setDistance(p1, p2) {
  33553. var x = (defined(p1[kdX]) &&
  33554. defined(p2[kdX])) ?
  33555. Math.pow(p1[kdX] - p2[kdX], 2) :
  33556. null, y = (defined(p1[kdY]) &&
  33557. defined(p2[kdY])) ?
  33558. Math.pow(p1[kdY] - p2[kdY], 2) :
  33559. null, r = (x || 0) + (y || 0);
  33560. p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
  33561. p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
  33562. }
  33563. /**
  33564. * @private
  33565. */
  33566. function _search(search, tree, depth, dimensions) {
  33567. var point = tree.point, axis = series.kdAxisArray[depth % dimensions], tdist, sideA, sideB, ret = point, nPoint1, nPoint2;
  33568. setDistance(search, point);
  33569. // Pick side based on distance to splitting point
  33570. tdist = search[axis] - point[axis];
  33571. sideA = tdist < 0 ? 'left' : 'right';
  33572. sideB = tdist < 0 ? 'right' : 'left';
  33573. // End of tree
  33574. if (tree[sideA]) {
  33575. nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
  33576. ret = (nPoint1[kdComparer] <
  33577. ret[kdComparer] ?
  33578. nPoint1 :
  33579. point);
  33580. }
  33581. if (tree[sideB]) {
  33582. // compare distance to current best to splitting point to
  33583. // decide wether to check side B or not
  33584. if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
  33585. nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
  33586. ret = (nPoint2[kdComparer] <
  33587. ret[kdComparer] ?
  33588. nPoint2 :
  33589. ret);
  33590. }
  33591. }
  33592. return ret;
  33593. }
  33594. if (!this.kdTree && !this.buildingKdTree) {
  33595. this.buildKDTree(e);
  33596. }
  33597. if (this.kdTree) {
  33598. return _search(point, this.kdTree, kdDimensions, kdDimensions);
  33599. }
  33600. },
  33601. /**
  33602. * @private
  33603. * @function Highcharts.Series#pointPlacementToXValue
  33604. * @return {number}
  33605. */
  33606. pointPlacementToXValue: function () {
  33607. var _a = this, _b = _a.options, pointPlacement = _b.pointPlacement, pointRange = _b.pointRange, axis = _a.xAxis;
  33608. var factor = pointPlacement;
  33609. // Point placement is relative to each series pointRange (#5889)
  33610. if (factor === 'between') {
  33611. factor = axis.reversed ? -0.5 : 0.5; // #11955
  33612. }
  33613. return isNumber(factor) ?
  33614. factor * pick(pointRange, axis.pointRange) :
  33615. 0;
  33616. },
  33617. /**
  33618. * @private
  33619. * @function Highcharts.Series#isPointInside
  33620. * @param {Highcharts.Point} point
  33621. * @return {boolean}
  33622. */
  33623. isPointInside: function (point) {
  33624. var isInside = typeof point.plotY !== 'undefined' &&
  33625. typeof point.plotX !== 'undefined' &&
  33626. point.plotY >= 0 &&
  33627. point.plotY <= this.yAxis.len && // #3519
  33628. point.plotX >= 0 &&
  33629. point.plotX <= this.xAxis.len;
  33630. return isInside;
  33631. }
  33632. }); // end Series prototype
  33633. /**
  33634. * A line series displays information as a series of data points connected by
  33635. * straight line segments.
  33636. *
  33637. * @sample {highcharts} highcharts/demo/line-basic/
  33638. * Line chart
  33639. * @sample {highstock} stock/demo/basic-line/
  33640. * Line chart
  33641. *
  33642. * @extends plotOptions.series
  33643. * @product highcharts highstock
  33644. * @apioption plotOptions.line
  33645. */
  33646. /**
  33647. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  33648. * of a line graph. Round means that lines are rounded in the ends and
  33649. * bends.
  33650. *
  33651. * @type {Highcharts.SeriesLinecapValue}
  33652. * @default round
  33653. * @since 3.0.7
  33654. * @apioption plotOptions.line.linecap
  33655. */
  33656. /**
  33657. * A `line` series. If the [type](#series.line.type) option is not
  33658. * specified, it is inherited from [chart.type](#chart.type).
  33659. *
  33660. * @extends series,plotOptions.line
  33661. * @excluding dataParser,dataURL
  33662. * @product highcharts highstock
  33663. * @apioption series.line
  33664. */
  33665. /**
  33666. * An array of data points for the series. For the `line` series type,
  33667. * points can be given in the following ways:
  33668. *
  33669. * 1. An array of numerical values. In this case, the numerical values will be
  33670. * interpreted as `y` options. The `x` values will be automatically
  33671. * calculated, either starting at 0 and incremented by 1, or from
  33672. * `pointStart` and `pointInterval` given in the series options. If the axis
  33673. * has categories, these will be used. Example:
  33674. * ```js
  33675. * data: [0, 5, 3, 5]
  33676. * ```
  33677. *
  33678. * 2. An array of arrays with 2 values. In this case, the values correspond to
  33679. * `x,y`. If the first value is a string, it is applied as the name of the
  33680. * point, and the `x` value is inferred.
  33681. * ```js
  33682. * data: [
  33683. * [0, 1],
  33684. * [1, 2],
  33685. * [2, 8]
  33686. * ]
  33687. * ```
  33688. *
  33689. * 3. An array of objects with named values. The following snippet shows only a
  33690. * few settings, see the complete options set below. If the total number of
  33691. * data points exceeds the series'
  33692. * [turboThreshold](#series.line.turboThreshold),
  33693. * this option is not available.
  33694. * ```js
  33695. * data: [{
  33696. * x: 1,
  33697. * y: 9,
  33698. * name: "Point2",
  33699. * color: "#00FF00"
  33700. * }, {
  33701. * x: 1,
  33702. * y: 6,
  33703. * name: "Point1",
  33704. * color: "#FF00FF"
  33705. * }]
  33706. * ```
  33707. *
  33708. * **Note:** In TypeScript you have to extend `PointOptionsObject` with an
  33709. * additional declaration to allow custom data types:
  33710. * ```ts
  33711. * declare module `highcharts` {
  33712. * interface PointOptionsObject {
  33713. * custom: Record<string, (boolean|number|string)>;
  33714. * }
  33715. * }
  33716. * ```
  33717. *
  33718. * @sample {highcharts} highcharts/chart/reflow-true/
  33719. * Numerical values
  33720. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  33721. * Arrays of numeric x and y
  33722. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  33723. * Arrays of datetime x and y
  33724. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  33725. * Arrays of point.name and y
  33726. * @sample {highcharts} highcharts/series/data-array-of-objects/
  33727. * Config objects
  33728. *
  33729. * @declare Highcharts.PointOptionsObject
  33730. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  33731. * @apioption series.line.data
  33732. */
  33733. /**
  33734. * An additional, individual class name for the data point's graphic
  33735. * representation.
  33736. *
  33737. * @type {string}
  33738. * @since 5.0.0
  33739. * @product highcharts gantt
  33740. * @apioption series.line.data.className
  33741. */
  33742. /**
  33743. * Individual color for the point. By default the color is pulled from
  33744. * the global `colors` array.
  33745. *
  33746. * In styled mode, the `color` option doesn't take effect. Instead, use
  33747. * `colorIndex`.
  33748. *
  33749. * @sample {highcharts} highcharts/point/color/
  33750. * Mark the highest point
  33751. *
  33752. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  33753. * @product highcharts highstock gantt
  33754. * @apioption series.line.data.color
  33755. */
  33756. /**
  33757. * A specific color index to use for the point, so its graphic representations
  33758. * are given the class name `highcharts-color-{n}`. In styled mode this will
  33759. * change the color of the graphic. In non-styled mode, the color by is set by
  33760. * the `fill` attribute, so the change in class name won't have a visual effect
  33761. * by default.
  33762. *
  33763. * @type {number}
  33764. * @since 5.0.0
  33765. * @product highcharts gantt
  33766. * @apioption series.line.data.colorIndex
  33767. */
  33768. /**
  33769. * A reserved subspace to store options and values for customized functionality.
  33770. * Here you can add additional data for your own event callbacks and formatter
  33771. * callbacks.
  33772. *
  33773. * @sample {highcharts} highcharts/point/custom/
  33774. * Point and series with custom data
  33775. *
  33776. * @type {Highcharts.Dictionary<*>}
  33777. * @apioption series.line.data.custom
  33778. */
  33779. /**
  33780. * Individual data label for each point. The options are the same as
  33781. * the ones for [plotOptions.series.dataLabels](
  33782. * #plotOptions.series.dataLabels).
  33783. *
  33784. * @sample highcharts/point/datalabels/
  33785. * Show a label for the last value
  33786. *
  33787. * @declare Highcharts.DataLabelsOptions
  33788. * @extends plotOptions.line.dataLabels
  33789. * @product highcharts highstock gantt
  33790. * @apioption series.line.data.dataLabels
  33791. */
  33792. /**
  33793. * A description of the point to add to the screen reader information
  33794. * about the point.
  33795. *
  33796. * @type {string}
  33797. * @since 5.0.0
  33798. * @requires modules/accessibility
  33799. * @apioption series.line.data.description
  33800. */
  33801. /**
  33802. * An id for the point. This can be used after render time to get a
  33803. * pointer to the point object through `chart.get()`.
  33804. *
  33805. * @sample {highcharts} highcharts/point/id/
  33806. * Remove an id'd point
  33807. *
  33808. * @type {string}
  33809. * @since 1.2.0
  33810. * @product highcharts highstock gantt
  33811. * @apioption series.line.data.id
  33812. */
  33813. /**
  33814. * The rank for this point's data label in case of collision. If two
  33815. * data labels are about to overlap, only the one with the highest `labelrank`
  33816. * will be drawn.
  33817. *
  33818. * @type {number}
  33819. * @apioption series.line.data.labelrank
  33820. */
  33821. /**
  33822. * The name of the point as shown in the legend, tooltip, dataLabels, etc.
  33823. *
  33824. * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
  33825. *
  33826. * @sample {highcharts} highcharts/series/data-array-of-objects/
  33827. * Point names
  33828. *
  33829. * @type {string}
  33830. * @apioption series.line.data.name
  33831. */
  33832. /**
  33833. * Whether the data point is selected initially.
  33834. *
  33835. * @type {boolean}
  33836. * @default false
  33837. * @product highcharts highstock gantt
  33838. * @apioption series.line.data.selected
  33839. */
  33840. /**
  33841. * The x value of the point. For datetime axes, the X value is the timestamp
  33842. * in milliseconds since 1970.
  33843. *
  33844. * @type {number}
  33845. * @product highcharts highstock
  33846. * @apioption series.line.data.x
  33847. */
  33848. /**
  33849. * The y value of the point.
  33850. *
  33851. * @type {number|null}
  33852. * @product highcharts highstock
  33853. * @apioption series.line.data.y
  33854. */
  33855. /**
  33856. * The individual point events.
  33857. *
  33858. * @extends plotOptions.series.point.events
  33859. * @product highcharts highstock gantt
  33860. * @apioption series.line.data.events
  33861. */
  33862. /**
  33863. * Options for the point markers of line-like series.
  33864. *
  33865. * @declare Highcharts.PointMarkerOptionsObject
  33866. * @extends plotOptions.series.marker
  33867. * @product highcharts highstock
  33868. * @apioption series.line.data.marker
  33869. */
  33870. ''; // include precedent doclets in transpilat
  33871. });
  33872. _registerModule(_modules, 'parts/Stacking.js', [_modules['parts/Axis.js'], _modules['parts/Chart.js'], _modules['parts/Globals.js'], _modules['parts/StackingAxis.js'], _modules['parts/Utilities.js']], function (Axis, Chart, H, StackingAxis, U) {
  33873. /* *
  33874. *
  33875. * (c) 2010-2020 Torstein Honsi
  33876. *
  33877. * License: www.highcharts.com/license
  33878. *
  33879. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  33880. *
  33881. * */
  33882. var correctFloat = U.correctFloat, defined = U.defined, destroyObjectProperties = U.destroyObjectProperties, format = U.format, isNumber = U.isNumber, pick = U.pick;
  33883. /**
  33884. * Stack of data points
  33885. *
  33886. * @product highcharts
  33887. *
  33888. * @interface Highcharts.StackItemObject
  33889. */ /**
  33890. * Alignment settings
  33891. * @name Highcharts.StackItemObject#alignOptions
  33892. * @type {Highcharts.AlignObject}
  33893. */ /**
  33894. * Related axis
  33895. * @name Highcharts.StackItemObject#axis
  33896. * @type {Highcharts.Axis}
  33897. */ /**
  33898. * Cumulative value of the stacked data points
  33899. * @name Highcharts.StackItemObject#cumulative
  33900. * @type {number}
  33901. */ /**
  33902. * True if on the negative side
  33903. * @name Highcharts.StackItemObject#isNegative
  33904. * @type {boolean}
  33905. */ /**
  33906. * Related SVG element
  33907. * @name Highcharts.StackItemObject#label
  33908. * @type {Highcharts.SVGElement}
  33909. */ /**
  33910. * Related stack options
  33911. * @name Highcharts.StackItemObject#options
  33912. * @type {Highcharts.YAxisStackLabelsOptions}
  33913. */ /**
  33914. * Total value of the stacked data points
  33915. * @name Highcharts.StackItemObject#total
  33916. * @type {number}
  33917. */ /**
  33918. * Shared x value of the stack
  33919. * @name Highcharts.StackItemObject#x
  33920. * @type {number}
  33921. */
  33922. ''; // detached doclets above
  33923. var Series = H.Series;
  33924. /* eslint-disable no-invalid-this, valid-jsdoc */
  33925. /**
  33926. * The class for stacks. Each stack, on a specific X value and either negative
  33927. * or positive, has its own stack item.
  33928. *
  33929. * @private
  33930. * @class
  33931. * @name Highcharts.StackItem
  33932. * @param {Highcharts.Axis} axis
  33933. * @param {Highcharts.YAxisStackLabelsOptions} options
  33934. * @param {boolean} isNegative
  33935. * @param {number} x
  33936. * @param {Highcharts.OptionsStackingValue} [stackOption]
  33937. */
  33938. var StackItem = /** @class */ (function () {
  33939. function StackItem(axis, options, isNegative, x, stackOption) {
  33940. var inverted = axis.chart.inverted;
  33941. this.axis = axis;
  33942. // Tells if the stack is negative
  33943. this.isNegative = isNegative;
  33944. // Save the options to be able to style the label
  33945. this.options = options = options || {};
  33946. // Save the x value to be able to position the label later
  33947. this.x = x;
  33948. // Initialize total value
  33949. this.total = null;
  33950. // This will keep each points' extremes stored by series.index and point
  33951. // index
  33952. this.points = {};
  33953. this.hasValidPoints = false;
  33954. // Save the stack option on the series configuration object,
  33955. // and whether to treat it as percent
  33956. this.stack = stackOption;
  33957. this.leftCliff = 0;
  33958. this.rightCliff = 0;
  33959. // The align options and text align varies on whether the stack is
  33960. // negative and if the chart is inverted or not.
  33961. // First test the user supplied value, then use the dynamic.
  33962. this.alignOptions = {
  33963. align: options.align ||
  33964. (inverted ? (isNegative ? 'left' : 'right') : 'center'),
  33965. verticalAlign: options.verticalAlign ||
  33966. (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
  33967. y: options.y,
  33968. x: options.x
  33969. };
  33970. this.textAlign = options.textAlign ||
  33971. (inverted ? (isNegative ? 'right' : 'left') : 'center');
  33972. }
  33973. /**
  33974. * @private
  33975. * @function Highcharts.StackItem#destroy
  33976. */
  33977. StackItem.prototype.destroy = function () {
  33978. destroyObjectProperties(this, this.axis);
  33979. };
  33980. /**
  33981. * Renders the stack total label and adds it to the stack label group.
  33982. *
  33983. * @private
  33984. * @function Highcharts.StackItem#render
  33985. * @param {Highcharts.SVGElement} group
  33986. */
  33987. StackItem.prototype.render = function (group) {
  33988. var chart = this.axis.chart, options = this.options, formatOption = options.format, attr = {}, str = formatOption ? // format the text in the label
  33989. format(formatOption, this, chart) :
  33990. options.formatter.call(this);
  33991. // Change the text to reflect the new total and set visibility to hidden
  33992. // in case the serie is hidden
  33993. if (this.label) {
  33994. this.label.attr({ text: str, visibility: 'hidden' });
  33995. }
  33996. else {
  33997. // Create new label
  33998. this.label = chart.renderer
  33999. .label(str, null, null, options.shape, null, null, options.useHTML, false, 'stack-labels');
  34000. attr = {
  34001. r: options.borderRadius || 0,
  34002. text: str,
  34003. rotation: options.rotation,
  34004. padding: pick(options.padding, 5),
  34005. visibility: 'hidden' // hidden until setOffset is called
  34006. };
  34007. if (!chart.styledMode) {
  34008. attr.fill = options.backgroundColor;
  34009. attr.stroke = options.borderColor;
  34010. attr['stroke-width'] = options.borderWidth;
  34011. this.label.css(options.style);
  34012. }
  34013. this.label.attr(attr);
  34014. if (!this.label.added) {
  34015. this.label.add(group); // add to the labels-group
  34016. }
  34017. }
  34018. // Rank it higher than data labels (#8742)
  34019. this.label.labelrank = chart.plotHeight;
  34020. };
  34021. /**
  34022. * Sets the offset that the stack has from the x value and repositions the
  34023. * label.
  34024. *
  34025. * @private
  34026. * @function Highcarts.StackItem#setOffset
  34027. * @param {number} xOffset
  34028. * @param {number} xWidth
  34029. * @param {number} [boxBottom]
  34030. * @param {number} [boxTop]
  34031. * @param {number} [defaultX]
  34032. */
  34033. StackItem.prototype.setOffset = function (xOffset, xWidth, boxBottom, boxTop, defaultX) {
  34034. var stackItem = this, axis = stackItem.axis, chart = axis.chart,
  34035. // stack value translated mapped to chart coordinates
  34036. y = axis.translate(axis.stacking.usePercentage ?
  34037. 100 :
  34038. (boxTop ?
  34039. boxTop :
  34040. stackItem.total), 0, 0, 0, 1), yZero = axis.translate(boxBottom ? boxBottom : 0), // stack origin
  34041. // stack height:
  34042. h = defined(y) && Math.abs(y - yZero),
  34043. // x position:
  34044. x = pick(defaultX, chart.xAxis[0].translate(stackItem.x)) +
  34045. xOffset, stackBox = defined(y) && stackItem.getStackBox(chart, stackItem, x, y, xWidth, h, axis), label = stackItem.label, isNegative = stackItem.isNegative, isJustify = pick(stackItem.options.overflow, 'justify') === 'justify', textAlign = stackItem.textAlign, visible;
  34046. if (label && stackBox) {
  34047. var bBox = label.getBBox(), padding = label.padding, boxOffsetX, boxOffsetY;
  34048. if (textAlign === 'left') {
  34049. boxOffsetX = chart.inverted ? -padding : padding;
  34050. }
  34051. else if (textAlign === 'right') {
  34052. boxOffsetX = bBox.width;
  34053. }
  34054. else {
  34055. if (chart.inverted && textAlign === 'center') {
  34056. boxOffsetX = bBox.width / 2;
  34057. }
  34058. else {
  34059. boxOffsetX = chart.inverted ?
  34060. (isNegative ? bBox.width + padding : -padding) : bBox.width / 2;
  34061. }
  34062. }
  34063. boxOffsetY = chart.inverted ?
  34064. bBox.height / 2 : (isNegative ? -padding : bBox.height);
  34065. // Reset alignOptions property after justify #12337
  34066. stackItem.alignOptions.x = pick(stackItem.options.x, 0);
  34067. stackItem.alignOptions.y = pick(stackItem.options.y, 0);
  34068. // Set the stackBox position
  34069. stackBox.x -= boxOffsetX;
  34070. stackBox.y -= boxOffsetY;
  34071. // Align the label to the box
  34072. label.align(stackItem.alignOptions, null, stackBox);
  34073. // Check if label is inside the plotArea #12294
  34074. if (chart.isInsidePlot(label.alignAttr.x + boxOffsetX - stackItem.alignOptions.x, label.alignAttr.y + boxOffsetY - stackItem.alignOptions.y)) {
  34075. label.show();
  34076. }
  34077. else {
  34078. // Move label away to avoid the overlapping issues
  34079. label.alignAttr.y = -9999;
  34080. isJustify = false;
  34081. }
  34082. if (isJustify) {
  34083. // Justify stackLabel into the stackBox
  34084. Series.prototype.justifyDataLabel.call(this.axis, label, stackItem.alignOptions, label.alignAttr, bBox, stackBox);
  34085. }
  34086. label.attr({
  34087. x: label.alignAttr.x,
  34088. y: label.alignAttr.y
  34089. });
  34090. if (pick(!isJustify && stackItem.options.crop, true)) {
  34091. visible =
  34092. isNumber(label.x) &&
  34093. isNumber(label.y) &&
  34094. chart.isInsidePlot(label.x - padding + label.width, label.y) &&
  34095. chart.isInsidePlot(label.x + padding, label.y);
  34096. if (!visible) {
  34097. label.hide();
  34098. }
  34099. }
  34100. }
  34101. };
  34102. /**
  34103. * @private
  34104. * @function Highcharts.StackItem#getStackBox
  34105. *
  34106. * @param {Highcharts.Chart} chart
  34107. *
  34108. * @param {Highcharts.StackItem} stackItem
  34109. *
  34110. * @param {number} x
  34111. *
  34112. * @param {number} y
  34113. *
  34114. * @param {number} xWidth
  34115. *
  34116. * @param {number} h
  34117. *
  34118. * @param {Highcharts.Axis} axis
  34119. *
  34120. * @return {Highcharts.BBoxObject}
  34121. */
  34122. StackItem.prototype.getStackBox = function (chart, stackItem, x, y, xWidth, h, axis) {
  34123. var reversed = stackItem.axis.reversed, inverted = chart.inverted, axisPos = axis.height + axis.pos -
  34124. (inverted ? chart.plotLeft : chart.plotTop), neg = (stackItem.isNegative && !reversed) ||
  34125. (!stackItem.isNegative && reversed); // #4056
  34126. return {
  34127. x: inverted ? (neg ? y - axis.right : y - h + axis.pos - chart.plotLeft) :
  34128. x + chart.xAxis[0].transB - chart.plotLeft,
  34129. y: inverted ?
  34130. axis.height - x - xWidth :
  34131. (neg ?
  34132. (axisPos - y - h) :
  34133. axisPos - y),
  34134. width: inverted ? h : xWidth,
  34135. height: inverted ? xWidth : h
  34136. };
  34137. };
  34138. return StackItem;
  34139. }());
  34140. /**
  34141. * Generate stacks for each series and calculate stacks total values
  34142. *
  34143. * @private
  34144. * @function Highcharts.Chart#getStacks
  34145. */
  34146. Chart.prototype.getStacks = function () {
  34147. var chart = this, inverted = chart.inverted;
  34148. // reset stacks for each yAxis
  34149. chart.yAxis.forEach(function (axis) {
  34150. if (axis.stacking && axis.stacking.stacks && axis.hasVisibleSeries) {
  34151. axis.stacking.oldStacks = axis.stacking.stacks;
  34152. }
  34153. });
  34154. chart.series.forEach(function (series) {
  34155. var xAxisOptions = series.xAxis && series.xAxis.options || {};
  34156. if (series.options.stacking &&
  34157. (series.visible === true ||
  34158. chart.options.chart.ignoreHiddenSeries === false)) {
  34159. series.stackKey = [
  34160. series.type,
  34161. pick(series.options.stack, ''),
  34162. inverted ? xAxisOptions.top : xAxisOptions.left,
  34163. inverted ? xAxisOptions.height : xAxisOptions.width
  34164. ].join(',');
  34165. }
  34166. });
  34167. };
  34168. // Stacking methods defined on the Axis prototype
  34169. StackingAxis.compose(Axis);
  34170. // Stacking methods defined for Series prototype
  34171. /**
  34172. * Set grouped points in a stack-like object. When `centerInCategory` is true,
  34173. * and `stacking` is not enabled, we need a pseudo (horizontal) stack in order
  34174. * to handle grouping of points within the same category.
  34175. *
  34176. * @private
  34177. * @function Highcharts.Series#setStackedPoints
  34178. * @return {void}
  34179. */
  34180. Series.prototype.setGroupedPoints = function () {
  34181. if (this.options.centerInCategory &&
  34182. (this.is('column') || this.is('columnrange')) &&
  34183. // With stacking enabled, we already have stacks that we can compute
  34184. // from
  34185. !this.options.stacking &&
  34186. // With only one series, we don't need to consider centerInCategory
  34187. this.chart.series.length > 1) {
  34188. Series.prototype.setStackedPoints.call(this, 'group');
  34189. }
  34190. };
  34191. /**
  34192. * Adds series' points value to corresponding stack
  34193. *
  34194. * @private
  34195. * @function Highcharts.Series#setStackedPoints
  34196. */
  34197. Series.prototype.setStackedPoints = function (stackingParam) {
  34198. var stacking = stackingParam || this.options.stacking;
  34199. if (!stacking ||
  34200. (this.visible !== true &&
  34201. this.chart.options.chart.ignoreHiddenSeries !== false)) {
  34202. return;
  34203. }
  34204. 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;
  34205. yAxis.stacking.stacksTouched += 1;
  34206. // loop over the non-null y values and read them into a local array
  34207. for (i = 0; i < yDataLength; i++) {
  34208. x = xData[i];
  34209. y = yData[i];
  34210. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index);
  34211. pointKey = stackIndicator.key;
  34212. // Read stacked values into a stack based on the x value,
  34213. // the sign of y and the stack key. Stacking is also handled for null
  34214. // values (#739)
  34215. isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
  34216. key = isNegative ? negKey : stackKey;
  34217. // Create empty object for this stack if it doesn't exist yet
  34218. if (!stacks[key]) {
  34219. stacks[key] =
  34220. {};
  34221. }
  34222. // Initialize StackItem for this x
  34223. if (!stacks[key][x]) {
  34224. if (oldStacks[key] &&
  34225. oldStacks[key][x]) {
  34226. stacks[key][x] = oldStacks[key][x];
  34227. stacks[key][x].total = null;
  34228. }
  34229. else {
  34230. stacks[key][x] = new StackItem(yAxis, yAxis.options.stackLabels, isNegative, x, stackOption);
  34231. }
  34232. }
  34233. // If the StackItem doesn't exist, create it first
  34234. stack = stacks[key][x];
  34235. if (y !== null) {
  34236. stack.points[pointKey] = stack.points[series.index] =
  34237. [pick(stack.cumulative, stackThreshold)];
  34238. // Record the base of the stack
  34239. if (!defined(stack.cumulative)) {
  34240. stack.base = pointKey;
  34241. }
  34242. stack.touched = yAxis.stacking.stacksTouched;
  34243. // In area charts, if there are multiple points on the same X value,
  34244. // let the area fill the full span of those points
  34245. if (stackIndicator.index > 0 && series.singleStacks === false) {
  34246. stack.points[pointKey][0] =
  34247. stack.points[series.index + ',' + x + ',0'][0];
  34248. }
  34249. // When updating to null, reset the point stack (#7493)
  34250. }
  34251. else {
  34252. stack.points[pointKey] = stack.points[series.index] =
  34253. null;
  34254. }
  34255. // Add value to the stack total
  34256. if (stacking === 'percent') {
  34257. // Percent stacked column, totals are the same for the positive and
  34258. // negative stacks
  34259. other = isNegative ? stackKey : negKey;
  34260. if (negStacks && stacks[other] && stacks[other][x]) {
  34261. other = stacks[other][x];
  34262. stack.total = other.total =
  34263. Math.max(other.total, stack.total) +
  34264. Math.abs(y) ||
  34265. 0;
  34266. // Percent stacked areas
  34267. }
  34268. else {
  34269. stack.total =
  34270. correctFloat(stack.total + (Math.abs(y) || 0));
  34271. }
  34272. }
  34273. else if (stacking === 'group') {
  34274. // In this stack, the total is the number of valid points
  34275. if (y !== null) {
  34276. stack.total = (stack.total || 0) + 1;
  34277. }
  34278. }
  34279. else {
  34280. stack.total = correctFloat(stack.total + (y || 0));
  34281. }
  34282. if (stacking === 'group') {
  34283. // This point's index within the stack, pushed to stack.points[1]
  34284. stack.cumulative = (stack.total || 1) - 1;
  34285. }
  34286. else {
  34287. stack.cumulative =
  34288. pick(stack.cumulative, stackThreshold) + (y || 0);
  34289. }
  34290. if (y !== null) {
  34291. stack.points[pointKey].push(stack.cumulative);
  34292. stackedYData[i] = stack.cumulative;
  34293. stack.hasValidPoints = true;
  34294. }
  34295. }
  34296. if (stacking === 'percent') {
  34297. yAxis.stacking.usePercentage = true;
  34298. }
  34299. if (stacking !== 'group') {
  34300. this.stackedYData = stackedYData; // To be used in getExtremes
  34301. }
  34302. // Reset old stacks
  34303. yAxis.stacking.oldStacks = {};
  34304. };
  34305. /**
  34306. * Iterate over all stacks and compute the absolute values to percent
  34307. *
  34308. * @private
  34309. * @function Highcharts.Series#modifyStacks
  34310. */
  34311. Series.prototype.modifyStacks = function () {
  34312. var series = this, yAxis = series.yAxis, stackKey = series.stackKey, stacks = yAxis.stacking.stacks, processedXData = series.processedXData, stackIndicator, stacking = series.options.stacking;
  34313. if (series[stacking + 'Stacker']) { // Modifier function exists
  34314. [stackKey, '-' + stackKey].forEach(function (key) {
  34315. var i = processedXData.length, x, stack, pointExtremes;
  34316. while (i--) {
  34317. x = processedXData[i];
  34318. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index, key);
  34319. stack = stacks[key] && stacks[key][x];
  34320. pointExtremes =
  34321. stack && stack.points[stackIndicator.key];
  34322. if (pointExtremes) {
  34323. series[stacking + 'Stacker'](pointExtremes, stack, i);
  34324. }
  34325. }
  34326. });
  34327. }
  34328. };
  34329. /**
  34330. * Modifier function for percent stacks. Blows up the stack to 100%.
  34331. *
  34332. * @private
  34333. * @function Highcharts.Series#percentStacker
  34334. * @param {Array<number>} pointExtremes
  34335. * @param {Highcharts.StackItem} stack
  34336. * @param {number} i
  34337. */
  34338. Series.prototype.percentStacker = function (pointExtremes, stack, i) {
  34339. var totalFactor = stack.total ? 100 / stack.total : 0;
  34340. // Y bottom value
  34341. pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
  34342. // Y value
  34343. pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
  34344. this.stackedYData[i] = pointExtremes[1];
  34345. };
  34346. /**
  34347. * Get stack indicator, according to it's x-value, to determine points with the
  34348. * same x-value
  34349. *
  34350. * @private
  34351. * @function Highcharts.Series#getStackIndicator
  34352. * @param {Highcharts.StackItemIndicatorObject|undefined} stackIndicator
  34353. * @param {number} x
  34354. * @param {number} index
  34355. * @param {string} [key]
  34356. * @return {Highcharts.StackItemIndicatorObject}
  34357. */
  34358. Series.prototype.getStackIndicator = function (stackIndicator, x, index, key) {
  34359. // Update stack indicator, when:
  34360. // first point in a stack || x changed || stack type (negative vs positive)
  34361. // changed:
  34362. if (!defined(stackIndicator) ||
  34363. stackIndicator.x !== x ||
  34364. (key && stackIndicator.key !== key)) {
  34365. stackIndicator = {
  34366. x: x,
  34367. index: 0,
  34368. key: key
  34369. };
  34370. }
  34371. else {
  34372. (stackIndicator).index++;
  34373. }
  34374. stackIndicator.key =
  34375. [index, x, stackIndicator.index].join(',');
  34376. return stackIndicator;
  34377. };
  34378. H.StackItem = StackItem;
  34379. return H.StackItem;
  34380. });
  34381. _registerModule(_modules, 'parts/Dynamics.js', [_modules['parts/Axis.js'], _modules['parts/Chart.js'], _modules['parts/Globals.js'], _modules['parts/Options.js'], _modules['parts/Point.js'], _modules['parts/Time.js'], _modules['parts/Utilities.js']], function (Axis, Chart, H, O, Point, Time, U) {
  34382. /* *
  34383. *
  34384. * (c) 2010-2020 Torstein Honsi
  34385. *
  34386. * License: www.highcharts.com/license
  34387. *
  34388. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  34389. *
  34390. * */
  34391. var time = O.time;
  34392. var addEvent = U.addEvent, animate = U.animate, createElement = U.createElement, css = U.css, defined = U.defined, erase = U.erase, error = U.error, extend = U.extend, fireEvent = U.fireEvent, isArray = U.isArray, isNumber = U.isNumber, isObject = U.isObject, isString = U.isString, merge = U.merge, objectEach = U.objectEach, pick = U.pick, relativeLength = U.relativeLength, setAnimation = U.setAnimation, splat = U.splat;
  34393. var Series = H.Series, seriesTypes = H.seriesTypes;
  34394. /* eslint-disable valid-jsdoc */
  34395. /**
  34396. * Remove settings that have not changed, to avoid unnecessary rendering or
  34397. * computing (#9197).
  34398. * @private
  34399. */
  34400. H.cleanRecursively = function (newer, older) {
  34401. var result = {};
  34402. objectEach(newer, function (val, key) {
  34403. var ob;
  34404. // Dive into objects (except DOM nodes)
  34405. if (isObject(newer[key], true) &&
  34406. !newer.nodeType && // #10044
  34407. older[key]) {
  34408. ob = H.cleanRecursively(newer[key], older[key]);
  34409. if (Object.keys(ob).length) {
  34410. result[key] = ob;
  34411. }
  34412. // Arrays, primitives and DOM nodes are copied directly
  34413. }
  34414. else if (isObject(newer[key]) ||
  34415. newer[key] !== older[key]) {
  34416. result[key] = newer[key];
  34417. }
  34418. });
  34419. return result;
  34420. };
  34421. // Extend the Chart prototype for dynamic methods
  34422. extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ {
  34423. /**
  34424. * Add a series to the chart after render time. Note that this method should
  34425. * never be used when adding data synchronously at chart render time, as it
  34426. * adds expense to the calculations and rendering. When adding data at the
  34427. * same time as the chart is initialized, add the series as a configuration
  34428. * option instead. With multiple axes, the `offset` is dynamically adjusted.
  34429. *
  34430. * @sample highcharts/members/chart-addseries/
  34431. * Add a series from a button
  34432. * @sample stock/members/chart-addseries/
  34433. * Add a series in Highstock
  34434. *
  34435. * @function Highcharts.Chart#addSeries
  34436. *
  34437. * @param {Highcharts.SeriesOptionsType} options
  34438. * The config options for the series.
  34439. *
  34440. * @param {boolean} [redraw=true]
  34441. * Whether to redraw the chart after adding.
  34442. *
  34443. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  34444. * Whether to apply animation, and optionally animation
  34445. * configuration.
  34446. *
  34447. * @return {Highcharts.Series}
  34448. * The newly created series object.
  34449. *
  34450. * @fires Highcharts.Chart#event:addSeries
  34451. * @fires Highcharts.Chart#event:afterAddSeries
  34452. */
  34453. addSeries: function (options, redraw, animation) {
  34454. var series, chart = this;
  34455. if (options) { // <- not necessary
  34456. redraw = pick(redraw, true); // defaults to true
  34457. fireEvent(chart, 'addSeries', { options: options }, function () {
  34458. series = chart.initSeries(options);
  34459. chart.isDirtyLegend = true;
  34460. chart.linkSeries();
  34461. if (series.enabledDataSorting) {
  34462. // We need to call `setData` after `linkSeries`
  34463. series.setData(options.data, false);
  34464. }
  34465. fireEvent(chart, 'afterAddSeries', { series: series });
  34466. if (redraw) {
  34467. chart.redraw(animation);
  34468. }
  34469. });
  34470. }
  34471. return series;
  34472. },
  34473. /**
  34474. * Add an axis to the chart after render time. Note that this method should
  34475. * never be used when adding data synchronously at chart render time, as it
  34476. * adds expense to the calculations and rendering. When adding data at the
  34477. * same time as the chart is initialized, add the axis as a configuration
  34478. * option instead.
  34479. *
  34480. * @sample highcharts/members/chart-addaxis/
  34481. * Add and remove axes
  34482. *
  34483. * @function Highcharts.Chart#addAxis
  34484. *
  34485. * @param {Highcharts.AxisOptions} options
  34486. * The axis options.
  34487. *
  34488. * @param {boolean} [isX=false]
  34489. * Whether it is an X axis or a value axis.
  34490. *
  34491. * @param {boolean} [redraw=true]
  34492. * Whether to redraw the chart after adding.
  34493. *
  34494. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=true]
  34495. * Whether and how to apply animation in the redraw.
  34496. *
  34497. * @return {Highcharts.Axis}
  34498. * The newly generated Axis object.
  34499. */
  34500. addAxis: function (options, isX, redraw, animation) {
  34501. return this.createAxis(isX ? 'xAxis' : 'yAxis', { axis: options, redraw: redraw, animation: animation });
  34502. },
  34503. /**
  34504. * Add a color axis to the chart after render time. Note that this method
  34505. * should never be used when adding data synchronously at chart render time,
  34506. * as it adds expense to the calculations and rendering. When adding data at
  34507. * the same time as the chart is initialized, add the axis as a
  34508. * configuration option instead.
  34509. *
  34510. * @sample highcharts/members/chart-addaxis/
  34511. * Add and remove axes
  34512. *
  34513. * @function Highcharts.Chart#addColorAxis
  34514. *
  34515. * @param {Highcharts.ColorAxisOptions} options
  34516. * The axis options.
  34517. *
  34518. * @param {boolean} [redraw=true]
  34519. * Whether to redraw the chart after adding.
  34520. *
  34521. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=true]
  34522. * Whether and how to apply animation in the redraw.
  34523. *
  34524. * @return {Highcharts.ColorAxis}
  34525. * The newly generated Axis object.
  34526. */
  34527. addColorAxis: function (options, redraw, animation) {
  34528. return this.createAxis('colorAxis', { axis: options, redraw: redraw, animation: animation });
  34529. },
  34530. /**
  34531. * Factory for creating different axis types.
  34532. *
  34533. * @private
  34534. * @function Highcharts.Chart#createAxis
  34535. *
  34536. * @param {string} type
  34537. * An axis type.
  34538. *
  34539. * @param {...Array<*>} arguments
  34540. * All arguments for the constructor.
  34541. *
  34542. * @return {Highcharts.Axis | Highcharts.ColorAxis}
  34543. * The newly generated Axis object.
  34544. */
  34545. createAxis: function (type, options) {
  34546. var chartOptions = this.options, isColorAxis = type === 'colorAxis', axisOptions = options.axis, redraw = options.redraw, animation = options.animation, userOptions = merge(axisOptions, {
  34547. index: this[type].length,
  34548. isX: type === 'xAxis'
  34549. }), axis;
  34550. if (isColorAxis) {
  34551. axis = new H.ColorAxis(this, userOptions);
  34552. }
  34553. else {
  34554. axis = new Axis(this, userOptions);
  34555. }
  34556. // Push the new axis options to the chart options
  34557. chartOptions[type] = splat(chartOptions[type] || {});
  34558. chartOptions[type].push(userOptions);
  34559. if (isColorAxis) {
  34560. this.isDirtyLegend = true;
  34561. // Clear before 'bindAxes' (#11924)
  34562. this.axes.forEach(function (axis) {
  34563. axis.series = [];
  34564. });
  34565. this.series.forEach(function (series) {
  34566. series.bindAxes();
  34567. series.isDirtyData = true;
  34568. });
  34569. }
  34570. if (pick(redraw, true)) {
  34571. this.redraw(animation);
  34572. }
  34573. return axis;
  34574. },
  34575. /**
  34576. * Dim the chart and show a loading text or symbol. Options for the loading
  34577. * screen are defined in {@link
  34578. * https://api.highcharts.com/highcharts/loading|the loading options}.
  34579. *
  34580. * @sample highcharts/members/chart-hideloading/
  34581. * Show and hide loading from a button
  34582. * @sample highcharts/members/chart-showloading/
  34583. * Apply different text labels
  34584. * @sample stock/members/chart-show-hide-loading/
  34585. * Toggle loading in Highstock
  34586. *
  34587. * @function Highcharts.Chart#showLoading
  34588. *
  34589. * @param {string} [str]
  34590. * An optional text to show in the loading label instead of the
  34591. * default one. The default text is set in
  34592. * [lang.loading](https://api.highcharts.com/highcharts/lang.loading).
  34593. */
  34594. showLoading: function (str) {
  34595. var chart = this, options = chart.options, loadingDiv = chart.loadingDiv, loadingOptions = options.loading, setLoadingSize = function () {
  34596. if (loadingDiv) {
  34597. css(loadingDiv, {
  34598. left: chart.plotLeft + 'px',
  34599. top: chart.plotTop + 'px',
  34600. width: chart.plotWidth + 'px',
  34601. height: chart.plotHeight + 'px'
  34602. });
  34603. }
  34604. };
  34605. // create the layer at the first call
  34606. if (!loadingDiv) {
  34607. chart.loadingDiv = loadingDiv = createElement('div', {
  34608. className: 'highcharts-loading highcharts-loading-hidden'
  34609. }, null, chart.container);
  34610. chart.loadingSpan = createElement('span', { className: 'highcharts-loading-inner' }, null, loadingDiv);
  34611. addEvent(chart, 'redraw', setLoadingSize); // #1080
  34612. }
  34613. loadingDiv.className = 'highcharts-loading';
  34614. // Update text
  34615. chart.loadingSpan.innerHTML =
  34616. pick(str, options.lang.loading, '');
  34617. if (!chart.styledMode) {
  34618. // Update visuals
  34619. css(loadingDiv, extend(loadingOptions.style, {
  34620. zIndex: 10
  34621. }));
  34622. css(chart.loadingSpan, loadingOptions.labelStyle);
  34623. // Show it
  34624. if (!chart.loadingShown) {
  34625. css(loadingDiv, {
  34626. opacity: 0,
  34627. display: ''
  34628. });
  34629. animate(loadingDiv, {
  34630. opacity: loadingOptions.style.opacity || 0.5
  34631. }, {
  34632. duration: loadingOptions.showDuration || 0
  34633. });
  34634. }
  34635. }
  34636. chart.loadingShown = true;
  34637. setLoadingSize();
  34638. },
  34639. /**
  34640. * Hide the loading layer.
  34641. *
  34642. * @see Highcharts.Chart#showLoading
  34643. *
  34644. * @sample highcharts/members/chart-hideloading/
  34645. * Show and hide loading from a button
  34646. * @sample stock/members/chart-show-hide-loading/
  34647. * Toggle loading in Highstock
  34648. *
  34649. * @function Highcharts.Chart#hideLoading
  34650. */
  34651. hideLoading: function () {
  34652. var options = this.options, loadingDiv = this.loadingDiv;
  34653. if (loadingDiv) {
  34654. loadingDiv.className =
  34655. 'highcharts-loading highcharts-loading-hidden';
  34656. if (!this.styledMode) {
  34657. animate(loadingDiv, {
  34658. opacity: 0
  34659. }, {
  34660. duration: options.loading.hideDuration || 100,
  34661. complete: function () {
  34662. css(loadingDiv, { display: 'none' });
  34663. }
  34664. });
  34665. }
  34666. }
  34667. this.loadingShown = false;
  34668. },
  34669. /**
  34670. * These properties cause isDirtyBox to be set to true when updating. Can be
  34671. * extended from plugins.
  34672. */
  34673. propsRequireDirtyBox: [
  34674. 'backgroundColor',
  34675. 'borderColor',
  34676. 'borderWidth',
  34677. 'borderRadius',
  34678. 'plotBackgroundColor',
  34679. 'plotBackgroundImage',
  34680. 'plotBorderColor',
  34681. 'plotBorderWidth',
  34682. 'plotShadow',
  34683. 'shadow'
  34684. ],
  34685. /**
  34686. * These properties require a full reflow of chart elements, best
  34687. * implemented through running `Chart.setSize` internally (#8190).
  34688. * @type {Array}
  34689. */
  34690. propsRequireReflow: [
  34691. 'margin',
  34692. 'marginTop',
  34693. 'marginRight',
  34694. 'marginBottom',
  34695. 'marginLeft',
  34696. 'spacing',
  34697. 'spacingTop',
  34698. 'spacingRight',
  34699. 'spacingBottom',
  34700. 'spacingLeft'
  34701. ],
  34702. /**
  34703. * These properties cause all series to be updated when updating. Can be
  34704. * extended from plugins.
  34705. */
  34706. propsRequireUpdateSeries: [
  34707. 'chart.inverted',
  34708. 'chart.polar',
  34709. 'chart.ignoreHiddenSeries',
  34710. 'chart.type',
  34711. 'colors',
  34712. 'plotOptions',
  34713. 'time',
  34714. 'tooltip'
  34715. ],
  34716. /**
  34717. * These collections (arrays) implement update() methods with support for
  34718. * one-to-one option.
  34719. */
  34720. collectionsWithUpdate: [
  34721. 'xAxis',
  34722. 'yAxis',
  34723. 'zAxis',
  34724. 'series'
  34725. ],
  34726. /**
  34727. * A generic function to update any element of the chart. Elements can be
  34728. * enabled and disabled, moved, re-styled, re-formatted etc.
  34729. *
  34730. * A special case is configuration objects that take arrays, for example
  34731. * [xAxis](https://api.highcharts.com/highcharts/xAxis),
  34732. * [yAxis](https://api.highcharts.com/highcharts/yAxis) or
  34733. * [series](https://api.highcharts.com/highcharts/series). For these
  34734. * collections, an `id` option is used to map the new option set to an
  34735. * existing object. If an existing object of the same id is not found, the
  34736. * corresponding item is updated. So for example, running `chart.update`
  34737. * with a series item without an id, will cause the existing chart's series
  34738. * with the same index in the series array to be updated. When the
  34739. * `oneToOne` parameter is true, `chart.update` will also take care of
  34740. * adding and removing items from the collection. Read more under the
  34741. * parameter description below.
  34742. *
  34743. * Note that when changing series data, `chart.update` may mutate the passed
  34744. * data options.
  34745. *
  34746. * See also the
  34747. * [responsive option set](https://api.highcharts.com/highcharts/responsive).
  34748. * Switching between `responsive.rules` basically runs `chart.update` under
  34749. * the hood.
  34750. *
  34751. * @sample highcharts/members/chart-update/
  34752. * Update chart geometry
  34753. *
  34754. * @function Highcharts.Chart#update
  34755. *
  34756. * @param {Highcharts.Options} options
  34757. * A configuration object for the new chart options.
  34758. *
  34759. * @param {boolean} [redraw=true]
  34760. * Whether to redraw the chart.
  34761. *
  34762. * @param {boolean} [oneToOne=false]
  34763. * When `true`, the `series`, `xAxis`, `yAxis` and `annotations`
  34764. * collections will be updated one to one, and items will be either
  34765. * added or removed to match the new updated options. For example,
  34766. * if the chart has two series and we call `chart.update` with a
  34767. * configuration containing three series, one will be added. If we
  34768. * call `chart.update` with one series, one will be removed. Setting
  34769. * an empty `series` array will remove all series, but leaving out
  34770. * the`series` property will leave all series untouched. If the
  34771. * series have id's, the new series options will be matched by id,
  34772. * and the remaining ones removed.
  34773. *
  34774. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=true]
  34775. * Whether to apply animation, and optionally animation
  34776. * configuration.
  34777. *
  34778. * @fires Highcharts.Chart#event:update
  34779. * @fires Highcharts.Chart#event:afterUpdate
  34780. */
  34781. update: function (options, redraw, oneToOne, animation) {
  34782. var chart = this, adders = {
  34783. credits: 'addCredits',
  34784. title: 'setTitle',
  34785. subtitle: 'setSubtitle',
  34786. caption: 'setCaption'
  34787. }, optionsChart, updateAllAxes, updateAllSeries, newWidth, newHeight, runSetSize, isResponsiveOptions = options.isResponsiveOptions, itemsForRemoval = [];
  34788. fireEvent(chart, 'update', { options: options });
  34789. // If there are responsive rules in action, undo the responsive rules
  34790. // before we apply the updated options and replay the responsive rules
  34791. // on top from the chart.redraw function (#9617).
  34792. if (!isResponsiveOptions) {
  34793. chart.setResponsive(false, true);
  34794. }
  34795. options = H.cleanRecursively(options, chart.options);
  34796. merge(true, chart.userOptions, options);
  34797. // If the top-level chart option is present, some special updates are
  34798. // required
  34799. optionsChart = options.chart;
  34800. if (optionsChart) {
  34801. merge(true, chart.options.chart, optionsChart);
  34802. // Setter function
  34803. if ('className' in optionsChart) {
  34804. chart.setClassName(optionsChart.className);
  34805. }
  34806. if ('reflow' in optionsChart) {
  34807. chart.setReflow(optionsChart.reflow);
  34808. }
  34809. if ('inverted' in optionsChart ||
  34810. 'polar' in optionsChart ||
  34811. 'type' in optionsChart) {
  34812. // Parse options.chart.inverted and options.chart.polar together
  34813. // with the available series.
  34814. chart.propFromSeries();
  34815. updateAllAxes = true;
  34816. }
  34817. if ('alignTicks' in optionsChart) { // #6452
  34818. updateAllAxes = true;
  34819. }
  34820. objectEach(optionsChart, function (val, key) {
  34821. if (chart.propsRequireUpdateSeries.indexOf('chart.' + key) !==
  34822. -1) {
  34823. updateAllSeries = true;
  34824. }
  34825. // Only dirty box
  34826. if (chart.propsRequireDirtyBox.indexOf(key) !== -1) {
  34827. chart.isDirtyBox = true;
  34828. }
  34829. // Chart setSize
  34830. if (chart.propsRequireReflow.indexOf(key) !== -1) {
  34831. if (isResponsiveOptions) {
  34832. chart.isDirtyBox = true;
  34833. }
  34834. else {
  34835. runSetSize = true;
  34836. }
  34837. }
  34838. });
  34839. if (!chart.styledMode && 'style' in optionsChart) {
  34840. chart.renderer.setStyle(optionsChart.style);
  34841. }
  34842. }
  34843. // Moved up, because tooltip needs updated plotOptions (#6218)
  34844. if (!chart.styledMode && options.colors) {
  34845. this.options.colors = options.colors;
  34846. }
  34847. if (options.plotOptions) {
  34848. merge(true, this.options.plotOptions, options.plotOptions);
  34849. }
  34850. // Maintaining legacy global time. If the chart is instanciated first
  34851. // with global time, then updated with time options, we need to create a
  34852. // new Time instance to avoid mutating the global time (#10536).
  34853. if (options.time && this.time === time) {
  34854. this.time = new Time(options.time);
  34855. }
  34856. // Some option stuctures correspond one-to-one to chart objects that
  34857. // have update methods, for example
  34858. // options.credits => chart.credits
  34859. // options.legend => chart.legend
  34860. // options.title => chart.title
  34861. // options.tooltip => chart.tooltip
  34862. // options.subtitle => chart.subtitle
  34863. // options.mapNavigation => chart.mapNavigation
  34864. // options.navigator => chart.navigator
  34865. // options.scrollbar => chart.scrollbar
  34866. objectEach(options, function (val, key) {
  34867. if (chart[key] &&
  34868. typeof chart[key].update === 'function') {
  34869. chart[key].update(val, false);
  34870. // If a one-to-one object does not exist, look for an adder function
  34871. }
  34872. else if (typeof chart[adders[key]] === 'function') {
  34873. chart[adders[key]](val);
  34874. }
  34875. if (key !== 'chart' &&
  34876. chart.propsRequireUpdateSeries.indexOf(key) !== -1) {
  34877. updateAllSeries = true;
  34878. }
  34879. });
  34880. // Setters for collections. For axes and series, each item is referred
  34881. // by an id. If the id is not found, it defaults to the corresponding
  34882. // item in the collection, so setting one series without an id, will
  34883. // update the first series in the chart. Setting two series without
  34884. // an id will update the first and the second respectively (#6019)
  34885. // chart.update and responsive.
  34886. this.collectionsWithUpdate.forEach(function (coll) {
  34887. var indexMap;
  34888. if (options[coll]) {
  34889. // In stock charts, the navigator series are also part of the
  34890. // chart.series array, but those series should not be handled
  34891. // here (#8196).
  34892. if (coll === 'series') {
  34893. indexMap = [];
  34894. chart[coll].forEach(function (s, i) {
  34895. if (!s.options.isInternal) {
  34896. indexMap.push(pick(s.options.index, i));
  34897. }
  34898. });
  34899. }
  34900. splat(options[coll]).forEach(function (newOptions, i) {
  34901. var hasId = defined(newOptions.id);
  34902. var item;
  34903. // Match by id
  34904. if (hasId) {
  34905. item = chart.get(newOptions.id);
  34906. }
  34907. // No match by id found, match by index instead
  34908. if (!item) {
  34909. item = chart[coll][indexMap ? indexMap[i] : i];
  34910. // Check if we grabbed an item with an exising but
  34911. // different id (#13541)
  34912. if (item && hasId && defined(item.options.id)) {
  34913. item = void 0;
  34914. }
  34915. }
  34916. if (item && item.coll === coll) {
  34917. item.update(newOptions, false);
  34918. if (oneToOne) {
  34919. item.touched = true;
  34920. }
  34921. }
  34922. // If oneToOne and no matching item is found, add one
  34923. if (!item && oneToOne && chart.collectionsWithInit[coll]) {
  34924. chart.collectionsWithInit[coll][0].apply(chart,
  34925. // [newOptions, ...extraArguments, redraw=false]
  34926. [
  34927. newOptions
  34928. ].concat(
  34929. // Not all initializers require extra args
  34930. chart.collectionsWithInit[coll][1] || []).concat([
  34931. false
  34932. ])).touched = true;
  34933. }
  34934. });
  34935. // Add items for removal
  34936. if (oneToOne) {
  34937. chart[coll].forEach(function (item) {
  34938. if (!item.touched && !item.options.isInternal) {
  34939. itemsForRemoval.push(item);
  34940. }
  34941. else {
  34942. delete item.touched;
  34943. }
  34944. });
  34945. }
  34946. }
  34947. });
  34948. itemsForRemoval.forEach(function (item) {
  34949. if (item.remove) {
  34950. item.remove(false);
  34951. }
  34952. });
  34953. if (updateAllAxes) {
  34954. chart.axes.forEach(function (axis) {
  34955. axis.update({}, false);
  34956. });
  34957. }
  34958. // Certain options require the whole series structure to be thrown away
  34959. // and rebuilt
  34960. if (updateAllSeries) {
  34961. chart.getSeriesOrderByLinks().forEach(function (series) {
  34962. // Avoid removed navigator series
  34963. if (series.chart) {
  34964. series.update({}, false);
  34965. }
  34966. }, this);
  34967. }
  34968. // For loading, just update the options, do not redraw
  34969. if (options.loading) {
  34970. merge(true, chart.options.loading, options.loading);
  34971. }
  34972. // Update size. Redraw is forced.
  34973. newWidth = optionsChart && optionsChart.width;
  34974. newHeight = optionsChart && optionsChart.height;
  34975. if (isString(newHeight)) {
  34976. newHeight = relativeLength(newHeight, newWidth || chart.chartWidth);
  34977. }
  34978. if (
  34979. // In this case, run chart.setSize with newWidth and newHeight which
  34980. // are undefined, only for reflowing chart elements because margin
  34981. // or spacing has been set (#8190)
  34982. runSetSize ||
  34983. // In this case, the size is actually set
  34984. (isNumber(newWidth) && newWidth !== chart.chartWidth) ||
  34985. (isNumber(newHeight) && newHeight !== chart.chartHeight)) {
  34986. chart.setSize(newWidth, newHeight, animation);
  34987. }
  34988. else if (pick(redraw, true)) {
  34989. chart.redraw(animation);
  34990. }
  34991. fireEvent(chart, 'afterUpdate', {
  34992. options: options,
  34993. redraw: redraw,
  34994. animation: animation
  34995. });
  34996. },
  34997. /**
  34998. * Shortcut to set the subtitle options. This can also be done from {@link
  34999. * Chart#update} or {@link Chart#setTitle}.
  35000. *
  35001. * @function Highcharts.Chart#setSubtitle
  35002. *
  35003. * @param {Highcharts.SubtitleOptions} options
  35004. * New subtitle options. The subtitle text itself is set by the
  35005. * `options.text` property.
  35006. */
  35007. setSubtitle: function (options, redraw) {
  35008. this.applyDescription('subtitle', options);
  35009. this.layOutTitles(redraw);
  35010. },
  35011. /**
  35012. * Set the caption options. This can also be done from {@link
  35013. * Chart#update}.
  35014. *
  35015. * @function Highcharts.Chart#setCaption
  35016. *
  35017. * @param {Highcharts.CaptionOptions} options
  35018. * New caption options. The caption text itself is set by the
  35019. * `options.text` property.
  35020. */
  35021. setCaption: function (options, redraw) {
  35022. this.applyDescription('caption', options);
  35023. this.layOutTitles(redraw);
  35024. }
  35025. });
  35026. /**
  35027. * These collections (arrays) implement `Chart.addSomethig` method used in
  35028. * chart.update() to create new object in the collection. Equivalent for
  35029. * deleting is resolved by simple `Somethig.remove()`.
  35030. *
  35031. * Note: We need to define these references after initializers are bound to
  35032. * chart's prototype.
  35033. */
  35034. Chart.prototype.collectionsWithInit = {
  35035. // collectionName: [ initializingMethod, [extraArguments] ]
  35036. xAxis: [Chart.prototype.addAxis, [true]],
  35037. yAxis: [Chart.prototype.addAxis, [false]],
  35038. series: [Chart.prototype.addSeries]
  35039. };
  35040. // extend the Point prototype for dynamic methods
  35041. extend(Point.prototype, /** @lends Highcharts.Point.prototype */ {
  35042. /**
  35043. * Update point with new options (typically x/y data) and optionally redraw
  35044. * the series.
  35045. *
  35046. * @sample highcharts/members/point-update-column/
  35047. * Update column value
  35048. * @sample highcharts/members/point-update-pie/
  35049. * Update pie slice
  35050. * @sample maps/members/point-update/
  35051. * Update map area value in Highmaps
  35052. *
  35053. * @function Highcharts.Point#update
  35054. *
  35055. * @param {Highcharts.PointOptionsType} options
  35056. * The point options. Point options are handled as described under
  35057. * the `series.type.data` item for each series type. For example
  35058. * for a line series, if options is a single number, the point will
  35059. * be given that number as the marin y value. If it is an array, it
  35060. * will be interpreted as x and y values respectively. If it is an
  35061. * object, advanced options are applied.
  35062. *
  35063. * @param {boolean} [redraw=true]
  35064. * Whether to redraw the chart after the point is updated. If doing
  35065. * more operations on the chart, it is best practice to set
  35066. * `redraw` to false and call `chart.redraw()` after.
  35067. *
  35068. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=true]
  35069. * Whether to apply animation, and optionally animation
  35070. * configuration.
  35071. *
  35072. * @return {void}
  35073. *
  35074. * @fires Highcharts.Point#event:update
  35075. */
  35076. update: function (options, redraw, animation, runEvent) {
  35077. var point = this, series = point.series, graphic = point.graphic, i, chart = series.chart, seriesOptions = series.options;
  35078. redraw = pick(redraw, true);
  35079. /**
  35080. * @private
  35081. */
  35082. function update() {
  35083. point.applyOptions(options);
  35084. // Update visuals, #4146
  35085. // Handle dummy graphic elements for a11y, #12718
  35086. var hasDummyGraphic = graphic && point.hasDummyGraphic;
  35087. var shouldDestroyGraphic = point.y === null ? !hasDummyGraphic : hasDummyGraphic;
  35088. if (graphic && shouldDestroyGraphic) {
  35089. point.graphic = graphic.destroy();
  35090. delete point.hasDummyGraphic;
  35091. }
  35092. if (isObject(options, true)) {
  35093. // Destroy so we can get new elements
  35094. if (graphic && graphic.element) {
  35095. // "null" is also a valid symbol
  35096. if (options &&
  35097. options.marker &&
  35098. typeof options.marker.symbol !== 'undefined') {
  35099. point.graphic = graphic.destroy();
  35100. }
  35101. }
  35102. if (options && options.dataLabels && point.dataLabel) {
  35103. point.dataLabel = point.dataLabel.destroy(); // #2468
  35104. }
  35105. if (point.connector) {
  35106. point.connector = point.connector.destroy(); // #7243
  35107. }
  35108. }
  35109. // record changes in the parallel arrays
  35110. i = point.index;
  35111. series.updateParallelArrays(point, i);
  35112. // Record the options to options.data. If the old or the new config
  35113. // is an object, use point options, otherwise use raw options
  35114. // (#4701, #4916).
  35115. seriesOptions.data[i] = (isObject(seriesOptions.data[i], true) ||
  35116. isObject(options, true)) ?
  35117. point.options :
  35118. pick(options, seriesOptions.data[i]);
  35119. // redraw
  35120. series.isDirty = series.isDirtyData = true;
  35121. if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
  35122. chart.isDirtyBox = true;
  35123. }
  35124. if (seriesOptions.legendType === 'point') { // #1831, #1885
  35125. chart.isDirtyLegend = true;
  35126. }
  35127. if (redraw) {
  35128. chart.redraw(animation);
  35129. }
  35130. }
  35131. // Fire the event with a default handler of doing the update
  35132. if (runEvent === false) { // When called from setData
  35133. update();
  35134. }
  35135. else {
  35136. point.firePointEvent('update', { options: options }, update);
  35137. }
  35138. },
  35139. /**
  35140. * Remove a point and optionally redraw the series and if necessary the axes
  35141. *
  35142. * @sample highcharts/plotoptions/series-point-events-remove/
  35143. * Remove point and confirm
  35144. * @sample highcharts/members/point-remove/
  35145. * Remove pie slice
  35146. * @sample maps/members/point-remove/
  35147. * Remove selected points in Highmaps
  35148. *
  35149. * @function Highcharts.Point#remove
  35150. *
  35151. * @param {boolean} [redraw=true]
  35152. * Whether to redraw the chart or wait for an explicit call. When
  35153. * doing more operations on the chart, for example running
  35154. * `point.remove()` in a loop, it is best practice to set `redraw`
  35155. * to false and call `chart.redraw()` after.
  35156. *
  35157. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=false]
  35158. * Whether to apply animation, and optionally animation
  35159. * configuration.
  35160. *
  35161. * @return {void}
  35162. */
  35163. remove: function (redraw, animation) {
  35164. this.series.removePoint(this.series.data.indexOf(this), redraw, animation);
  35165. }
  35166. });
  35167. // Extend the series prototype for dynamic methods
  35168. extend(Series.prototype, /** @lends Series.prototype */ {
  35169. /**
  35170. * Add a point to the series after render time. The point can be added at
  35171. * the end, or by giving it an X value, to the start or in the middle of the
  35172. * series.
  35173. *
  35174. * @sample highcharts/members/series-addpoint-append/
  35175. * Append point
  35176. * @sample highcharts/members/series-addpoint-append-and-shift/
  35177. * Append and shift
  35178. * @sample highcharts/members/series-addpoint-x-and-y/
  35179. * Both X and Y values given
  35180. * @sample highcharts/members/series-addpoint-pie/
  35181. * Append pie slice
  35182. * @sample stock/members/series-addpoint/
  35183. * Append 100 points in Highstock
  35184. * @sample stock/members/series-addpoint-shift/
  35185. * Append and shift in Highstock
  35186. * @sample maps/members/series-addpoint/
  35187. * Add a point in Highmaps
  35188. *
  35189. * @function Highcharts.Series#addPoint
  35190. *
  35191. * @param {Highcharts.PointOptionsType} options
  35192. * The point options. If options is a single number, a point with
  35193. * that y value is appended to the series. If it is an array, it will
  35194. * be interpreted as x and y values respectively. If it is an
  35195. * object, advanced options as outlined under `series.data` are
  35196. * applied.
  35197. *
  35198. * @param {boolean} [redraw=true]
  35199. * Whether to redraw the chart after the point is added. When adding
  35200. * more than one point, it is highly recommended that the redraw
  35201. * option be set to false, and instead {@link Chart#redraw} is
  35202. * explicitly called after the adding of points is finished.
  35203. * Otherwise, the chart will redraw after adding each point.
  35204. *
  35205. * @param {boolean} [shift=false]
  35206. * If true, a point is shifted off the start of the series as one is
  35207. * appended to the end.
  35208. *
  35209. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  35210. * Whether to apply animation, and optionally animation
  35211. * configuration.
  35212. *
  35213. * @param {boolean} [withEvent=true]
  35214. * Used internally, whether to fire the series `addPoint` event.
  35215. *
  35216. * @return {void}
  35217. *
  35218. * @fires Highcharts.Series#event:addPoint
  35219. */
  35220. addPoint: function (options, redraw, shift, animation, withEvent) {
  35221. var series = this, seriesOptions = series.options, data = series.data, chart = series.chart, xAxis = series.xAxis, names = xAxis && xAxis.hasNames && xAxis.names, dataOptions = seriesOptions.data, point, xData = series.xData, isInTheMiddle, i, x;
  35222. // Optional redraw, defaults to true
  35223. redraw = pick(redraw, true);
  35224. // Get options and push the point to xData, yData and series.options. In
  35225. // series.generatePoints the Point instance will be created on demand
  35226. // and pushed to the series.data array.
  35227. point = { series: series };
  35228. series.pointClass.prototype.applyOptions.apply(point, [options]);
  35229. x = point.x;
  35230. // Get the insertion point
  35231. i = xData.length;
  35232. if (series.requireSorting && x < xData[i - 1]) {
  35233. isInTheMiddle = true;
  35234. while (i && xData[i - 1] > x) {
  35235. i--;
  35236. }
  35237. }
  35238. // Insert undefined item
  35239. series.updateParallelArrays(point, 'splice', i, 0, 0);
  35240. // Update it
  35241. series.updateParallelArrays(point, i);
  35242. if (names && point.name) {
  35243. names[x] = point.name;
  35244. }
  35245. dataOptions.splice(i, 0, options);
  35246. if (isInTheMiddle) {
  35247. series.data.splice(i, 0, null);
  35248. series.processData();
  35249. }
  35250. // Generate points to be added to the legend (#1329)
  35251. if (seriesOptions.legendType === 'point') {
  35252. series.generatePoints();
  35253. }
  35254. // Shift the first point off the parallel arrays
  35255. if (shift) {
  35256. if (data[0] && data[0].remove) {
  35257. data[0].remove(false);
  35258. }
  35259. else {
  35260. data.shift();
  35261. series.updateParallelArrays(point, 'shift');
  35262. dataOptions.shift();
  35263. }
  35264. }
  35265. // Fire event
  35266. if (withEvent !== false) {
  35267. fireEvent(series, 'addPoint', { point: point });
  35268. }
  35269. // redraw
  35270. series.isDirty = true;
  35271. series.isDirtyData = true;
  35272. if (redraw) {
  35273. chart.redraw(animation); // Animation is set anyway on redraw, #5665
  35274. }
  35275. },
  35276. /**
  35277. * Remove a point from the series. Unlike the
  35278. * {@link Highcharts.Point#remove} method, this can also be done on a point
  35279. * that is not instanciated because it is outside the view or subject to
  35280. * Highstock data grouping.
  35281. *
  35282. * @sample highcharts/members/series-removepoint/
  35283. * Remove cropped point
  35284. *
  35285. * @function Highcharts.Series#removePoint
  35286. *
  35287. * @param {number} i
  35288. * The index of the point in the {@link Highcharts.Series.data|data}
  35289. * array.
  35290. *
  35291. * @param {boolean} [redraw=true]
  35292. * Whether to redraw the chart after the point is added. When
  35293. * removing more than one point, it is highly recommended that the
  35294. * `redraw` option be set to `false`, and instead {@link
  35295. * Highcharts.Chart#redraw} is explicitly called after the adding of
  35296. * points is finished.
  35297. *
  35298. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  35299. * Whether and optionally how the series should be animated.
  35300. *
  35301. * @return {void}
  35302. *
  35303. * @fires Highcharts.Point#event:remove
  35304. */
  35305. removePoint: function (i, redraw, animation) {
  35306. var series = this, data = series.data, point = data[i], points = series.points, chart = series.chart, remove = function () {
  35307. if (points && points.length === data.length) { // #4935
  35308. points.splice(i, 1);
  35309. }
  35310. data.splice(i, 1);
  35311. series.options.data.splice(i, 1);
  35312. series.updateParallelArrays(point || { series: series }, 'splice', i, 1);
  35313. if (point) {
  35314. point.destroy();
  35315. }
  35316. // redraw
  35317. series.isDirty = true;
  35318. series.isDirtyData = true;
  35319. if (redraw) {
  35320. chart.redraw();
  35321. }
  35322. };
  35323. setAnimation(animation, chart);
  35324. redraw = pick(redraw, true);
  35325. // Fire the event with a default handler of removing the point
  35326. if (point) {
  35327. point.firePointEvent('remove', null, remove);
  35328. }
  35329. else {
  35330. remove();
  35331. }
  35332. },
  35333. /**
  35334. * Remove a series and optionally redraw the chart.
  35335. *
  35336. * @sample highcharts/members/series-remove/
  35337. * Remove first series from a button
  35338. *
  35339. * @function Highcharts.Series#remove
  35340. *
  35341. * @param {boolean} [redraw=true]
  35342. * Whether to redraw the chart or wait for an explicit call to
  35343. * {@link Highcharts.Chart#redraw}.
  35344. *
  35345. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  35346. * Whether to apply animation, and optionally animation
  35347. * configuration.
  35348. *
  35349. * @param {boolean} [withEvent=true]
  35350. * Used internally, whether to fire the series `remove` event.
  35351. *
  35352. * @return {void}
  35353. *
  35354. * @fires Highcharts.Series#event:remove
  35355. */
  35356. remove: function (redraw, animation, withEvent, keepEvents) {
  35357. var series = this, chart = series.chart;
  35358. /**
  35359. * @private
  35360. */
  35361. function remove() {
  35362. // Destroy elements
  35363. series.destroy(keepEvents);
  35364. series.remove = null; // Prevent from doing again (#9097)
  35365. // Redraw
  35366. chart.isDirtyLegend = chart.isDirtyBox = true;
  35367. chart.linkSeries();
  35368. if (pick(redraw, true)) {
  35369. chart.redraw(animation);
  35370. }
  35371. }
  35372. // Fire the event with a default handler of removing the point
  35373. if (withEvent !== false) {
  35374. fireEvent(series, 'remove', null, remove);
  35375. }
  35376. else {
  35377. remove();
  35378. }
  35379. },
  35380. /**
  35381. * Update the series with a new set of options. For a clean and precise
  35382. * handling of new options, all methods and elements from the series are
  35383. * removed, and it is initialized from scratch. Therefore, this method is
  35384. * more performance expensive than some other utility methods like {@link
  35385. * Series#setData} or {@link Series#setVisible}.
  35386. *
  35387. * Note that `Series.update` may mutate the passed `data` options.
  35388. *
  35389. * @sample highcharts/members/series-update/
  35390. * Updating series options
  35391. * @sample maps/members/series-update/
  35392. * Update series options in Highmaps
  35393. *
  35394. * @function Highcharts.Series#update
  35395. *
  35396. * @param {Highcharts.SeriesOptionsType} options
  35397. * New options that will be merged with the series' existing options.
  35398. *
  35399. * @param {boolean} [redraw=true]
  35400. * Whether to redraw the chart after the series is altered. If doing
  35401. * more operations on the chart, it is a good idea to set redraw to
  35402. * false and call {@link Chart#redraw} after.
  35403. *
  35404. * @return {void}
  35405. *
  35406. * @fires Highcharts.Series#event:update
  35407. * @fires Highcharts.Series#event:afterUpdate
  35408. */
  35409. update: function (options, redraw) {
  35410. options = H.cleanRecursively(options, this.userOptions);
  35411. fireEvent(this, 'update', { options: options });
  35412. var series = this, chart = series.chart,
  35413. // must use user options when changing type because series.options
  35414. // is merged in with type specific plotOptions
  35415. oldOptions = series.userOptions, seriesOptions, initialType = series.initialType || series.type, newType = (options.type ||
  35416. oldOptions.type ||
  35417. chart.options.chart.type), keepPoints = !(
  35418. // Indicators, histograms etc recalculate the data. It should be
  35419. // possible to omit this.
  35420. this.hasDerivedData ||
  35421. // Changes to data grouping requires new points in new groups
  35422. options.dataGrouping ||
  35423. // New type requires new point classes
  35424. (newType && newType !== this.type) ||
  35425. // New options affecting how the data points are built
  35426. typeof options.pointStart !== 'undefined' ||
  35427. options.pointInterval ||
  35428. options.pointIntervalUnit ||
  35429. options.keys), initialSeriesProto = seriesTypes[initialType].prototype, n, groups = [
  35430. 'group',
  35431. 'markerGroup',
  35432. 'dataLabelsGroup',
  35433. 'transformGroup'
  35434. ], preserve = [
  35435. 'eventOptions',
  35436. 'navigatorSeries',
  35437. 'baseSeries'
  35438. ],
  35439. // Animation must be enabled when calling update before the initial
  35440. // animation has first run. This happens when calling update
  35441. // directly after chart initialization, or when applying responsive
  35442. // rules (#6912).
  35443. animation = series.finishedAnimating && { animation: false }, kinds = {};
  35444. if (keepPoints) {
  35445. preserve.push('data', 'isDirtyData', 'points', 'processedXData', 'processedYData', 'xIncrement', 'cropped', '_hasPointMarkers', '_hasPointLabels',
  35446. // Map specific, consider moving it to series-specific preserve-
  35447. // properties (#10617)
  35448. 'mapMap', 'mapData', 'minY', 'maxY', 'minX', 'maxX');
  35449. if (options.visible !== false) {
  35450. preserve.push('area', 'graph');
  35451. }
  35452. series.parallelArrays.forEach(function (key) {
  35453. preserve.push(key + 'Data');
  35454. });
  35455. if (options.data) {
  35456. // setData uses dataSorting options so we need to update them
  35457. // earlier
  35458. if (options.dataSorting) {
  35459. extend(series.options.dataSorting, options.dataSorting);
  35460. }
  35461. this.setData(options.data, false);
  35462. }
  35463. }
  35464. // Do the merge, with some forced options
  35465. options = merge(oldOptions, animation, {
  35466. // When oldOptions.index is null it should't be cleared.
  35467. // Otherwise navigator series will have wrong indexes (#10193).
  35468. index: typeof oldOptions.index === 'undefined' ?
  35469. series.index : oldOptions.index,
  35470. pointStart: pick(
  35471. // when updating from blank (#7933)
  35472. oldOptions.pointStart,
  35473. // when updating after addPoint
  35474. series.xData[0])
  35475. }, (!keepPoints && { data: series.options.data }), options);
  35476. // Merge does not merge arrays, but replaces them. Since points were
  35477. // updated, `series.options.data` has correct merged options, use it:
  35478. if (keepPoints && options.data) {
  35479. options.data = series.options.data;
  35480. }
  35481. // Make sure preserved properties are not destroyed (#3094)
  35482. preserve = groups.concat(preserve);
  35483. preserve.forEach(function (prop) {
  35484. preserve[prop] = series[prop];
  35485. delete series[prop];
  35486. });
  35487. // Destroy the series and delete all properties. Reinsert all
  35488. // methods and properties from the new type prototype (#2270,
  35489. // #3719).
  35490. series.remove(false, null, false, true);
  35491. for (n in initialSeriesProto) { // eslint-disable-line guard-for-in
  35492. series[n] = void 0;
  35493. }
  35494. if (seriesTypes[newType || initialType]) {
  35495. extend(series, seriesTypes[newType || initialType].prototype);
  35496. }
  35497. else {
  35498. error(17, true, chart, { missingModuleFor: (newType || initialType) });
  35499. }
  35500. // Re-register groups (#3094) and other preserved properties
  35501. preserve.forEach(function (prop) {
  35502. series[prop] = preserve[prop];
  35503. });
  35504. series.init(chart, options);
  35505. // Remove particular elements of the points. Check `series.options`
  35506. // because we need to consider the options being set on plotOptions as
  35507. // well.
  35508. if (keepPoints && this.points) {
  35509. seriesOptions = series.options;
  35510. // What kind of elements to destroy
  35511. if (seriesOptions.visible === false) {
  35512. kinds.graphic = 1;
  35513. kinds.dataLabel = 1;
  35514. }
  35515. else if (!series._hasPointLabels) {
  35516. var marker = seriesOptions.marker, dataLabels = seriesOptions.dataLabels;
  35517. if (marker && (marker.enabled === false ||
  35518. 'symbol' in marker // #10870
  35519. )) {
  35520. kinds.graphic = 1;
  35521. }
  35522. if (dataLabels &&
  35523. dataLabels.enabled === false) {
  35524. kinds.dataLabel = 1;
  35525. }
  35526. }
  35527. this.points.forEach(function (point) {
  35528. if (point && point.series) {
  35529. point.resolveColor();
  35530. // Destroy elements in order to recreate based on updated
  35531. // series options.
  35532. if (Object.keys(kinds).length) {
  35533. point.destroyElements(kinds);
  35534. }
  35535. if (seriesOptions.showInLegend === false &&
  35536. point.legendItem) {
  35537. chart.legend.destroyItem(point);
  35538. }
  35539. }
  35540. }, this);
  35541. }
  35542. series.initialType = initialType;
  35543. chart.linkSeries(); // Links are lost in series.remove (#3028)
  35544. fireEvent(this, 'afterUpdate');
  35545. if (pick(redraw, true)) {
  35546. chart.redraw(keepPoints ? void 0 : false);
  35547. }
  35548. },
  35549. /**
  35550. * Used from within series.update
  35551. *
  35552. * @private
  35553. * @function Highcharts.Series#setName
  35554. *
  35555. * @param {string} name
  35556. *
  35557. * @return {void}
  35558. */
  35559. setName: function (name) {
  35560. this.name = this.options.name = this.userOptions.name = name;
  35561. this.chart.isDirtyLegend = true;
  35562. }
  35563. });
  35564. // Extend the Axis.prototype for dynamic methods
  35565. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  35566. /**
  35567. * Update an axis object with a new set of options. The options are merged
  35568. * with the existing options, so only new or altered options need to be
  35569. * specified.
  35570. *
  35571. * @sample highcharts/members/axis-update/
  35572. * Axis update demo
  35573. *
  35574. * @function Highcharts.Axis#update
  35575. *
  35576. * @param {Highcharts.AxisOptions} options
  35577. * The new options that will be merged in with existing options on
  35578. * the axis.
  35579. *
  35580. * @param {boolean} [redraw=true]
  35581. * Whether to redraw the chart after the axis is altered. If doing
  35582. * more operations on the chart, it is a good idea to set redraw to
  35583. * false and call {@link Chart#redraw} after.
  35584. *
  35585. * @return {void}
  35586. */
  35587. update: function (options, redraw) {
  35588. var chart = this.chart, newEvents = ((options && options.events) || {});
  35589. options = merge(this.userOptions, options);
  35590. // Color Axis is not an array,
  35591. // This change is applied in the ColorAxis wrapper
  35592. if (chart.options[this.coll].indexOf) {
  35593. // Don't use this.options.index,
  35594. // StockChart has Axes in navigator too
  35595. chart.options[this.coll][chart.options[this.coll].indexOf(this.userOptions)] = options;
  35596. }
  35597. // Remove old events, if no new exist (#8161)
  35598. objectEach(chart.options[this.coll].events, function (fn, ev) {
  35599. if (typeof newEvents[ev] === 'undefined') {
  35600. newEvents[ev] = void 0;
  35601. }
  35602. });
  35603. this.destroy(true);
  35604. this.init(chart, extend(options, { events: newEvents }));
  35605. chart.isDirtyBox = true;
  35606. if (pick(redraw, true)) {
  35607. chart.redraw();
  35608. }
  35609. },
  35610. /**
  35611. * Remove the axis from the chart.
  35612. *
  35613. * @sample highcharts/members/chart-addaxis/
  35614. * Add and remove axes
  35615. *
  35616. * @function Highcharts.Axis#remove
  35617. *
  35618. * @param {boolean} [redraw=true]
  35619. * Whether to redraw the chart following the remove.
  35620. *
  35621. * @return {void}
  35622. */
  35623. remove: function (redraw) {
  35624. var chart = this.chart, key = this.coll, // xAxis or yAxis
  35625. axisSeries = this.series, i = axisSeries.length;
  35626. // Remove associated series (#2687)
  35627. while (i--) {
  35628. if (axisSeries[i]) {
  35629. axisSeries[i].remove(false);
  35630. }
  35631. }
  35632. // Remove the axis
  35633. erase(chart.axes, this);
  35634. erase(chart[key], this);
  35635. if (isArray(chart.options[key])) {
  35636. chart.options[key].splice(this.options.index, 1);
  35637. }
  35638. else { // color axis, #6488
  35639. delete chart.options[key];
  35640. }
  35641. chart[key].forEach(function (axis, i) {
  35642. // Re-index, #1706, #8075
  35643. axis.options.index = axis.userOptions.index = i;
  35644. });
  35645. this.destroy();
  35646. chart.isDirtyBox = true;
  35647. if (pick(redraw, true)) {
  35648. chart.redraw();
  35649. }
  35650. },
  35651. /**
  35652. * Update the axis title by options after render time.
  35653. *
  35654. * @sample highcharts/members/axis-settitle/
  35655. * Set a new Y axis title
  35656. *
  35657. * @function Highcharts.Axis#setTitle
  35658. *
  35659. * @param {Highcharts.AxisTitleOptions} titleOptions
  35660. * The additional title options.
  35661. *
  35662. * @param {boolean} [redraw=true]
  35663. * Whether to redraw the chart after setting the title.
  35664. *
  35665. * @return {void}
  35666. */
  35667. setTitle: function (titleOptions, redraw) {
  35668. this.update({ title: titleOptions }, redraw);
  35669. },
  35670. /**
  35671. * Set new axis categories and optionally redraw.
  35672. *
  35673. * @sample highcharts/members/axis-setcategories/
  35674. * Set categories by click on a button
  35675. *
  35676. * @function Highcharts.Axis#setCategories
  35677. *
  35678. * @param {Array<string>} categories
  35679. * The new categories.
  35680. *
  35681. * @param {boolean} [redraw=true]
  35682. * Whether to redraw the chart.
  35683. *
  35684. * @return {void}
  35685. */
  35686. setCategories: function (categories, redraw) {
  35687. this.update({ categories: categories }, redraw);
  35688. }
  35689. });
  35690. });
  35691. _registerModule(_modules, 'parts/AreaSeries.js', [_modules['parts/Globals.js'], _modules['parts/Color.js'], _modules['mixins/legend-symbol.js'], _modules['parts/Utilities.js']], function (H, Color, LegendSymbolMixin, U) {
  35692. /* *
  35693. *
  35694. * (c) 2010-2020 Torstein Honsi
  35695. *
  35696. * License: www.highcharts.com/license
  35697. *
  35698. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  35699. *
  35700. * */
  35701. var color = Color.parse;
  35702. var objectEach = U.objectEach, pick = U.pick, seriesType = U.seriesType;
  35703. var Series = H.Series;
  35704. /**
  35705. * Area series type.
  35706. *
  35707. * @private
  35708. * @class
  35709. * @name Highcharts.seriesTypes.area
  35710. *
  35711. * @augments Highcharts.Series
  35712. */
  35713. seriesType('area', 'line',
  35714. /**
  35715. * The area series type.
  35716. *
  35717. * @sample {highcharts} highcharts/demo/area-basic/
  35718. * Area chart
  35719. * @sample {highstock} stock/demo/area/
  35720. * Area chart
  35721. *
  35722. * @extends plotOptions.line
  35723. * @excluding useOhlcData
  35724. * @product highcharts highstock
  35725. * @optionparent plotOptions.area
  35726. */
  35727. {
  35728. /**
  35729. * Fill color or gradient for the area. When `null`, the series' `color`
  35730. * is used with the series' `fillOpacity`.
  35731. *
  35732. * In styled mode, the fill color can be set with the `.highcharts-area`
  35733. * class name.
  35734. *
  35735. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-default/
  35736. * Null by default
  35737. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-gradient/
  35738. * Gradient
  35739. *
  35740. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  35741. * @product highcharts highstock
  35742. * @apioption plotOptions.area.fillColor
  35743. */
  35744. /**
  35745. * Fill opacity for the area. When you set an explicit `fillColor`,
  35746. * the `fillOpacity` is not applied. Instead, you should define the
  35747. * opacity in the `fillColor` with an rgba color definition. The
  35748. * `fillOpacity` setting, also the default setting, overrides the alpha
  35749. * component of the `color` setting.
  35750. *
  35751. * In styled mode, the fill opacity can be set with the
  35752. * `.highcharts-area` class name.
  35753. *
  35754. * @sample {highcharts} highcharts/plotoptions/area-fillopacity/
  35755. * Automatic fill color and fill opacity of 0.1
  35756. *
  35757. * @type {number}
  35758. * @default {highcharts} 0.75
  35759. * @default {highstock} 0.75
  35760. * @product highcharts highstock
  35761. * @apioption plotOptions.area.fillOpacity
  35762. */
  35763. /**
  35764. * A separate color for the graph line. By default the line takes the
  35765. * `color` of the series, but the lineColor setting allows setting a
  35766. * separate color for the line without altering the `fillColor`.
  35767. *
  35768. * In styled mode, the line stroke can be set with the
  35769. * `.highcharts-graph` class name.
  35770. *
  35771. * @sample {highcharts} highcharts/plotoptions/area-linecolor/
  35772. * Dark gray line
  35773. *
  35774. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  35775. * @product highcharts highstock
  35776. * @apioption plotOptions.area.lineColor
  35777. */
  35778. /**
  35779. * A separate color for the negative part of the area.
  35780. *
  35781. * In styled mode, a negative color is set with the
  35782. * `.highcharts-negative` class name.
  35783. *
  35784. * @see [negativeColor](#plotOptions.area.negativeColor)
  35785. *
  35786. * @sample {highcharts} highcharts/css/series-negative-color/
  35787. * Negative color in styled mode
  35788. *
  35789. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  35790. * @since 3.0
  35791. * @product highcharts
  35792. * @apioption plotOptions.area.negativeFillColor
  35793. */
  35794. /**
  35795. * Whether the whole area or just the line should respond to mouseover
  35796. * tooltips and other mouse or touch events.
  35797. *
  35798. * @sample {highcharts|highstock} highcharts/plotoptions/area-trackbyarea/
  35799. * Display the tooltip when the area is hovered
  35800. *
  35801. * @type {boolean}
  35802. * @default false
  35803. * @since 1.1.6
  35804. * @product highcharts highstock
  35805. * @apioption plotOptions.area.trackByArea
  35806. */
  35807. /**
  35808. * When this is true, the series will not cause the Y axis to cross
  35809. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  35810. * unless the data actually crosses the plane.
  35811. *
  35812. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  35813. * 3 will make the Y axis show negative values according to the
  35814. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  35815. * at 0.
  35816. *
  35817. * @since 4.1.9
  35818. * @product highcharts highstock
  35819. */
  35820. softThreshold: false,
  35821. /**
  35822. * The Y axis value to serve as the base for the area, for
  35823. * distinguishing between values above and below a threshold. The area
  35824. * between the graph and the threshold is filled.
  35825. *
  35826. * * If a number is given, the Y axis will scale to the threshold.
  35827. * * If `null`, the scaling behaves like a line series with fill between
  35828. * the graph and the Y axis minimum.
  35829. * * If `Infinity` or `-Infinity`, the area between the graph and the
  35830. * corresponding Y axis extreme is filled (since v6.1.0).
  35831. *
  35832. * @sample {highcharts} highcharts/plotoptions/area-threshold/
  35833. * A threshold of 100
  35834. * @sample {highcharts} highcharts/plotoptions/area-threshold-infinity/
  35835. * A threshold of Infinity
  35836. *
  35837. * @type {number|null}
  35838. * @since 2.0
  35839. * @product highcharts highstock
  35840. */
  35841. threshold: 0
  35842. },
  35843. /* eslint-disable valid-jsdoc */
  35844. /**
  35845. * @lends seriesTypes.area.prototype
  35846. */
  35847. {
  35848. singleStacks: false,
  35849. /**
  35850. * Return an array of stacked points, where null and missing points are
  35851. * replaced by dummy points in order for gaps to be drawn correctly in
  35852. * stacks.
  35853. * @private
  35854. */
  35855. getStackPoints: function (points) {
  35856. var series = this, segment = [], keys = [], xAxis = this.xAxis, yAxis = this.yAxis, stack = yAxis.stacking.stacks[this.stackKey], pointMap = {}, seriesIndex = series.index, yAxisSeries = yAxis.series, seriesLength = yAxisSeries.length, visibleSeries, upOrDown = pick(yAxis.options.reversedStacks, true) ? 1 : -1, i;
  35857. points = points || this.points;
  35858. if (this.options.stacking) {
  35859. for (i = 0; i < points.length; i++) {
  35860. // Reset after point update (#7326)
  35861. points[i].leftNull = points[i].rightNull = void 0;
  35862. // Create a map where we can quickly look up the points by
  35863. // their X values.
  35864. pointMap[points[i].x] = points[i];
  35865. }
  35866. // Sort the keys (#1651)
  35867. objectEach(stack, function (stackX, x) {
  35868. // nulled after switching between
  35869. // grouping and not (#1651, #2336)
  35870. if (stackX.total !== null) {
  35871. keys.push(x);
  35872. }
  35873. });
  35874. keys.sort(function (a, b) {
  35875. return a - b;
  35876. });
  35877. visibleSeries = yAxisSeries.map(function (s) {
  35878. return s.visible;
  35879. });
  35880. keys.forEach(function (x, idx) {
  35881. var y = 0, stackPoint, stackedValues;
  35882. if (pointMap[x] && !pointMap[x].isNull) {
  35883. segment.push(pointMap[x]);
  35884. // Find left and right cliff. -1 goes left, 1 goes
  35885. // right.
  35886. [-1, 1].forEach(function (direction) {
  35887. var nullName = direction === 1 ?
  35888. 'rightNull' :
  35889. 'leftNull', cliffName = direction === 1 ?
  35890. 'rightCliff' :
  35891. 'leftCliff', cliff = 0, otherStack = stack[keys[idx + direction]];
  35892. // If there is a stack next to this one,
  35893. // to the left or to the right...
  35894. if (otherStack) {
  35895. i = seriesIndex;
  35896. // Can go either up or down,
  35897. // depending on reversedStacks
  35898. while (i >= 0 && i < seriesLength) {
  35899. stackPoint = otherStack.points[i];
  35900. if (!stackPoint) {
  35901. // If the next point in this series
  35902. // is missing, mark the point
  35903. // with point.leftNull or
  35904. // point.rightNull = true.
  35905. if (i === seriesIndex) {
  35906. pointMap[x][nullName] =
  35907. true;
  35908. // If there are missing points in
  35909. // the next stack in any of the
  35910. // series below this one, we need
  35911. // to substract the missing values
  35912. // and add a hiatus to the left or
  35913. // right.
  35914. }
  35915. else if (visibleSeries[i]) {
  35916. stackedValues =
  35917. stack[x].points[i];
  35918. if (stackedValues) {
  35919. cliff -=
  35920. stackedValues[1] -
  35921. stackedValues[0];
  35922. }
  35923. }
  35924. }
  35925. // When reversedStacks is true, loop up,
  35926. // else loop down
  35927. i += upOrDown;
  35928. }
  35929. }
  35930. pointMap[x][cliffName] = cliff;
  35931. });
  35932. // There is no point for this X value in this series, so we
  35933. // insert a dummy point in order for the areas to be drawn
  35934. // correctly.
  35935. }
  35936. else {
  35937. // Loop down the stack to find the series below this
  35938. // one that has a value (#1991)
  35939. i = seriesIndex;
  35940. while (i >= 0 && i < seriesLength) {
  35941. stackPoint = stack[x].points[i];
  35942. if (stackPoint) {
  35943. y = stackPoint[1];
  35944. break;
  35945. }
  35946. // When reversedStacks is true, loop up, else loop
  35947. // down
  35948. i += upOrDown;
  35949. }
  35950. y = yAxis.translate(// #6272
  35951. y, 0, 1, 0, 1);
  35952. segment.push({
  35953. isNull: true,
  35954. plotX: xAxis.translate(// #6272
  35955. x, 0, 0, 0, 1),
  35956. x: x,
  35957. plotY: y,
  35958. yBottom: y
  35959. });
  35960. }
  35961. });
  35962. }
  35963. return segment;
  35964. },
  35965. /**
  35966. * @private
  35967. */
  35968. getGraphPath: function (points) {
  35969. 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
  35970. yAxis.getThreshold(options.threshold)), isNull, yBottom, connectNulls = pick(// #10574
  35971. options.connectNulls, stacking === 'percent'),
  35972. // To display null points in underlying stacked series, this
  35973. // series graph must be broken, and the area also fall down to
  35974. // fill the gap left by the null point. #2069
  35975. addDummyPoints = function (i, otherI, side) {
  35976. var point = points[i], stackedValues = stacking &&
  35977. stacks[point.x].points[seriesIndex], nullVal = point[side + 'Null'] || 0, cliffVal = point[side + 'Cliff'] || 0, top, bottom, isNull = true;
  35978. if (cliffVal || nullVal) {
  35979. top = (nullVal ?
  35980. stackedValues[0] :
  35981. stackedValues[1]) + cliffVal;
  35982. bottom = stackedValues[0] + cliffVal;
  35983. isNull = !!nullVal;
  35984. }
  35985. else if (!stacking &&
  35986. points[otherI] &&
  35987. points[otherI].isNull) {
  35988. top = bottom = threshold;
  35989. }
  35990. // Add to the top and bottom line of the area
  35991. if (typeof top !== 'undefined') {
  35992. graphPoints.push({
  35993. plotX: plotX,
  35994. plotY: top === null ?
  35995. translatedThreshold :
  35996. yAxis.getThreshold(top),
  35997. isNull: isNull,
  35998. isCliff: true
  35999. });
  36000. bottomPoints.push({
  36001. plotX: plotX,
  36002. plotY: bottom === null ?
  36003. translatedThreshold :
  36004. yAxis.getThreshold(bottom),
  36005. doCurve: false // #1041, gaps in areaspline areas
  36006. });
  36007. }
  36008. };
  36009. // Find what points to use
  36010. points = points || this.points;
  36011. // Fill in missing points
  36012. if (stacking) {
  36013. points = this.getStackPoints(points);
  36014. }
  36015. for (i = 0; i < points.length; i++) {
  36016. // Reset after series.update of stacking property (#12033)
  36017. if (!stacking) {
  36018. points[i].leftCliff = points[i].rightCliff =
  36019. points[i].leftNull = points[i].rightNull = void 0;
  36020. }
  36021. isNull = points[i].isNull;
  36022. plotX = pick(points[i].rectPlotX, points[i].plotX);
  36023. yBottom = pick(points[i].yBottom, translatedThreshold);
  36024. if (!isNull || connectNulls) {
  36025. if (!connectNulls) {
  36026. addDummyPoints(i, i - 1, 'left');
  36027. }
  36028. // Skip null point when stacking is false and connectNulls
  36029. // true
  36030. if (!(isNull && !stacking && connectNulls)) {
  36031. graphPoints.push(points[i]);
  36032. bottomPoints.push({
  36033. x: i,
  36034. plotX: plotX,
  36035. plotY: yBottom
  36036. });
  36037. }
  36038. if (!connectNulls) {
  36039. addDummyPoints(i, i + 1, 'right');
  36040. }
  36041. }
  36042. }
  36043. topPath = getGraphPath.call(this, graphPoints, true, true);
  36044. bottomPoints.reversed = true;
  36045. bottomPath = getGraphPath.call(this, bottomPoints, true, true);
  36046. var firstBottomPoint = bottomPath[0];
  36047. if (firstBottomPoint && firstBottomPoint[0] === 'M') {
  36048. bottomPath[0] = ['L', firstBottomPoint[1], firstBottomPoint[2]];
  36049. }
  36050. areaPath = topPath.concat(bottomPath);
  36051. // TODO: don't set leftCliff and rightCliff when connectNulls?
  36052. graphPath = getGraphPath
  36053. .call(this, graphPoints, false, connectNulls);
  36054. areaPath.xMap = topPath.xMap;
  36055. this.areaPath = areaPath;
  36056. return graphPath;
  36057. },
  36058. /**
  36059. * Draw the graph and the underlying area. This method calls the Series
  36060. * base function and adds the area. The areaPath is calculated in the
  36061. * getSegmentPath method called from Series.prototype.drawGraph.
  36062. * @private
  36063. */
  36064. drawGraph: function () {
  36065. // Define or reset areaPath
  36066. this.areaPath = [];
  36067. // Call the base method
  36068. Series.prototype.drawGraph.apply(this);
  36069. // Define local variables
  36070. var series = this, areaPath = this.areaPath, options = this.options, zones = this.zones, props = [[
  36071. 'area',
  36072. 'highcharts-area',
  36073. this.color,
  36074. options.fillColor
  36075. ]]; // area name, main color, fill color
  36076. zones.forEach(function (zone, i) {
  36077. props.push([
  36078. 'zone-area-' + i,
  36079. 'highcharts-area highcharts-zone-area-' + i + ' ' +
  36080. zone.className,
  36081. zone.color || series.color,
  36082. zone.fillColor || options.fillColor
  36083. ]);
  36084. });
  36085. props.forEach(function (prop) {
  36086. var areaKey = prop[0], area = series[areaKey], verb = area ? 'animate' : 'attr', attribs = {};
  36087. // Create or update the area
  36088. if (area) { // update
  36089. area.endX = series.preventGraphAnimation ?
  36090. null :
  36091. areaPath.xMap;
  36092. area.animate({ d: areaPath });
  36093. }
  36094. else { // create
  36095. attribs.zIndex = 0; // #1069
  36096. area = series[areaKey] = series.chart.renderer
  36097. .path(areaPath)
  36098. .addClass(prop[1])
  36099. .add(series.group);
  36100. area.isArea = true;
  36101. }
  36102. if (!series.chart.styledMode) {
  36103. attribs.fill = pick(prop[3], color(prop[2])
  36104. .setOpacity(pick(options.fillOpacity, 0.75))
  36105. .get());
  36106. }
  36107. area[verb](attribs);
  36108. area.startX = areaPath.xMap;
  36109. area.shiftUnit = options.step ? 2 : 1;
  36110. });
  36111. },
  36112. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  36113. });
  36114. /* eslint-enable valid-jsdoc */
  36115. /**
  36116. * A `area` series. If the [type](#series.area.type) option is not
  36117. * specified, it is inherited from [chart.type](#chart.type).
  36118. *
  36119. * @extends series,plotOptions.area
  36120. * @excluding dataParser, dataURL, useOhlcData
  36121. * @product highcharts highstock
  36122. * @apioption series.area
  36123. */
  36124. /**
  36125. * An array of data points for the series. For the `area` series type,
  36126. * points can be given in the following ways:
  36127. *
  36128. * 1. An array of numerical values. In this case, the numerical values will be
  36129. * interpreted as `y` options. The `x` values will be automatically
  36130. * calculated, either starting at 0 and incremented by 1, or from
  36131. * `pointStart` * and `pointInterval` given in the series options. If the
  36132. * axis has categories, these will be used. Example:
  36133. * ```js
  36134. * data: [0, 5, 3, 5]
  36135. * ```
  36136. *
  36137. * 2. An array of arrays with 2 values. In this case, the values correspond to
  36138. * `x,y`. If the first value is a string, it is applied as the name of the
  36139. * point, and the `x` value is inferred.
  36140. * ```js
  36141. * data: [
  36142. * [0, 9],
  36143. * [1, 7],
  36144. * [2, 6]
  36145. * ]
  36146. * ```
  36147. *
  36148. * 3. An array of objects with named values. The following snippet shows only a
  36149. * few settings, see the complete options set below. If the total number of
  36150. * data points exceeds the series'
  36151. * [turboThreshold](#series.area.turboThreshold), this option is not
  36152. * available.
  36153. * ```js
  36154. * data: [{
  36155. * x: 1,
  36156. * y: 9,
  36157. * name: "Point2",
  36158. * color: "#00FF00"
  36159. * }, {
  36160. * x: 1,
  36161. * y: 6,
  36162. * name: "Point1",
  36163. * color: "#FF00FF"
  36164. * }]
  36165. * ```
  36166. *
  36167. * @sample {highcharts} highcharts/chart/reflow-true/
  36168. * Numerical values
  36169. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  36170. * Arrays of numeric x and y
  36171. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  36172. * Arrays of datetime x and y
  36173. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  36174. * Arrays of point.name and y
  36175. * @sample {highcharts} highcharts/series/data-array-of-objects/
  36176. * Config objects
  36177. *
  36178. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  36179. * @extends series.line.data
  36180. * @product highcharts highstock
  36181. * @apioption series.area.data
  36182. */
  36183. ''; // adds doclets above to transpilat
  36184. });
  36185. _registerModule(_modules, 'parts/SplineSeries.js', [_modules['parts/Utilities.js']], function (U) {
  36186. /* *
  36187. *
  36188. * (c) 2010-2020 Torstein Honsi
  36189. *
  36190. * License: www.highcharts.com/license
  36191. *
  36192. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  36193. *
  36194. * */
  36195. var pick = U.pick, seriesType = U.seriesType;
  36196. /**
  36197. * Spline series type.
  36198. *
  36199. * @private
  36200. * @class
  36201. * @name Highcharts.seriesTypes.spline
  36202. *
  36203. * @augments Highcarts.Series
  36204. */
  36205. seriesType('spline', 'line',
  36206. /**
  36207. * A spline series is a special type of line series, where the segments
  36208. * between the data points are smoothed.
  36209. *
  36210. * @sample {highcharts} highcharts/demo/spline-irregular-time/
  36211. * Spline chart
  36212. * @sample {highstock} stock/demo/spline/
  36213. * Spline chart
  36214. *
  36215. * @extends plotOptions.series
  36216. * @excluding step
  36217. * @product highcharts highstock
  36218. * @optionparent plotOptions.spline
  36219. */
  36220. {},
  36221. /**
  36222. * @lends seriesTypes.spline.prototype
  36223. */
  36224. {
  36225. /* eslint-disable valid-jsdoc */
  36226. /**
  36227. * Get the spline segment from a given point's previous neighbour to the
  36228. * given point.
  36229. *
  36230. * @private
  36231. * @function Highcharts.seriesTypes.spline#getPointSpline
  36232. *
  36233. * @param {Array<Highcharts.Point>}
  36234. *
  36235. * @param {Highcharts.Point} point
  36236. *
  36237. * @param {number} i
  36238. *
  36239. * @return {Highcharts.SVGPathArray}
  36240. */
  36241. getPointSpline: function (points, point, i) {
  36242. var
  36243. // 1 means control points midway between points, 2 means 1/3
  36244. // from the point, 3 is 1/4 etc
  36245. smoothing = 1.5, denom = smoothing + 1, plotX = point.plotX || 0, plotY = point.plotY || 0, lastPoint = points[i - 1], nextPoint = points[i + 1], leftContX, leftContY, rightContX, rightContY, ret;
  36246. /**
  36247. * @private
  36248. */
  36249. function doCurve(otherPoint) {
  36250. return otherPoint &&
  36251. !otherPoint.isNull &&
  36252. otherPoint.doCurve !== false &&
  36253. // #6387, area splines next to null:
  36254. !point.isCliff;
  36255. }
  36256. // Find control points
  36257. if (doCurve(lastPoint) && doCurve(nextPoint)) {
  36258. var lastX = lastPoint.plotX || 0, lastY = lastPoint.plotY || 0, nextX = nextPoint.plotX || 0, nextY = nextPoint.plotY || 0, correction = 0;
  36259. leftContX = (smoothing * plotX + lastX) / denom;
  36260. leftContY = (smoothing * plotY + lastY) / denom;
  36261. rightContX = (smoothing * plotX + nextX) / denom;
  36262. rightContY = (smoothing * plotY + nextY) / denom;
  36263. // Have the two control points make a straight line through main
  36264. // point
  36265. if (rightContX !== leftContX) { // #5016, division by zero
  36266. correction = (((rightContY - leftContY) *
  36267. (rightContX - plotX)) /
  36268. (rightContX - leftContX) + plotY - rightContY);
  36269. }
  36270. leftContY += correction;
  36271. rightContY += correction;
  36272. // to prevent false extremes, check that control points are
  36273. // between neighbouring points' y values
  36274. if (leftContY > lastY && leftContY > plotY) {
  36275. leftContY = Math.max(lastY, plotY);
  36276. // mirror of left control point
  36277. rightContY = 2 * plotY - leftContY;
  36278. }
  36279. else if (leftContY < lastY && leftContY < plotY) {
  36280. leftContY = Math.min(lastY, plotY);
  36281. rightContY = 2 * plotY - leftContY;
  36282. }
  36283. if (rightContY > nextY && rightContY > plotY) {
  36284. rightContY = Math.max(nextY, plotY);
  36285. leftContY = 2 * plotY - rightContY;
  36286. }
  36287. else if (rightContY < nextY && rightContY < plotY) {
  36288. rightContY = Math.min(nextY, plotY);
  36289. leftContY = 2 * plotY - rightContY;
  36290. }
  36291. // record for drawing in next point
  36292. point.rightContX = rightContX;
  36293. point.rightContY = rightContY;
  36294. }
  36295. // Visualize control points for debugging
  36296. /*
  36297. if (leftContX) {
  36298. this.chart.renderer.circle(
  36299. leftContX + this.chart.plotLeft,
  36300. leftContY + this.chart.plotTop,
  36301. 2
  36302. )
  36303. .attr({
  36304. stroke: 'red',
  36305. 'stroke-width': 2,
  36306. fill: 'none',
  36307. zIndex: 9
  36308. })
  36309. .add();
  36310. this.chart.renderer.path(['M', leftContX + this.chart.plotLeft,
  36311. leftContY + this.chart.plotTop,
  36312. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  36313. .attr({
  36314. stroke: 'red',
  36315. 'stroke-width': 2,
  36316. zIndex: 9
  36317. })
  36318. .add();
  36319. }
  36320. if (rightContX) {
  36321. this.chart.renderer.circle(
  36322. rightContX + this.chart.plotLeft,
  36323. rightContY + this.chart.plotTop,
  36324. 2
  36325. )
  36326. .attr({
  36327. stroke: 'green',
  36328. 'stroke-width': 2,
  36329. fill: 'none',
  36330. zIndex: 9
  36331. })
  36332. .add();
  36333. this.chart.renderer.path(['M', rightContX + this.chart.plotLeft,
  36334. rightContY + this.chart.plotTop,
  36335. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  36336. .attr({
  36337. stroke: 'green',
  36338. 'stroke-width': 2,
  36339. zIndex: 9
  36340. })
  36341. .add();
  36342. }
  36343. // */
  36344. ret = [
  36345. 'C',
  36346. pick(lastPoint.rightContX, lastPoint.plotX, 0),
  36347. pick(lastPoint.rightContY, lastPoint.plotY, 0),
  36348. pick(leftContX, plotX, 0),
  36349. pick(leftContY, plotY, 0),
  36350. plotX,
  36351. plotY
  36352. ];
  36353. // reset for updating series later
  36354. lastPoint.rightContX = lastPoint.rightContY = void 0;
  36355. return ret;
  36356. }
  36357. /* eslint-enable valid-jsdoc */
  36358. });
  36359. /**
  36360. * A `spline` series. If the [type](#series.spline.type) option is
  36361. * not specified, it is inherited from [chart.type](#chart.type).
  36362. *
  36363. * @extends series,plotOptions.spline
  36364. * @excluding dataParser, dataURL, step
  36365. * @product highcharts highstock
  36366. * @apioption series.spline
  36367. */
  36368. /**
  36369. * An array of data points for the series. For the `spline` series type,
  36370. * points can be given in the following ways:
  36371. *
  36372. * 1. An array of numerical values. In this case, the numerical values will be
  36373. * interpreted as `y` options. The `x` values will be automatically
  36374. * calculated, either starting at 0 and incremented by 1, or from
  36375. * `pointStart` and `pointInterval` given in the series options. If the axis
  36376. * has categories, these will be used. Example:
  36377. * ```js
  36378. * data: [0, 5, 3, 5]
  36379. * ```
  36380. *
  36381. * 2. An array of arrays with 2 values. In this case, the values correspond to
  36382. * `x,y`. If the first value is a string, it is applied as the name of the
  36383. * point, and the `x` value is inferred.
  36384. * ```js
  36385. * data: [
  36386. * [0, 9],
  36387. * [1, 2],
  36388. * [2, 8]
  36389. * ]
  36390. * ```
  36391. *
  36392. * 3. An array of objects with named values. The following snippet shows only a
  36393. * few settings, see the complete options set below. If the total number of
  36394. * data points exceeds the series'
  36395. * [turboThreshold](#series.spline.turboThreshold),
  36396. * this option is not available.
  36397. * ```js
  36398. * data: [{
  36399. * x: 1,
  36400. * y: 9,
  36401. * name: "Point2",
  36402. * color: "#00FF00"
  36403. * }, {
  36404. * x: 1,
  36405. * y: 0,
  36406. * name: "Point1",
  36407. * color: "#FF00FF"
  36408. * }]
  36409. * ```
  36410. *
  36411. * @sample {highcharts} highcharts/chart/reflow-true/
  36412. * Numerical values
  36413. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  36414. * Arrays of numeric x and y
  36415. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  36416. * Arrays of datetime x and y
  36417. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  36418. * Arrays of point.name and y
  36419. * @sample {highcharts} highcharts/series/data-array-of-objects/
  36420. * Config objects
  36421. *
  36422. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  36423. * @extends series.line.data
  36424. * @product highcharts highstock
  36425. * @apioption series.spline.data
  36426. */
  36427. ''; // adds doclets above intro transpilat
  36428. });
  36429. _registerModule(_modules, 'parts/AreaSplineSeries.js', [_modules['parts/Globals.js'], _modules['mixins/legend-symbol.js'], _modules['parts/Options.js'], _modules['parts/Utilities.js']], function (H, LegendSymbolMixin, O, U) {
  36430. /* *
  36431. *
  36432. * (c) 2010-2020 Torstein Honsi
  36433. *
  36434. * License: www.highcharts.com/license
  36435. *
  36436. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  36437. *
  36438. * */
  36439. var defaultOptions = O.defaultOptions;
  36440. var seriesType = U.seriesType;
  36441. var areaProto = H.seriesTypes.area.prototype;
  36442. /**
  36443. * AreaSpline series type.
  36444. *
  36445. * @private
  36446. * @class
  36447. * @name Highcharts.seriesTypes.areaspline
  36448. *
  36449. * @augments Highcharts.Series
  36450. */
  36451. seriesType('areaspline', 'spline',
  36452. /**
  36453. * The area spline series is an area series where the graph between the
  36454. * points is smoothed into a spline.
  36455. *
  36456. * @sample {highcharts} highcharts/demo/areaspline/
  36457. * Area spline chart
  36458. * @sample {highstock} stock/demo/areaspline/
  36459. * Area spline chart
  36460. *
  36461. * @extends plotOptions.area
  36462. * @excluding step
  36463. * @product highcharts highstock
  36464. * @apioption plotOptions.areaspline
  36465. */
  36466. defaultOptions.plotOptions.area, {
  36467. getStackPoints: areaProto.getStackPoints,
  36468. getGraphPath: areaProto.getGraphPath,
  36469. drawGraph: areaProto.drawGraph,
  36470. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  36471. });
  36472. /**
  36473. * A `areaspline` series. If the [type](#series.areaspline.type) option
  36474. * is not specified, it is inherited from [chart.type](#chart.type).
  36475. *
  36476. *
  36477. * @extends series,plotOptions.areaspline
  36478. * @excluding dataParser, dataURL, step
  36479. * @product highcharts highstock
  36480. * @apioption series.areaspline
  36481. */
  36482. /**
  36483. * An array of data points for the series. For the `areaspline` series
  36484. * type, points can be given in the following ways:
  36485. *
  36486. * 1. An array of numerical values. In this case, the numerical values will be
  36487. * interpreted as `y` options. The `x` values will be automatically
  36488. * calculated, either starting at 0 and incremented by 1, or from
  36489. * `pointStart` and `pointInterval` given in the series options. If the axis
  36490. * has categories, these will be used. Example:
  36491. * ```js
  36492. * data: [0, 5, 3, 5]
  36493. * ```
  36494. *
  36495. * 2. An array of arrays with 2 values. In this case, the values correspond to
  36496. * `x,y`. If the first value is a string, it is applied as the name of the
  36497. * point, and the `x` value is inferred.
  36498. * ```js
  36499. * data: [
  36500. * [0, 10],
  36501. * [1, 9],
  36502. * [2, 3]
  36503. * ]
  36504. * ```
  36505. *
  36506. * 3. An array of objects with named values. The following snippet shows only a
  36507. * few settings, see the complete options set below. If the total number of
  36508. * data points exceeds the series'
  36509. * [turboThreshold](#series.areaspline.turboThreshold), this option is not
  36510. * available.
  36511. * ```js
  36512. * data: [{
  36513. * x: 1,
  36514. * y: 4,
  36515. * name: "Point2",
  36516. * color: "#00FF00"
  36517. * }, {
  36518. * x: 1,
  36519. * y: 4,
  36520. * name: "Point1",
  36521. * color: "#FF00FF"
  36522. * }]
  36523. * ```
  36524. *
  36525. * @sample {highcharts} highcharts/chart/reflow-true/
  36526. * Numerical values
  36527. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  36528. * Arrays of numeric x and y
  36529. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  36530. * Arrays of datetime x and y
  36531. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  36532. * Arrays of point.name and y
  36533. * @sample {highcharts} highcharts/series/data-array-of-objects/
  36534. * Config objects
  36535. *
  36536. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  36537. * @extends series.line.data
  36538. * @product highcharts highstock
  36539. * @apioption series.areaspline.data
  36540. */
  36541. ''; // adds doclets above into transpilat
  36542. });
  36543. _registerModule(_modules, 'parts/ColumnSeries.js', [_modules['parts/Globals.js'], _modules['parts/Color.js'], _modules['mixins/legend-symbol.js'], _modules['parts/Utilities.js']], function (H, Color, LegendSymbolMixin, U) {
  36544. /* *
  36545. *
  36546. * (c) 2010-2020 Torstein Honsi
  36547. *
  36548. * License: www.highcharts.com/license
  36549. *
  36550. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  36551. *
  36552. * */
  36553. /**
  36554. * Adjusted width and x offset of the columns for grouping.
  36555. *
  36556. * @private
  36557. * @interface Highcharts.ColumnMetricsObject
  36558. */ /**
  36559. * Width of the columns.
  36560. * @name Highcharts.ColumnMetricsObject#width
  36561. * @type {number}
  36562. */ /**
  36563. * Offset of the columns.
  36564. * @name Highcharts.ColumnMetricsObject#offset
  36565. * @type {number}
  36566. */
  36567. ''; // detach doclets above
  36568. var color = Color.parse;
  36569. var animObject = U.animObject, clamp = U.clamp, defined = U.defined, extend = U.extend, isNumber = U.isNumber, merge = U.merge, pick = U.pick, seriesType = U.seriesType;
  36570. var noop = H.noop, Series = H.Series, svg = H.svg;
  36571. /**
  36572. * The column series type.
  36573. *
  36574. * @private
  36575. * @class
  36576. * @name Highcharts.seriesTypes.column
  36577. *
  36578. * @augments Highcharts.Series
  36579. */
  36580. seriesType('column', 'line',
  36581. /**
  36582. * Column series display one column per value along an X axis.
  36583. *
  36584. * @sample {highcharts} highcharts/demo/column-basic/
  36585. * Column chart
  36586. * @sample {highstock} stock/demo/column/
  36587. * Column chart
  36588. *
  36589. * @extends plotOptions.line
  36590. * @excluding connectEnds, connectNulls, gapSize, gapUnit, linecap,
  36591. * lineWidth, marker, step, useOhlcData
  36592. * @product highcharts highstock
  36593. * @optionparent plotOptions.column
  36594. */
  36595. {
  36596. /**
  36597. * The corner radius of the border surrounding each column or bar.
  36598. *
  36599. * @sample {highcharts} highcharts/plotoptions/column-borderradius/
  36600. * Rounded columns
  36601. *
  36602. * @product highcharts highstock gantt
  36603. *
  36604. * @private
  36605. */
  36606. borderRadius: 0,
  36607. /**
  36608. * When using automatic point colors pulled from the global
  36609. * [colors](colors) or series-specific
  36610. * [plotOptions.column.colors](series.colors) collections, this option
  36611. * determines whether the chart should receive one color per series or
  36612. * one color per point.
  36613. *
  36614. * In styled mode, the `colors` or `series.colors` arrays are not
  36615. * supported, and instead this option gives the points individual color
  36616. * class names on the form `highcharts-color-{n}`.
  36617. *
  36618. * @see [series colors](#plotOptions.column.colors)
  36619. *
  36620. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-false/
  36621. * False by default
  36622. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-true/
  36623. * True
  36624. *
  36625. * @type {boolean}
  36626. * @default false
  36627. * @since 2.0
  36628. * @product highcharts highstock gantt
  36629. * @apioption plotOptions.column.colorByPoint
  36630. */
  36631. /**
  36632. * A series specific or series type specific color set to apply instead
  36633. * of the global [colors](#colors) when [colorByPoint](
  36634. * #plotOptions.column.colorByPoint) is true.
  36635. *
  36636. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  36637. * @since 3.0
  36638. * @product highcharts highstock gantt
  36639. * @apioption plotOptions.column.colors
  36640. */
  36641. /**
  36642. * When `true`, the columns will center in the category, ignoring null
  36643. * or missing points. When `false`, space will be reserved for null or
  36644. * missing points.
  36645. *
  36646. * @sample {highcharts} highcharts/series-column/centerincategory/
  36647. * Center in category
  36648. *
  36649. * @since 8.0.1
  36650. * @product highcharts highstock gantt
  36651. */
  36652. centerInCategory: false,
  36653. /**
  36654. * Padding between each value groups, in x axis units.
  36655. *
  36656. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-default/
  36657. * 0.2 by default
  36658. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-none/
  36659. * No group padding - all columns are evenly spaced
  36660. *
  36661. * @product highcharts highstock gantt
  36662. *
  36663. * @private
  36664. */
  36665. groupPadding: 0.2,
  36666. /**
  36667. * Whether to group non-stacked columns or to let them render
  36668. * independent of each other. Non-grouped columns will be laid out
  36669. * individually and overlap each other.
  36670. *
  36671. * @sample {highcharts} highcharts/plotoptions/column-grouping-false/
  36672. * Grouping disabled
  36673. * @sample {highstock} highcharts/plotoptions/column-grouping-false/
  36674. * Grouping disabled
  36675. *
  36676. * @type {boolean}
  36677. * @default true
  36678. * @since 2.3.0
  36679. * @product highcharts highstock gantt
  36680. * @apioption plotOptions.column.grouping
  36681. */
  36682. /**
  36683. * @ignore-option
  36684. * @private
  36685. */
  36686. marker: null,
  36687. /**
  36688. * The maximum allowed pixel width for a column, translated to the
  36689. * height of a bar in a bar chart. This prevents the columns from
  36690. * becoming too wide when there is a small number of points in the
  36691. * chart.
  36692. *
  36693. * @see [pointWidth](#plotOptions.column.pointWidth)
  36694. *
  36695. * @sample {highcharts} highcharts/plotoptions/column-maxpointwidth-20/
  36696. * Limited to 50
  36697. * @sample {highstock} highcharts/plotoptions/column-maxpointwidth-20/
  36698. * Limited to 50
  36699. *
  36700. * @type {number}
  36701. * @since 4.1.8
  36702. * @product highcharts highstock gantt
  36703. * @apioption plotOptions.column.maxPointWidth
  36704. */
  36705. /**
  36706. * Padding between each column or bar, in x axis units.
  36707. *
  36708. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-default/
  36709. * 0.1 by default
  36710. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-025/
  36711. * 0.25
  36712. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-none/
  36713. * 0 for tightly packed columns
  36714. *
  36715. * @product highcharts highstock gantt
  36716. *
  36717. * @private
  36718. */
  36719. pointPadding: 0.1,
  36720. /**
  36721. * A pixel value specifying a fixed width for each column or bar. When
  36722. * `null`, the width is calculated from the `pointPadding` and
  36723. * `groupPadding`.
  36724. *
  36725. * @see [maxPointWidth](#plotOptions.column.maxPointWidth)
  36726. *
  36727. * @sample {highcharts} highcharts/plotoptions/column-pointwidth-20/
  36728. * 20px wide columns regardless of chart width or the amount of
  36729. * data points
  36730. *
  36731. * @type {number}
  36732. * @since 1.2.5
  36733. * @product highcharts highstock gantt
  36734. * @apioption plotOptions.column.pointWidth
  36735. */
  36736. /**
  36737. * A pixel value specifying a fixed width for the column or bar.
  36738. * Overrides pointWidth on the series.
  36739. *
  36740. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  36741. *
  36742. * @type {number}
  36743. * @default undefined
  36744. * @since 7.0.0
  36745. * @product highcharts highstock gantt
  36746. * @apioption series.column.data.pointWidth
  36747. */
  36748. /**
  36749. * The minimal height for a column or width for a bar. By default,
  36750. * 0 values are not shown. To visualize a 0 (or close to zero) point,
  36751. * set the minimal point length to a pixel value like 3\. In stacked
  36752. * column charts, minPointLength might not be respected for tightly
  36753. * packed values.
  36754. *
  36755. * @sample {highcharts} highcharts/plotoptions/column-minpointlength/
  36756. * Zero base value
  36757. * @sample {highcharts} highcharts/plotoptions/column-minpointlength-pos-and-neg/
  36758. * Positive and negative close to zero values
  36759. *
  36760. * @product highcharts highstock gantt
  36761. *
  36762. * @private
  36763. */
  36764. minPointLength: 0,
  36765. /**
  36766. * When the series contains less points than the crop threshold, all
  36767. * points are drawn, event if the points fall outside the visible plot
  36768. * area at the current zoom. The advantage of drawing all points
  36769. * (including markers and columns), is that animation is performed on
  36770. * updates. On the other hand, when the series contains more points than
  36771. * the crop threshold, the series data is cropped to only contain points
  36772. * that fall within the plot area. The advantage of cropping away
  36773. * invisible points is to increase performance on large series.
  36774. *
  36775. * @product highcharts highstock gantt
  36776. *
  36777. * @private
  36778. */
  36779. cropThreshold: 50,
  36780. /**
  36781. * The X axis range that each point is valid for. This determines the
  36782. * width of the column. On a categorized axis, the range will be 1
  36783. * by default (one category unit). On linear and datetime axes, the
  36784. * range will be computed as the distance between the two closest data
  36785. * points.
  36786. *
  36787. * The default `null` means it is computed automatically, but this
  36788. * option can be used to override the automatic value.
  36789. *
  36790. * This option is set by default to 1 if data sorting is enabled.
  36791. *
  36792. * @sample {highcharts} highcharts/plotoptions/column-pointrange/
  36793. * Set the point range to one day on a data set with one week
  36794. * between the points
  36795. *
  36796. * @type {number|null}
  36797. * @since 2.3
  36798. * @product highcharts highstock gantt
  36799. *
  36800. * @private
  36801. */
  36802. pointRange: null,
  36803. states: {
  36804. /**
  36805. * Options for the hovered point. These settings override the normal
  36806. * state options when a point is moused over or touched.
  36807. *
  36808. * @extends plotOptions.series.states.hover
  36809. * @excluding halo, lineWidth, lineWidthPlus, marker
  36810. * @product highcharts highstock gantt
  36811. */
  36812. hover: {
  36813. /** @ignore-option */
  36814. halo: false,
  36815. /**
  36816. * A specific border color for the hovered point. Defaults to
  36817. * inherit the normal state border color.
  36818. *
  36819. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36820. * @product highcharts gantt
  36821. * @apioption plotOptions.column.states.hover.borderColor
  36822. */
  36823. /**
  36824. * A specific color for the hovered point.
  36825. *
  36826. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36827. * @product highcharts gantt
  36828. * @apioption plotOptions.column.states.hover.color
  36829. */
  36830. /**
  36831. * How much to brighten the point on interaction. Requires the
  36832. * main color to be defined in hex or rgb(a) format.
  36833. *
  36834. * In styled mode, the hover brightening is by default replaced
  36835. * with a fill-opacity set in the `.highcharts-point:hover`
  36836. * rule.
  36837. *
  36838. * @sample {highcharts} highcharts/plotoptions/column-states-hover-brightness/
  36839. * Brighten by 0.5
  36840. *
  36841. * @product highcharts highstock gantt
  36842. */
  36843. brightness: 0.1
  36844. },
  36845. /**
  36846. * Options for the selected point. These settings override the
  36847. * normal state options when a point is selected.
  36848. *
  36849. * @extends plotOptions.series.states.select
  36850. * @excluding halo, lineWidth, lineWidthPlus, marker
  36851. * @product highcharts highstock gantt
  36852. */
  36853. select: {
  36854. /**
  36855. * A specific color for the selected point.
  36856. *
  36857. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36858. * @default #cccccc
  36859. * @product highcharts highstock gantt
  36860. */
  36861. color: '#cccccc',
  36862. /**
  36863. * A specific border color for the selected point.
  36864. *
  36865. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36866. * @default #000000
  36867. * @product highcharts highstock gantt
  36868. */
  36869. borderColor: '#000000'
  36870. }
  36871. },
  36872. dataLabels: {
  36873. align: void 0,
  36874. verticalAlign: void 0,
  36875. /**
  36876. * The y position offset of the label relative to the point in
  36877. * pixels.
  36878. *
  36879. * @type {number}
  36880. */
  36881. y: void 0
  36882. },
  36883. /**
  36884. * When this is true, the series will not cause the Y axis to cross
  36885. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  36886. * unless the data actually crosses the plane.
  36887. *
  36888. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  36889. * 3 will make the Y axis show negative values according to the
  36890. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  36891. * at 0.
  36892. *
  36893. * @since 4.1.9
  36894. * @product highcharts highstock
  36895. *
  36896. * @private
  36897. */
  36898. softThreshold: false,
  36899. // false doesn't work well: https://jsfiddle.net/highcharts/hz8fopan/14/
  36900. /**
  36901. * @ignore-option
  36902. * @private
  36903. */
  36904. startFromThreshold: true,
  36905. stickyTracking: false,
  36906. tooltip: {
  36907. distance: 6
  36908. },
  36909. /**
  36910. * The Y axis value to serve as the base for the columns, for
  36911. * distinguishing between values above and below a threshold. If `null`,
  36912. * the columns extend from the padding Y axis minimum.
  36913. *
  36914. * @type {number|null}
  36915. * @since 2.0
  36916. * @product highcharts
  36917. *
  36918. * @private
  36919. */
  36920. threshold: 0,
  36921. /**
  36922. * The width of the border surrounding each column or bar. Defaults to
  36923. * `1` when there is room for a border, but to `0` when the columns are
  36924. * so dense that a border would cover the next column.
  36925. *
  36926. * In styled mode, the stroke width can be set with the
  36927. * `.highcharts-point` rule.
  36928. *
  36929. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  36930. * 2px black border
  36931. *
  36932. * @type {number}
  36933. * @default undefined
  36934. * @product highcharts highstock gantt
  36935. * @apioption plotOptions.column.borderWidth
  36936. */
  36937. /**
  36938. * The color of the border surrounding each column or bar.
  36939. *
  36940. * In styled mode, the border stroke can be set with the
  36941. * `.highcharts-point` rule.
  36942. *
  36943. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  36944. * Dark gray border
  36945. *
  36946. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36947. * @default #ffffff
  36948. * @product highcharts highstock gantt
  36949. *
  36950. * @private
  36951. */
  36952. borderColor: '#ffffff'
  36953. },
  36954. /**
  36955. * @lends seriesTypes.column.prototype
  36956. */
  36957. {
  36958. cropShoulder: 0,
  36959. // When tooltip is not shared, this series (and derivatives) requires
  36960. // direct touch/hover. KD-tree does not apply.
  36961. directTouch: true,
  36962. trackerGroups: ['group', 'dataLabelsGroup'],
  36963. // use separate negative stacks, unlike area stacks where a negative
  36964. // point is substracted from previous (#1910)
  36965. negStacks: true,
  36966. /* eslint-disable valid-jsdoc */
  36967. /**
  36968. * Initialize the series. Extends the basic Series.init method by
  36969. * marking other series of the same type as dirty.
  36970. *
  36971. * @private
  36972. * @function Highcharts.seriesTypes.column#init
  36973. * @return {void}
  36974. */
  36975. init: function () {
  36976. Series.prototype.init.apply(this, arguments);
  36977. var series = this, chart = series.chart;
  36978. // if the series is added dynamically, force redraw of other
  36979. // series affected by a new column
  36980. if (chart.hasRendered) {
  36981. chart.series.forEach(function (otherSeries) {
  36982. if (otherSeries.type === series.type) {
  36983. otherSeries.isDirty = true;
  36984. }
  36985. });
  36986. }
  36987. },
  36988. /**
  36989. * Return the width and x offset of the columns adjusted for grouping,
  36990. * groupPadding, pointPadding, pointWidth etc.
  36991. *
  36992. * @private
  36993. * @function Highcharts.seriesTypes.column#getColumnMetrics
  36994. * @return {Highcharts.ColumnMetricsObject}
  36995. */
  36996. getColumnMetrics: function () {
  36997. var series = this, options = series.options, xAxis = series.xAxis, yAxis = series.yAxis, reversedStacks = xAxis.options.reversedStacks,
  36998. // Keep backward compatibility: reversed xAxis had reversed
  36999. // stacks
  37000. reverseStacks = (xAxis.reversed && !reversedStacks) ||
  37001. (!xAxis.reversed && reversedStacks), stackKey, stackGroups = {}, columnCount = 0;
  37002. // Get the total number of column type series. This is called on
  37003. // every series. Consider moving this logic to a chart.orderStacks()
  37004. // function and call it on init, addSeries and removeSeries
  37005. if (options.grouping === false) {
  37006. columnCount = 1;
  37007. }
  37008. else {
  37009. series.chart.series.forEach(function (otherSeries) {
  37010. var otherYAxis = otherSeries.yAxis, otherOptions = otherSeries.options, columnIndex;
  37011. if (otherSeries.type === series.type &&
  37012. (otherSeries.visible ||
  37013. !series.chart.options.chart
  37014. .ignoreHiddenSeries) &&
  37015. yAxis.len === otherYAxis.len &&
  37016. yAxis.pos === otherYAxis.pos) { // #642, #2086
  37017. if (otherOptions.stacking && otherOptions.stacking !== 'group') {
  37018. stackKey = otherSeries.stackKey;
  37019. if (typeof stackGroups[stackKey] ===
  37020. 'undefined') {
  37021. stackGroups[stackKey] = columnCount++;
  37022. }
  37023. columnIndex = stackGroups[stackKey];
  37024. }
  37025. else if (otherOptions.grouping !== false) { // #1162
  37026. columnIndex = columnCount++;
  37027. }
  37028. otherSeries.columnIndex = columnIndex;
  37029. }
  37030. });
  37031. }
  37032. var categoryWidth = Math.min(Math.abs(xAxis.transA) * ((xAxis.ordinal && xAxis.ordinal.slope) ||
  37033. options.pointRange ||
  37034. xAxis.closestPointRange ||
  37035. xAxis.tickInterval ||
  37036. 1), // #2610
  37037. xAxis.len // #1535
  37038. ), groupPadding = categoryWidth * options.groupPadding, groupWidth = categoryWidth - 2 * groupPadding, pointOffsetWidth = groupWidth / (columnCount || 1), pointWidth = Math.min(options.maxPointWidth || xAxis.len, pick(options.pointWidth, pointOffsetWidth * (1 - 2 * options.pointPadding))), pointPadding = (pointOffsetWidth - pointWidth) / 2,
  37039. // #1251, #3737
  37040. colIndex = (series.columnIndex || 0) + (reverseStacks ? 1 : 0), pointXOffset = pointPadding +
  37041. (groupPadding +
  37042. colIndex * pointOffsetWidth -
  37043. (categoryWidth / 2)) * (reverseStacks ? -1 : 1);
  37044. // Save it for reading in linked series (Error bars particularly)
  37045. series.columnMetrics = {
  37046. width: pointWidth,
  37047. offset: pointXOffset,
  37048. paddedWidth: pointOffsetWidth,
  37049. columnCount: columnCount
  37050. };
  37051. return series.columnMetrics;
  37052. },
  37053. /**
  37054. * Make the columns crisp. The edges are rounded to the nearest full
  37055. * pixel.
  37056. *
  37057. * @private
  37058. * @function Highcharts.seriesTypes.column#crispCol
  37059. * @param {number} x
  37060. * @param {number} y
  37061. * @param {number} w
  37062. * @param {number} h
  37063. * @return {Highcharts.BBoxObject}
  37064. */
  37065. crispCol: function (x, y, w, h) {
  37066. var chart = this.chart, borderWidth = this.borderWidth, xCrisp = -(borderWidth % 2 ? 0.5 : 0), yCrisp = borderWidth % 2 ? 0.5 : 1, right, bottom, fromTop;
  37067. if (chart.inverted && chart.renderer.isVML) {
  37068. yCrisp += 1;
  37069. }
  37070. // Horizontal. We need to first compute the exact right edge, then
  37071. // round it and compute the width from there.
  37072. if (this.options.crisp) {
  37073. right = Math.round(x + w) + xCrisp;
  37074. x = Math.round(x) + xCrisp;
  37075. w = right - x;
  37076. }
  37077. // Vertical
  37078. bottom = Math.round(y + h) + yCrisp;
  37079. fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
  37080. y = Math.round(y) + yCrisp;
  37081. h = bottom - y;
  37082. // Top edges are exceptions
  37083. if (fromTop && h) { // #5146
  37084. y -= 1;
  37085. h += 1;
  37086. }
  37087. return {
  37088. x: x,
  37089. y: y,
  37090. width: w,
  37091. height: h
  37092. };
  37093. },
  37094. /**
  37095. * Adjust for missing columns, according to the `centerInCategory`
  37096. * option. Missing columns are either single points or stacks where the
  37097. * point or points are either missing or null.
  37098. *
  37099. * @private
  37100. * @function Highcharts.seriesTypes.column#adjustForMissingColumns
  37101. * @param {number} x
  37102. * The x coordinate of the column, left side
  37103. * @param {number} pointWidth
  37104. * The pointWidth, already computed upstream
  37105. * @param {Highcharts.ColumnPoint} point
  37106. * The point instance
  37107. * @param {Highcharts.ColumnMetricsObject} metrics
  37108. * The series-wide column metrics
  37109. * @return {number}
  37110. * The adjusted x position, or the original if not adjusted
  37111. */
  37112. adjustForMissingColumns: function (x, pointWidth, point, metrics) {
  37113. var _this = this;
  37114. var stacking = this.options.stacking;
  37115. if (!point.isNull && metrics.columnCount > 1) {
  37116. var indexInCategory_1 = 0;
  37117. var totalInCategory_1 = 0;
  37118. // Loop over all the stacks on the Y axis. When stacking is
  37119. // enabled, these are real point stacks. When stacking is not
  37120. // enabled, but `centerInCategory` is true, there is one stack
  37121. // handling the grouping of points in each category. This is
  37122. // done in the `setGroupedPoints` function.
  37123. Highcharts.objectEach(this.yAxis.stacking && this.yAxis.stacking.stacks, function (stack) {
  37124. if (typeof point.x === 'number') {
  37125. var stackItem = stack[point.x.toString()];
  37126. if (stackItem) {
  37127. var pointValues = stackItem.points[_this.index], total = stackItem.total;
  37128. // If true `stacking` is enabled, count the
  37129. // total number of non-null stacks in the
  37130. // category, and note which index this point is
  37131. // within those stacks.
  37132. if (stacking) {
  37133. if (pointValues) {
  37134. indexInCategory_1 = totalInCategory_1;
  37135. }
  37136. if (stackItem.hasValidPoints) {
  37137. totalInCategory_1++;
  37138. }
  37139. // If `stacking` is not enabled, look for the
  37140. // index and total of the `group` stack.
  37141. }
  37142. else if (H.isArray(pointValues)) {
  37143. indexInCategory_1 = pointValues[1];
  37144. totalInCategory_1 = total || 0;
  37145. }
  37146. }
  37147. }
  37148. });
  37149. // Compute the adjusted x position
  37150. var boxWidth = (totalInCategory_1 - 1) * metrics.paddedWidth +
  37151. pointWidth;
  37152. x = (point.plotX || 0) + boxWidth / 2 - pointWidth -
  37153. indexInCategory_1 * metrics.paddedWidth;
  37154. }
  37155. return x;
  37156. },
  37157. /**
  37158. * Translate each point to the plot area coordinate system and find
  37159. * shape positions
  37160. *
  37161. * @private
  37162. * @function Highcharts.seriesTypes.column#translate
  37163. */
  37164. translate: function () {
  37165. var series = this, chart = series.chart, options = series.options, dense = series.dense =
  37166. series.closestPointRange * series.xAxis.transA < 2, borderWidth = series.borderWidth = pick(options.borderWidth, dense ? 0 : 1 // #3635
  37167. ), xAxis = series.xAxis, yAxis = series.yAxis, threshold = options.threshold, translatedThreshold = series.translatedThreshold =
  37168. yAxis.getThreshold(threshold), minPointLength = pick(options.minPointLength, 5), metrics = series.getColumnMetrics(), seriesPointWidth = metrics.width,
  37169. // postprocessed for border width
  37170. seriesBarW = series.barW =
  37171. Math.max(seriesPointWidth, 1 + 2 * borderWidth), seriesXOffset = series.pointXOffset = metrics.offset, dataMin = series.dataMin, dataMax = series.dataMax;
  37172. if (chart.inverted) {
  37173. translatedThreshold -= 0.5; // #3355
  37174. }
  37175. // When the pointPadding is 0, we want the columns to be packed
  37176. // tightly, so we allow individual columns to have individual sizes.
  37177. // When pointPadding is greater, we strive for equal-width columns
  37178. // (#2694).
  37179. if (options.pointPadding) {
  37180. seriesBarW = Math.ceil(seriesBarW);
  37181. }
  37182. Series.prototype.translate.apply(series);
  37183. // Record the new values
  37184. series.points.forEach(function (point) {
  37185. var yBottom = pick(point.yBottom, translatedThreshold), safeDistance = 999 + Math.abs(yBottom), pointWidth = seriesPointWidth, plotX = point.plotX || 0,
  37186. // Don't draw too far outside plot area (#1303, #2241,
  37187. // #4264)
  37188. plotY = clamp(point.plotY, -safeDistance, yAxis.len + safeDistance), barX = plotX + seriesXOffset, barW = seriesBarW, barY = Math.min(plotY, yBottom), up, barH = Math.max(plotY, yBottom) - barY;
  37189. // Handle options.minPointLength
  37190. if (minPointLength && Math.abs(barH) < minPointLength) {
  37191. barH = minPointLength;
  37192. up = (!yAxis.reversed && !point.negative) ||
  37193. (yAxis.reversed && point.negative);
  37194. // Reverse zeros if there's no positive value in the series
  37195. // in visible range (#7046)
  37196. if (isNumber(threshold) &&
  37197. isNumber(dataMax) &&
  37198. point.y === threshold &&
  37199. dataMax <= threshold &&
  37200. // and if there's room for it (#7311)
  37201. (yAxis.min || 0) < threshold &&
  37202. // if all points are the same value (i.e zero) not draw
  37203. // as negative points (#10646)
  37204. dataMin !== dataMax) {
  37205. up = !up;
  37206. }
  37207. // If stacked...
  37208. barY = (Math.abs(barY - translatedThreshold) > minPointLength ?
  37209. // ...keep position
  37210. yBottom - minPointLength :
  37211. // #1485, #4051
  37212. translatedThreshold -
  37213. (up ? minPointLength : 0));
  37214. }
  37215. // Handle point.options.pointWidth
  37216. // @todo Handle grouping/stacking too. Calculate offset properly
  37217. if (defined(point.options.pointWidth)) {
  37218. pointWidth = barW =
  37219. Math.ceil(point.options.pointWidth);
  37220. barX -= Math.round((pointWidth - seriesPointWidth) / 2);
  37221. }
  37222. // Adjust for null or missing points
  37223. if (options.centerInCategory) {
  37224. barX = series.adjustForMissingColumns(barX, pointWidth, point, metrics);
  37225. }
  37226. // Cache for access in polar
  37227. point.barX = barX;
  37228. point.pointWidth = pointWidth;
  37229. // Fix the tooltip on center of grouped columns (#1216, #424,
  37230. // #3648)
  37231. point.tooltipPos = chart.inverted ?
  37232. [
  37233. yAxis.len + yAxis.pos - chart.plotLeft - plotY,
  37234. xAxis.len + xAxis.pos - chart.plotTop - (plotX || 0) - seriesXOffset - barW / 2,
  37235. barH
  37236. ] :
  37237. [barX + barW / 2, plotY + yAxis.pos -
  37238. chart.plotTop, barH];
  37239. // Register shape type and arguments to be used in drawPoints
  37240. // Allow shapeType defined on pointClass level
  37241. point.shapeType =
  37242. series.pointClass.prototype.shapeType || 'rect';
  37243. point.shapeArgs = series.crispCol.apply(series, point.isNull ?
  37244. // #3169, drilldown from null must have a position to work
  37245. // from #6585, dataLabel should be placed on xAxis, not
  37246. // floating in the middle of the chart
  37247. [barX, translatedThreshold, barW, 0] :
  37248. [barX, barY, barW, barH]);
  37249. });
  37250. },
  37251. getSymbol: noop,
  37252. /**
  37253. * Use a solid rectangle like the area series types
  37254. *
  37255. * @private
  37256. * @function Highcharts.seriesTypes.column#drawLegendSymbol
  37257. *
  37258. * @param {Highcharts.Legend} legend
  37259. * The legend object
  37260. *
  37261. * @param {Highcharts.Series|Highcharts.Point} item
  37262. * The series (this) or point
  37263. */
  37264. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  37265. /**
  37266. * Columns have no graph
  37267. *
  37268. * @private
  37269. * @function Highcharts.seriesTypes.column#drawGraph
  37270. */
  37271. drawGraph: function () {
  37272. this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
  37273. },
  37274. /**
  37275. * Get presentational attributes
  37276. *
  37277. * @private
  37278. * @function Highcharts.seriesTypes.column#pointAttribs
  37279. *
  37280. * @param {Highcharts.ColumnPoint} point
  37281. *
  37282. * @param {string} state
  37283. *
  37284. * @return {Highcharts.SVGAttributes}
  37285. */
  37286. pointAttribs: function (point, state) {
  37287. var options = this.options, stateOptions, ret, p2o = this.pointAttrToOptions || {}, strokeOption = p2o.stroke || 'borderColor', strokeWidthOption = p2o['stroke-width'] || 'borderWidth', fill = (point && point.color) || this.color,
  37288. // set to fill when borderColor null:
  37289. stroke = ((point && point[strokeOption]) ||
  37290. options[strokeOption] ||
  37291. this.color ||
  37292. fill), strokeWidth = (point && point[strokeWidthOption]) ||
  37293. options[strokeWidthOption] ||
  37294. this[strokeWidthOption] || 0, dashstyle = (point && point.options.dashStyle) || options.dashStyle, opacity = pick(point && point.opacity, options.opacity, 1), zone, brightness;
  37295. // Handle zone colors
  37296. if (point && this.zones.length) {
  37297. zone = point.getZone();
  37298. // When zones are present, don't use point.color (#4267).
  37299. // Changed order (#6527), added support for colorAxis (#10670)
  37300. fill = (point.options.color ||
  37301. (zone && (zone.color || point.nonZonedColor)) ||
  37302. this.color);
  37303. if (zone) {
  37304. stroke = zone.borderColor || stroke;
  37305. dashstyle = zone.dashStyle || dashstyle;
  37306. strokeWidth = zone.borderWidth || strokeWidth;
  37307. }
  37308. }
  37309. // Select or hover states
  37310. if (state && point) {
  37311. stateOptions = merge(options.states[state],
  37312. // #6401
  37313. point.options.states &&
  37314. point.options.states[state] ||
  37315. {});
  37316. brightness = stateOptions.brightness;
  37317. fill =
  37318. stateOptions.color || (typeof brightness !== 'undefined' &&
  37319. color(fill)
  37320. .brighten(stateOptions.brightness)
  37321. .get()) || fill;
  37322. stroke = stateOptions[strokeOption] || stroke;
  37323. strokeWidth =
  37324. stateOptions[strokeWidthOption] || strokeWidth;
  37325. dashstyle = stateOptions.dashStyle || dashstyle;
  37326. opacity = pick(stateOptions.opacity, opacity);
  37327. }
  37328. ret = {
  37329. fill: fill,
  37330. stroke: stroke,
  37331. 'stroke-width': strokeWidth,
  37332. opacity: opacity
  37333. };
  37334. if (dashstyle) {
  37335. ret.dashstyle = dashstyle;
  37336. }
  37337. return ret;
  37338. },
  37339. /**
  37340. * Draw the columns. For bars, the series.group is rotated, so the same
  37341. * coordinates apply for columns and bars. This method is inherited by
  37342. * scatter series.
  37343. *
  37344. * @private
  37345. * @function Highcharts.seriesTypes.column#drawPoints
  37346. */
  37347. drawPoints: function () {
  37348. var series = this, chart = this.chart, options = series.options, renderer = chart.renderer, animationLimit = options.animationLimit || 250, shapeArgs;
  37349. // draw the columns
  37350. series.points.forEach(function (point) {
  37351. var plotY = point.plotY, graphic = point.graphic, hasGraphic = !!graphic, verb = graphic && chart.pointCount < animationLimit ?
  37352. 'animate' : 'attr';
  37353. if (isNumber(plotY) && point.y !== null) {
  37354. shapeArgs = point.shapeArgs;
  37355. // When updating a series between 2d and 3d or cartesian and
  37356. // polar, the shape type changes.
  37357. if (graphic && point.hasNewShapeType()) {
  37358. graphic = graphic.destroy();
  37359. }
  37360. // Set starting position for point sliding animation.
  37361. if (series.enabledDataSorting) {
  37362. point.startXPos = series.xAxis.reversed ?
  37363. -(shapeArgs ? shapeArgs.width : 0) :
  37364. series.xAxis.width;
  37365. }
  37366. if (!graphic) {
  37367. point.graphic = graphic =
  37368. renderer[point.shapeType](shapeArgs)
  37369. .add(point.group || series.group);
  37370. if (graphic &&
  37371. series.enabledDataSorting &&
  37372. chart.hasRendered &&
  37373. chart.pointCount < animationLimit) {
  37374. graphic.attr({
  37375. x: point.startXPos
  37376. });
  37377. hasGraphic = true;
  37378. verb = 'animate';
  37379. }
  37380. }
  37381. if (graphic && hasGraphic) { // update
  37382. graphic[verb](merge(shapeArgs));
  37383. }
  37384. // Border radius is not stylable (#6900)
  37385. if (options.borderRadius) {
  37386. graphic[verb]({
  37387. r: options.borderRadius
  37388. });
  37389. }
  37390. // Presentational
  37391. if (!chart.styledMode) {
  37392. graphic[verb](series.pointAttribs(point, (point.selected && 'select')))
  37393. .shadow(point.allowShadow !== false && options.shadow, null, options.stacking && !options.borderRadius);
  37394. }
  37395. graphic.addClass(point.getClassName(), true);
  37396. }
  37397. else if (graphic) {
  37398. point.graphic = graphic.destroy(); // #1269
  37399. }
  37400. });
  37401. },
  37402. /**
  37403. * Animate the column heights one by one from zero.
  37404. *
  37405. * @private
  37406. * @function Highcharts.seriesTypes.column#animate
  37407. *
  37408. * @param {boolean} init
  37409. * Whether to initialize the animation or run it
  37410. */
  37411. animate: function (init) {
  37412. var series = this, yAxis = this.yAxis, options = series.options, inverted = this.chart.inverted, attr = {}, translateProp = inverted ? 'translateX' : 'translateY', translateStart, translatedThreshold;
  37413. if (init) {
  37414. attr.scaleY = 0.001;
  37415. translatedThreshold = clamp(yAxis.toPixels(options.threshold), yAxis.pos, yAxis.pos + yAxis.len);
  37416. if (inverted) {
  37417. attr.translateX = translatedThreshold - yAxis.len;
  37418. }
  37419. else {
  37420. attr.translateY = translatedThreshold;
  37421. }
  37422. // apply finnal clipping (used in Highstock) (#7083)
  37423. // animation is done by scaleY, so cliping is for panes
  37424. if (series.clipBox) {
  37425. series.setClip();
  37426. }
  37427. series.group.attr(attr);
  37428. }
  37429. else { // run the animation
  37430. translateStart = series.group.attr(translateProp);
  37431. series.group.animate({ scaleY: 1 }, extend(animObject(series.options.animation), {
  37432. // Do the scale synchronously to ensure smooth
  37433. // updating (#5030, #7228)
  37434. step: function (val, fx) {
  37435. if (series.group) {
  37436. attr[translateProp] = translateStart +
  37437. fx.pos * (yAxis.pos - translateStart);
  37438. series.group.attr(attr);
  37439. }
  37440. }
  37441. }));
  37442. }
  37443. },
  37444. /**
  37445. * Remove this series from the chart
  37446. *
  37447. * @private
  37448. * @function Highcharts.seriesTypes.column#remove
  37449. */
  37450. remove: function () {
  37451. var series = this, chart = series.chart;
  37452. // column and bar series affects other series of the same type
  37453. // as they are either stacked or grouped
  37454. if (chart.hasRendered) {
  37455. chart.series.forEach(function (otherSeries) {
  37456. if (otherSeries.type === series.type) {
  37457. otherSeries.isDirty = true;
  37458. }
  37459. });
  37460. }
  37461. Series.prototype.remove.apply(series, arguments);
  37462. }
  37463. });
  37464. /* eslint-enable valid-jsdoc */
  37465. /**
  37466. * A `column` series. If the [type](#series.column.type) option is
  37467. * not specified, it is inherited from [chart.type](#chart.type).
  37468. *
  37469. * @extends series,plotOptions.column
  37470. * @excluding connectNulls, dataParser, dataURL, gapSize, gapUnit, linecap,
  37471. * lineWidth, marker, connectEnds, step
  37472. * @product highcharts highstock
  37473. * @apioption series.column
  37474. */
  37475. /**
  37476. * An array of data points for the series. For the `column` series type,
  37477. * points can be given in the following ways:
  37478. *
  37479. * 1. An array of numerical values. In this case, the numerical values will be
  37480. * interpreted as `y` options. The `x` values will be automatically
  37481. * calculated, either starting at 0 and incremented by 1, or from
  37482. * `pointStart` and `pointInterval` given in the series options. If the axis
  37483. * has categories, these will be used. Example:
  37484. * ```js
  37485. * data: [0, 5, 3, 5]
  37486. * ```
  37487. *
  37488. * 2. An array of arrays with 2 values. In this case, the values correspond to
  37489. * `x,y`. If the first value is a string, it is applied as the name of the
  37490. * point, and the `x` value is inferred.
  37491. * ```js
  37492. * data: [
  37493. * [0, 6],
  37494. * [1, 2],
  37495. * [2, 6]
  37496. * ]
  37497. * ```
  37498. *
  37499. * 3. An array of objects with named values. The following snippet shows only a
  37500. * few settings, see the complete options set below. If the total number of
  37501. * data points exceeds the series'
  37502. * [turboThreshold](#series.column.turboThreshold), this option is not
  37503. * available.
  37504. * ```js
  37505. * data: [{
  37506. * x: 1,
  37507. * y: 9,
  37508. * name: "Point2",
  37509. * color: "#00FF00"
  37510. * }, {
  37511. * x: 1,
  37512. * y: 6,
  37513. * name: "Point1",
  37514. * color: "#FF00FF"
  37515. * }]
  37516. * ```
  37517. *
  37518. * @sample {highcharts} highcharts/chart/reflow-true/
  37519. * Numerical values
  37520. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  37521. * Arrays of numeric x and y
  37522. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  37523. * Arrays of datetime x and y
  37524. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  37525. * Arrays of point.name and y
  37526. * @sample {highcharts} highcharts/series/data-array-of-objects/
  37527. * Config objects
  37528. *
  37529. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  37530. * @extends series.line.data
  37531. * @excluding marker
  37532. * @product highcharts highstock
  37533. * @apioption series.column.data
  37534. */
  37535. /**
  37536. * The color of the border surrounding the column or bar.
  37537. *
  37538. * In styled mode, the border stroke can be set with the `.highcharts-point`
  37539. * rule.
  37540. *
  37541. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  37542. * Dark gray border
  37543. *
  37544. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37545. * @product highcharts highstock
  37546. * @apioption series.column.data.borderColor
  37547. */
  37548. /**
  37549. * The width of the border surrounding the column or bar.
  37550. *
  37551. * In styled mode, the stroke width can be set with the `.highcharts-point`
  37552. * rule.
  37553. *
  37554. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  37555. * 2px black border
  37556. *
  37557. * @type {number}
  37558. * @product highcharts highstock
  37559. * @apioption series.column.data.borderWidth
  37560. */
  37561. /**
  37562. * A name for the dash style to use for the column or bar. Overrides
  37563. * dashStyle on the series.
  37564. *
  37565. * In styled mode, the stroke dash-array can be set with the same classes as
  37566. * listed under [data.color](#series.column.data.color).
  37567. *
  37568. * @see [series.pointWidth](#plotOptions.column.dashStyle)
  37569. *
  37570. * @type {Highcharts.DashStyleValue}
  37571. * @apioption series.column.data.dashStyle
  37572. */
  37573. /**
  37574. * A pixel value specifying a fixed width for the column or bar. Overrides
  37575. * pointWidth on the series.
  37576. *
  37577. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  37578. *
  37579. * @type {number}
  37580. * @apioption series.column.data.pointWidth
  37581. */
  37582. /**
  37583. * @excluding halo, lineWidth, lineWidthPlus, marker
  37584. * @product highcharts highstock
  37585. * @apioption series.column.states.hover
  37586. */
  37587. /**
  37588. * @excluding halo, lineWidth, lineWidthPlus, marker
  37589. * @product highcharts highstock
  37590. * @apioption series.column.states.select
  37591. */
  37592. ''; // includes above doclets in transpilat
  37593. });
  37594. _registerModule(_modules, 'parts/BarSeries.js', [_modules['parts/Utilities.js']], function (U) {
  37595. /* *
  37596. *
  37597. * (c) 2010-2020 Torstein Honsi
  37598. *
  37599. * License: www.highcharts.com/license
  37600. *
  37601. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37602. *
  37603. * */
  37604. var seriesType = U.seriesType;
  37605. /**
  37606. * Bar series type.
  37607. *
  37608. * @private
  37609. * @class
  37610. * @name Highcharts.seriesTypes.bar
  37611. *
  37612. * @augments Highcharts.Series
  37613. */
  37614. seriesType('bar', 'column',
  37615. /**
  37616. * A bar series is a special type of column series where the columns are
  37617. * horizontal.
  37618. *
  37619. * @sample highcharts/demo/bar-basic/
  37620. * Bar chart
  37621. *
  37622. * @extends plotOptions.column
  37623. * @product highcharts
  37624. * @apioption plotOptions.bar
  37625. */
  37626. /**
  37627. * @ignore
  37628. */
  37629. null, {
  37630. inverted: true
  37631. });
  37632. /**
  37633. * A `bar` series. If the [type](#series.bar.type) option is not specified,
  37634. * it is inherited from [chart.type](#chart.type).
  37635. *
  37636. * @extends series,plotOptions.bar
  37637. * @excluding connectNulls, dashStyle, dataParser, dataURL, gapSize, gapUnit,
  37638. * linecap, lineWidth, marker, connectEnds, step
  37639. * @product highcharts
  37640. * @apioption series.bar
  37641. */
  37642. /**
  37643. * An array of data points for the series. For the `bar` series type,
  37644. * points can be given in the following ways:
  37645. *
  37646. * 1. An array of numerical values. In this case, the numerical values will be
  37647. * interpreted as `y` options. The `x` values will be automatically
  37648. * calculated, either starting at 0 and incremented by 1, or from
  37649. * `pointStart` and `pointInterval` given in the series options. If the axis
  37650. * has categories, these will be used. Example:
  37651. * ```js
  37652. * data: [0, 5, 3, 5]
  37653. * ```
  37654. *
  37655. * 2. An array of arrays with 2 values. In this case, the values correspond to
  37656. * `x,y`. If the first value is a string, it is applied as the name of the
  37657. * point, and the `x` value is inferred.
  37658. * ```js
  37659. * data: [
  37660. * [0, 5],
  37661. * [1, 10],
  37662. * [2, 3]
  37663. * ]
  37664. * ```
  37665. *
  37666. * 3. An array of objects with named values. The following snippet shows only a
  37667. * few settings, see the complete options set below. If the total number of
  37668. * data points exceeds the series'
  37669. * [turboThreshold](#series.bar.turboThreshold), this option is not
  37670. * available.
  37671. * ```js
  37672. * data: [{
  37673. * x: 1,
  37674. * y: 1,
  37675. * name: "Point2",
  37676. * color: "#00FF00"
  37677. * }, {
  37678. * x: 1,
  37679. * y: 10,
  37680. * name: "Point1",
  37681. * color: "#FF00FF"
  37682. * }]
  37683. * ```
  37684. *
  37685. * @sample {highcharts} highcharts/chart/reflow-true/
  37686. * Numerical values
  37687. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  37688. * Arrays of numeric x and y
  37689. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  37690. * Arrays of datetime x and y
  37691. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  37692. * Arrays of point.name and y
  37693. * @sample {highcharts} highcharts/series/data-array-of-objects/
  37694. * Config objects
  37695. *
  37696. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  37697. * @extends series.column.data
  37698. * @product highcharts
  37699. * @apioption series.bar.data
  37700. */
  37701. /**
  37702. * @excluding halo,lineWidth,lineWidthPlus,marker
  37703. * @product highcharts highstock
  37704. * @apioption series.bar.states.hover
  37705. */
  37706. /**
  37707. * @excluding halo,lineWidth,lineWidthPlus,marker
  37708. * @product highcharts highstock
  37709. * @apioption series.bar.states.select
  37710. */
  37711. ''; // gets doclets above into transpilat
  37712. });
  37713. _registerModule(_modules, 'parts/ScatterSeries.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  37714. /* *
  37715. *
  37716. * (c) 2010-2020 Torstein Honsi
  37717. *
  37718. * License: www.highcharts.com/license
  37719. *
  37720. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37721. *
  37722. * */
  37723. var addEvent = U.addEvent, seriesType = U.seriesType;
  37724. var Series = H.Series;
  37725. /**
  37726. * Scatter series type.
  37727. *
  37728. * @private
  37729. * @class
  37730. * @name Highcharts.seriesTypes.scatter
  37731. *
  37732. * @augments Highcharts.Series
  37733. */
  37734. seriesType('scatter', 'line',
  37735. /**
  37736. * A scatter plot uses cartesian coordinates to display values for two
  37737. * variables for a set of data.
  37738. *
  37739. * @sample {highcharts} highcharts/demo/scatter/
  37740. * Scatter plot
  37741. *
  37742. * @extends plotOptions.line
  37743. * @excluding pointPlacement, shadow, useOhlcData
  37744. * @product highcharts highstock
  37745. * @optionparent plotOptions.scatter
  37746. */
  37747. {
  37748. /**
  37749. * The width of the line connecting the data points.
  37750. *
  37751. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-none/
  37752. * 0 by default
  37753. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-1/
  37754. * 1px
  37755. *
  37756. * @product highcharts highstock
  37757. */
  37758. lineWidth: 0,
  37759. findNearestPointBy: 'xy',
  37760. /**
  37761. * Apply a jitter effect for the rendered markers. When plotting
  37762. * discrete values, a little random noise may help telling the points
  37763. * apart. The jitter setting applies a random displacement of up to `n`
  37764. * axis units in either direction. So for example on a horizontal X
  37765. * axis, setting the `jitter.x` to 0.24 will render the point in a
  37766. * random position between 0.24 units to the left and 0.24 units to the
  37767. * right of the true axis position. On a category axis, setting it to
  37768. * 0.5 will fill up the bin and make the data appear continuous.
  37769. *
  37770. * When rendered on top of a box plot or a column series, a jitter value
  37771. * of 0.24 will correspond to the underlying series' default
  37772. * [groupPadding](
  37773. * https://api.highcharts.com/highcharts/plotOptions.column.groupPadding)
  37774. * and [pointPadding](
  37775. * https://api.highcharts.com/highcharts/plotOptions.column.pointPadding)
  37776. * settings.
  37777. *
  37778. * @sample {highcharts} highcharts/series-scatter/jitter
  37779. * Jitter on a scatter plot
  37780. *
  37781. * @sample {highcharts} highcharts/series-scatter/jitter-boxplot
  37782. * Jittered scatter plot on top of a box plot
  37783. *
  37784. * @product highcharts highstock
  37785. * @since 7.0.2
  37786. */
  37787. jitter: {
  37788. /**
  37789. * The maximal X offset for the random jitter effect.
  37790. */
  37791. x: 0,
  37792. /**
  37793. * The maximal Y offset for the random jitter effect.
  37794. */
  37795. y: 0
  37796. },
  37797. marker: {
  37798. enabled: true // Overrides auto-enabling in line series (#3647)
  37799. },
  37800. /**
  37801. * Sticky tracking of mouse events. When true, the `mouseOut` event
  37802. * on a series isn't triggered until the mouse moves over another
  37803. * series, or out of the plot area. When false, the `mouseOut` event on
  37804. * a series is triggered when the mouse leaves the area around the
  37805. * series' graph or markers. This also implies the tooltip. When
  37806. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  37807. * will be hidden when moving the mouse between series.
  37808. *
  37809. * @type {boolean}
  37810. * @default false
  37811. * @product highcharts highstock
  37812. * @apioption plotOptions.scatter.stickyTracking
  37813. */
  37814. /**
  37815. * A configuration object for the tooltip rendering of each single
  37816. * series. Properties are inherited from [tooltip](#tooltip).
  37817. * Overridable properties are `headerFormat`, `pointFormat`,
  37818. * `yDecimals`, `xDateFormat`, `yPrefix` and `ySuffix`. Unlike other
  37819. * series, in a scatter plot the series.name by default shows in the
  37820. * headerFormat and point.x and point.y in the pointFormat.
  37821. *
  37822. * @product highcharts highstock
  37823. */
  37824. tooltip: {
  37825. headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  37826. '<span style="font-size: 10px"> {series.name}</span><br/>',
  37827. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
  37828. }
  37829. // Prototype members
  37830. }, {
  37831. sorted: false,
  37832. requireSorting: false,
  37833. noSharedTooltip: true,
  37834. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  37835. takeOrdinalPosition: false,
  37836. /* eslint-disable valid-jsdoc */
  37837. /**
  37838. * @private
  37839. * @function Highcharts.seriesTypes.scatter#drawGraph
  37840. */
  37841. drawGraph: function () {
  37842. if (this.options.lineWidth) {
  37843. Series.prototype.drawGraph.call(this);
  37844. }
  37845. },
  37846. // Optionally add the jitter effect
  37847. applyJitter: function () {
  37848. var series = this, jitter = this.options.jitter, len = this.points.length;
  37849. /**
  37850. * Return a repeatable, pseudo-random number based on an integer
  37851. * seed.
  37852. * @private
  37853. */
  37854. function unrandom(seed) {
  37855. var rand = Math.sin(seed) * 10000;
  37856. return rand - Math.floor(rand);
  37857. }
  37858. if (jitter) {
  37859. this.points.forEach(function (point, i) {
  37860. ['x', 'y'].forEach(function (dim, j) {
  37861. var axis, plotProp = 'plot' + dim.toUpperCase(), min, max, translatedJitter;
  37862. if (jitter[dim] && !point.isNull) {
  37863. axis = series[dim + 'Axis'];
  37864. translatedJitter =
  37865. jitter[dim] * axis.transA;
  37866. if (axis && !axis.isLog) {
  37867. // Identify the outer bounds of the jitter range
  37868. min = Math.max(0, point[plotProp] - translatedJitter);
  37869. max = Math.min(axis.len, point[plotProp] + translatedJitter);
  37870. // Find a random position within this range
  37871. point[plotProp] = min +
  37872. (max - min) * unrandom(i + j * len);
  37873. // Update clientX for the tooltip k-d-tree
  37874. if (dim === 'x') {
  37875. point.clientX = point.plotX;
  37876. }
  37877. }
  37878. }
  37879. });
  37880. });
  37881. }
  37882. }
  37883. /* eslint-enable valid-jsdoc */
  37884. });
  37885. /* eslint-disable no-invalid-this */
  37886. addEvent(Series, 'afterTranslate', function () {
  37887. if (this.applyJitter) {
  37888. this.applyJitter();
  37889. }
  37890. });
  37891. /* eslint-enable no-invalid-this */
  37892. /**
  37893. * A `scatter` series. If the [type](#series.scatter.type) option is
  37894. * not specified, it is inherited from [chart.type](#chart.type).
  37895. *
  37896. * @extends series,plotOptions.scatter
  37897. * @excluding dataParser, dataURL, useOhlcData
  37898. * @product highcharts highstock
  37899. * @apioption series.scatter
  37900. */
  37901. /**
  37902. * An array of data points for the series. For the `scatter` series
  37903. * type, points can be given in the following ways:
  37904. *
  37905. * 1. An array of numerical values. In this case, the numerical values will be
  37906. * interpreted as `y` options. The `x` values will be automatically
  37907. * calculated, either starting at 0 and incremented by 1, or from
  37908. * `pointStart` and `pointInterval` given in the series options. If the axis
  37909. * has categories, these will be used. Example:
  37910. * ```js
  37911. * data: [0, 5, 3, 5]
  37912. * ```
  37913. *
  37914. * 2. An array of arrays with 2 values. In this case, the values correspond to
  37915. * `x,y`. If the first value is a string, it is applied as the name of the
  37916. * point, and the `x` value is inferred.
  37917. * ```js
  37918. * data: [
  37919. * [0, 0],
  37920. * [1, 8],
  37921. * [2, 9]
  37922. * ]
  37923. * ```
  37924. *
  37925. * 3. An array of objects with named values. The following snippet shows only a
  37926. * few settings, see the complete options set below. If the total number of
  37927. * data points exceeds the series'
  37928. * [turboThreshold](#series.scatter.turboThreshold), this option is not
  37929. * available.
  37930. * ```js
  37931. * data: [{
  37932. * x: 1,
  37933. * y: 2,
  37934. * name: "Point2",
  37935. * color: "#00FF00"
  37936. * }, {
  37937. * x: 1,
  37938. * y: 4,
  37939. * name: "Point1",
  37940. * color: "#FF00FF"
  37941. * }]
  37942. * ```
  37943. *
  37944. * @sample {highcharts} highcharts/chart/reflow-true/
  37945. * Numerical values
  37946. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  37947. * Arrays of numeric x and y
  37948. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  37949. * Arrays of datetime x and y
  37950. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  37951. * Arrays of point.name and y
  37952. * @sample {highcharts} highcharts/series/data-array-of-objects/
  37953. * Config objects
  37954. *
  37955. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  37956. * @extends series.line.data
  37957. * @product highcharts highstock
  37958. * @apioption series.scatter.data
  37959. */
  37960. ''; // adds doclets above to transpilat
  37961. });
  37962. _registerModule(_modules, 'mixins/centered-series.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  37963. /* *
  37964. *
  37965. * (c) 2010-2020 Torstein Honsi
  37966. *
  37967. * License: www.highcharts.com/license
  37968. *
  37969. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37970. *
  37971. * */
  37972. /**
  37973. * @private
  37974. * @interface Highcharts.RadianAngles
  37975. */ /**
  37976. * @name Highcharts.RadianAngles#end
  37977. * @type {number}
  37978. */ /**
  37979. * @name Highcharts.RadianAngles#start
  37980. * @type {number}
  37981. */
  37982. var isNumber = U.isNumber, pick = U.pick, relativeLength = U.relativeLength;
  37983. var deg2rad = H.deg2rad;
  37984. /* eslint-disable valid-jsdoc */
  37985. /**
  37986. * @private
  37987. * @mixin Highcharts.CenteredSeriesMixin
  37988. */
  37989. H.CenteredSeriesMixin = {
  37990. /**
  37991. * Get the center of the pie based on the size and center options relative
  37992. * to the plot area. Borrowed by the polar and gauge series types.
  37993. *
  37994. * @private
  37995. * @function Highcharts.CenteredSeriesMixin.getCenter
  37996. *
  37997. * @return {Array<number>}
  37998. */
  37999. getCenter: function () {
  38000. var options = this.options, chart = this.chart, slicingRoom = 2 * (options.slicedOffset || 0), handleSlicingRoom, plotWidth = chart.plotWidth - 2 * slicingRoom, plotHeight = chart.plotHeight - 2 * slicingRoom, centerOption = options.center, smallestSize = Math.min(plotWidth, plotHeight), size = options.size, innerSize = options.innerSize || 0, positions, i, value;
  38001. if (typeof size === 'string') {
  38002. size = parseFloat(size);
  38003. }
  38004. if (typeof innerSize === 'string') {
  38005. innerSize = parseFloat(innerSize);
  38006. }
  38007. positions = [
  38008. pick(centerOption[0], '50%'),
  38009. pick(centerOption[1], '50%'),
  38010. // Prevent from negative values
  38011. pick(size && size < 0 ? void 0 : options.size, '100%'),
  38012. pick(innerSize && innerSize < 0 ? void 0 : options.innerSize || 0, '0%')
  38013. ];
  38014. // No need for inner size in angular (gauges) series but still required
  38015. // for pie series
  38016. if (chart.angular && !(this instanceof H.Series)) {
  38017. positions[3] = 0;
  38018. }
  38019. for (i = 0; i < 4; ++i) {
  38020. value = positions[i];
  38021. handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
  38022. // i == 0: centerX, relative to width
  38023. // i == 1: centerY, relative to height
  38024. // i == 2: size, relative to smallestSize
  38025. // i == 3: innerSize, relative to size
  38026. positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) + (handleSlicingRoom ? slicingRoom : 0);
  38027. }
  38028. // innerSize cannot be larger than size (#3632)
  38029. if (positions[3] > positions[2]) {
  38030. positions[3] = positions[2];
  38031. }
  38032. return positions;
  38033. },
  38034. /**
  38035. * getStartAndEndRadians - Calculates start and end angles in radians.
  38036. * Used in series types such as pie and sunburst.
  38037. *
  38038. * @private
  38039. * @function Highcharts.CenteredSeriesMixin.getStartAndEndRadians
  38040. *
  38041. * @param {number} [start]
  38042. * Start angle in degrees.
  38043. *
  38044. * @param {number} [end]
  38045. * Start angle in degrees.
  38046. *
  38047. * @return {Highcharts.RadianAngles}
  38048. * Returns an object containing start and end angles as radians.
  38049. */
  38050. getStartAndEndRadians: function (start, end) {
  38051. var startAngle = isNumber(start) ? start : 0, // must be a number
  38052. endAngle = ((isNumber(end) && // must be a number
  38053. end > startAngle && // must be larger than the start angle
  38054. // difference must be less than 360 degrees
  38055. (end - startAngle) < 360) ?
  38056. end :
  38057. startAngle + 360), correction = -90;
  38058. return {
  38059. start: deg2rad * (startAngle + correction),
  38060. end: deg2rad * (endAngle + correction)
  38061. };
  38062. }
  38063. };
  38064. });
  38065. _registerModule(_modules, 'parts/PieSeries.js', [_modules['parts/Globals.js'], _modules['mixins/legend-symbol.js'], _modules['parts/Point.js'], _modules['parts/Utilities.js']], function (H, LegendSymbolMixin, Point, U) {
  38066. /* *
  38067. *
  38068. * (c) 2010-2020 Torstein Honsi
  38069. *
  38070. * License: www.highcharts.com/license
  38071. *
  38072. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38073. *
  38074. * */
  38075. var addEvent = U.addEvent, clamp = U.clamp, defined = U.defined, fireEvent = U.fireEvent, isNumber = U.isNumber, merge = U.merge, pick = U.pick, relativeLength = U.relativeLength, seriesType = U.seriesType, setAnimation = U.setAnimation;
  38076. var CenteredSeriesMixin = H.CenteredSeriesMixin, getStartAndEndRadians = CenteredSeriesMixin.getStartAndEndRadians, noop = H.noop, Series = H.Series, seriesTypes = H.seriesTypes;
  38077. /**
  38078. * Pie series type.
  38079. *
  38080. * @private
  38081. * @class
  38082. * @name Highcharts.seriesTypes.pie
  38083. *
  38084. * @augments Highcharts.Series
  38085. */
  38086. seriesType('pie', 'line',
  38087. /**
  38088. * A pie chart is a circular graphic which is divided into slices to
  38089. * illustrate numerical proportion.
  38090. *
  38091. * @sample highcharts/demo/pie-basic/
  38092. * Pie chart
  38093. *
  38094. * @extends plotOptions.line
  38095. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  38096. * cropThreshold, dashStyle, dataSorting, dragDrop,
  38097. * findNearestPointBy, getExtremesFromAll, label, lineWidth,
  38098. * marker, negativeColor, pointInterval, pointIntervalUnit,
  38099. * pointPlacement, pointStart, softThreshold, stacking, step,
  38100. * threshold, turboThreshold, zoneAxis, zones, dataSorting
  38101. * @product highcharts
  38102. * @optionparent plotOptions.pie
  38103. */
  38104. {
  38105. /**
  38106. * @excluding legendItemClick
  38107. * @apioption plotOptions.pie.events
  38108. */
  38109. /**
  38110. * Fires when the checkbox next to the point name in the legend is
  38111. * clicked. One parameter, event, is passed to the function. The state
  38112. * of the checkbox is found by event.checked. The checked item is found
  38113. * by event.item. Return false to prevent the default action which is to
  38114. * toggle the select state of the series.
  38115. *
  38116. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  38117. * Alert checkbox status
  38118. *
  38119. * @type {Function}
  38120. * @since 1.2.0
  38121. * @product highcharts
  38122. * @context Highcharts.Point
  38123. * @apioption plotOptions.pie.events.checkboxClick
  38124. */
  38125. /**
  38126. * Fires when the legend item belonging to the pie point (slice) is
  38127. * clicked. The `this` keyword refers to the point itself. One
  38128. * parameter, `event`, is passed to the function, containing common
  38129. * event information. The default action is to toggle the visibility of
  38130. * the point. This can be prevented by calling `event.preventDefault()`.
  38131. *
  38132. * @sample {highcharts} highcharts/plotoptions/pie-point-events-legenditemclick/
  38133. * Confirm toggle visibility
  38134. *
  38135. * @type {Highcharts.PointLegendItemClickCallbackFunction}
  38136. * @since 1.2.0
  38137. * @product highcharts
  38138. * @apioption plotOptions.pie.point.events.legendItemClick
  38139. */
  38140. /**
  38141. * The center of the pie chart relative to the plot area. Can be
  38142. * percentages or pixel values. The default behaviour (as of 3.0) is to
  38143. * center the pie so that all slices and data labels are within the plot
  38144. * area. As a consequence, the pie may actually jump around in a chart
  38145. * with dynamic values, as the data labels move. In that case, the
  38146. * center should be explicitly set, for example to `["50%", "50%"]`.
  38147. *
  38148. * @sample {highcharts} highcharts/plotoptions/pie-center/
  38149. * Centered at 100, 100
  38150. *
  38151. * @type {Array<(number|string|null),(number|string|null)>}
  38152. * @default [null, null]
  38153. * @product highcharts
  38154. *
  38155. * @private
  38156. */
  38157. center: [null, null],
  38158. /**
  38159. * The color of the pie series. A pie series is represented as an empty
  38160. * circle if the total sum of its values is 0. Use this property to
  38161. * define the color of its border.
  38162. *
  38163. * In styled mode, the color can be defined by the
  38164. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  38165. * color can be set with the `.highcharts-series`,
  38166. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  38167. * `.highcharts-series-{n}` class, or individual classes given by the
  38168. * `className` option.
  38169. *
  38170. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  38171. * Empty pie series
  38172. *
  38173. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38174. * @default #cccccc
  38175. * @apioption plotOptions.pie.color
  38176. */
  38177. /**
  38178. * @product highcharts
  38179. *
  38180. * @private
  38181. */
  38182. clip: false,
  38183. /**
  38184. * @ignore-option
  38185. *
  38186. * @private
  38187. */
  38188. colorByPoint: true,
  38189. /**
  38190. * A series specific or series type specific color set to use instead
  38191. * of the global [colors](#colors).
  38192. *
  38193. * @sample {highcharts} highcharts/demo/pie-monochrome/
  38194. * Set default colors for all pies
  38195. *
  38196. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  38197. * @since 3.0
  38198. * @product highcharts
  38199. * @apioption plotOptions.pie.colors
  38200. */
  38201. /**
  38202. * @declare Highcharts.SeriesPieDataLabelsOptionsObject
  38203. * @extends plotOptions.series.dataLabels
  38204. * @excluding align, allowOverlap, inside, staggerLines, step
  38205. * @private
  38206. */
  38207. dataLabels: {
  38208. /**
  38209. * Alignment method for data labels. Possible values are:
  38210. *
  38211. * - `toPlotEdges`: Each label touches the nearest vertical edge of
  38212. * the plot area.
  38213. *
  38214. * - `connectors`: Connectors have the same x position and the
  38215. * widest label of each half (left & right) touches the nearest
  38216. * vertical edge of the plot area.
  38217. *
  38218. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-connectors/
  38219. * alignTo: connectors
  38220. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-plotedges/
  38221. * alignTo: plotEdges
  38222. *
  38223. * @type {string}
  38224. * @since 7.0.0
  38225. * @product highcharts
  38226. * @apioption plotOptions.pie.dataLabels.alignTo
  38227. */
  38228. allowOverlap: true,
  38229. /**
  38230. * The color of the line connecting the data label to the pie slice.
  38231. * The default color is the same as the point's color.
  38232. *
  38233. * In styled mode, the connector stroke is given in the
  38234. * `.highcharts-data-label-connector` class.
  38235. *
  38236. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorcolor/
  38237. * Blue connectors
  38238. * @sample {highcharts} highcharts/css/pie-point/
  38239. * Styled connectors
  38240. *
  38241. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38242. * @since 2.1
  38243. * @product highcharts
  38244. * @apioption plotOptions.pie.dataLabels.connectorColor
  38245. */
  38246. /**
  38247. * The distance from the data label to the connector. Note that
  38248. * data labels also have a default `padding`, so in order for the
  38249. * connector to touch the text, the `padding` must also be 0.
  38250. *
  38251. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorpadding/
  38252. * No padding
  38253. *
  38254. * @since 2.1
  38255. * @product highcharts
  38256. */
  38257. connectorPadding: 5,
  38258. /**
  38259. * Specifies the method that is used to generate the connector path.
  38260. * Highcharts provides 3 built-in connector shapes: `'fixedOffset'`
  38261. * (default), `'straight'` and `'crookedLine'`. Using
  38262. * `'crookedLine'` has the most sense (in most of the cases) when
  38263. * `'alignTo'` is set.
  38264. *
  38265. * Users can provide their own method by passing a function instead
  38266. * of a String. 3 arguments are passed to the callback:
  38267. *
  38268. * - Object that holds the information about the coordinates of the
  38269. * label (`x` & `y` properties) and how the label is located in
  38270. * relation to the pie (`alignment` property). `alignment` can by
  38271. * one of the following:
  38272. * `'left'` (pie on the left side of the data label),
  38273. * `'right'` (pie on the right side of the data label) or
  38274. * `'center'` (data label overlaps the pie).
  38275. *
  38276. * - Object that holds the information about the position of the
  38277. * connector. Its `touchingSliceAt` porperty tells the position
  38278. * of the place where the connector touches the slice.
  38279. *
  38280. * - Data label options
  38281. *
  38282. * The function has to return an SVG path definition in array form
  38283. * (see the example).
  38284. *
  38285. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-string/
  38286. * connectorShape is a String
  38287. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-function/
  38288. * connectorShape is a function
  38289. *
  38290. * @type {string|Function}
  38291. * @since 7.0.0
  38292. * @product highcharts
  38293. */
  38294. connectorShape: 'fixedOffset',
  38295. /**
  38296. * The width of the line connecting the data label to the pie slice.
  38297. *
  38298. * In styled mode, the connector stroke width is given in the
  38299. * `.highcharts-data-label-connector` class.
  38300. *
  38301. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorwidth-disabled/
  38302. * Disable the connector
  38303. * @sample {highcharts} highcharts/css/pie-point/
  38304. * Styled connectors
  38305. *
  38306. * @type {number}
  38307. * @default 1
  38308. * @since 2.1
  38309. * @product highcharts
  38310. * @apioption plotOptions.pie.dataLabels.connectorWidth
  38311. */
  38312. /**
  38313. * Works only if `connectorShape` is `'crookedLine'`. It defines how
  38314. * far from the vertical plot edge the coonnector path should be
  38315. * crooked.
  38316. *
  38317. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-crookdistance/
  38318. * crookDistance set to 90%
  38319. *
  38320. * @since 7.0.0
  38321. * @product highcharts
  38322. */
  38323. crookDistance: '70%',
  38324. /**
  38325. * The distance of the data label from the pie's edge. Negative
  38326. * numbers put the data label on top of the pie slices. Can also be
  38327. * defined as a percentage of pie's radius. Connectors are only
  38328. * shown for data labels outside the pie.
  38329. *
  38330. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-distance/
  38331. * Data labels on top of the pie
  38332. *
  38333. * @type {number|string}
  38334. * @since 2.1
  38335. * @product highcharts
  38336. */
  38337. distance: 30,
  38338. enabled: true,
  38339. formatter: function () {
  38340. return this.point.isNull ? void 0 : this.point.name;
  38341. },
  38342. /**
  38343. * Whether to render the connector as a soft arc or a line with
  38344. * sharp break. Works only if `connectorShape` equals to
  38345. * `fixedOffset`.
  38346. *
  38347. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-true/
  38348. * Soft
  38349. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-false/
  38350. * Non soft
  38351. *
  38352. * @since 2.1.7
  38353. * @product highcharts
  38354. */
  38355. softConnector: true,
  38356. /**
  38357. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow
  38358. * Long labels truncated with an ellipsis
  38359. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap
  38360. * Long labels are wrapped
  38361. *
  38362. * @type {Highcharts.CSSObject}
  38363. * @apioption plotOptions.pie.dataLabels.style
  38364. */
  38365. x: 0
  38366. },
  38367. /**
  38368. * If the total sum of the pie's values is 0, the series is represented
  38369. * as an empty circle . The `fillColor` option defines the color of that
  38370. * circle. Use [pie.borderWidth](#plotOptions.pie.borderWidth) to set
  38371. * the border thickness.
  38372. *
  38373. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  38374. * Empty pie series
  38375. *
  38376. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38377. * @private
  38378. */
  38379. fillColor: void 0,
  38380. /**
  38381. * The end angle of the pie in degrees where 0 is top and 90 is right.
  38382. * Defaults to `startAngle` plus 360.
  38383. *
  38384. * @sample {highcharts} highcharts/demo/pie-semi-circle/
  38385. * Semi-circle donut
  38386. *
  38387. * @type {number}
  38388. * @since 1.3.6
  38389. * @product highcharts
  38390. * @apioption plotOptions.pie.endAngle
  38391. */
  38392. /**
  38393. * Equivalent to [chart.ignoreHiddenSeries](#chart.ignoreHiddenSeries),
  38394. * this option tells whether the series shall be redrawn as if the
  38395. * hidden point were `null`.
  38396. *
  38397. * The default value changed from `false` to `true` with Highcharts
  38398. * 3.0.
  38399. *
  38400. * @sample {highcharts} highcharts/plotoptions/pie-ignorehiddenpoint/
  38401. * True, the hiddden point is ignored
  38402. *
  38403. * @since 2.3.0
  38404. * @product highcharts
  38405. *
  38406. * @private
  38407. */
  38408. ignoreHiddenPoint: true,
  38409. /**
  38410. * @ignore-option
  38411. *
  38412. * @private
  38413. */
  38414. inactiveOtherPoints: true,
  38415. /**
  38416. * The size of the inner diameter for the pie. A size greater than 0
  38417. * renders a donut chart. Can be a percentage or pixel value.
  38418. * Percentages are relative to the pie size. Pixel values are given as
  38419. * integers.
  38420. *
  38421. *
  38422. * Note: in Highcharts < 4.1.2, the percentage was relative to the plot
  38423. * area, not the pie size.
  38424. *
  38425. * @sample {highcharts} highcharts/plotoptions/pie-innersize-80px/
  38426. * 80px inner size
  38427. * @sample {highcharts} highcharts/plotoptions/pie-innersize-50percent/
  38428. * 50% of the plot area
  38429. * @sample {highcharts} highcharts/demo/3d-pie-donut/
  38430. * 3D donut
  38431. *
  38432. * @type {number|string}
  38433. * @default 0
  38434. * @since 2.0
  38435. * @product highcharts
  38436. * @apioption plotOptions.pie.innerSize
  38437. */
  38438. /**
  38439. * @ignore-option
  38440. *
  38441. * @private
  38442. */
  38443. legendType: 'point',
  38444. /**
  38445. * @ignore-option
  38446. *
  38447. * @private
  38448. */
  38449. marker: null,
  38450. /**
  38451. * The minimum size for a pie in response to auto margins. The pie will
  38452. * try to shrink to make room for data labels in side the plot area,
  38453. * but only to this size.
  38454. *
  38455. * @type {number|string}
  38456. * @default 80
  38457. * @since 3.0
  38458. * @product highcharts
  38459. * @apioption plotOptions.pie.minSize
  38460. */
  38461. /**
  38462. * The diameter of the pie relative to the plot area. Can be a
  38463. * percentage or pixel value. Pixel values are given as integers. The
  38464. * default behaviour (as of 3.0) is to scale to the plot area and give
  38465. * room for data labels within the plot area.
  38466. * [slicedOffset](#plotOptions.pie.slicedOffset) is also included in the
  38467. * default size calculation. As a consequence, the size of the pie may
  38468. * vary when points are updated and data labels more around. In that
  38469. * case it is best to set a fixed value, for example `"75%"`.
  38470. *
  38471. * @sample {highcharts} highcharts/plotoptions/pie-size/
  38472. * Smaller pie
  38473. *
  38474. * @type {number|string|null}
  38475. * @product highcharts
  38476. *
  38477. * @private
  38478. */
  38479. size: null,
  38480. /**
  38481. * Whether to display this particular series or series type in the
  38482. * legend. Since 2.1, pies are not shown in the legend by default.
  38483. *
  38484. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  38485. * One series in the legend, one hidden
  38486. *
  38487. * @product highcharts
  38488. *
  38489. * @private
  38490. */
  38491. showInLegend: false,
  38492. /**
  38493. * If a point is sliced, moved out from the center, how many pixels
  38494. * should it be moved?.
  38495. *
  38496. * @sample {highcharts} highcharts/plotoptions/pie-slicedoffset-20/
  38497. * 20px offset
  38498. *
  38499. * @product highcharts
  38500. *
  38501. * @private
  38502. */
  38503. slicedOffset: 10,
  38504. /**
  38505. * The start angle of the pie slices in degrees where 0 is top and 90
  38506. * right.
  38507. *
  38508. * @sample {highcharts} highcharts/plotoptions/pie-startangle-90/
  38509. * Start from right
  38510. *
  38511. * @type {number}
  38512. * @default 0
  38513. * @since 2.3.4
  38514. * @product highcharts
  38515. * @apioption plotOptions.pie.startAngle
  38516. */
  38517. /**
  38518. * Sticky tracking of mouse events. When true, the `mouseOut` event
  38519. * on a series isn't triggered until the mouse moves over another
  38520. * series, or out of the plot area. When false, the `mouseOut` event on
  38521. * a series is triggered when the mouse leaves the area around the
  38522. * series' graph or markers. This also implies the tooltip. When
  38523. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  38524. * will be hidden when moving the mouse between series.
  38525. *
  38526. * @product highcharts
  38527. *
  38528. * @private
  38529. */
  38530. stickyTracking: false,
  38531. tooltip: {
  38532. followPointer: true
  38533. },
  38534. /**
  38535. * The color of the border surrounding each slice. When `null`, the
  38536. * border takes the same color as the slice fill. This can be used
  38537. * together with a `borderWidth` to fill drawing gaps created by
  38538. * antialiazing artefacts in borderless pies.
  38539. *
  38540. * In styled mode, the border stroke is given in the `.highcharts-point`
  38541. * class.
  38542. *
  38543. * @sample {highcharts} highcharts/plotoptions/pie-bordercolor-black/
  38544. * Black border
  38545. *
  38546. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38547. * @default #ffffff
  38548. * @product highcharts
  38549. *
  38550. * @private
  38551. */
  38552. borderColor: '#ffffff',
  38553. /**
  38554. * The width of the border surrounding each slice.
  38555. *
  38556. * When setting the border width to 0, there may be small gaps between
  38557. * the slices due to SVG antialiasing artefacts. To work around this,
  38558. * keep the border width at 0.5 or 1, but set the `borderColor` to
  38559. * `null` instead.
  38560. *
  38561. * In styled mode, the border stroke width is given in the
  38562. * `.highcharts-point` class.
  38563. *
  38564. * @sample {highcharts} highcharts/plotoptions/pie-borderwidth/
  38565. * 3px border
  38566. *
  38567. * @product highcharts
  38568. *
  38569. * @private
  38570. */
  38571. borderWidth: 1,
  38572. /**
  38573. * @ignore-options
  38574. * @private
  38575. */
  38576. lineWidth: void 0,
  38577. states: {
  38578. /**
  38579. * @extends plotOptions.series.states.hover
  38580. * @excluding marker, lineWidth, lineWidthPlus
  38581. * @product highcharts
  38582. */
  38583. hover: {
  38584. /**
  38585. * How much to brighten the point on interaction. Requires the
  38586. * main color to be defined in hex or rgb(a) format.
  38587. *
  38588. * In styled mode, the hover brightness is by default replaced
  38589. * by a fill-opacity given in the `.highcharts-point-hover`
  38590. * class.
  38591. *
  38592. * @sample {highcharts} highcharts/plotoptions/pie-states-hover-brightness/
  38593. * Brightened by 0.5
  38594. *
  38595. * @product highcharts
  38596. */
  38597. brightness: 0.1
  38598. }
  38599. }
  38600. },
  38601. /* eslint-disable valid-jsdoc */
  38602. /**
  38603. * @lends seriesTypes.pie.prototype
  38604. */
  38605. {
  38606. isCartesian: false,
  38607. requireSorting: false,
  38608. directTouch: true,
  38609. noSharedTooltip: true,
  38610. trackerGroups: ['group', 'dataLabelsGroup'],
  38611. axisTypes: [],
  38612. pointAttribs: seriesTypes.column.prototype.pointAttribs,
  38613. /**
  38614. * Animate the pies in
  38615. *
  38616. * @private
  38617. * @function Highcharts.seriesTypes.pie#animate
  38618. *
  38619. * @param {boolean} [init=false]
  38620. */
  38621. animate: function (init) {
  38622. var series = this, points = series.points, startAngleRad = series.startAngleRad;
  38623. if (!init) {
  38624. points.forEach(function (point) {
  38625. var graphic = point.graphic, args = point.shapeArgs;
  38626. if (graphic && args) {
  38627. // start values
  38628. graphic.attr({
  38629. // animate from inner radius (#779)
  38630. r: pick(point.startR, (series.center && series.center[3] / 2)),
  38631. start: startAngleRad,
  38632. end: startAngleRad
  38633. });
  38634. // animate
  38635. graphic.animate({
  38636. r: args.r,
  38637. start: args.start,
  38638. end: args.end
  38639. }, series.options.animation);
  38640. }
  38641. });
  38642. }
  38643. },
  38644. // Define hasData function for non-cartesian series.
  38645. // Returns true if the series has points at all.
  38646. hasData: function () {
  38647. return !!this.processedXData.length; // != 0
  38648. },
  38649. /**
  38650. * Recompute total chart sum and update percentages of points.
  38651. *
  38652. * @private
  38653. * @function Highcharts.seriesTypes.pie#updateTotals
  38654. * @return {void}
  38655. */
  38656. updateTotals: function () {
  38657. var i, total = 0, points = this.points, len = points.length, point, ignoreHiddenPoint = this.options.ignoreHiddenPoint;
  38658. // Get the total sum
  38659. for (i = 0; i < len; i++) {
  38660. point = points[i];
  38661. total += (ignoreHiddenPoint && !point.visible) ?
  38662. 0 :
  38663. point.isNull ?
  38664. 0 :
  38665. point.y;
  38666. }
  38667. this.total = total;
  38668. // Set each point's properties
  38669. for (i = 0; i < len; i++) {
  38670. point = points[i];
  38671. point.percentage =
  38672. (total > 0 && (point.visible || !ignoreHiddenPoint)) ?
  38673. point.y / total * 100 :
  38674. 0;
  38675. point.total = total;
  38676. }
  38677. },
  38678. /**
  38679. * Extend the generatePoints method by adding total and percentage
  38680. * properties to each point
  38681. *
  38682. * @private
  38683. * @function Highcharts.seriesTypes.pie#generatePoints
  38684. * @return {void}
  38685. */
  38686. generatePoints: function () {
  38687. Series.prototype.generatePoints.call(this);
  38688. this.updateTotals();
  38689. },
  38690. /**
  38691. * Utility for getting the x value from a given y, used for
  38692. * anticollision logic in data labels. Added point for using specific
  38693. * points' label distance.
  38694. * @private
  38695. */
  38696. getX: function (y, left, point) {
  38697. var center = this.center,
  38698. // Variable pie has individual radius
  38699. radius = this.radii ?
  38700. this.radii[point.index] :
  38701. center[2] / 2, angle, x;
  38702. angle = Math.asin(clamp((y - center[1]) / (radius + point.labelDistance), -1, 1));
  38703. x = center[0] +
  38704. (left ? -1 : 1) *
  38705. (Math.cos(angle) * (radius + point.labelDistance)) +
  38706. (point.labelDistance > 0 ?
  38707. (left ? -1 : 1) * this.options.dataLabels.padding :
  38708. 0);
  38709. return x;
  38710. },
  38711. /**
  38712. * Do translation for pie slices
  38713. *
  38714. * @private
  38715. * @function Highcharts.seriesTypes.pie#translate
  38716. * @param {Array<number>} [positions]
  38717. * @return {void}
  38718. */
  38719. translate: function (positions) {
  38720. this.generatePoints();
  38721. var series = this, cumulative = 0, precision = 1000, // issue #172
  38722. options = series.options, slicedOffset = options.slicedOffset, connectorOffset = slicedOffset + (options.borderWidth || 0), finalConnectorOffset, start, end, angle, radians = getStartAndEndRadians(options.startAngle, options.endAngle), startAngleRad = series.startAngleRad = radians.start, endAngleRad = series.endAngleRad = radians.end, circ = endAngleRad - startAngleRad, // 2 * Math.PI,
  38723. points = series.points,
  38724. // the x component of the radius vector for a given point
  38725. radiusX, radiusY, labelDistance = options.dataLabels.distance, ignoreHiddenPoint = options.ignoreHiddenPoint, i, len = points.length, point;
  38726. // Get positions - either an integer or a percentage string must be
  38727. // given. If positions are passed as a parameter, we're in a
  38728. // recursive loop for adjusting space for data labels.
  38729. if (!positions) {
  38730. series.center = positions = series.getCenter();
  38731. }
  38732. // Calculate the geometry for each point
  38733. for (i = 0; i < len; i++) {
  38734. point = points[i];
  38735. // set start and end angle
  38736. start = startAngleRad + (cumulative * circ);
  38737. if (!ignoreHiddenPoint || point.visible) {
  38738. cumulative += point.percentage / 100;
  38739. }
  38740. end = startAngleRad + (cumulative * circ);
  38741. // set the shape
  38742. point.shapeType = 'arc';
  38743. point.shapeArgs = {
  38744. x: positions[0],
  38745. y: positions[1],
  38746. r: positions[2] / 2,
  38747. innerR: positions[3] / 2,
  38748. start: Math.round(start * precision) / precision,
  38749. end: Math.round(end * precision) / precision
  38750. };
  38751. // Used for distance calculation for specific point.
  38752. point.labelDistance = pick((point.options.dataLabels &&
  38753. point.options.dataLabels.distance), labelDistance);
  38754. // Compute point.labelDistance if it's defined as percentage
  38755. // of slice radius (#8854)
  38756. point.labelDistance = relativeLength(point.labelDistance, point.shapeArgs.r);
  38757. // Saved for later dataLabels distance calculation.
  38758. series.maxLabelDistance = Math.max(series.maxLabelDistance || 0, point.labelDistance);
  38759. // The angle must stay within -90 and 270 (#2645)
  38760. angle = (end + start) / 2;
  38761. if (angle > 1.5 * Math.PI) {
  38762. angle -= 2 * Math.PI;
  38763. }
  38764. else if (angle < -Math.PI / 2) {
  38765. angle += 2 * Math.PI;
  38766. }
  38767. // Center for the sliced out slice
  38768. point.slicedTranslation = {
  38769. translateX: Math.round(Math.cos(angle) * slicedOffset),
  38770. translateY: Math.round(Math.sin(angle) * slicedOffset)
  38771. };
  38772. // set the anchor point for tooltips
  38773. radiusX = Math.cos(angle) * positions[2] / 2;
  38774. radiusY = Math.sin(angle) * positions[2] / 2;
  38775. point.tooltipPos = [
  38776. positions[0] + radiusX * 0.7,
  38777. positions[1] + radiusY * 0.7
  38778. ];
  38779. point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ?
  38780. 1 :
  38781. 0;
  38782. point.angle = angle;
  38783. // Set the anchor point for data labels. Use point.labelDistance
  38784. // instead of labelDistance // #1174
  38785. // finalConnectorOffset - not override connectorOffset value.
  38786. finalConnectorOffset = Math.min(connectorOffset, point.labelDistance / 5); // #1678
  38787. point.labelPosition = {
  38788. natural: {
  38789. // initial position of the data label - it's utilized for
  38790. // finding the final position for the label
  38791. x: positions[0] + radiusX + Math.cos(angle) *
  38792. point.labelDistance,
  38793. y: positions[1] + radiusY + Math.sin(angle) *
  38794. point.labelDistance
  38795. },
  38796. 'final': {
  38797. // used for generating connector path -
  38798. // initialized later in drawDataLabels function
  38799. // x: undefined,
  38800. // y: undefined
  38801. },
  38802. // left - pie on the left side of the data label
  38803. // right - pie on the right side of the data label
  38804. // center - data label overlaps the pie
  38805. alignment: point.labelDistance < 0 ?
  38806. 'center' : point.half ? 'right' : 'left',
  38807. connectorPosition: {
  38808. breakAt: {
  38809. x: positions[0] + radiusX + Math.cos(angle) *
  38810. finalConnectorOffset,
  38811. y: positions[1] + radiusY + Math.sin(angle) *
  38812. finalConnectorOffset
  38813. },
  38814. touchingSliceAt: {
  38815. x: positions[0] + radiusX,
  38816. y: positions[1] + radiusY
  38817. }
  38818. }
  38819. };
  38820. }
  38821. fireEvent(series, 'afterTranslate');
  38822. },
  38823. /**
  38824. * Called internally to draw auxiliary graph in pie-like series in
  38825. * situtation when the default graph is not sufficient enough to present
  38826. * the data well. Auxiliary graph is saved in the same object as
  38827. * regular graph.
  38828. *
  38829. * @private
  38830. * @function Highcharts.seriesTypes.pie#drawEmpty
  38831. */
  38832. drawEmpty: function () {
  38833. var centerX, centerY, start = this.startAngleRad, end = this.endAngleRad, options = this.options;
  38834. // Draw auxiliary graph if there're no visible points.
  38835. if (this.total === 0) {
  38836. centerX = this.center[0];
  38837. centerY = this.center[1];
  38838. if (!this.graph) {
  38839. this.graph = this.chart.renderer
  38840. .arc(centerX, centerY, this.center[1] / 2, 0, start, end)
  38841. .addClass('highcharts-empty-series')
  38842. .add(this.group);
  38843. }
  38844. this.graph.attr({
  38845. d: Highcharts.SVGRenderer.prototype.symbols.arc(centerX, centerY, this.center[2] / 2, 0, {
  38846. start: start,
  38847. end: end,
  38848. innerR: this.center[3] / 2
  38849. })
  38850. });
  38851. if (!this.chart.styledMode) {
  38852. this.graph.attr({
  38853. 'stroke-width': options.borderWidth,
  38854. fill: options.fillColor || 'none',
  38855. stroke: options.color ||
  38856. '#cccccc'
  38857. });
  38858. }
  38859. }
  38860. else if (this.graph) { // Destroy the graph object.
  38861. this.graph = this.graph.destroy();
  38862. }
  38863. },
  38864. /**
  38865. * Draw the data points
  38866. *
  38867. * @private
  38868. * @function Highcharts.seriesTypes.pie#drawPoints
  38869. * @return {void}
  38870. */
  38871. redrawPoints: function () {
  38872. var series = this, chart = series.chart, renderer = chart.renderer, groupTranslation, graphic, pointAttr, shapeArgs, shadow = series.options.shadow;
  38873. this.drawEmpty();
  38874. if (shadow && !series.shadowGroup && !chart.styledMode) {
  38875. series.shadowGroup = renderer.g('shadow')
  38876. .attr({ zIndex: -1 })
  38877. .add(series.group);
  38878. }
  38879. // draw the slices
  38880. series.points.forEach(function (point) {
  38881. var animateTo = {};
  38882. graphic = point.graphic;
  38883. if (!point.isNull && graphic) {
  38884. shapeArgs = point.shapeArgs;
  38885. // If the point is sliced, use special translation, else use
  38886. // plot area translation
  38887. groupTranslation = point.getTranslate();
  38888. if (!chart.styledMode) {
  38889. // Put the shadow behind all points
  38890. var shadowGroup = point.shadowGroup;
  38891. if (shadow && !shadowGroup) {
  38892. shadowGroup = point.shadowGroup = renderer
  38893. .g('shadow')
  38894. .add(series.shadowGroup);
  38895. }
  38896. if (shadowGroup) {
  38897. shadowGroup.attr(groupTranslation);
  38898. }
  38899. pointAttr = series.pointAttribs(point, (point.selected && 'select'));
  38900. }
  38901. // Draw the slice
  38902. if (!point.delayedRendering) {
  38903. graphic
  38904. .setRadialReference(series.center);
  38905. if (!chart.styledMode) {
  38906. merge(true, animateTo, pointAttr);
  38907. }
  38908. merge(true, animateTo, shapeArgs, groupTranslation);
  38909. graphic.animate(animateTo);
  38910. }
  38911. else {
  38912. graphic
  38913. .setRadialReference(series.center)
  38914. .attr(shapeArgs)
  38915. .attr(groupTranslation);
  38916. if (!chart.styledMode) {
  38917. graphic
  38918. .attr(pointAttr)
  38919. .attr({ 'stroke-linejoin': 'round' })
  38920. .shadow(shadow, shadowGroup);
  38921. }
  38922. point.delayedRendering = false;
  38923. }
  38924. graphic.attr({
  38925. visibility: point.visible ? 'inherit' : 'hidden'
  38926. });
  38927. graphic.addClass(point.getClassName());
  38928. }
  38929. else if (graphic) {
  38930. point.graphic = graphic.destroy();
  38931. }
  38932. });
  38933. },
  38934. /**
  38935. * Slices in pie chart are initialized in DOM, but it's shapes and
  38936. * animations are normally run in `drawPoints()`.
  38937. * @private
  38938. */
  38939. drawPoints: function () {
  38940. var renderer = this.chart.renderer;
  38941. this.points.forEach(function (point) {
  38942. // When updating a series between 2d and 3d or cartesian and
  38943. // polar, the shape type changes.
  38944. if (point.graphic && point.hasNewShapeType()) {
  38945. point.graphic = point.graphic.destroy();
  38946. }
  38947. if (!point.graphic) {
  38948. point.graphic = renderer[point.shapeType](point.shapeArgs)
  38949. .add(point.series.group);
  38950. point.delayedRendering = true;
  38951. }
  38952. });
  38953. },
  38954. /**
  38955. * @private
  38956. * @deprecated
  38957. * @function Highcharts.seriesTypes.pie#searchPoint
  38958. */
  38959. searchPoint: noop,
  38960. /**
  38961. * Utility for sorting data labels
  38962. *
  38963. * @private
  38964. * @function Highcharts.seriesTypes.pie#sortByAngle
  38965. * @param {Array<Highcharts.Point>} points
  38966. * @param {number} sign
  38967. * @return {void}
  38968. */
  38969. sortByAngle: function (points, sign) {
  38970. points.sort(function (a, b) {
  38971. return ((typeof a.angle !== 'undefined') &&
  38972. (b.angle - a.angle) * sign);
  38973. });
  38974. },
  38975. /**
  38976. * Use a simple symbol from LegendSymbolMixin.
  38977. *
  38978. * @private
  38979. * @borrows Highcharts.LegendSymbolMixin.drawRectangle as Highcharts.seriesTypes.pie#drawLegendSymbol
  38980. */
  38981. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  38982. /**
  38983. * Use the getCenter method from drawLegendSymbol.
  38984. *
  38985. * @private
  38986. * @borrows Highcharts.CenteredSeriesMixin.getCenter as Highcharts.seriesTypes.pie#getCenter
  38987. */
  38988. getCenter: CenteredSeriesMixin.getCenter,
  38989. /**
  38990. * Pies don't have point marker symbols.
  38991. *
  38992. * @deprecated
  38993. * @private
  38994. * @function Highcharts.seriesTypes.pie#getSymbol
  38995. */
  38996. getSymbol: noop,
  38997. /**
  38998. * @private
  38999. * @type {null}
  39000. */
  39001. drawGraph: null
  39002. },
  39003. /**
  39004. * @lends seriesTypes.pie.prototype.pointClass.prototype
  39005. */
  39006. {
  39007. /**
  39008. * Initialize the pie slice
  39009. *
  39010. * @private
  39011. * @function Highcharts.seriesTypes.pie#pointClass#init
  39012. * @return {Highcharts.Point}
  39013. */
  39014. init: function () {
  39015. Point.prototype.init.apply(this, arguments);
  39016. var point = this, toggleSlice;
  39017. point.name = pick(point.name, 'Slice');
  39018. // add event listener for select
  39019. toggleSlice = function (e) {
  39020. point.slice(e.type === 'select');
  39021. };
  39022. addEvent(point, 'select', toggleSlice);
  39023. addEvent(point, 'unselect', toggleSlice);
  39024. return point;
  39025. },
  39026. /**
  39027. * Negative points are not valid (#1530, #3623, #5322)
  39028. *
  39029. * @private
  39030. * @function Highcharts.seriesTypes.pie#pointClass#isValid
  39031. * @return {boolean}
  39032. */
  39033. isValid: function () {
  39034. return isNumber(this.y) && this.y >= 0;
  39035. },
  39036. /**
  39037. * Toggle the visibility of the pie slice
  39038. *
  39039. * @private
  39040. * @function Highcharts.seriesTypes.pie#pointClass#setVisible
  39041. * @param {boolean} vis
  39042. * Whether to show the slice or not. If undefined, the visibility
  39043. * is toggled.
  39044. * @param {boolean} [redraw=false]
  39045. * @return {void}
  39046. */
  39047. setVisible: function (vis, redraw) {
  39048. var point = this, series = point.series, chart = series.chart, ignoreHiddenPoint = series.options.ignoreHiddenPoint;
  39049. redraw = pick(redraw, ignoreHiddenPoint);
  39050. if (vis !== point.visible) {
  39051. // If called without an argument, toggle visibility
  39052. point.visible = point.options.visible = vis =
  39053. typeof vis === 'undefined' ? !point.visible : vis;
  39054. // update userOptions.data
  39055. series.options.data[series.data.indexOf(point)] =
  39056. point.options;
  39057. // Show and hide associated elements. This is performed
  39058. // regardless of redraw or not, because chart.redraw only
  39059. // handles full series.
  39060. ['graphic', 'dataLabel', 'connector', 'shadowGroup'].forEach(function (key) {
  39061. if (point[key]) {
  39062. point[key][vis ? 'show' : 'hide'](true);
  39063. }
  39064. });
  39065. if (point.legendItem) {
  39066. chart.legend.colorizeItem(point, vis);
  39067. }
  39068. // #4170, hide halo after hiding point
  39069. if (!vis && point.state === 'hover') {
  39070. point.setState('');
  39071. }
  39072. // Handle ignore hidden slices
  39073. if (ignoreHiddenPoint) {
  39074. series.isDirty = true;
  39075. }
  39076. if (redraw) {
  39077. chart.redraw();
  39078. }
  39079. }
  39080. },
  39081. /**
  39082. * Set or toggle whether the slice is cut out from the pie
  39083. *
  39084. * @private
  39085. * @function Highcharts.seriesTypes.pie#pointClass#slice
  39086. * @param {boolean} sliced
  39087. * When undefined, the slice state is toggled.
  39088. * @param {boolean} redraw
  39089. * Whether to redraw the chart. True by default.
  39090. * @param {boolean|Highcharts.AnimationOptionsObject}
  39091. * Animation options.
  39092. * @return {void}
  39093. */
  39094. slice: function (sliced, redraw, animation) {
  39095. var point = this, series = point.series, chart = series.chart;
  39096. setAnimation(animation, chart);
  39097. // redraw is true by default
  39098. redraw = pick(redraw, true);
  39099. /**
  39100. * Pie series only. Whether to display a slice offset from the
  39101. * center.
  39102. * @name Highcharts.Point#sliced
  39103. * @type {boolean|undefined}
  39104. */
  39105. // if called without an argument, toggle
  39106. point.sliced = point.options.sliced = sliced =
  39107. defined(sliced) ? sliced : !point.sliced;
  39108. // update userOptions.data
  39109. series.options.data[series.data.indexOf(point)] =
  39110. point.options;
  39111. if (point.graphic) {
  39112. point.graphic.animate(this.getTranslate());
  39113. }
  39114. if (point.shadowGroup) {
  39115. point.shadowGroup.animate(this.getTranslate());
  39116. }
  39117. },
  39118. /**
  39119. * @private
  39120. * @function Highcharts.seriesTypes.pie#pointClass#getTranslate
  39121. * @return {Highcharts.TranslationAttributes}
  39122. */
  39123. getTranslate: function () {
  39124. return this.sliced ? this.slicedTranslation : {
  39125. translateX: 0,
  39126. translateY: 0
  39127. };
  39128. },
  39129. /**
  39130. * @private
  39131. * @function Highcharts.seriesTypes.pie#pointClass#haloPath
  39132. * @param {number} size
  39133. * @return {Highcharts.SVGPathArray}
  39134. */
  39135. haloPath: function (size) {
  39136. var shapeArgs = this.shapeArgs;
  39137. return this.sliced || !this.visible ?
  39138. [] :
  39139. this.series.chart.renderer.symbols.arc(shapeArgs.x, shapeArgs.y, shapeArgs.r + size, shapeArgs.r + size, {
  39140. // Substract 1px to ensure the background is not bleeding
  39141. // through between the halo and the slice (#7495).
  39142. innerR: shapeArgs.r - 1,
  39143. start: shapeArgs.start,
  39144. end: shapeArgs.end
  39145. });
  39146. },
  39147. connectorShapes: {
  39148. // only one available before v7.0.0
  39149. fixedOffset: function (labelPosition, connectorPosition, options) {
  39150. var breakAt = connectorPosition.breakAt, touchingSliceAt = connectorPosition.touchingSliceAt, lineSegment = options.softConnector ? [
  39151. 'C',
  39152. // 1st control point (of the curve)
  39153. labelPosition.x +
  39154. // 5 gives the connector a little horizontal bend
  39155. (labelPosition.alignment === 'left' ? -5 : 5),
  39156. labelPosition.y,
  39157. 2 * breakAt.x - touchingSliceAt.x,
  39158. 2 * breakAt.y - touchingSliceAt.y,
  39159. breakAt.x,
  39160. breakAt.y //
  39161. ] : [
  39162. 'L',
  39163. breakAt.x,
  39164. breakAt.y
  39165. ];
  39166. // assemble the path
  39167. return ([
  39168. ['M', labelPosition.x, labelPosition.y],
  39169. lineSegment,
  39170. ['L', touchingSliceAt.x, touchingSliceAt.y]
  39171. ]);
  39172. },
  39173. straight: function (labelPosition, connectorPosition) {
  39174. var touchingSliceAt = connectorPosition.touchingSliceAt;
  39175. // direct line to the slice
  39176. return [
  39177. ['M', labelPosition.x, labelPosition.y],
  39178. ['L', touchingSliceAt.x, touchingSliceAt.y]
  39179. ];
  39180. },
  39181. crookedLine: function (labelPosition, connectorPosition, options) {
  39182. var touchingSliceAt = connectorPosition.touchingSliceAt, series = this.series, pieCenterX = series.center[0], plotWidth = series.chart.plotWidth, plotLeft = series.chart.plotLeft, alignment = labelPosition.alignment, radius = this.shapeArgs.r, crookDistance = relativeLength(// % to fraction
  39183. options.crookDistance, 1), crookX = alignment === 'left' ?
  39184. pieCenterX + radius + (plotWidth + plotLeft -
  39185. pieCenterX - radius) * (1 - crookDistance) :
  39186. plotLeft + (pieCenterX - radius) * crookDistance, segmentWithCrook = [
  39187. 'L',
  39188. crookX,
  39189. labelPosition.y
  39190. ], useCrook = true;
  39191. // crookedLine formula doesn't make sense if the path overlaps
  39192. // the label - use straight line instead in that case
  39193. if (alignment === 'left' ?
  39194. (crookX > labelPosition.x || crookX < touchingSliceAt.x) :
  39195. (crookX < labelPosition.x || crookX > touchingSliceAt.x)) {
  39196. useCrook = false;
  39197. }
  39198. // assemble the path
  39199. var path = [
  39200. ['M', labelPosition.x, labelPosition.y]
  39201. ];
  39202. if (useCrook) {
  39203. path.push(segmentWithCrook);
  39204. }
  39205. path.push(['L', touchingSliceAt.x, touchingSliceAt.y]);
  39206. return path;
  39207. }
  39208. },
  39209. /**
  39210. * Extendable method for getting the path of the connector between the
  39211. * data label and the pie slice.
  39212. */
  39213. getConnectorPath: function () {
  39214. var labelPosition = this.labelPosition, options = this.series.options.dataLabels, connectorShape = options.connectorShape, predefinedShapes = this.connectorShapes;
  39215. // find out whether to use the predefined shape
  39216. if (predefinedShapes[connectorShape]) {
  39217. connectorShape = predefinedShapes[connectorShape];
  39218. }
  39219. return connectorShape.call(this, {
  39220. // pass simplified label position object for user's convenience
  39221. x: labelPosition.final.x,
  39222. y: labelPosition.final.y,
  39223. alignment: labelPosition.alignment
  39224. }, labelPosition.connectorPosition, options);
  39225. }
  39226. }
  39227. /* eslint-enable valid-jsdoc */
  39228. );
  39229. /**
  39230. * A `pie` series. If the [type](#series.pie.type) option is not specified,
  39231. * it is inherited from [chart.type](#chart.type).
  39232. *
  39233. * @extends series,plotOptions.pie
  39234. * @excluding dataParser, dataURL, stack, xAxis, yAxis, dataSorting, step
  39235. * @product highcharts
  39236. * @apioption series.pie
  39237. */
  39238. /**
  39239. * An array of data points for the series. For the `pie` series type,
  39240. * points can be given in the following ways:
  39241. *
  39242. * 1. An array of numerical values. In this case, the numerical values will be
  39243. * interpreted as `y` options. Example:
  39244. * ```js
  39245. * data: [0, 5, 3, 5]
  39246. * ```
  39247. *
  39248. * 2. An array of objects with named values. The following snippet shows only a
  39249. * few settings, see the complete options set below. If the total number of
  39250. * data points exceeds the series'
  39251. * [turboThreshold](#series.pie.turboThreshold),
  39252. * this option is not available.
  39253. * ```js
  39254. * data: [{
  39255. * y: 1,
  39256. * name: "Point2",
  39257. * color: "#00FF00"
  39258. * }, {
  39259. * y: 7,
  39260. * name: "Point1",
  39261. * color: "#FF00FF"
  39262. * }]
  39263. * ```
  39264. *
  39265. * @sample {highcharts} highcharts/chart/reflow-true/
  39266. * Numerical values
  39267. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  39268. * Arrays of numeric x and y
  39269. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  39270. * Arrays of datetime x and y
  39271. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  39272. * Arrays of point.name and y
  39273. * @sample {highcharts} highcharts/series/data-array-of-objects/
  39274. * Config objects
  39275. *
  39276. * @type {Array<number|Array<string,(number|null)>|null|*>}
  39277. * @extends series.line.data
  39278. * @excluding marker, x
  39279. * @product highcharts
  39280. * @apioption series.pie.data
  39281. */
  39282. /**
  39283. * @type {Highcharts.SeriesPieDataLabelsOptionsObject}
  39284. * @product highcharts
  39285. * @apioption series.pie.data.dataLabels
  39286. */
  39287. /**
  39288. * The sequential index of the data point in the legend.
  39289. *
  39290. * @type {number}
  39291. * @product highcharts
  39292. * @apioption series.pie.data.legendIndex
  39293. */
  39294. /**
  39295. * Whether to display a slice offset from the center.
  39296. *
  39297. * @sample {highcharts} highcharts/point/sliced/
  39298. * One sliced point
  39299. *
  39300. * @type {boolean}
  39301. * @product highcharts
  39302. * @apioption series.pie.data.sliced
  39303. */
  39304. /**
  39305. * @excluding legendItemClick
  39306. * @product highcharts
  39307. * @apioption series.pie.events
  39308. */
  39309. ''; // placeholder for transpiled doclets above
  39310. });
  39311. _registerModule(_modules, 'parts/DataLabels.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
  39312. /* *
  39313. *
  39314. * (c) 2010-2020 Torstein Honsi
  39315. *
  39316. * License: www.highcharts.com/license
  39317. *
  39318. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39319. *
  39320. * */
  39321. var noop = H.noop, seriesTypes = H.seriesTypes;
  39322. var animObject = U.animObject, arrayMax = U.arrayMax, clamp = U.clamp, defined = U.defined, extend = U.extend, fireEvent = U.fireEvent, format = U.format, isArray = U.isArray, merge = U.merge, objectEach = U.objectEach, pick = U.pick, relativeLength = U.relativeLength, splat = U.splat, stableSort = U.stableSort;
  39323. /**
  39324. * Callback JavaScript function to format the data label as a string. Note that
  39325. * if a `format` is defined, the format takes precedence and the formatter is
  39326. * ignored.
  39327. *
  39328. * @callback Highcharts.DataLabelsFormatterCallbackFunction
  39329. *
  39330. * @param {Highcharts.PointLabelObject} this
  39331. * Data label context to format
  39332. *
  39333. * @param {Highcharts.DataLabelsOptions} options
  39334. * [API options](/highcharts/plotOptions.series.dataLabels) of the data label
  39335. *
  39336. * @return {number|string|null|undefined}
  39337. * Formatted data label text
  39338. */
  39339. /**
  39340. * Values for handling data labels that flow outside the plot area.
  39341. *
  39342. * @typedef {"allow"|"justify"} Highcharts.DataLabelsOverflowValue
  39343. */
  39344. var Series = H.Series;
  39345. /* eslint-disable valid-jsdoc */
  39346. /**
  39347. * General distribution algorithm for distributing labels of differing size
  39348. * along a confined length in two dimensions. The algorithm takes an array of
  39349. * objects containing a size, a target and a rank. It will place the labels as
  39350. * close as possible to their targets, skipping the lowest ranked labels if
  39351. * necessary.
  39352. *
  39353. * @private
  39354. * @function Highcharts.distribute
  39355. * @param {Highcharts.DataLabelsBoxArray} boxes
  39356. * @param {number} len
  39357. * @param {number} [maxDistance]
  39358. * @return {void}
  39359. */
  39360. H.distribute = function (boxes, len, maxDistance) {
  39361. var i, overlapping = true, origBoxes = boxes, // Original array will be altered with added .pos
  39362. restBoxes = [], // The outranked overshoot
  39363. box, target, total = 0, reducedLen = origBoxes.reducedLen || len;
  39364. /**
  39365. * @private
  39366. */
  39367. function sortByTarget(a, b) {
  39368. return a.target - b.target;
  39369. }
  39370. // If the total size exceeds the len, remove those boxes with the lowest
  39371. // rank
  39372. i = boxes.length;
  39373. while (i--) {
  39374. total += boxes[i].size;
  39375. }
  39376. // Sort by rank, then slice away overshoot
  39377. if (total > reducedLen) {
  39378. stableSort(boxes, function (a, b) {
  39379. return (b.rank || 0) - (a.rank || 0);
  39380. });
  39381. i = 0;
  39382. total = 0;
  39383. while (total <= reducedLen) {
  39384. total += boxes[i].size;
  39385. i++;
  39386. }
  39387. restBoxes = boxes.splice(i - 1, boxes.length);
  39388. }
  39389. // Order by target
  39390. stableSort(boxes, sortByTarget);
  39391. // So far we have been mutating the original array. Now
  39392. // create a copy with target arrays
  39393. boxes = boxes.map(function (box) {
  39394. return {
  39395. size: box.size,
  39396. targets: [box.target],
  39397. align: pick(box.align, 0.5)
  39398. };
  39399. });
  39400. while (overlapping) {
  39401. // Initial positions: target centered in box
  39402. i = boxes.length;
  39403. while (i--) {
  39404. box = boxes[i];
  39405. // Composite box, average of targets
  39406. target = (Math.min.apply(0, box.targets) +
  39407. Math.max.apply(0, box.targets)) / 2;
  39408. box.pos = clamp(target - box.size * box.align, 0, len - box.size);
  39409. }
  39410. // Detect overlap and join boxes
  39411. i = boxes.length;
  39412. overlapping = false;
  39413. while (i--) {
  39414. // Overlap
  39415. if (i > 0 &&
  39416. boxes[i - 1].pos + boxes[i - 1].size >
  39417. boxes[i].pos) {
  39418. // Add this size to the previous box
  39419. boxes[i - 1].size += boxes[i].size;
  39420. boxes[i - 1].targets = boxes[i - 1]
  39421. .targets
  39422. .concat(boxes[i].targets);
  39423. boxes[i - 1].align = 0.5;
  39424. // Overlapping right, push left
  39425. if (boxes[i - 1].pos + boxes[i - 1].size > len) {
  39426. boxes[i - 1].pos = len - boxes[i - 1].size;
  39427. }
  39428. boxes.splice(i, 1); // Remove this item
  39429. overlapping = true;
  39430. }
  39431. }
  39432. }
  39433. // Add the rest (hidden boxes)
  39434. origBoxes.push.apply(origBoxes, restBoxes);
  39435. // Now the composite boxes are placed, we need to put the original boxes
  39436. // within them
  39437. i = 0;
  39438. boxes.some(function (box) {
  39439. var posInCompositeBox = 0;
  39440. if (box.targets.some(function () {
  39441. origBoxes[i].pos = box.pos + posInCompositeBox;
  39442. // If the distance between the position and the target exceeds
  39443. // maxDistance, abort the loop and decrease the length in increments
  39444. // of 10% to recursively reduce the number of visible boxes by
  39445. // rank. Once all boxes are within the maxDistance, we're good.
  39446. if (typeof maxDistance !== 'undefined' &&
  39447. Math.abs(origBoxes[i].pos - origBoxes[i].target) > maxDistance) {
  39448. // Reset the positions that are already set
  39449. origBoxes.slice(0, i + 1).forEach(function (box) {
  39450. delete box.pos;
  39451. });
  39452. // Try with a smaller length
  39453. origBoxes.reducedLen =
  39454. (origBoxes.reducedLen || len) - (len * 0.1);
  39455. // Recurse
  39456. if (origBoxes.reducedLen > len * 0.1) {
  39457. H.distribute(origBoxes, len, maxDistance);
  39458. }
  39459. // Exceeded maxDistance => abort
  39460. return true;
  39461. }
  39462. posInCompositeBox += origBoxes[i].size;
  39463. i++;
  39464. })) {
  39465. // Exceeded maxDistance => abort
  39466. return true;
  39467. }
  39468. });
  39469. // Add the rest (hidden) boxes and sort by target
  39470. stableSort(origBoxes, sortByTarget);
  39471. };
  39472. /**
  39473. * Draw the data labels
  39474. *
  39475. * @private
  39476. * @function Highcharts.Series#drawDataLabels
  39477. * @return {void}
  39478. * @fires Highcharts.Series#event:afterDrawDataLabels
  39479. */
  39480. Series.prototype.drawDataLabels = function () {
  39481. var series = this, chart = series.chart, seriesOptions = series.options, seriesDlOptions = seriesOptions.dataLabels, points = series.points, pointOptions, hasRendered = series.hasRendered || 0, dataLabelsGroup, seriesAnimDuration = animObject(seriesOptions.animation).duration, fadeInDuration = Math.min(seriesAnimDuration, 200), defer = !chart.renderer.forExport && pick(seriesDlOptions.defer, fadeInDuration > 0), renderer = chart.renderer;
  39482. /**
  39483. * Handle the dataLabels.filter option.
  39484. * @private
  39485. */
  39486. function applyFilter(point, options) {
  39487. var filter = options.filter, op, prop, val;
  39488. if (filter) {
  39489. op = filter.operator;
  39490. prop = point[filter.property];
  39491. val = filter.value;
  39492. if ((op === '>' && prop > val) ||
  39493. (op === '<' && prop < val) ||
  39494. (op === '>=' && prop >= val) ||
  39495. (op === '<=' && prop <= val) ||
  39496. (op === '==' && prop == val) || // eslint-disable-line eqeqeq
  39497. (op === '===' && prop === val)) {
  39498. return true;
  39499. }
  39500. return false;
  39501. }
  39502. return true;
  39503. }
  39504. /**
  39505. * Merge two objects that can be arrays. If one of them is an array, the
  39506. * other is merged into each element. If both are arrays, each element is
  39507. * merged by index. If neither are arrays, we use normal merge.
  39508. * @private
  39509. */
  39510. function mergeArrays(one, two) {
  39511. var res = [], i;
  39512. if (isArray(one) && !isArray(two)) {
  39513. res = one.map(function (el) {
  39514. return merge(el, two);
  39515. });
  39516. }
  39517. else if (isArray(two) && !isArray(one)) {
  39518. res = two.map(function (el) {
  39519. return merge(one, el);
  39520. });
  39521. }
  39522. else if (!isArray(one) && !isArray(two)) {
  39523. res = merge(one, two);
  39524. }
  39525. else {
  39526. i = Math.max(one.length, two.length);
  39527. while (i--) {
  39528. res[i] = merge(one[i], two[i]);
  39529. }
  39530. }
  39531. return res;
  39532. }
  39533. // Merge in plotOptions.dataLabels for series
  39534. seriesDlOptions = mergeArrays(mergeArrays(chart.options.plotOptions &&
  39535. chart.options.plotOptions.series &&
  39536. chart.options.plotOptions.series.dataLabels, chart.options.plotOptions &&
  39537. chart.options.plotOptions[series.type] &&
  39538. chart.options.plotOptions[series.type].dataLabels), seriesDlOptions);
  39539. fireEvent(this, 'drawDataLabels');
  39540. if (isArray(seriesDlOptions) ||
  39541. seriesDlOptions.enabled ||
  39542. series._hasPointLabels) {
  39543. // Create a separate group for the data labels to avoid rotation
  39544. dataLabelsGroup = series.plotGroup('dataLabelsGroup', 'data-labels', defer && !hasRendered ? 'hidden' : 'inherit', // #5133, #10220
  39545. seriesDlOptions.zIndex || 6);
  39546. if (defer) {
  39547. dataLabelsGroup.attr({ opacity: +hasRendered }); // #3300
  39548. if (!hasRendered) {
  39549. setTimeout(function () {
  39550. var group = series.dataLabelsGroup;
  39551. if (group) {
  39552. if (series.visible) { // #2597, #3023, #3024
  39553. dataLabelsGroup.show(true);
  39554. }
  39555. group[seriesOptions.animation ? 'animate' : 'attr']({ opacity: 1 }, { duration: fadeInDuration });
  39556. }
  39557. }, seriesAnimDuration - fadeInDuration);
  39558. }
  39559. }
  39560. // Make the labels for each point
  39561. points.forEach(function (point) {
  39562. // Merge in series options for the point.
  39563. // @note dataLabelAttribs (like pointAttribs) would eradicate
  39564. // the need for dlOptions, and simplify the section below.
  39565. pointOptions = splat(mergeArrays(seriesDlOptions, point.dlOptions || // dlOptions is used in treemaps
  39566. (point.options && point.options.dataLabels)));
  39567. // Handle each individual data label for this point
  39568. pointOptions.forEach(function (labelOptions, i) {
  39569. // Options for one datalabel
  39570. var labelEnabled = (labelOptions.enabled &&
  39571. // #2282, #4641, #7112, #10049
  39572. (!point.isNull || point.dataLabelOnNull) &&
  39573. applyFilter(point, labelOptions)), labelConfig, formatString, labelText, style, rotation, attr, dataLabel = point.dataLabels ? point.dataLabels[i] :
  39574. point.dataLabel, connector = point.connectors ? point.connectors[i] :
  39575. point.connector, labelDistance = pick(labelOptions.distance, point.labelDistance), isNew = !dataLabel;
  39576. if (labelEnabled) {
  39577. // Create individual options structure that can be extended
  39578. // without affecting others
  39579. labelConfig = point.getLabelConfig();
  39580. formatString = pick(labelOptions[point.formatPrefix + 'Format'], labelOptions.format);
  39581. labelText = defined(formatString) ?
  39582. format(formatString, labelConfig, chart) :
  39583. (labelOptions[point.formatPrefix + 'Formatter'] ||
  39584. labelOptions.formatter).call(labelConfig, labelOptions);
  39585. style = labelOptions.style;
  39586. rotation = labelOptions.rotation;
  39587. if (!chart.styledMode) {
  39588. // Determine the color
  39589. style.color = pick(labelOptions.color, style.color, series.color, '#000000');
  39590. // Get automated contrast color
  39591. if (style.color === 'contrast') {
  39592. point.contrastColor = renderer.getContrast((point.color || series.color));
  39593. style.color = (!defined(labelDistance) &&
  39594. labelOptions.inside) ||
  39595. labelDistance < 0 ||
  39596. !!seriesOptions.stacking ?
  39597. point.contrastColor :
  39598. '#000000';
  39599. }
  39600. else {
  39601. delete point.contrastColor;
  39602. }
  39603. if (seriesOptions.cursor) {
  39604. style.cursor = seriesOptions.cursor;
  39605. }
  39606. }
  39607. attr = {
  39608. r: labelOptions.borderRadius || 0,
  39609. rotation: rotation,
  39610. padding: labelOptions.padding,
  39611. zIndex: 1
  39612. };
  39613. if (!chart.styledMode) {
  39614. attr.fill = labelOptions.backgroundColor;
  39615. attr.stroke = labelOptions.borderColor;
  39616. attr['stroke-width'] = labelOptions.borderWidth;
  39617. }
  39618. // Remove unused attributes (#947)
  39619. objectEach(attr, function (val, name) {
  39620. if (typeof val === 'undefined') {
  39621. delete attr[name];
  39622. }
  39623. });
  39624. }
  39625. // If the point is outside the plot area, destroy it. #678, #820
  39626. if (dataLabel && (!labelEnabled || !defined(labelText))) {
  39627. point.dataLabel =
  39628. point.dataLabel && point.dataLabel.destroy();
  39629. if (point.dataLabels) {
  39630. // Remove point.dataLabels if this was the last one
  39631. if (point.dataLabels.length === 1) {
  39632. delete point.dataLabels;
  39633. }
  39634. else {
  39635. delete point.dataLabels[i];
  39636. }
  39637. }
  39638. if (!i) {
  39639. delete point.dataLabel;
  39640. }
  39641. if (connector) {
  39642. point.connector = point.connector.destroy();
  39643. if (point.connectors) {
  39644. // Remove point.connectors if this was the last one
  39645. if (point.connectors.length === 1) {
  39646. delete point.connectors;
  39647. }
  39648. else {
  39649. delete point.connectors[i];
  39650. }
  39651. }
  39652. }
  39653. // Individual labels are disabled if the are explicitly disabled
  39654. // in the point options, or if they fall outside the plot area.
  39655. }
  39656. else if (labelEnabled && defined(labelText)) {
  39657. if (!dataLabel) {
  39658. // Create new label element
  39659. point.dataLabels = point.dataLabels || [];
  39660. dataLabel = point.dataLabels[i] = rotation ?
  39661. // Labels don't rotate, use text element
  39662. renderer.text(labelText, 0, -9999, labelOptions.useHTML)
  39663. .addClass('highcharts-data-label') :
  39664. // We can use label
  39665. renderer.label(labelText, 0, -9999, labelOptions.shape, null, null, labelOptions.useHTML, null, 'data-label');
  39666. // Store for backwards compatibility
  39667. if (!i) {
  39668. point.dataLabel = dataLabel;
  39669. }
  39670. dataLabel.addClass(' highcharts-data-label-color-' + point.colorIndex +
  39671. ' ' + (labelOptions.className || '') +
  39672. ( // #3398
  39673. labelOptions.useHTML ?
  39674. ' highcharts-tracker' :
  39675. ''));
  39676. }
  39677. else {
  39678. // Use old element and just update text
  39679. attr.text = labelText;
  39680. }
  39681. // Store data label options for later access
  39682. dataLabel.options = labelOptions;
  39683. dataLabel.attr(attr);
  39684. if (!chart.styledMode) {
  39685. // Styles must be applied before add in order to read
  39686. // text bounding box
  39687. dataLabel.css(style).shadow(labelOptions.shadow);
  39688. }
  39689. if (!dataLabel.added) {
  39690. dataLabel.add(dataLabelsGroup);
  39691. }
  39692. if (labelOptions.textPath && !labelOptions.useHTML) {
  39693. dataLabel.setTextPath((point.getDataLabelPath &&
  39694. point.getDataLabelPath(dataLabel)) || point.graphic, labelOptions.textPath);
  39695. if (point.dataLabelPath &&
  39696. !labelOptions.textPath.enabled) {
  39697. // clean the DOM
  39698. point.dataLabelPath = point.dataLabelPath.destroy();
  39699. }
  39700. }
  39701. // Now the data label is created and placed at 0,0, so we
  39702. // need to align it
  39703. series.alignDataLabel(point, dataLabel, labelOptions, null, isNew);
  39704. }
  39705. });
  39706. });
  39707. }
  39708. fireEvent(this, 'afterDrawDataLabels');
  39709. };
  39710. /**
  39711. * Align each individual data label.
  39712. *
  39713. * @private
  39714. * @function Highcharts.Series#alignDataLabel
  39715. * @param {Highcharts.Point} point
  39716. * @param {Highcharts.SVGElement} dataLabel
  39717. * @param {Highcharts.DataLabelsOptions} options
  39718. * @param {Highcharts.BBoxObject} alignTo
  39719. * @param {boolean} [isNew]
  39720. * @return {void}
  39721. */
  39722. Series.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  39723. var series = this, chart = this.chart, inverted = this.isCartesian && chart.inverted, enabledDataSorting = this.enabledDataSorting, plotX = pick(point.dlBox && point.dlBox.centerX, point.plotX, -9999), plotY = pick(point.plotY, -9999), bBox = dataLabel.getBBox(), baseline, rotation = options.rotation, normRotation, negRotation, align = options.align, rotCorr, // rotation correction
  39724. isInsidePlot = chart.isInsidePlot(plotX, Math.round(plotY), inverted),
  39725. // Math.round for rounding errors (#2683), alignTo to allow column
  39726. // labels (#2700)
  39727. alignAttr, // the final position;
  39728. justify = pick(options.overflow, (enabledDataSorting ? 'none' : 'justify')) === 'justify', visible = this.visible &&
  39729. point.visible !== false &&
  39730. (point.series.forceDL ||
  39731. (enabledDataSorting && !justify) ||
  39732. isInsidePlot ||
  39733. (
  39734. // If the data label is inside the align box, it is enough
  39735. // that parts of the align box is inside the plot area
  39736. // (#12370)
  39737. options.inside && alignTo && chart.isInsidePlot(plotX, inverted ?
  39738. alignTo.x + 1 :
  39739. alignTo.y + alignTo.height - 1, inverted))), setStartPos = function (alignOptions) {
  39740. if (enabledDataSorting && series.xAxis && !justify) {
  39741. series.setDataLabelStartPos(point, dataLabel, isNew, isInsidePlot, alignOptions);
  39742. }
  39743. };
  39744. if (visible) {
  39745. baseline = chart.renderer.fontMetrics(chart.styledMode ? void 0 : options.style.fontSize, dataLabel).b;
  39746. // The alignment box is a singular point
  39747. alignTo = extend({
  39748. x: inverted ? this.yAxis.len - plotY : plotX,
  39749. y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
  39750. width: 0,
  39751. height: 0
  39752. }, alignTo);
  39753. // Add the text size for alignment calculation
  39754. extend(options, {
  39755. width: bBox.width,
  39756. height: bBox.height
  39757. });
  39758. // Allow a hook for changing alignment in the last moment, then do the
  39759. // alignment
  39760. if (rotation) {
  39761. justify = false; // Not supported for rotated text
  39762. rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
  39763. alignAttr = {
  39764. x: (alignTo.x +
  39765. (options.x || 0) +
  39766. alignTo.width / 2 +
  39767. rotCorr.x),
  39768. y: (alignTo.y +
  39769. (options.y || 0) +
  39770. { top: 0, middle: 0.5, bottom: 1 }[options.verticalAlign] *
  39771. alignTo.height)
  39772. };
  39773. setStartPos(alignAttr); // data sorting
  39774. dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
  39775. .attr({
  39776. align: align
  39777. });
  39778. // Compensate for the rotated label sticking out on the sides
  39779. normRotation = (rotation + 720) % 360;
  39780. negRotation = normRotation > 180 && normRotation < 360;
  39781. if (align === 'left') {
  39782. alignAttr.y -= negRotation ? bBox.height : 0;
  39783. }
  39784. else if (align === 'center') {
  39785. alignAttr.x -= bBox.width / 2;
  39786. alignAttr.y -= bBox.height / 2;
  39787. }
  39788. else if (align === 'right') {
  39789. alignAttr.x -= bBox.width;
  39790. alignAttr.y -= negRotation ? 0 : bBox.height;
  39791. }
  39792. dataLabel.placed = true;
  39793. dataLabel.alignAttr = alignAttr;
  39794. }
  39795. else {
  39796. setStartPos(alignTo); // data sorting
  39797. dataLabel.align(options, null, alignTo);
  39798. alignAttr = dataLabel.alignAttr;
  39799. }
  39800. // Handle justify or crop
  39801. if (justify && alignTo.height >= 0) { // #8830
  39802. this.justifyDataLabel(dataLabel, options, alignAttr, bBox, alignTo, isNew);
  39803. // Now check that the data label is within the plot area
  39804. }
  39805. else if (pick(options.crop, true)) {
  39806. visible =
  39807. chart.isInsidePlot(alignAttr.x, alignAttr.y) &&
  39808. chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height);
  39809. }
  39810. // When we're using a shape, make it possible with a connector or an
  39811. // arrow pointing to thie point
  39812. if (options.shape && !rotation) {
  39813. dataLabel[isNew ? 'attr' : 'animate']({
  39814. anchorX: inverted ?
  39815. chart.plotWidth - point.plotY :
  39816. point.plotX,
  39817. anchorY: inverted ?
  39818. chart.plotHeight - point.plotX :
  39819. point.plotY
  39820. });
  39821. }
  39822. }
  39823. // To use alignAttr property in hideOverlappingLabels
  39824. if (isNew && enabledDataSorting) {
  39825. dataLabel.placed = false;
  39826. }
  39827. // Show or hide based on the final aligned position
  39828. if (!visible && (!enabledDataSorting || justify)) {
  39829. dataLabel.hide(true);
  39830. dataLabel.placed = false; // don't animate back in
  39831. }
  39832. };
  39833. /**
  39834. * Set starting position for data label sorting animation.
  39835. *
  39836. * @private
  39837. * @function Highcharts.Series#setDataLabelStartPos
  39838. * @param {Highcharts.SVGElement} dataLabel
  39839. * @param {Highcharts.ColumnPoint} point
  39840. * @param {boolean | undefined} [isNew]
  39841. * @param {boolean} [isInside]
  39842. * @param {Highcharts.AlignObject} [alignOptions]
  39843. *
  39844. * @return {void}
  39845. */
  39846. Series.prototype.setDataLabelStartPos = function (point, dataLabel, isNew, isInside, alignOptions) {
  39847. var chart = this.chart, inverted = chart.inverted, xAxis = this.xAxis, reversed = xAxis.reversed, labelCenter = inverted ? dataLabel.height / 2 : dataLabel.width / 2, pointWidth = point.pointWidth, halfWidth = pointWidth ? pointWidth / 2 : 0, startXPos, startYPos;
  39848. startXPos = inverted ?
  39849. alignOptions.x :
  39850. (reversed ?
  39851. -labelCenter - halfWidth :
  39852. xAxis.width - labelCenter + halfWidth);
  39853. startYPos = inverted ?
  39854. (reversed ?
  39855. this.yAxis.height - labelCenter + halfWidth :
  39856. -labelCenter - halfWidth) : alignOptions.y;
  39857. dataLabel.startXPos = startXPos;
  39858. dataLabel.startYPos = startYPos;
  39859. // We need to handle visibility in case of sorting point outside plot area
  39860. if (!isInside) {
  39861. dataLabel
  39862. .attr({ opacity: 1 })
  39863. .animate({ opacity: 0 }, void 0, dataLabel.hide);
  39864. }
  39865. else if (dataLabel.visibility === 'hidden') {
  39866. dataLabel.show();
  39867. dataLabel
  39868. .attr({ opacity: 0 })
  39869. .animate({ opacity: 1 });
  39870. }
  39871. // Save start position on first render, but do not change position
  39872. if (!chart.hasRendered) {
  39873. return;
  39874. }
  39875. // Set start position
  39876. if (isNew) {
  39877. dataLabel.attr({ x: dataLabel.startXPos, y: dataLabel.startYPos });
  39878. }
  39879. dataLabel.placed = true;
  39880. };
  39881. /**
  39882. * If data labels fall partly outside the plot area, align them back in, in a
  39883. * way that doesn't hide the point.
  39884. *
  39885. * @private
  39886. * @function Highcharts.Series#justifyDataLabel
  39887. * @param {Highcharts.SVGElement} dataLabel
  39888. * @param {Highcharts.DataLabelsOptions} options
  39889. * @param {Highcharts.SVGAttributes} alignAttr
  39890. * @param {Highcharts.BBoxObject} bBox
  39891. * @param {Highcharts.BBoxObject} [alignTo]
  39892. * @param {boolean} [isNew]
  39893. * @return {boolean|undefined}
  39894. */
  39895. Series.prototype.justifyDataLabel = function (dataLabel, options, alignAttr, bBox, alignTo, isNew) {
  39896. var chart = this.chart, align = options.align, verticalAlign = options.verticalAlign, off, justified, padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
  39897. var _a = options.x, x = _a === void 0 ? 0 : _a, _b = options.y, y = _b === void 0 ? 0 : _b;
  39898. // Off left
  39899. off = alignAttr.x + padding;
  39900. if (off < 0) {
  39901. if (align === 'right' && x >= 0) {
  39902. options.align = 'left';
  39903. options.inside = true;
  39904. }
  39905. else {
  39906. x -= off;
  39907. }
  39908. justified = true;
  39909. }
  39910. // Off right
  39911. off = alignAttr.x + bBox.width - padding;
  39912. if (off > chart.plotWidth) {
  39913. if (align === 'left' && x <= 0) {
  39914. options.align = 'right';
  39915. options.inside = true;
  39916. }
  39917. else {
  39918. x += chart.plotWidth - off;
  39919. }
  39920. justified = true;
  39921. }
  39922. // Off top
  39923. off = alignAttr.y + padding;
  39924. if (off < 0) {
  39925. if (verticalAlign === 'bottom' && y >= 0) {
  39926. options.verticalAlign = 'top';
  39927. options.inside = true;
  39928. }
  39929. else {
  39930. y -= off;
  39931. }
  39932. justified = true;
  39933. }
  39934. // Off bottom
  39935. off = alignAttr.y + bBox.height - padding;
  39936. if (off > chart.plotHeight) {
  39937. if (verticalAlign === 'top' && y <= 0) {
  39938. options.verticalAlign = 'bottom';
  39939. options.inside = true;
  39940. }
  39941. else {
  39942. y += chart.plotHeight - off;
  39943. }
  39944. justified = true;
  39945. }
  39946. if (justified) {
  39947. options.x = x;
  39948. options.y = y;
  39949. dataLabel.placed = !isNew;
  39950. dataLabel.align(options, void 0, alignTo);
  39951. }
  39952. return justified;
  39953. };
  39954. if (seriesTypes.pie) {
  39955. seriesTypes.pie.prototype.dataLabelPositioners = {
  39956. // Based on the value computed in Highcharts' distribute algorithm.
  39957. radialDistributionY: function (point) {
  39958. return point.top + point.distributeBox.pos;
  39959. },
  39960. // get the x - use the natural x position for labels near the
  39961. // top and bottom, to prevent the top and botton slice
  39962. // connectors from touching each other on either side
  39963. // Based on the value computed in Highcharts' distribute algorithm.
  39964. radialDistributionX: function (series, point, y, naturalY) {
  39965. return series.getX(y < point.top + 2 || y > point.bottom - 2 ?
  39966. naturalY :
  39967. y, point.half, point);
  39968. },
  39969. // dataLabels.distance determines the x position of the label
  39970. justify: function (point, radius, seriesCenter) {
  39971. return seriesCenter[0] + (point.half ? -1 : 1) *
  39972. (radius + point.labelDistance);
  39973. },
  39974. // Left edges of the left-half labels touch the left edge of the plot
  39975. // area. Right edges of the right-half labels touch the right edge of
  39976. // the plot area.
  39977. alignToPlotEdges: function (dataLabel, half, plotWidth, plotLeft) {
  39978. var dataLabelWidth = dataLabel.getBBox().width;
  39979. return half ? dataLabelWidth + plotLeft :
  39980. plotWidth - dataLabelWidth - plotLeft;
  39981. },
  39982. // Connectors of each side end in the same x position. Labels are
  39983. // aligned to them. Left edge of the widest left-half label touches the
  39984. // left edge of the plot area. Right edge of the widest right-half label
  39985. // touches the right edge of the plot area.
  39986. alignToConnectors: function (points, half, plotWidth, plotLeft) {
  39987. var maxDataLabelWidth = 0, dataLabelWidth;
  39988. // find widest data label
  39989. points.forEach(function (point) {
  39990. dataLabelWidth = point.dataLabel.getBBox().width;
  39991. if (dataLabelWidth > maxDataLabelWidth) {
  39992. maxDataLabelWidth = dataLabelWidth;
  39993. }
  39994. });
  39995. return half ? maxDataLabelWidth + plotLeft :
  39996. plotWidth - maxDataLabelWidth - plotLeft;
  39997. }
  39998. };
  39999. /**
  40000. * Override the base drawDataLabels method by pie specific functionality
  40001. *
  40002. * @private
  40003. * @function Highcharts.seriesTypes.pie#drawDataLabels
  40004. * @return {void}
  40005. */
  40006. seriesTypes.pie.prototype.drawDataLabels = function () {
  40007. var series = this, data = series.data, point, chart = series.chart, options = series.options.dataLabels || {}, connectorPadding = options.connectorPadding, connectorWidth, plotWidth = chart.plotWidth, plotHeight = chart.plotHeight, plotLeft = chart.plotLeft, maxWidth = Math.round(chart.chartWidth / 3), connector, seriesCenter = series.center, radius = seriesCenter[2] / 2, centerY = seriesCenter[1], dataLabel, dataLabelWidth,
  40008. // labelPos,
  40009. labelPosition, labelHeight,
  40010. // divide the points into right and left halves for anti collision
  40011. halves = [
  40012. [],
  40013. [] // left
  40014. ], x, y, visibility, j, overflow = [0, 0, 0, 0], // top, right, bottom, left
  40015. dataLabelPositioners = series.dataLabelPositioners, pointDataLabelsOptions;
  40016. // get out if not enabled
  40017. if (!series.visible ||
  40018. (!options.enabled &&
  40019. !series._hasPointLabels)) {
  40020. return;
  40021. }
  40022. // Reset all labels that have been shortened
  40023. data.forEach(function (point) {
  40024. if (point.dataLabel && point.visible && point.dataLabel.shortened) {
  40025. point.dataLabel
  40026. .attr({
  40027. width: 'auto'
  40028. }).css({
  40029. width: 'auto',
  40030. textOverflow: 'clip'
  40031. });
  40032. point.dataLabel.shortened = false;
  40033. }
  40034. });
  40035. // run parent method
  40036. Series.prototype.drawDataLabels.apply(series);
  40037. data.forEach(function (point) {
  40038. if (point.dataLabel) {
  40039. if (point.visible) { // #407, #2510
  40040. // Arrange points for detection collision
  40041. halves[point.half].push(point);
  40042. // Reset positions (#4905)
  40043. point.dataLabel._pos = null;
  40044. // Avoid long labels squeezing the pie size too far down
  40045. if (!defined(options.style.width) &&
  40046. !defined(point.options.dataLabels &&
  40047. point.options.dataLabels.style &&
  40048. point.options.dataLabels.style.width)) {
  40049. if (point.dataLabel.getBBox().width > maxWidth) {
  40050. point.dataLabel.css({
  40051. // Use a fraction of the maxWidth to avoid
  40052. // wrapping close to the end of the string.
  40053. width: Math.round(maxWidth * 0.7) + 'px'
  40054. });
  40055. point.dataLabel.shortened = true;
  40056. }
  40057. }
  40058. }
  40059. else {
  40060. point.dataLabel = point.dataLabel.destroy();
  40061. // Workaround to make pies destroy multiple datalabels
  40062. // correctly. This logic needs rewriting to support multiple
  40063. // datalabels fully.
  40064. if (point.dataLabels && point.dataLabels.length === 1) {
  40065. delete point.dataLabels;
  40066. }
  40067. }
  40068. }
  40069. });
  40070. /* Loop over the points in each half, starting from the top and bottom
  40071. * of the pie to detect overlapping labels.
  40072. */
  40073. halves.forEach(function (points, i) {
  40074. var top, bottom, length = points.length, positions = [], naturalY, sideOverflow, size, distributionLength;
  40075. if (!length) {
  40076. return;
  40077. }
  40078. // Sort by angle
  40079. series.sortByAngle(points, i - 0.5);
  40080. // Only do anti-collision when we have dataLabels outside the pie
  40081. // and have connectors. (#856)
  40082. if (series.maxLabelDistance > 0) {
  40083. top = Math.max(0, centerY - radius - series.maxLabelDistance);
  40084. bottom = Math.min(centerY + radius + series.maxLabelDistance, chart.plotHeight);
  40085. points.forEach(function (point) {
  40086. // check if specific points' label is outside the pie
  40087. if (point.labelDistance > 0 && point.dataLabel) {
  40088. // point.top depends on point.labelDistance value
  40089. // Used for calculation of y value in getX method
  40090. point.top = Math.max(0, centerY - radius - point.labelDistance);
  40091. point.bottom = Math.min(centerY + radius + point.labelDistance, chart.plotHeight);
  40092. size = point.dataLabel.getBBox().height || 21;
  40093. // point.positionsIndex is needed for getting index of
  40094. // parameter related to specific point inside positions
  40095. // array - not every point is in positions array.
  40096. point.distributeBox = {
  40097. target: point.labelPosition.natural.y -
  40098. point.top + size / 2,
  40099. size: size,
  40100. rank: point.y
  40101. };
  40102. positions.push(point.distributeBox);
  40103. }
  40104. });
  40105. distributionLength = bottom + size - top;
  40106. H.distribute(positions, distributionLength, distributionLength / 5);
  40107. }
  40108. // Now the used slots are sorted, fill them up sequentially
  40109. for (j = 0; j < length; j++) {
  40110. point = points[j];
  40111. // labelPos = point.labelPos;
  40112. labelPosition = point.labelPosition;
  40113. dataLabel = point.dataLabel;
  40114. visibility = point.visible === false ? 'hidden' : 'inherit';
  40115. naturalY = labelPosition.natural.y;
  40116. y = naturalY;
  40117. if (positions && defined(point.distributeBox)) {
  40118. if (typeof point.distributeBox.pos === 'undefined') {
  40119. visibility = 'hidden';
  40120. }
  40121. else {
  40122. labelHeight = point.distributeBox.size;
  40123. // Find label's y position
  40124. y = dataLabelPositioners
  40125. .radialDistributionY(point);
  40126. }
  40127. }
  40128. // It is needed to delete point.positionIndex for
  40129. // dynamically added points etc.
  40130. delete point.positionIndex; // @todo unused
  40131. // Find label's x position
  40132. // justify is undocumented in the API - preserve support for it
  40133. if (options.justify) {
  40134. x = dataLabelPositioners.justify(point, radius, seriesCenter);
  40135. }
  40136. else {
  40137. switch (options.alignTo) {
  40138. case 'connectors':
  40139. x = dataLabelPositioners.alignToConnectors(points, i, plotWidth, plotLeft);
  40140. break;
  40141. case 'plotEdges':
  40142. x = dataLabelPositioners.alignToPlotEdges(dataLabel, i, plotWidth, plotLeft);
  40143. break;
  40144. default:
  40145. x = dataLabelPositioners.radialDistributionX(series, point, y, naturalY);
  40146. }
  40147. }
  40148. // Record the placement and visibility
  40149. dataLabel._attr = {
  40150. visibility: visibility,
  40151. align: labelPosition.alignment
  40152. };
  40153. pointDataLabelsOptions = point.options.dataLabels || {};
  40154. dataLabel._pos = {
  40155. x: (x +
  40156. pick(pointDataLabelsOptions.x, options.x) + // (#12985)
  40157. ({
  40158. left: connectorPadding,
  40159. right: -connectorPadding
  40160. }[labelPosition.alignment] || 0)),
  40161. // 10 is for the baseline (label vs text)
  40162. y: (y +
  40163. pick(pointDataLabelsOptions.y, options.y) - // (#12985)
  40164. 10)
  40165. };
  40166. // labelPos.x = x;
  40167. // labelPos.y = y;
  40168. labelPosition.final.x = x;
  40169. labelPosition.final.y = y;
  40170. // Detect overflowing data labels
  40171. if (pick(options.crop, true)) {
  40172. dataLabelWidth = dataLabel.getBBox().width;
  40173. sideOverflow = null;
  40174. // Overflow left
  40175. if (x - dataLabelWidth < connectorPadding &&
  40176. i === 1 // left half
  40177. ) {
  40178. sideOverflow = Math.round(dataLabelWidth - x + connectorPadding);
  40179. overflow[3] = Math.max(sideOverflow, overflow[3]);
  40180. // Overflow right
  40181. }
  40182. else if (x + dataLabelWidth > plotWidth - connectorPadding &&
  40183. i === 0 // right half
  40184. ) {
  40185. sideOverflow = Math.round(x + dataLabelWidth - plotWidth + connectorPadding);
  40186. overflow[1] = Math.max(sideOverflow, overflow[1]);
  40187. }
  40188. // Overflow top
  40189. if (y - labelHeight / 2 < 0) {
  40190. overflow[0] = Math.max(Math.round(-y + labelHeight / 2), overflow[0]);
  40191. // Overflow left
  40192. }
  40193. else if (y + labelHeight / 2 > plotHeight) {
  40194. overflow[2] = Math.max(Math.round(y + labelHeight / 2 - plotHeight), overflow[2]);
  40195. }
  40196. dataLabel.sideOverflow = sideOverflow;
  40197. }
  40198. } // for each point
  40199. }); // for each half
  40200. // Do not apply the final placement and draw the connectors until we
  40201. // have verified that labels are not spilling over.
  40202. if (arrayMax(overflow) === 0 ||
  40203. this.verifyDataLabelOverflow(overflow)) {
  40204. // Place the labels in the final position
  40205. this.placeDataLabels();
  40206. this.points.forEach(function (point) {
  40207. // #8864: every connector can have individual options
  40208. pointDataLabelsOptions =
  40209. merge(options, point.options.dataLabels);
  40210. connectorWidth =
  40211. pick(pointDataLabelsOptions.connectorWidth, 1);
  40212. // Draw the connector
  40213. if (connectorWidth) {
  40214. var isNew;
  40215. connector = point.connector;
  40216. dataLabel = point.dataLabel;
  40217. if (dataLabel &&
  40218. dataLabel._pos &&
  40219. point.visible &&
  40220. point.labelDistance > 0) {
  40221. visibility = dataLabel._attr.visibility;
  40222. isNew = !connector;
  40223. if (isNew) {
  40224. point.connector = connector = chart.renderer
  40225. .path()
  40226. .addClass('highcharts-data-label-connector ' +
  40227. ' highcharts-color-' + point.colorIndex +
  40228. (point.className ?
  40229. ' ' + point.className :
  40230. ''))
  40231. .add(series.dataLabelsGroup);
  40232. if (!chart.styledMode) {
  40233. connector.attr({
  40234. 'stroke-width': connectorWidth,
  40235. 'stroke': (pointDataLabelsOptions.connectorColor ||
  40236. point.color ||
  40237. '#666666')
  40238. });
  40239. }
  40240. }
  40241. connector[isNew ? 'attr' : 'animate']({
  40242. d: point.getConnectorPath()
  40243. });
  40244. connector.attr('visibility', visibility);
  40245. }
  40246. else if (connector) {
  40247. point.connector = connector.destroy();
  40248. }
  40249. }
  40250. });
  40251. }
  40252. };
  40253. /**
  40254. * Extendable method for getting the path of the connector between the data
  40255. * label and the pie slice.
  40256. *
  40257. * @private
  40258. * @function Highcharts.seriesTypes.pie#connectorPath
  40259. *
  40260. * @param {*} labelPos
  40261. *
  40262. * @return {Highcharts.SVGPathArray}
  40263. */
  40264. // TODO: depracated - remove it
  40265. /*
  40266. seriesTypes.pie.prototype.connectorPath = function (labelPos) {
  40267. var x = labelPos.x,
  40268. y = labelPos.y;
  40269. return pick(this.options.dataLabels.softConnector, true) ? [
  40270. 'M',
  40271. // end of the string at the label
  40272. x + (labelPos[6] === 'left' ? 5 : -5), y,
  40273. 'C',
  40274. x, y, // first break, next to the label
  40275. 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
  40276. labelPos[2], labelPos[3], // second break
  40277. 'L',
  40278. labelPos[4], labelPos[5] // base
  40279. ] : [
  40280. 'M',
  40281. // end of the string at the label
  40282. x + (labelPos[6] === 'left' ? 5 : -5), y,
  40283. 'L',
  40284. labelPos[2], labelPos[3], // second break
  40285. 'L',
  40286. labelPos[4], labelPos[5] // base
  40287. ];
  40288. };
  40289. */
  40290. /**
  40291. * Perform the final placement of the data labels after we have verified
  40292. * that they fall within the plot area.
  40293. *
  40294. * @private
  40295. * @function Highcharts.seriesTypes.pie#placeDataLabels
  40296. * @return {void}
  40297. */
  40298. seriesTypes.pie.prototype.placeDataLabels = function () {
  40299. this.points.forEach(function (point) {
  40300. var dataLabel = point.dataLabel, _pos;
  40301. if (dataLabel && point.visible) {
  40302. _pos = dataLabel._pos;
  40303. if (_pos) {
  40304. // Shorten data labels with ellipsis if they still overflow
  40305. // after the pie has reached minSize (#223).
  40306. if (dataLabel.sideOverflow) {
  40307. dataLabel._attr.width =
  40308. Math.max(dataLabel.getBBox().width -
  40309. dataLabel.sideOverflow, 0);
  40310. dataLabel.css({
  40311. width: dataLabel._attr.width + 'px',
  40312. textOverflow: ((this.options.dataLabels.style || {})
  40313. .textOverflow ||
  40314. 'ellipsis')
  40315. });
  40316. dataLabel.shortened = true;
  40317. }
  40318. dataLabel.attr(dataLabel._attr);
  40319. dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
  40320. dataLabel.moved = true;
  40321. }
  40322. else if (dataLabel) {
  40323. dataLabel.attr({ y: -9999 });
  40324. }
  40325. }
  40326. // Clear for update
  40327. delete point.distributeBox;
  40328. }, this);
  40329. };
  40330. seriesTypes.pie.prototype.alignDataLabel = noop;
  40331. /**
  40332. * Verify whether the data labels are allowed to draw, or we should run more
  40333. * translation and data label positioning to keep them inside the plot area.
  40334. * Returns true when data labels are ready to draw.
  40335. *
  40336. * @private
  40337. * @function Highcharts.seriesTypes.pie#verifyDataLabelOverflow
  40338. * @param {Array<number>} overflow
  40339. * @return {boolean}
  40340. */
  40341. seriesTypes.pie.prototype.verifyDataLabelOverflow = function (overflow) {
  40342. var center = this.center, options = this.options, centerOption = options.center, minSize = options.minSize || 80, newSize = minSize,
  40343. // If a size is set, return true and don't try to shrink the pie
  40344. // to fit the labels.
  40345. ret = options.size !== null;
  40346. if (!ret) {
  40347. // Handle horizontal size and center
  40348. if (centerOption[0] !== null) { // Fixed center
  40349. newSize = Math.max(center[2] -
  40350. Math.max(overflow[1], overflow[3]), minSize);
  40351. }
  40352. else { // Auto center
  40353. newSize = Math.max(
  40354. // horizontal overflow
  40355. center[2] - overflow[1] - overflow[3], minSize);
  40356. // horizontal center
  40357. center[0] += (overflow[3] - overflow[1]) / 2;
  40358. }
  40359. // Handle vertical size and center
  40360. if (centerOption[1] !== null) { // Fixed center
  40361. newSize = clamp(newSize, minSize, center[2] - Math.max(overflow[0], overflow[2]));
  40362. }
  40363. else { // Auto center
  40364. newSize = clamp(newSize, minSize,
  40365. // vertical overflow
  40366. center[2] - overflow[0] - overflow[2]);
  40367. // vertical center
  40368. center[1] += (overflow[0] - overflow[2]) / 2;
  40369. }
  40370. // If the size must be decreased, we need to run translate and
  40371. // drawDataLabels again
  40372. if (newSize < center[2]) {
  40373. center[2] = newSize;
  40374. center[3] = Math.min(// #3632
  40375. relativeLength(options.innerSize || 0, newSize), newSize);
  40376. this.translate(center);
  40377. if (this.drawDataLabels) {
  40378. this.drawDataLabels();
  40379. }
  40380. // Else, return true to indicate that the pie and its labels is
  40381. // within the plot area
  40382. }
  40383. else {
  40384. ret = true;
  40385. }
  40386. }
  40387. return ret;
  40388. };
  40389. }
  40390. if (seriesTypes.column) {
  40391. /**
  40392. * Override the basic data label alignment by adjusting for the position of
  40393. * the column.
  40394. *
  40395. * @private
  40396. * @function Highcharts.seriesTypes.column#alignDataLabel
  40397. * @param {Highcharts.Point} point
  40398. * @param {Highcharts.SVGElement} dataLabel
  40399. * @param {Highcharts.DataLabelsOptions} options
  40400. * @param {Highcharts.BBoxObject} alignTo
  40401. * @param {boolean} [isNew]
  40402. * @return {void}
  40403. */
  40404. seriesTypes.column.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  40405. var inverted = this.chart.inverted, series = point.series,
  40406. // data label box for alignment
  40407. dlBox = point.dlBox || point.shapeArgs, below = pick(point.below, // range series
  40408. point.plotY >
  40409. pick(this.translatedThreshold, series.yAxis.len)),
  40410. // draw it inside the box?
  40411. inside = pick(options.inside, !!this.options.stacking), overshoot;
  40412. // Align to the column itself, or the top of it
  40413. if (dlBox) { // Area range uses this method but not alignTo
  40414. alignTo = merge(dlBox);
  40415. if (alignTo.y < 0) {
  40416. alignTo.height += alignTo.y;
  40417. alignTo.y = 0;
  40418. }
  40419. // If parts of the box overshoots outside the plot area, modify the
  40420. // box to center the label inside
  40421. overshoot = alignTo.y + alignTo.height - series.yAxis.len;
  40422. if (overshoot > 0 && overshoot < alignTo.height) {
  40423. alignTo.height -= overshoot;
  40424. }
  40425. if (inverted) {
  40426. alignTo = {
  40427. x: series.yAxis.len - alignTo.y - alignTo.height,
  40428. y: series.xAxis.len - alignTo.x - alignTo.width,
  40429. width: alignTo.height,
  40430. height: alignTo.width
  40431. };
  40432. }
  40433. // Compute the alignment box
  40434. if (!inside) {
  40435. if (inverted) {
  40436. alignTo.x += below ? 0 : alignTo.width;
  40437. alignTo.width = 0;
  40438. }
  40439. else {
  40440. alignTo.y += below ? alignTo.height : 0;
  40441. alignTo.height = 0;
  40442. }
  40443. }
  40444. }
  40445. // When alignment is undefined (typically columns and bars), display the
  40446. // individual point below or above the point depending on the threshold
  40447. options.align = pick(options.align, !inverted || inside ? 'center' : below ? 'right' : 'left');
  40448. options.verticalAlign = pick(options.verticalAlign, inverted || inside ? 'middle' : below ? 'top' : 'bottom');
  40449. // Call the parent method
  40450. Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
  40451. // If label was justified and we have contrast, set it:
  40452. if (options.inside && point.contrastColor) {
  40453. dataLabel.css({
  40454. color: point.contrastColor
  40455. });
  40456. }
  40457. };
  40458. }
  40459. });
  40460. _registerModule(_modules, 'modules/overlapping-datalabels.src.js', [_modules['parts/Chart.js'], _modules['parts/Utilities.js']], function (Chart, U) {
  40461. /* *
  40462. *
  40463. * Highcharts module to hide overlapping data labels.
  40464. * This module is included in Highcharts.
  40465. *
  40466. * (c) 2009-2020 Torstein Honsi
  40467. *
  40468. * License: www.highcharts.com/license
  40469. *
  40470. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40471. *
  40472. * */
  40473. var addEvent = U.addEvent, fireEvent = U.fireEvent, isArray = U.isArray, isNumber = U.isNumber, objectEach = U.objectEach, pick = U.pick;
  40474. /* eslint-disable no-invalid-this */
  40475. // Collect potensial overlapping data labels. Stack labels probably don't need
  40476. // to be considered because they are usually accompanied by data labels that lie
  40477. // inside the columns.
  40478. addEvent(Chart, 'render', function collectAndHide() {
  40479. var labels = [];
  40480. // Consider external label collectors
  40481. (this.labelCollectors || []).forEach(function (collector) {
  40482. labels = labels.concat(collector());
  40483. });
  40484. (this.yAxis || []).forEach(function (yAxis) {
  40485. if (yAxis.stacking &&
  40486. yAxis.options.stackLabels &&
  40487. !yAxis.options.stackLabels.allowOverlap) {
  40488. objectEach(yAxis.stacking.stacks, function (stack) {
  40489. objectEach(stack, function (stackItem) {
  40490. labels.push(stackItem.label);
  40491. });
  40492. });
  40493. }
  40494. });
  40495. (this.series || []).forEach(function (series) {
  40496. var dlOptions = series.options.dataLabels;
  40497. if (series.visible &&
  40498. !(dlOptions.enabled === false && !series._hasPointLabels)) { // #3866
  40499. (series.nodes || series.points).forEach(function (point) {
  40500. if (point.visible) {
  40501. var dataLabels = (isArray(point.dataLabels) ?
  40502. point.dataLabels :
  40503. (point.dataLabel ? [point.dataLabel] : []));
  40504. dataLabels.forEach(function (label) {
  40505. var options = label.options;
  40506. label.labelrank = pick(options.labelrank, point.labelrank, point.shapeArgs && point.shapeArgs.height); // #4118
  40507. if (!options.allowOverlap) {
  40508. labels.push(label);
  40509. }
  40510. });
  40511. }
  40512. });
  40513. }
  40514. });
  40515. this.hideOverlappingLabels(labels);
  40516. });
  40517. /**
  40518. * Hide overlapping labels. Labels are moved and faded in and out on zoom to
  40519. * provide a smooth visual imression.
  40520. *
  40521. * @private
  40522. * @function Highcharts.Chart#hideOverlappingLabels
  40523. * @param {Array<Highcharts.SVGElement>} labels
  40524. * Rendered data labels
  40525. * @requires modules/overlapping-datalabels
  40526. */
  40527. Chart.prototype.hideOverlappingLabels = function (labels) {
  40528. var chart = this, len = labels.length, ren = chart.renderer, label, i, j, label1, label2, box1, box2, isLabelAffected = false, isIntersectRect = function (box1, box2) {
  40529. return !(box2.x > box1.x + box1.width ||
  40530. box2.x + box2.width < box1.x ||
  40531. box2.y > box1.y + box1.height ||
  40532. box2.y + box2.height < box1.y);
  40533. },
  40534. // Get the box with its position inside the chart, as opposed to getBBox
  40535. // that only reports the position relative to the parent.
  40536. getAbsoluteBox = function (label) {
  40537. var pos, parent, bBox,
  40538. // Substract the padding if no background or border (#4333)
  40539. padding = label.box ? 0 : (label.padding || 0), lineHeightCorrection = 0, xOffset = 0, boxWidth, alignValue;
  40540. if (label &&
  40541. (!label.alignAttr || label.placed)) {
  40542. pos = label.alignAttr || {
  40543. x: label.attr('x'),
  40544. y: label.attr('y')
  40545. };
  40546. parent = label.parentGroup;
  40547. // Get width and height if pure text nodes (stack labels)
  40548. if (!label.width) {
  40549. bBox = label.getBBox();
  40550. label.width = bBox.width;
  40551. label.height = bBox.height;
  40552. // Labels positions are computed from top left corner, so
  40553. // we need to substract the text height from text nodes too.
  40554. lineHeightCorrection = ren
  40555. .fontMetrics(null, label.element).h;
  40556. }
  40557. boxWidth = label.width - 2 * padding;
  40558. alignValue = {
  40559. left: '0',
  40560. center: '0.5',
  40561. right: '1'
  40562. }[label.alignValue];
  40563. if (alignValue) {
  40564. xOffset = +alignValue * boxWidth;
  40565. }
  40566. else if (isNumber(label.x) && Math.round(label.x) !== label.translateX) {
  40567. xOffset = label.x - label.translateX;
  40568. }
  40569. return {
  40570. x: pos.x + (parent.translateX || 0) + padding - xOffset,
  40571. y: pos.y + (parent.translateY || 0) + padding -
  40572. lineHeightCorrection,
  40573. width: label.width - 2 * padding,
  40574. height: label.height - 2 * padding
  40575. };
  40576. }
  40577. };
  40578. for (i = 0; i < len; i++) {
  40579. label = labels[i];
  40580. if (label) {
  40581. // Mark with initial opacity
  40582. label.oldOpacity = label.opacity;
  40583. label.newOpacity = 1;
  40584. label.absoluteBox = getAbsoluteBox(label);
  40585. }
  40586. }
  40587. // Prevent a situation in a gradually rising slope, that each label will
  40588. // hide the previous one because the previous one always has lower rank.
  40589. labels.sort(function (a, b) {
  40590. return (b.labelrank || 0) - (a.labelrank || 0);
  40591. });
  40592. // Detect overlapping labels
  40593. for (i = 0; i < len; i++) {
  40594. label1 = labels[i];
  40595. box1 = label1 && label1.absoluteBox;
  40596. for (j = i + 1; j < len; ++j) {
  40597. label2 = labels[j];
  40598. box2 = label2 && label2.absoluteBox;
  40599. if (box1 &&
  40600. box2 &&
  40601. label1 !== label2 && // #6465, polar chart with connectEnds
  40602. label1.newOpacity !== 0 &&
  40603. label2.newOpacity !== 0) {
  40604. if (isIntersectRect(box1, box2)) {
  40605. (label1.labelrank < label2.labelrank ? label1 : label2)
  40606. .newOpacity = 0;
  40607. }
  40608. }
  40609. }
  40610. }
  40611. // Hide or show
  40612. labels.forEach(function (label) {
  40613. var complete, newOpacity;
  40614. if (label) {
  40615. newOpacity = label.newOpacity;
  40616. if (label.oldOpacity !== newOpacity) {
  40617. // Make sure the label is completely hidden to avoid catching
  40618. // clicks (#4362)
  40619. if (label.alignAttr && label.placed) { // data labels
  40620. label[newOpacity ? 'removeClass' : 'addClass']('highcharts-data-label-hidden');
  40621. complete = function () {
  40622. if (!chart.styledMode) {
  40623. label.css({ pointerEvents: newOpacity ? 'auto' : 'none' });
  40624. }
  40625. label.visibility = newOpacity ? 'inherit' : 'hidden';
  40626. label.placed = !!newOpacity;
  40627. };
  40628. isLabelAffected = true;
  40629. // Animate or set the opacity
  40630. label.alignAttr.opacity = newOpacity;
  40631. label[label.isOld ? 'animate' : 'attr'](label.alignAttr, null, complete);
  40632. fireEvent(chart, 'afterHideOverlappingLabel');
  40633. }
  40634. else { // other labels, tick labels
  40635. label.attr({
  40636. opacity: newOpacity
  40637. });
  40638. }
  40639. }
  40640. label.isOld = true;
  40641. }
  40642. });
  40643. if (isLabelAffected) {
  40644. fireEvent(chart, 'afterHideAllOverlappingLabels');
  40645. }
  40646. };
  40647. });
  40648. _registerModule(_modules, 'parts/Interaction.js', [_modules['parts/Chart.js'], _modules['parts/Globals.js'], _modules['parts/Legend.js'], _modules['parts/Options.js'], _modules['parts/Point.js'], _modules['parts/Utilities.js']], function (Chart, H, Legend, O, Point, U) {
  40649. /* *
  40650. *
  40651. * (c) 2010-2020 Torstein Honsi
  40652. *
  40653. * License: www.highcharts.com/license
  40654. *
  40655. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40656. *
  40657. * */
  40658. var defaultOptions = O.defaultOptions;
  40659. var addEvent = U.addEvent, createElement = U.createElement, css = U.css, defined = U.defined, extend = U.extend, fireEvent = U.fireEvent, isArray = U.isArray, isFunction = U.isFunction, isNumber = U.isNumber, isObject = U.isObject, merge = U.merge, objectEach = U.objectEach, pick = U.pick;
  40660. /**
  40661. * @interface Highcharts.PointEventsOptionsObject
  40662. */ /**
  40663. * Fires when the point is selected either programmatically or following a click
  40664. * on the point. One parameter, `event`, is passed to the function. Returning
  40665. * `false` cancels the operation.
  40666. * @name Highcharts.PointEventsOptionsObject#select
  40667. * @type {Highcharts.PointSelectCallbackFunction|undefined}
  40668. */ /**
  40669. * Fires when the point is unselected either programmatically or following a
  40670. * click on the point. One parameter, `event`, is passed to the function.
  40671. * Returning `false` cancels the operation.
  40672. * @name Highcharts.PointEventsOptionsObject#unselect
  40673. * @type {Highcharts.PointUnselectCallbackFunction|undefined}
  40674. */
  40675. /**
  40676. * Information about the select/unselect event.
  40677. *
  40678. * @interface Highcharts.PointInteractionEventObject
  40679. * @extends global.Event
  40680. */ /**
  40681. * @name Highcharts.PointInteractionEventObject#accumulate
  40682. * @type {boolean}
  40683. */
  40684. /**
  40685. * Gets fired when the point is selected either programmatically or following a
  40686. * click on the point.
  40687. *
  40688. * @callback Highcharts.PointSelectCallbackFunction
  40689. *
  40690. * @param {Highcharts.Point} this
  40691. * Point where the event occured.
  40692. *
  40693. * @param {Highcharts.PointInteractionEventObject} event
  40694. * Event that occured.
  40695. */
  40696. /**
  40697. * Fires when the point is unselected either programmatically or following a
  40698. * click on the point.
  40699. *
  40700. * @callback Highcharts.PointUnselectCallbackFunction
  40701. *
  40702. * @param {Highcharts.Point} this
  40703. * Point where the event occured.
  40704. *
  40705. * @param {Highcharts.PointInteractionEventObject} event
  40706. * Event that occured.
  40707. */
  40708. var hasTouch = H.hasTouch, Series = H.Series, seriesTypes = H.seriesTypes, svg = H.svg, TrackerMixin;
  40709. /* eslint-disable valid-jsdoc */
  40710. /**
  40711. * TrackerMixin for points and graphs.
  40712. *
  40713. * @private
  40714. * @mixin Highcharts.TrackerMixin
  40715. */
  40716. TrackerMixin = H.TrackerMixin = {
  40717. /**
  40718. * Draw the tracker for a point.
  40719. *
  40720. * @private
  40721. * @function Highcharts.TrackerMixin.drawTrackerPoint
  40722. * @param {Highcharts.Series} this
  40723. * @fires Highcharts.Series#event:afterDrawTracker
  40724. */
  40725. drawTrackerPoint: function () {
  40726. var series = this, chart = series.chart, pointer = chart.pointer, onMouseOver = function (e) {
  40727. var point = pointer.getPointFromEvent(e);
  40728. // undefined on graph in scatterchart
  40729. if (typeof point !== 'undefined') {
  40730. pointer.isDirectTouch = true;
  40731. point.onMouseOver(e);
  40732. }
  40733. }, dataLabels;
  40734. // Add reference to the point
  40735. series.points.forEach(function (point) {
  40736. dataLabels = (isArray(point.dataLabels) ?
  40737. point.dataLabels :
  40738. (point.dataLabel ? [point.dataLabel] : []));
  40739. if (point.graphic) {
  40740. point.graphic.element.point = point;
  40741. }
  40742. dataLabels.forEach(function (dataLabel) {
  40743. if (dataLabel.div) {
  40744. dataLabel.div.point = point;
  40745. }
  40746. else {
  40747. dataLabel.element.point = point;
  40748. }
  40749. });
  40750. });
  40751. // Add the event listeners, we need to do this only once
  40752. if (!series._hasTracking) {
  40753. series.trackerGroups.forEach(function (key) {
  40754. if (series[key]) {
  40755. // we don't always have dataLabelsGroup
  40756. series[key]
  40757. .addClass('highcharts-tracker')
  40758. .on('mouseover', onMouseOver)
  40759. .on('mouseout', function (e) {
  40760. pointer.onTrackerMouseOut(e);
  40761. });
  40762. if (hasTouch) {
  40763. series[key].on('touchstart', onMouseOver);
  40764. }
  40765. if (!chart.styledMode && series.options.cursor) {
  40766. series[key]
  40767. .css(css)
  40768. .css({ cursor: series.options.cursor });
  40769. }
  40770. }
  40771. });
  40772. series._hasTracking = true;
  40773. }
  40774. fireEvent(this, 'afterDrawTracker');
  40775. },
  40776. /**
  40777. * Draw the tracker object that sits above all data labels and markers to
  40778. * track mouse events on the graph or points. For the line type charts
  40779. * the tracker uses the same graphPath, but with a greater stroke width
  40780. * for better control.
  40781. *
  40782. * @private
  40783. * @function Highcharts.TrackerMixin.drawTrackerGraph
  40784. * @param {Highcharts.Series} this
  40785. * @fires Highcharts.Series#event:afterDrawTracker
  40786. */
  40787. drawTrackerGraph: function () {
  40788. var series = this, options = series.options, trackByArea = options.trackByArea, trackerPath = [].concat(trackByArea ?
  40789. series.areaPath :
  40790. series.graphPath),
  40791. // trackerPathLength = trackerPath.length,
  40792. chart = series.chart, pointer = chart.pointer, renderer = chart.renderer, snap = chart.options.tooltip.snap, tracker = series.tracker, i, onMouseOver = function (e) {
  40793. if (chart.hoverSeries !== series) {
  40794. series.onMouseOver();
  40795. }
  40796. },
  40797. /*
  40798. * Empirical lowest possible opacities for TRACKER_FILL for an
  40799. * element to stay invisible but clickable
  40800. * IE6: 0.002
  40801. * IE7: 0.002
  40802. * IE8: 0.002
  40803. * IE9: 0.00000000001 (unlimited)
  40804. * IE10: 0.0001 (exporting only)
  40805. * FF: 0.00000000001 (unlimited)
  40806. * Chrome: 0.000001
  40807. * Safari: 0.000001
  40808. * Opera: 0.00000000001 (unlimited)
  40809. */
  40810. TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
  40811. // Draw the tracker
  40812. if (tracker) {
  40813. tracker.attr({ d: trackerPath });
  40814. }
  40815. else if (series.graph) { // create
  40816. series.tracker = renderer.path(trackerPath)
  40817. .attr({
  40818. visibility: series.visible ? 'visible' : 'hidden',
  40819. zIndex: 2
  40820. })
  40821. .addClass(trackByArea ?
  40822. 'highcharts-tracker-area' :
  40823. 'highcharts-tracker-line')
  40824. .add(series.group);
  40825. if (!chart.styledMode) {
  40826. series.tracker.attr({
  40827. 'stroke-linecap': 'round',
  40828. 'stroke-linejoin': 'round',
  40829. stroke: TRACKER_FILL,
  40830. fill: trackByArea ? TRACKER_FILL : 'none',
  40831. 'stroke-width': series.graph.strokeWidth() +
  40832. (trackByArea ? 0 : 2 * snap)
  40833. });
  40834. }
  40835. // The tracker is added to the series group, which is clipped, but
  40836. // is covered by the marker group. So the marker group also needs to
  40837. // capture events.
  40838. [series.tracker, series.markerGroup].forEach(function (tracker) {
  40839. tracker.addClass('highcharts-tracker')
  40840. .on('mouseover', onMouseOver)
  40841. .on('mouseout', function (e) {
  40842. pointer.onTrackerMouseOut(e);
  40843. });
  40844. if (options.cursor && !chart.styledMode) {
  40845. tracker.css({ cursor: options.cursor });
  40846. }
  40847. if (hasTouch) {
  40848. tracker.on('touchstart', onMouseOver);
  40849. }
  40850. });
  40851. }
  40852. fireEvent(this, 'afterDrawTracker');
  40853. }
  40854. };
  40855. /* End TrackerMixin */
  40856. // Add tracking event listener to the series group, so the point graphics
  40857. // themselves act as trackers
  40858. if (seriesTypes.column) {
  40859. /**
  40860. * @private
  40861. * @borrows Highcharts.TrackerMixin.drawTrackerPoint as Highcharts.seriesTypes.column#drawTracker
  40862. */
  40863. seriesTypes.column.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
  40864. }
  40865. if (seriesTypes.pie) {
  40866. /**
  40867. * @private
  40868. * @borrows Highcharts.TrackerMixin.drawTrackerPoint as Highcharts.seriesTypes.pie#drawTracker
  40869. */
  40870. seriesTypes.pie.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
  40871. }
  40872. if (seriesTypes.scatter) {
  40873. /**
  40874. * @private
  40875. * @borrows Highcharts.TrackerMixin.drawTrackerPoint as Highcharts.seriesTypes.scatter#drawTracker
  40876. */
  40877. seriesTypes.scatter.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
  40878. }
  40879. // Extend Legend for item events.
  40880. extend(Legend.prototype, {
  40881. /**
  40882. * @private
  40883. * @function Highcharts.Legend#setItemEvents
  40884. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  40885. * @param {Highcharts.SVGElement} legendItem
  40886. * @param {boolean} [useHTML=false]
  40887. * @fires Highcharts.Point#event:legendItemClick
  40888. * @fires Highcharts.Series#event:legendItemClick
  40889. */
  40890. setItemEvents: function (item, legendItem, useHTML) {
  40891. var legend = this, boxWrapper = legend.chart.renderer.boxWrapper, isPoint = item instanceof Point, activeClass = 'highcharts-legend-' +
  40892. (isPoint ? 'point' : 'series') + '-active', styledMode = legend.chart.styledMode,
  40893. // When `useHTML`, the symbol is rendered in other group, so
  40894. // we need to apply events listeners to both places
  40895. legendItems = useHTML ?
  40896. [legendItem, item.legendSymbol] :
  40897. [item.legendGroup];
  40898. // Set the events on the item group, or in case of useHTML, the item
  40899. // itself (#1249)
  40900. legendItems.forEach(function (element) {
  40901. if (element) {
  40902. element
  40903. .on('mouseover', function () {
  40904. if (item.visible) {
  40905. legend.allItems.forEach(function (inactiveItem) {
  40906. if (item !== inactiveItem) {
  40907. inactiveItem.setState('inactive', !isPoint);
  40908. }
  40909. });
  40910. }
  40911. item.setState('hover');
  40912. // A CSS class to dim or hide other than the hovered
  40913. // series.
  40914. // Works only if hovered series is visible (#10071).
  40915. if (item.visible) {
  40916. boxWrapper.addClass(activeClass);
  40917. }
  40918. if (!styledMode) {
  40919. legendItem.css(legend.options.itemHoverStyle);
  40920. }
  40921. })
  40922. .on('mouseout', function () {
  40923. if (!legend.chart.styledMode) {
  40924. legendItem.css(merge(item.visible ?
  40925. legend.itemStyle :
  40926. legend.itemHiddenStyle));
  40927. }
  40928. legend.allItems.forEach(function (inactiveItem) {
  40929. if (item !== inactiveItem) {
  40930. inactiveItem.setState('', !isPoint);
  40931. }
  40932. });
  40933. // A CSS class to dim or hide other than the hovered
  40934. // series.
  40935. boxWrapper.removeClass(activeClass);
  40936. item.setState();
  40937. })
  40938. .on('click', function (event) {
  40939. var strLegendItemClick = 'legendItemClick', fnLegendItemClick = function () {
  40940. if (item.setVisible) {
  40941. item.setVisible();
  40942. }
  40943. // Reset inactive state
  40944. legend.allItems.forEach(function (inactiveItem) {
  40945. if (item !== inactiveItem) {
  40946. inactiveItem.setState(item.visible ? 'inactive' : '', !isPoint);
  40947. }
  40948. });
  40949. };
  40950. // A CSS class to dim or hide other than the hovered
  40951. // series. Event handling in iOS causes the activeClass
  40952. // to be added prior to click in some cases (#7418).
  40953. boxWrapper.removeClass(activeClass);
  40954. // Pass over the click/touch event. #4.
  40955. event = {
  40956. browserEvent: event
  40957. };
  40958. // click the name or symbol
  40959. if (item.firePointEvent) { // point
  40960. item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
  40961. }
  40962. else {
  40963. fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
  40964. }
  40965. });
  40966. }
  40967. });
  40968. },
  40969. /**
  40970. * @private
  40971. * @function Highcharts.Legend#createCheckboxForItem
  40972. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  40973. * @fires Highcharts.Series#event:checkboxClick
  40974. */
  40975. createCheckboxForItem: function (item) {
  40976. var legend = this;
  40977. item.checkbox = createElement('input', {
  40978. type: 'checkbox',
  40979. className: 'highcharts-legend-checkbox',
  40980. checked: item.selected,
  40981. defaultChecked: item.selected // required by IE7
  40982. }, legend.options.itemCheckboxStyle, legend.chart.container);
  40983. addEvent(item.checkbox, 'click', function (event) {
  40984. var target = event.target;
  40985. fireEvent(item.series || item, 'checkboxClick', {
  40986. checked: target.checked,
  40987. item: item
  40988. }, function () {
  40989. item.select();
  40990. });
  40991. });
  40992. }
  40993. });
  40994. // Extend the Chart object with interaction
  40995. extend(Chart.prototype, /** @lends Chart.prototype */ {
  40996. /**
  40997. * Display the zoom button, so users can reset zoom to the default view
  40998. * settings.
  40999. *
  41000. * @function Highcharts.Chart#showResetZoom
  41001. *
  41002. * @fires Highcharts.Chart#event:afterShowResetZoom
  41003. * @fires Highcharts.Chart#event:beforeShowResetZoom
  41004. */
  41005. showResetZoom: function () {
  41006. var chart = this, lang = defaultOptions.lang, btnOptions = chart.options.chart.resetZoomButton, theme = btnOptions.theme, states = theme.states, alignTo = (btnOptions.relativeTo === 'chart' ||
  41007. btnOptions.relativeTo === 'spaceBox' ?
  41008. null :
  41009. 'plotBox');
  41010. /**
  41011. * @private
  41012. */
  41013. function zoomOut() {
  41014. chart.zoomOut();
  41015. }
  41016. fireEvent(this, 'beforeShowResetZoom', null, function () {
  41017. chart.resetZoomButton = chart.renderer
  41018. .button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
  41019. .attr({
  41020. align: btnOptions.position.align,
  41021. title: lang.resetZoomTitle
  41022. })
  41023. .addClass('highcharts-reset-zoom')
  41024. .add()
  41025. .align(btnOptions.position, false, alignTo);
  41026. });
  41027. fireEvent(this, 'afterShowResetZoom');
  41028. },
  41029. /**
  41030. * Zoom the chart out after a user has zoomed in. See also
  41031. * [Axis.setExtremes](/class-reference/Highcharts.Axis#setExtremes).
  41032. *
  41033. * @function Highcharts.Chart#zoomOut
  41034. *
  41035. * @fires Highcharts.Chart#event:selection
  41036. */
  41037. zoomOut: function () {
  41038. fireEvent(this, 'selection', { resetSelection: true }, this.zoom);
  41039. },
  41040. /**
  41041. * Zoom into a given portion of the chart given by axis coordinates.
  41042. *
  41043. * @private
  41044. * @function Highcharts.Chart#zoom
  41045. * @param {Highcharts.SelectEventObject} event
  41046. */
  41047. zoom: function (event) {
  41048. var chart = this, hasZoomed, pointer = chart.pointer, displayButton = false, mouseDownPos = chart.inverted ? pointer.mouseDownX : pointer.mouseDownY, resetZoomButton;
  41049. // If zoom is called with no arguments, reset the axes
  41050. if (!event || event.resetSelection) {
  41051. chart.axes.forEach(function (axis) {
  41052. hasZoomed = axis.zoom();
  41053. });
  41054. pointer.initiated = false; // #6804
  41055. }
  41056. else { // else, zoom in on all axes
  41057. event.xAxis.concat(event.yAxis).forEach(function (axisData) {
  41058. var axis = axisData.axis, axisStartPos = chart.inverted ? axis.left : axis.top, axisEndPos = chart.inverted ?
  41059. axisStartPos + axis.width : axisStartPos + axis.height, isXAxis = axis.isXAxis, isWithinPane = false;
  41060. // Check if zoomed area is within the pane (#1289).
  41061. // In case of multiple panes only one pane should be zoomed.
  41062. if ((!isXAxis &&
  41063. mouseDownPos >= axisStartPos &&
  41064. mouseDownPos <= axisEndPos) ||
  41065. isXAxis ||
  41066. !defined(mouseDownPos)) {
  41067. isWithinPane = true;
  41068. }
  41069. // don't zoom more than minRange
  41070. if (pointer[isXAxis ? 'zoomX' : 'zoomY'] && isWithinPane) {
  41071. hasZoomed = axis.zoom(axisData.min, axisData.max);
  41072. if (axis.displayBtn) {
  41073. displayButton = true;
  41074. }
  41075. }
  41076. });
  41077. }
  41078. // Show or hide the Reset zoom button
  41079. resetZoomButton = chart.resetZoomButton;
  41080. if (displayButton && !resetZoomButton) {
  41081. chart.showResetZoom();
  41082. }
  41083. else if (!displayButton && isObject(resetZoomButton)) {
  41084. chart.resetZoomButton = resetZoomButton.destroy();
  41085. }
  41086. // Redraw
  41087. if (hasZoomed) {
  41088. chart.redraw(pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100));
  41089. }
  41090. },
  41091. /**
  41092. * Pan the chart by dragging the mouse across the pane. This function is
  41093. * called on mouse move, and the distance to pan is computed from chartX
  41094. * compared to the first chartX position in the dragging operation.
  41095. *
  41096. * @private
  41097. * @function Highcharts.Chart#pan
  41098. * @param {Highcharts.PointerEventObject} e
  41099. * @param {string} panning
  41100. */
  41101. pan: function (e, panning) {
  41102. var chart = this, hoverPoints = chart.hoverPoints, panningOptions, chartOptions = chart.options.chart, hasMapNavigation = chart.options.mapNavigation &&
  41103. chart.options.mapNavigation.enabled, doRedraw, type;
  41104. if (typeof panning === 'object') {
  41105. panningOptions = panning;
  41106. }
  41107. else {
  41108. panningOptions = {
  41109. enabled: panning,
  41110. type: 'x'
  41111. };
  41112. }
  41113. if (chartOptions && chartOptions.panning) {
  41114. chartOptions.panning = panningOptions;
  41115. }
  41116. type = panningOptions.type;
  41117. fireEvent(this, 'pan', { originalEvent: e }, function () {
  41118. // remove active points for shared tooltip
  41119. if (hoverPoints) {
  41120. hoverPoints.forEach(function (point) {
  41121. point.setState();
  41122. });
  41123. }
  41124. // panning axis mapping
  41125. var xy = [1]; // x
  41126. if (type === 'xy') {
  41127. xy = [1, 0];
  41128. }
  41129. else if (type === 'y') {
  41130. xy = [0];
  41131. }
  41132. xy.forEach(function (isX) {
  41133. 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) ||
  41134. (!axis.reversed && chart.inverted) ?
  41135. -1 :
  41136. 1, extremes = axis.getExtremes(), panMin = axis.toValue(startPos - mousePos, true) +
  41137. halfPointRange * pointRangeDirection, panMax = axis.toValue(startPos + axis.len - mousePos, true) -
  41138. halfPointRange * pointRangeDirection, flipped = panMax < panMin, newMin = flipped ? panMax : panMin, newMax = flipped ? panMin : panMax, hasVerticalPanning = axis.hasVerticalPanning(), paddedMin, paddedMax, spill, panningState = axis.panningState;
  41139. // General calculations of panning state.
  41140. // This is related to using vertical panning. (#11315).
  41141. axis.series.forEach(function (series) {
  41142. if (hasVerticalPanning &&
  41143. !isX && (!panningState || panningState.isDirty)) {
  41144. var processedData = series.getProcessedData(true), dataExtremes = series.getExtremes(processedData.yData, true);
  41145. if (!panningState) {
  41146. panningState = {
  41147. startMin: Number.MAX_VALUE,
  41148. startMax: -Number.MAX_VALUE
  41149. };
  41150. }
  41151. if (isNumber(dataExtremes.dataMin) &&
  41152. isNumber(dataExtremes.dataMax)) {
  41153. panningState.startMin = Math.min(dataExtremes.dataMin, panningState.startMin);
  41154. panningState.startMax = Math.max(dataExtremes.dataMax, panningState.startMax);
  41155. }
  41156. }
  41157. });
  41158. paddedMin = Math.min(H.pick(panningState === null || panningState === void 0 ? void 0 : panningState.startMin, extremes.dataMin), halfPointRange ?
  41159. extremes.min :
  41160. axis.toValue(axis.toPixels(extremes.min) -
  41161. axis.minPixelPadding));
  41162. paddedMax = Math.max(H.pick(panningState === null || panningState === void 0 ? void 0 : panningState.startMax, extremes.dataMax), halfPointRange ?
  41163. extremes.max :
  41164. axis.toValue(axis.toPixels(extremes.max) +
  41165. axis.minPixelPadding));
  41166. axis.panningState = panningState;
  41167. // It is not necessary to calculate extremes on ordinal axis,
  41168. // because they are already calculated, so we don't want to
  41169. // override them.
  41170. if (!axis.isOrdinal) {
  41171. // If the new range spills over, either to the min or max,
  41172. // adjust the new range.
  41173. spill = paddedMin - newMin;
  41174. if (spill > 0) {
  41175. newMax += spill;
  41176. newMin = paddedMin;
  41177. }
  41178. spill = newMax - paddedMax;
  41179. if (spill > 0) {
  41180. newMax = paddedMax;
  41181. newMin -= spill;
  41182. }
  41183. // Set new extremes if they are actually new
  41184. if (axis.series.length &&
  41185. newMin !== extremes.min &&
  41186. newMax !== extremes.max &&
  41187. newMin >= paddedMin &&
  41188. newMax <= paddedMax) {
  41189. axis.setExtremes(newMin, newMax, false, false, { trigger: 'pan' });
  41190. if (!chart.resetZoomButton &&
  41191. !hasMapNavigation &&
  41192. // Show reset zoom button only when both newMin and
  41193. // newMax values are between padded axis range.
  41194. newMin !== paddedMin &&
  41195. newMax !== paddedMax &&
  41196. type.match('y')) {
  41197. chart.showResetZoom();
  41198. axis.displayBtn = false;
  41199. }
  41200. doRedraw = true;
  41201. }
  41202. // set new reference for next run:
  41203. chart[mouseDown] = mousePos;
  41204. }
  41205. });
  41206. if (doRedraw) {
  41207. chart.redraw(false);
  41208. }
  41209. css(chart.container, { cursor: 'move' });
  41210. });
  41211. }
  41212. });
  41213. // Extend the Point object with interaction
  41214. extend(Point.prototype, /** @lends Highcharts.Point.prototype */ {
  41215. /**
  41216. * Toggle the selection status of a point.
  41217. *
  41218. * @see Highcharts.Chart#getSelectedPoints
  41219. *
  41220. * @sample highcharts/members/point-select/
  41221. * Select a point from a button
  41222. * @sample highcharts/chart/events-selection-points/
  41223. * Select a range of points through a drag selection
  41224. * @sample maps/series/data-id/
  41225. * Select a point in Highmaps
  41226. *
  41227. * @function Highcharts.Point#select
  41228. *
  41229. * @param {boolean} [selected]
  41230. * When `true`, the point is selected. When `false`, the point is
  41231. * unselected. When `null` or `undefined`, the selection state is toggled.
  41232. *
  41233. * @param {boolean} [accumulate=false]
  41234. * When `true`, the selection is added to other selected points.
  41235. * When `false`, other selected points are deselected. Internally in
  41236. * Highcharts, when
  41237. * [allowPointSelect](https://api.highcharts.com/highcharts/plotOptions.series.allowPointSelect)
  41238. * is `true`, selected points are accumulated on Control, Shift or Cmd
  41239. * clicking the point.
  41240. *
  41241. * @fires Highcharts.Point#event:select
  41242. * @fires Highcharts.Point#event:unselect
  41243. */
  41244. select: function (selected, accumulate) {
  41245. var point = this, series = point.series, chart = series.chart;
  41246. selected = pick(selected, !point.selected);
  41247. this.selectedStaging = selected;
  41248. // fire the event with the default handler
  41249. point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () {
  41250. /**
  41251. * Whether the point is selected or not.
  41252. *
  41253. * @see Point#select
  41254. * @see Chart#getSelectedPoints
  41255. *
  41256. * @name Highcharts.Point#selected
  41257. * @type {boolean}
  41258. */
  41259. point.selected = point.options.selected = selected;
  41260. series.options.data[series.data.indexOf(point)] =
  41261. point.options;
  41262. point.setState(selected && 'select');
  41263. // unselect all other points unless Ctrl or Cmd + click
  41264. if (!accumulate) {
  41265. chart.getSelectedPoints().forEach(function (loopPoint) {
  41266. var loopSeries = loopPoint.series;
  41267. if (loopPoint.selected && loopPoint !== point) {
  41268. loopPoint.selected = loopPoint.options.selected =
  41269. false;
  41270. loopSeries.options.data[loopSeries.data.indexOf(loopPoint)] = loopPoint.options;
  41271. // Programatically selecting a point should restore
  41272. // normal state, but when click happened on other
  41273. // point, set inactive state to match other points
  41274. loopPoint.setState(chart.hoverPoints &&
  41275. loopSeries.options.inactiveOtherPoints ?
  41276. 'inactive' : '');
  41277. loopPoint.firePointEvent('unselect');
  41278. }
  41279. });
  41280. }
  41281. });
  41282. delete this.selectedStaging;
  41283. },
  41284. /**
  41285. * Runs on mouse over the point. Called internally from mouse and touch
  41286. * events.
  41287. *
  41288. * @function Highcharts.Point#onMouseOver
  41289. *
  41290. * @param {Highcharts.PointerEventObject} [e]
  41291. * The event arguments.
  41292. */
  41293. onMouseOver: function (e) {
  41294. var point = this, series = point.series, chart = series.chart, pointer = chart.pointer;
  41295. e = e ?
  41296. pointer.normalize(e) :
  41297. // In cases where onMouseOver is called directly without an event
  41298. pointer.getChartCoordinatesFromPoint(point, chart.inverted);
  41299. pointer.runPointActions(e, point);
  41300. },
  41301. /**
  41302. * Runs on mouse out from the point. Called internally from mouse and touch
  41303. * events.
  41304. *
  41305. * @function Highcharts.Point#onMouseOut
  41306. * @fires Highcharts.Point#event:mouseOut
  41307. */
  41308. onMouseOut: function () {
  41309. var point = this, chart = point.series.chart;
  41310. point.firePointEvent('mouseOut');
  41311. if (!point.series.options.inactiveOtherPoints) {
  41312. (chart.hoverPoints || []).forEach(function (p) {
  41313. p.setState();
  41314. });
  41315. }
  41316. chart.hoverPoints = chart.hoverPoint = null;
  41317. },
  41318. /**
  41319. * Import events from the series' and point's options. Only do it on
  41320. * demand, to save processing time on hovering.
  41321. *
  41322. * @private
  41323. * @function Highcharts.Point#importEvents
  41324. */
  41325. importEvents: function () {
  41326. if (!this.hasImportedEvents) {
  41327. var point = this, options = merge(point.series.options.point, point.options), events = options.events;
  41328. point.events = events;
  41329. objectEach(events, function (event, eventType) {
  41330. if (isFunction(event)) {
  41331. addEvent(point, eventType, event);
  41332. }
  41333. });
  41334. this.hasImportedEvents = true;
  41335. }
  41336. },
  41337. /**
  41338. * Set the point's state.
  41339. *
  41340. * @function Highcharts.Point#setState
  41341. *
  41342. * @param {Highcharts.PointStateValue|""} [state]
  41343. * The new state, can be one of `'hover'`, `'select'`, `'inactive'`,
  41344. * or `''` (an empty string), `'normal'` or `undefined` to set to
  41345. * normal state.
  41346. * @param {boolean} [move]
  41347. * State for animation.
  41348. *
  41349. * @fires Highcharts.Point#event:afterSetState
  41350. */
  41351. setState: function (state, move) {
  41352. var point = this, series = point.series, previousState = point.state, stateOptions = (series.options.states[state || 'normal'] ||
  41353. {}), markerOptions = (defaultOptions.plotOptions[series.type].marker &&
  41354. series.options.marker), normalDisabled = (markerOptions && markerOptions.enabled === false), markerStateOptions = ((markerOptions &&
  41355. markerOptions.states &&
  41356. markerOptions.states[state || 'normal']) || {}), stateDisabled = markerStateOptions.enabled === false, stateMarkerGraphic = series.stateMarkerGraphic, pointMarker = point.marker || {}, chart = series.chart, halo = series.halo, haloOptions, markerAttribs, pointAttribs, pointAttribsAnimation, hasMarkers = (markerOptions && series.markerAttribs), newSymbol;
  41357. state = state || ''; // empty string
  41358. if (
  41359. // already has this state
  41360. (state === point.state && !move) ||
  41361. // selected points don't respond to hover
  41362. (point.selected && state !== 'select') ||
  41363. // series' state options is disabled
  41364. (stateOptions.enabled === false) ||
  41365. // general point marker's state options is disabled
  41366. (state && (stateDisabled ||
  41367. (normalDisabled &&
  41368. markerStateOptions.enabled === false))) ||
  41369. // individual point marker's state options is disabled
  41370. (state &&
  41371. pointMarker.states &&
  41372. pointMarker.states[state] &&
  41373. pointMarker.states[state].enabled === false) // #1610
  41374. ) {
  41375. return;
  41376. }
  41377. point.state = state;
  41378. if (hasMarkers) {
  41379. markerAttribs = series.markerAttribs(point, state);
  41380. }
  41381. // Apply hover styles to the existing point
  41382. if (point.graphic) {
  41383. if (previousState) {
  41384. point.graphic.removeClass('highcharts-point-' + previousState);
  41385. }
  41386. if (state) {
  41387. point.graphic.addClass('highcharts-point-' + state);
  41388. }
  41389. if (!chart.styledMode) {
  41390. pointAttribs = series.pointAttribs(point, state);
  41391. pointAttribsAnimation = pick(chart.options.chart.animation, stateOptions.animation);
  41392. // Some inactive points (e.g. slices in pie) should apply
  41393. // oppacity also for it's labels
  41394. if (series.options.inactiveOtherPoints && pointAttribs.opacity) {
  41395. (point.dataLabels || []).forEach(function (label) {
  41396. if (label) {
  41397. label.animate({
  41398. opacity: pointAttribs.opacity
  41399. }, pointAttribsAnimation);
  41400. }
  41401. });
  41402. if (point.connector) {
  41403. point.connector.animate({
  41404. opacity: pointAttribs.opacity
  41405. }, pointAttribsAnimation);
  41406. }
  41407. }
  41408. point.graphic.animate(pointAttribs, pointAttribsAnimation);
  41409. }
  41410. if (markerAttribs) {
  41411. point.graphic.animate(markerAttribs, pick(
  41412. // Turn off globally:
  41413. chart.options.chart.animation, markerStateOptions.animation, markerOptions.animation));
  41414. }
  41415. // Zooming in from a range with no markers to a range with markers
  41416. if (stateMarkerGraphic) {
  41417. stateMarkerGraphic.hide();
  41418. }
  41419. }
  41420. else {
  41421. // if a graphic is not applied to each point in the normal state,
  41422. // create a shared graphic for the hover state
  41423. if (state && markerStateOptions) {
  41424. newSymbol = pointMarker.symbol || series.symbol;
  41425. // If the point has another symbol than the previous one, throw
  41426. // away the state marker graphic and force a new one (#1459)
  41427. if (stateMarkerGraphic &&
  41428. stateMarkerGraphic.currentSymbol !== newSymbol) {
  41429. stateMarkerGraphic = stateMarkerGraphic.destroy();
  41430. }
  41431. // Add a new state marker graphic
  41432. if (markerAttribs) {
  41433. if (!stateMarkerGraphic) {
  41434. if (newSymbol) {
  41435. series.stateMarkerGraphic = stateMarkerGraphic =
  41436. chart.renderer
  41437. .symbol(newSymbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height)
  41438. .add(series.markerGroup);
  41439. stateMarkerGraphic.currentSymbol = newSymbol;
  41440. }
  41441. // Move the existing graphic
  41442. }
  41443. else {
  41444. stateMarkerGraphic[move ? 'animate' : 'attr']({
  41445. x: markerAttribs.x,
  41446. y: markerAttribs.y
  41447. });
  41448. }
  41449. }
  41450. if (!chart.styledMode && stateMarkerGraphic) {
  41451. stateMarkerGraphic.attr(series.pointAttribs(point, state));
  41452. }
  41453. }
  41454. if (stateMarkerGraphic) {
  41455. stateMarkerGraphic[state && point.isInside ? 'show' : 'hide'](); // #2450
  41456. stateMarkerGraphic.element.point = point; // #4310
  41457. }
  41458. }
  41459. // Show me your halo
  41460. haloOptions = stateOptions.halo;
  41461. var markerGraphic = (point.graphic || stateMarkerGraphic);
  41462. var markerVisibility = (markerGraphic && markerGraphic.visibility || 'inherit');
  41463. if (haloOptions &&
  41464. haloOptions.size &&
  41465. markerGraphic &&
  41466. markerVisibility !== 'hidden' &&
  41467. !point.isCluster) {
  41468. if (!halo) {
  41469. series.halo = halo = chart.renderer.path()
  41470. // #5818, #5903, #6705
  41471. .add(markerGraphic.parentGroup);
  41472. }
  41473. halo.show()[move ? 'animate' : 'attr']({
  41474. d: point.haloPath(haloOptions.size)
  41475. });
  41476. halo.attr({
  41477. 'class': 'highcharts-halo highcharts-color-' +
  41478. pick(point.colorIndex, series.colorIndex) +
  41479. (point.className ? ' ' + point.className : ''),
  41480. 'visibility': markerVisibility,
  41481. 'zIndex': -1 // #4929, #8276
  41482. });
  41483. halo.point = point; // #6055
  41484. if (!chart.styledMode) {
  41485. halo.attr(extend({
  41486. 'fill': point.color || series.color,
  41487. 'fill-opacity': haloOptions.opacity
  41488. }, haloOptions.attributes));
  41489. }
  41490. }
  41491. else if (halo && halo.point && halo.point.haloPath) {
  41492. // Animate back to 0 on the current halo point (#6055)
  41493. halo.animate({ d: halo.point.haloPath(0) }, null,
  41494. // Hide after unhovering. The `complete` callback runs in the
  41495. // halo's context (#7681).
  41496. halo.hide);
  41497. }
  41498. fireEvent(point, 'afterSetState');
  41499. },
  41500. /**
  41501. * Get the path definition for the halo, which is usually a shadow-like
  41502. * circle around the currently hovered point.
  41503. *
  41504. * @function Highcharts.Point#haloPath
  41505. *
  41506. * @param {number} size
  41507. * The radius of the circular halo.
  41508. *
  41509. * @return {Highcharts.SVGPathArray}
  41510. * The path definition.
  41511. */
  41512. haloPath: function (size) {
  41513. var series = this.series, chart = series.chart;
  41514. return chart.renderer.symbols.circle(Math.floor(this.plotX) - size, this.plotY - size, size * 2, size * 2);
  41515. }
  41516. });
  41517. // Extend the Series object with interaction
  41518. extend(Series.prototype, /** @lends Highcharts.Series.prototype */ {
  41519. /**
  41520. * Runs on mouse over the series graphical items.
  41521. *
  41522. * @function Highcharts.Series#onMouseOver
  41523. * @fires Highcharts.Series#event:mouseOver
  41524. */
  41525. onMouseOver: function () {
  41526. var series = this, chart = series.chart, hoverSeries = chart.hoverSeries, pointer = chart.pointer;
  41527. pointer.setHoverChartIndex();
  41528. // set normal state to previous series
  41529. if (hoverSeries && hoverSeries !== series) {
  41530. hoverSeries.onMouseOut();
  41531. }
  41532. // trigger the event, but to save processing time,
  41533. // only if defined
  41534. if (series.options.events.mouseOver) {
  41535. fireEvent(series, 'mouseOver');
  41536. }
  41537. // hover this
  41538. series.setState('hover');
  41539. /**
  41540. * Contains the original hovered series.
  41541. *
  41542. * @name Highcharts.Chart#hoverSeries
  41543. * @type {Highcharts.Series|null}
  41544. */
  41545. chart.hoverSeries = series;
  41546. },
  41547. /**
  41548. * Runs on mouse out of the series graphical items.
  41549. *
  41550. * @function Highcharts.Series#onMouseOut
  41551. *
  41552. * @fires Highcharts.Series#event:mouseOut
  41553. */
  41554. onMouseOut: function () {
  41555. // trigger the event only if listeners exist
  41556. var series = this, options = series.options, chart = series.chart, tooltip = chart.tooltip, hoverPoint = chart.hoverPoint;
  41557. // #182, set to null before the mouseOut event fires
  41558. chart.hoverSeries = null;
  41559. // trigger mouse out on the point, which must be in this series
  41560. if (hoverPoint) {
  41561. hoverPoint.onMouseOut();
  41562. }
  41563. // fire the mouse out event
  41564. if (series && options.events.mouseOut) {
  41565. fireEvent(series, 'mouseOut');
  41566. }
  41567. // hide the tooltip
  41568. if (tooltip &&
  41569. !series.stickyTracking &&
  41570. (!tooltip.shared || series.noSharedTooltip)) {
  41571. tooltip.hide();
  41572. }
  41573. // Reset all inactive states
  41574. chart.series.forEach(function (s) {
  41575. s.setState('', true);
  41576. });
  41577. },
  41578. /**
  41579. * Set the state of the series. Called internally on mouse interaction
  41580. * operations, but it can also be called directly to visually
  41581. * highlight a series.
  41582. *
  41583. * @function Highcharts.Series#setState
  41584. *
  41585. * @param {Highcharts.SeriesStateValue|""} [state]
  41586. * The new state, can be either `'hover'`, `'inactive'`, `'select'`,
  41587. * or `''` (an empty string), `'normal'` or `undefined` to set to
  41588. * normal state.
  41589. * @param {boolean} [inherit]
  41590. * Determines if state should be inherited by points too.
  41591. */
  41592. setState: function (state, inherit) {
  41593. var series = this, options = series.options, graph = series.graph, inactiveOtherPoints = options.inactiveOtherPoints, stateOptions = options.states, lineWidth = options.lineWidth, opacity = options.opacity,
  41594. // By default a quick animation to hover/inactive,
  41595. // slower to un-hover
  41596. stateAnimation = pick((stateOptions[state || 'normal'] &&
  41597. stateOptions[state || 'normal'].animation), series.chart.options.chart.animation), attribs, i = 0;
  41598. state = state || '';
  41599. if (series.state !== state) {
  41600. // Toggle class names
  41601. [
  41602. series.group,
  41603. series.markerGroup,
  41604. series.dataLabelsGroup
  41605. ].forEach(function (group) {
  41606. if (group) {
  41607. // Old state
  41608. if (series.state) {
  41609. group.removeClass('highcharts-series-' + series.state);
  41610. }
  41611. // New state
  41612. if (state) {
  41613. group.addClass('highcharts-series-' + state);
  41614. }
  41615. }
  41616. });
  41617. series.state = state;
  41618. if (!series.chart.styledMode) {
  41619. if (stateOptions[state] &&
  41620. stateOptions[state].enabled === false) {
  41621. return;
  41622. }
  41623. if (state) {
  41624. lineWidth = (stateOptions[state].lineWidth ||
  41625. lineWidth + (stateOptions[state].lineWidthPlus || 0)); // #4035
  41626. opacity = pick(stateOptions[state].opacity, opacity);
  41627. }
  41628. if (graph && !graph.dashstyle) {
  41629. attribs = {
  41630. 'stroke-width': lineWidth
  41631. };
  41632. // Animate the graph stroke-width.
  41633. graph.animate(attribs, stateAnimation);
  41634. while (series['zone-graph-' + i]) {
  41635. series['zone-graph-' + i].attr(attribs);
  41636. i = i + 1;
  41637. }
  41638. }
  41639. // For some types (pie, networkgraph, sankey) opacity is
  41640. // resolved on a point level
  41641. if (!inactiveOtherPoints) {
  41642. [
  41643. series.group,
  41644. series.markerGroup,
  41645. series.dataLabelsGroup,
  41646. series.labelBySeries
  41647. ].forEach(function (group) {
  41648. if (group) {
  41649. group.animate({
  41650. opacity: opacity
  41651. }, stateAnimation);
  41652. }
  41653. });
  41654. }
  41655. }
  41656. }
  41657. // Don't loop over points on a series that doesn't apply inactive state
  41658. // to siblings markers (e.g. line, column)
  41659. if (inherit && inactiveOtherPoints && series.points) {
  41660. series.setAllPointsToState(state);
  41661. }
  41662. },
  41663. /**
  41664. * Set the state for all points in the series.
  41665. *
  41666. * @function Highcharts.Series#setAllPointsToState
  41667. *
  41668. * @private
  41669. *
  41670. * @param {string} [state]
  41671. * Can be either `hover` or undefined to set to normal state.
  41672. */
  41673. setAllPointsToState: function (state) {
  41674. this.points.forEach(function (point) {
  41675. if (point.setState) {
  41676. point.setState(state);
  41677. }
  41678. });
  41679. },
  41680. /**
  41681. * Show or hide the series.
  41682. *
  41683. * @function Highcharts.Series#setVisible
  41684. *
  41685. * @param {boolean} [visible]
  41686. * True to show the series, false to hide. If undefined, the visibility is
  41687. * toggled.
  41688. *
  41689. * @param {boolean} [redraw=true]
  41690. * Whether to redraw the chart after the series is altered. If doing more
  41691. * operations on the chart, it is a good idea to set redraw to false and
  41692. * call {@link Chart#redraw|chart.redraw()} after.
  41693. *
  41694. * @fires Highcharts.Series#event:hide
  41695. * @fires Highcharts.Series#event:show
  41696. */
  41697. setVisible: function (vis, redraw) {
  41698. var series = this, chart = series.chart, legendItem = series.legendItem, showOrHide, ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries, oldVisibility = series.visible;
  41699. // if called without an argument, toggle visibility
  41700. series.visible =
  41701. vis =
  41702. series.options.visible =
  41703. series.userOptions.visible =
  41704. typeof vis === 'undefined' ? !oldVisibility : vis; // #5618
  41705. showOrHide = vis ? 'show' : 'hide';
  41706. // show or hide elements
  41707. [
  41708. 'group',
  41709. 'dataLabelsGroup',
  41710. 'markerGroup',
  41711. 'tracker',
  41712. 'tt'
  41713. ].forEach(function (key) {
  41714. if (series[key]) {
  41715. series[key][showOrHide]();
  41716. }
  41717. });
  41718. // hide tooltip (#1361)
  41719. if (chart.hoverSeries === series ||
  41720. (chart.hoverPoint && chart.hoverPoint.series) === series) {
  41721. series.onMouseOut();
  41722. }
  41723. if (legendItem) {
  41724. chart.legend.colorizeItem(series, vis);
  41725. }
  41726. // rescale or adapt to resized chart
  41727. series.isDirty = true;
  41728. // in a stack, all other series are affected
  41729. if (series.options.stacking) {
  41730. chart.series.forEach(function (otherSeries) {
  41731. if (otherSeries.options.stacking && otherSeries.visible) {
  41732. otherSeries.isDirty = true;
  41733. }
  41734. });
  41735. }
  41736. // show or hide linked series
  41737. series.linkedSeries.forEach(function (otherSeries) {
  41738. otherSeries.setVisible(vis, false);
  41739. });
  41740. if (ignoreHiddenSeries) {
  41741. chart.isDirtyBox = true;
  41742. }
  41743. fireEvent(series, showOrHide);
  41744. if (redraw !== false) {
  41745. chart.redraw();
  41746. }
  41747. },
  41748. /**
  41749. * Show the series if hidden.
  41750. *
  41751. * @sample highcharts/members/series-hide/
  41752. * Toggle visibility from a button
  41753. *
  41754. * @function Highcharts.Series#show
  41755. * @fires Highcharts.Series#event:show
  41756. */
  41757. show: function () {
  41758. this.setVisible(true);
  41759. },
  41760. /**
  41761. * Hide the series if visible. If the
  41762. * [chart.ignoreHiddenSeries](https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries)
  41763. * option is true, the chart is redrawn without this series.
  41764. *
  41765. * @sample highcharts/members/series-hide/
  41766. * Toggle visibility from a button
  41767. *
  41768. * @function Highcharts.Series#hide
  41769. * @fires Highcharts.Series#event:hide
  41770. */
  41771. hide: function () {
  41772. this.setVisible(false);
  41773. },
  41774. /**
  41775. * Select or unselect the series. This means its
  41776. * {@link Highcharts.Series.selected|selected}
  41777. * property is set, the checkbox in the legend is toggled and when selected,
  41778. * the series is returned by the {@link Highcharts.Chart#getSelectedSeries}
  41779. * function.
  41780. *
  41781. * @sample highcharts/members/series-select/
  41782. * Select a series from a button
  41783. *
  41784. * @function Highcharts.Series#select
  41785. *
  41786. * @param {boolean} [selected]
  41787. * True to select the series, false to unselect. If undefined, the selection
  41788. * state is toggled.
  41789. *
  41790. * @fires Highcharts.Series#event:select
  41791. * @fires Highcharts.Series#event:unselect
  41792. */
  41793. select: function (selected) {
  41794. var series = this;
  41795. series.selected =
  41796. selected =
  41797. this.options.selected = (typeof selected === 'undefined' ?
  41798. !series.selected :
  41799. selected);
  41800. if (series.checkbox) {
  41801. series.checkbox.checked = selected;
  41802. }
  41803. fireEvent(series, selected ? 'select' : 'unselect');
  41804. },
  41805. /**
  41806. * @private
  41807. * @borrows Highcharts.TrackerMixin.drawTrackerGraph as Highcharts.Series#drawTracker
  41808. */
  41809. drawTracker: TrackerMixin.drawTrackerGraph
  41810. });
  41811. });
  41812. _registerModule(_modules, 'parts/Responsive.js', [_modules['parts/Chart.js'], _modules['parts/Utilities.js']], function (Chart, U) {
  41813. /* *
  41814. *
  41815. * (c) 2010-2020 Torstein Honsi
  41816. *
  41817. * License: www.highcharts.com/license
  41818. *
  41819. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41820. *
  41821. * */
  41822. var find = U.find, isArray = U.isArray, isObject = U.isObject, merge = U.merge, objectEach = U.objectEach, pick = U.pick, splat = U.splat, uniqueKey = U.uniqueKey;
  41823. /**
  41824. * A callback function to gain complete control on when the responsive rule
  41825. * applies.
  41826. *
  41827. * @callback Highcharts.ResponsiveCallbackFunction
  41828. *
  41829. * @param {Highcharts.Chart} this
  41830. * Chart context.
  41831. *
  41832. * @return {boolean}
  41833. * Return `true` if it applies.
  41834. */
  41835. /**
  41836. * Allows setting a set of rules to apply for different screen or chart
  41837. * sizes. Each rule specifies additional chart options.
  41838. *
  41839. * @sample {highstock} stock/demo/responsive/
  41840. * Stock chart
  41841. * @sample highcharts/responsive/axis/
  41842. * Axis
  41843. * @sample highcharts/responsive/legend/
  41844. * Legend
  41845. * @sample highcharts/responsive/classname/
  41846. * Class name
  41847. *
  41848. * @since 5.0.0
  41849. * @apioption responsive
  41850. */
  41851. /**
  41852. * A set of rules for responsive settings. The rules are executed from
  41853. * the top down.
  41854. *
  41855. * @sample {highcharts} highcharts/responsive/axis/
  41856. * Axis changes
  41857. * @sample {highstock} highcharts/responsive/axis/
  41858. * Axis changes
  41859. * @sample {highmaps} highcharts/responsive/axis/
  41860. * Axis changes
  41861. *
  41862. * @type {Array<*>}
  41863. * @since 5.0.0
  41864. * @apioption responsive.rules
  41865. */
  41866. /**
  41867. * A full set of chart options to apply as overrides to the general
  41868. * chart options. The chart options are applied when the given rule
  41869. * is active.
  41870. *
  41871. * A special case is configuration objects that take arrays, for example
  41872. * [xAxis](#xAxis), [yAxis](#yAxis) or [series](#series). For these
  41873. * collections, an `id` option is used to map the new option set to
  41874. * an existing object. If an existing object of the same id is not found,
  41875. * the item of the same indexupdated. So for example, setting `chartOptions`
  41876. * with two series items without an `id`, will cause the existing chart's
  41877. * two series to be updated with respective options.
  41878. *
  41879. * @sample {highstock} stock/demo/responsive/
  41880. * Stock chart
  41881. * @sample highcharts/responsive/axis/
  41882. * Axis
  41883. * @sample highcharts/responsive/legend/
  41884. * Legend
  41885. * @sample highcharts/responsive/classname/
  41886. * Class name
  41887. *
  41888. * @type {Highcharts.Options}
  41889. * @since 5.0.0
  41890. * @apioption responsive.rules.chartOptions
  41891. */
  41892. /**
  41893. * Under which conditions the rule applies.
  41894. *
  41895. * @since 5.0.0
  41896. * @apioption responsive.rules.condition
  41897. */
  41898. /**
  41899. * A callback function to gain complete control on when the responsive
  41900. * rule applies. Return `true` if it applies. This opens for checking
  41901. * against other metrics than the chart size, for example the document
  41902. * size or other elements.
  41903. *
  41904. * @type {Highcharts.ResponsiveCallbackFunction}
  41905. * @since 5.0.0
  41906. * @context Highcharts.Chart
  41907. * @apioption responsive.rules.condition.callback
  41908. */
  41909. /**
  41910. * The responsive rule applies if the chart height is less than this.
  41911. *
  41912. * @type {number}
  41913. * @since 5.0.0
  41914. * @apioption responsive.rules.condition.maxHeight
  41915. */
  41916. /**
  41917. * The responsive rule applies if the chart width is less than this.
  41918. *
  41919. * @sample highcharts/responsive/axis/
  41920. * Max width is 500
  41921. *
  41922. * @type {number}
  41923. * @since 5.0.0
  41924. * @apioption responsive.rules.condition.maxWidth
  41925. */
  41926. /**
  41927. * The responsive rule applies if the chart height is greater than this.
  41928. *
  41929. * @type {number}
  41930. * @default 0
  41931. * @since 5.0.0
  41932. * @apioption responsive.rules.condition.minHeight
  41933. */
  41934. /**
  41935. * The responsive rule applies if the chart width is greater than this.
  41936. *
  41937. * @type {number}
  41938. * @default 0
  41939. * @since 5.0.0
  41940. * @apioption responsive.rules.condition.minWidth
  41941. */
  41942. /* eslint-disable no-invalid-this, valid-jsdoc */
  41943. /**
  41944. * Update the chart based on the current chart/document size and options for
  41945. * responsiveness.
  41946. *
  41947. * @private
  41948. * @function Highcharts.Chart#setResponsive
  41949. * @param {boolean} [redraw=true]
  41950. * @param {boolean} [reset=false]
  41951. * Reset by un-applying all rules. Chart.update resets all rules before applying
  41952. * updated options.
  41953. */
  41954. Chart.prototype.setResponsive = function (redraw, reset) {
  41955. var options = this.options.responsive, ruleIds = [], currentResponsive = this.currentResponsive, currentRuleIds, undoOptions;
  41956. if (!reset && options && options.rules) {
  41957. options.rules.forEach(function (rule) {
  41958. if (typeof rule._id === 'undefined') {
  41959. rule._id = uniqueKey();
  41960. }
  41961. this.matchResponsiveRule(rule, ruleIds /* , redraw */);
  41962. }, this);
  41963. }
  41964. // Merge matching rules
  41965. var mergedOptions = merge.apply(0, ruleIds.map(function (ruleId) {
  41966. return find(options.rules, function (rule) {
  41967. return rule._id === ruleId;
  41968. }).chartOptions;
  41969. }));
  41970. mergedOptions.isResponsiveOptions = true;
  41971. // Stringified key for the rules that currently apply.
  41972. ruleIds = (ruleIds.toString() || void 0);
  41973. currentRuleIds = currentResponsive && currentResponsive.ruleIds;
  41974. // Changes in what rules apply
  41975. if (ruleIds !== currentRuleIds) {
  41976. // Undo previous rules. Before we apply a new set of rules, we need to
  41977. // roll back completely to base options (#6291).
  41978. if (currentResponsive) {
  41979. this.update(currentResponsive.undoOptions, redraw, true);
  41980. }
  41981. if (ruleIds) {
  41982. // Get undo-options for matching rules
  41983. undoOptions = this.currentOptions(mergedOptions);
  41984. undoOptions.isResponsiveOptions = true;
  41985. this.currentResponsive = {
  41986. ruleIds: ruleIds,
  41987. mergedOptions: mergedOptions,
  41988. undoOptions: undoOptions
  41989. };
  41990. this.update(mergedOptions, redraw, true);
  41991. }
  41992. else {
  41993. this.currentResponsive = void 0;
  41994. }
  41995. }
  41996. };
  41997. /**
  41998. * Handle a single responsiveness rule.
  41999. *
  42000. * @private
  42001. * @function Highcharts.Chart#matchResponsiveRule
  42002. * @param {Highcharts.ResponsiveRulesOptions} rule
  42003. * @param {Array<string>} matches
  42004. */
  42005. Chart.prototype.matchResponsiveRule = function (rule, matches) {
  42006. var condition = rule.condition, fn = condition.callback || function () {
  42007. return (this.chartWidth <= pick(condition.maxWidth, Number.MAX_VALUE) &&
  42008. this.chartHeight <=
  42009. pick(condition.maxHeight, Number.MAX_VALUE) &&
  42010. this.chartWidth >= pick(condition.minWidth, 0) &&
  42011. this.chartHeight >= pick(condition.minHeight, 0));
  42012. };
  42013. if (fn.call(this)) {
  42014. matches.push(rule._id);
  42015. }
  42016. };
  42017. /**
  42018. * Get the current values for a given set of options. Used before we update
  42019. * the chart with a new responsiveness rule.
  42020. *
  42021. * @todo Restore axis options (by id?). The matching of items in collections
  42022. * bears resemblance to the oneToOne matching in Chart.update. Probably we can
  42023. * refactor out that matching and reuse it in both functions.
  42024. *
  42025. * @private
  42026. * @function Highcharts.Chart#currentOptions
  42027. * @param {Highcharts.Options} options
  42028. * @return {Highcharts.Options}
  42029. */
  42030. Chart.prototype.currentOptions = function (options) {
  42031. var chart = this, ret = {};
  42032. /**
  42033. * Recurse over a set of options and its current values,
  42034. * and store the current values in the ret object.
  42035. */
  42036. function getCurrent(options, curr, ret, depth) {
  42037. var i;
  42038. objectEach(options, function (val, key) {
  42039. if (!depth &&
  42040. chart.collectionsWithUpdate.indexOf(key) > -1) {
  42041. val = splat(val);
  42042. ret[key] = [];
  42043. // Iterate over collections like series, xAxis or yAxis and map
  42044. // the items by index.
  42045. for (i = 0; i < Math.max(val.length, curr[key].length); i++) {
  42046. // Item exists in current data (#6347)
  42047. if (curr[key][i]) {
  42048. // If the item is missing from the new data, we need to
  42049. // save the whole config structure. Like when
  42050. // responsively updating from a dual axis layout to a
  42051. // single axis and back (#13544).
  42052. if (val[i] === void 0) {
  42053. ret[key][i] = curr[key][i];
  42054. // Otherwise, proceed
  42055. }
  42056. else {
  42057. ret[key][i] = {};
  42058. getCurrent(val[i], curr[key][i], ret[key][i], depth + 1);
  42059. }
  42060. }
  42061. }
  42062. }
  42063. else if (isObject(val)) {
  42064. ret[key] = isArray(val) ? [] : {};
  42065. getCurrent(val, curr[key] || {}, ret[key], depth + 1);
  42066. }
  42067. else if (typeof curr[key] === 'undefined') { // #10286
  42068. ret[key] = null;
  42069. }
  42070. else {
  42071. ret[key] = curr[key];
  42072. }
  42073. });
  42074. }
  42075. getCurrent(options, this.options, ret, 0);
  42076. return ret;
  42077. };
  42078. });
  42079. _registerModule(_modules, 'masters/highcharts.src.js', [_modules['parts/Globals.js']], function (Highcharts) {
  42080. return Highcharts;
  42081. });
  42082. _modules['masters/highcharts.src.js']._modules = _modules;
  42083. return _modules['masters/highcharts.src.js'];
  42084. }));